stm32f0xx_cec.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_cec.c
  4. * @author MCD Application Team
  5. * @version V1.5.0
  6. * @date 05-December-2014
  7. * @brief This file provides firmware functions to manage the following
  8. * functionalities of the Consumer Electronics Control (CEC) peripheral
  9. * applicable only on STM32F051, STM32F042 and STM32F072 devices:
  10. * + Initialization and Configuration
  11. * + Data transfers functions
  12. * + Interrupts and flags management
  13. *
  14. * @verbatim
  15. ==============================================================================
  16. ##### CEC features #####
  17. ==============================================================================
  18. [..] This device provides some features:
  19. (#) Supports HDMI-CEC specification 1.4.
  20. (#) Supports two source clocks(HSI/244 or LSE).
  21. (#) Works in stop mode(without APB clock, but with CEC clock 32KHz).
  22. It can genarate an interrupt in the CEC clock domain that the CPU
  23. wakes up from the low power mode.
  24. (#) Configurable Signal Free Time before of transmission start. The
  25. number of nominal data bit periods waited before transmission can be
  26. ruled by Hardware or Software.
  27. (#) Configurable Peripheral Address (multi-addressing configuration).
  28. (#) Supports listen mode.The CEC Messages addressed to different destination
  29. can be received without interfering with CEC bus when Listen mode option is enabled.
  30. (#) Configurable Rx-Tolerance(Standard and Extended tolerance margin).
  31. (#) Error detection with configurable error bit generation.
  32. (#) Arbitration lost error in the case of two CEC devices starting at the same time.
  33. ##### How to use this driver #####
  34. ==============================================================================
  35. [..] This driver provides functions to configure and program the CEC device,
  36. follow steps below:
  37. (#) The source clock can be configured using:
  38. (++) RCC_CECCLKConfig(RCC_CECCLK_HSI_Div244) for HSI(Default)
  39. (++) RCC_CECCLKConfig(RCC_CECCLK_LSE) for LSE.
  40. (#) Enable CEC peripheral clock using RCC_APBPeriphClockCmd(RCC_APBPeriph_CEC, ENABLE).
  41. (#) Peripherals alternate function.
  42. (++) Connect the pin to the desired peripherals' Alternate Function (AF) using
  43. GPIO_PinAFConfig() function.
  44. (++) Configure the desired pin in alternate function by:
  45. GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF.
  46. (++) Select the type open-drain and output speed via GPIO_OType
  47. and GPIO_Speed members.
  48. (++) Call GPIO_Init() function.
  49. (#) Configure the Signal Free Time, Rx Tolerance, Stop reception generation
  50. and Bit error generation using the CEC_Init() function.
  51. The function CEC_Init() must be called when the CEC peripheral is disabled.
  52. (#) Configure the CEC own address by calling the fuction CEC_OwnAddressConfig().
  53. (#) Optionally, you can configure the Listen mode using the function CEC_ListenModeCmd().
  54. (#) Enable the NVIC and the corresponding interrupt using the function
  55. CEC_ITConfig() if you need to use interrupt mode.
  56. CEC_ITConfig() must be called before enabling the CEC peripheral.
  57. (#) Enable the CEC using the CEC_Cmd() function.
  58. (#) Charge the first data byte in the TXDR register using CEC_SendDataByte().
  59. (#) Enable the transmission of the Byte of a CEC message using CEC_StartOfMessage()
  60. (#) Transmit single data through the CEC peripheral using CEC_SendDataByte()
  61. and Receive the last transmitted byte using CEC_ReceiveDataByte().
  62. (#) Enable the CEC_EndOfMessage() in order to indicate the last byte of the message.
  63. [..]
  64. (@) If the listen mode is enabled, Stop reception generation and Bit error generation
  65. must be in reset state.
  66. (@) If the CEC message consists of only 1 byte, the function CEC_EndOfMessage()
  67. must be called before CEC_StartOfMessage().
  68. @endverbatim
  69. *
  70. ******************************************************************************
  71. * @attention
  72. *
  73. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  74. *
  75. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  76. * You may not use this file except in compliance with the License.
  77. * You may obtain a copy of the License at:
  78. *
  79. * http://www.st.com/software_license_agreement_liberty_v2
  80. *
  81. * Unless required by applicable law or agreed to in writing, software
  82. * distributed under the License is distributed on an "AS IS" BASIS,
  83. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  84. * See the License for the specific language governing permissions and
  85. * limitations under the License.
  86. *
  87. ******************************************************************************
  88. */
  89. /* Includes ------------------------------------------------------------------*/
  90. #include "stm32f0xx_cec.h"
  91. #include "stm32f0xx_rcc.h"
  92. /** @addtogroup STM32F0xx_StdPeriph_Driver
  93. * @{
  94. */
  95. /** @defgroup CEC
  96. * @brief CEC driver modules
  97. * @{
  98. */
  99. /* Private typedef -----------------------------------------------------------*/
  100. /* Private define ------------------------------------------------------------*/
  101. #define BROADCAST_ADDRESS ((uint32_t)0x0000F)
  102. #define CFGR_CLEAR_MASK ((uint32_t)0x7000FE00) /* CFGR register Mask */
  103. /* Private macro -------------------------------------------------------------*/
  104. /* Private variables ---------------------------------------------------------*/
  105. /* Private function prototypes -----------------------------------------------*/
  106. /* Private functions ---------------------------------------------------------*/
  107. /** @defgroup CEC_Private_Functions
  108. * @{
  109. */
  110. /** @defgroup CEC_Group1 Initialization and Configuration functions
  111. * @brief Initialization and Configuration functions
  112. *
  113. @verbatim
  114. ===============================================================================
  115. ##### Initialization and Configuration functions #####
  116. ===============================================================================
  117. [..] This section provides functions allowing to initialize:
  118. (+) CEC own addresses
  119. (+) CEC Signal Free Time
  120. (+) CEC Rx Tolerance
  121. (+) CEC Stop Reception
  122. (+) CEC Bit Rising Error
  123. (+) CEC Long Bit Period Error
  124. [..] This section provides also a function to configure the CEC peripheral in Listen Mode.
  125. Messages addressed to different destination can be received when Listen mode is
  126. enabled without interfering with CEC bus.
  127. @endverbatim
  128. * @{
  129. */
  130. /**
  131. * @brief Deinitializes the CEC peripheral registers to their default reset values.
  132. * @param None
  133. * @retval None
  134. */
  135. void CEC_DeInit(void)
  136. {
  137. RCC_APB1PeriphResetCmd(RCC_APB1Periph_CEC, ENABLE);
  138. RCC_APB1PeriphResetCmd(RCC_APB1Periph_CEC, DISABLE);
  139. }
  140. /**
  141. * @brief Initializes the CEC peripheral according to the specified parameters
  142. * in the CEC_InitStruct.
  143. * @note The CEC parameters must be configured before enabling the CEC peripheral.
  144. * @param CEC_InitStruct: pointer to an CEC_InitTypeDef structure that contains
  145. * the configuration information for the specified CEC peripheral.
  146. * @retval None
  147. */
  148. void CEC_Init(CEC_InitTypeDef* CEC_InitStruct)
  149. {
  150. uint32_t tmpreg = 0;
  151. /* Check the parameters */
  152. assert_param(IS_CEC_SIGNAL_FREE_TIME(CEC_InitStruct->CEC_SignalFreeTime));
  153. assert_param(IS_CEC_RX_TOLERANCE(CEC_InitStruct->CEC_RxTolerance));
  154. assert_param(IS_CEC_STOP_RECEPTION(CEC_InitStruct->CEC_StopReception));
  155. assert_param(IS_CEC_BIT_RISING_ERROR(CEC_InitStruct->CEC_BitRisingError));
  156. assert_param(IS_CEC_LONG_BIT_PERIOD_ERROR(CEC_InitStruct->CEC_LongBitPeriodError));
  157. assert_param(IS_CEC_BDR_NO_GEN_ERROR(CEC_InitStruct->CEC_BRDNoGen));
  158. assert_param(IS_CEC_SFT_OPTION(CEC_InitStruct->CEC_SFTOption));
  159. /* Get the CEC CFGR value */
  160. tmpreg = CEC->CFGR;
  161. /* Clear CFGR bits */
  162. tmpreg &= CFGR_CLEAR_MASK;
  163. /* Configure the CEC peripheral */
  164. tmpreg |= (CEC_InitStruct->CEC_SignalFreeTime | CEC_InitStruct->CEC_RxTolerance |
  165. CEC_InitStruct->CEC_StopReception | CEC_InitStruct->CEC_BitRisingError |
  166. CEC_InitStruct->CEC_LongBitPeriodError| CEC_InitStruct->CEC_BRDNoGen |
  167. CEC_InitStruct->CEC_SFTOption);
  168. /* Write to CEC CFGR register */
  169. CEC->CFGR = tmpreg;
  170. }
  171. /**
  172. * @brief Fills each CEC_InitStruct member with its default value.
  173. * @param CEC_InitStruct: pointer to a CEC_InitTypeDef structure which will
  174. * be initialized.
  175. * @retval None
  176. */
  177. void CEC_StructInit(CEC_InitTypeDef* CEC_InitStruct)
  178. {
  179. CEC_InitStruct->CEC_SignalFreeTime = CEC_SignalFreeTime_Standard;
  180. CEC_InitStruct->CEC_RxTolerance = CEC_RxTolerance_Standard;
  181. CEC_InitStruct->CEC_StopReception = CEC_StopReception_Off;
  182. CEC_InitStruct->CEC_BitRisingError = CEC_BitRisingError_Off;
  183. CEC_InitStruct->CEC_LongBitPeriodError = CEC_LongBitPeriodError_Off;
  184. CEC_InitStruct->CEC_BRDNoGen = CEC_BRDNoGen_Off;
  185. CEC_InitStruct->CEC_SFTOption = CEC_SFTOption_Off;
  186. }
  187. /**
  188. * @brief Enables or disables the CEC peripheral.
  189. * @param NewState: new state of the CEC peripheral.
  190. * This parameter can be: ENABLE or DISABLE.
  191. * @retval None
  192. */
  193. void CEC_Cmd(FunctionalState NewState)
  194. {
  195. assert_param(IS_FUNCTIONAL_STATE(NewState));
  196. if (NewState != DISABLE)
  197. {
  198. /* Enable the CEC peripheral */
  199. CEC->CR |= CEC_CR_CECEN;
  200. }
  201. else
  202. {
  203. /* Disable the CEC peripheral */
  204. CEC->CR &= ~CEC_CR_CECEN;
  205. }
  206. }
  207. /**
  208. * @brief Enables or disables the CEC Listen Mode.
  209. * @param NewState: new state of the Listen Mode.
  210. * This parameter can be: ENABLE or DISABLE.
  211. * @retval None
  212. */
  213. void CEC_ListenModeCmd(FunctionalState NewState)
  214. {
  215. assert_param(IS_FUNCTIONAL_STATE(NewState));
  216. if (NewState != DISABLE)
  217. {
  218. /* Enable the Listen Mode */
  219. CEC->CFGR |= CEC_CFGR_LSTN;
  220. }
  221. else
  222. {
  223. /* Disable the Listen Mode */
  224. CEC->CFGR &= ~CEC_CFGR_LSTN;
  225. }
  226. }
  227. /**
  228. * @brief Defines the Own Address of the CEC device.
  229. * @param CEC_OwnAddress: The CEC own address.
  230. * @retval None
  231. */
  232. void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress)
  233. {
  234. uint32_t tmp =0x00;
  235. /* Check the parameters */
  236. assert_param(IS_CEC_ADDRESS(CEC_OwnAddress));
  237. tmp = 1 <<(CEC_OwnAddress + 16);
  238. /* Set the CEC own address */
  239. CEC->CFGR |= tmp;
  240. }
  241. /**
  242. * @brief Clears the Own Address of the CEC device.
  243. * @param CEC_OwnAddress: The CEC own address.
  244. * @retval None
  245. */
  246. void CEC_OwnAddressClear(void)
  247. {
  248. /* Set the CEC own address */
  249. CEC->CFGR = 0x0;
  250. }
  251. /**
  252. * @}
  253. */
  254. /** @defgroup CEC_Group2 Data transfers functions
  255. * @brief Data transfers functions
  256. *
  257. @verbatim
  258. ===============================================================================
  259. ##### Data transfers functions #####
  260. ===============================================================================
  261. [..] This section provides functions allowing the CEC data transfers.The read
  262. access of the CEC_RXDR register can be done using the CEC_ReceiveData()function
  263. and returns the Rx buffered value. Whereas a write access to the CEC_TXDR can be
  264. done using CEC_SendData() function.
  265. @endverbatim
  266. * @{
  267. */
  268. /**
  269. * @brief Transmits single data through the CEC peripheral.
  270. * @param Data: the data to transmit.
  271. * @retval None
  272. */
  273. void CEC_SendData(uint8_t Data)
  274. {
  275. /* Transmit Data */
  276. CEC->TXDR = Data;
  277. }
  278. /**
  279. * @brief Returns the most recent received data by the CEC peripheral.
  280. * @param None
  281. * @retval The received data.
  282. */
  283. uint8_t CEC_ReceiveData(void)
  284. {
  285. /* Receive Data */
  286. return (uint8_t)(CEC->RXDR);
  287. }
  288. /**
  289. * @brief Starts a new message.
  290. * @param None
  291. * @retval None
  292. */
  293. void CEC_StartOfMessage(void)
  294. {
  295. /* Starts of new message */
  296. CEC->CR |= CEC_CR_TXSOM;
  297. }
  298. /**
  299. * @brief Transmits message with an EOM bit.
  300. * @param None
  301. * @retval None
  302. */
  303. void CEC_EndOfMessage(void)
  304. {
  305. /* The data byte will be transmitted with an EOM bit */
  306. CEC->CR |= CEC_CR_TXEOM;
  307. }
  308. /**
  309. * @}
  310. */
  311. /** @defgroup CEC_Group3 Interrupts and flags management functions
  312. * @brief Interrupts and flags management functions
  313. *
  314. @verbatim
  315. ===============================================================================
  316. ##### Interrupts and flags management functions #####
  317. ===============================================================================
  318. [..] This section provides functions allowing to configure the CEC Interrupts
  319. sources and check or clear the flags or pending bits status.
  320. [..] The user should identify which mode will be used in his application to manage
  321. the communication: Polling mode or Interrupt mode.
  322. [..] In polling mode, the CEC can be managed by the following flags:
  323. (+) CEC_FLAG_TXACKE : to indicate a missing acknowledge in transmission mode.
  324. (+) CEC_FLAG_TXERR : to indicate an error occurs during transmission mode.
  325. The initiator detects low impedance in the CEC line.
  326. (+) CEC_FLAG_TXUDR : to indicate if an underrun error occurs in transmission mode.
  327. The transmission is enabled while the software has not yet
  328. loaded any value into the TXDR register.
  329. (+) CEC_FLAG_TXEND : to indicate the end of successful transmission.
  330. (+) CEC_FLAG_TXBR : to indicate the next transmission data has to be written to TXDR.
  331. (+) CEC_FLAG_ARBLST : to indicate arbitration lost in the case of two CEC devices
  332. starting at the same time.
  333. (+) CEC_FLAG_RXACKE : to indicate a missing acknowledge in receive mode.
  334. (+) CEC_FLAG_LBPE : to indicate a long bit period error generated during receive mode.
  335. (+) CEC_FLAG_SBPE : to indicate a short bit period error generated during receive mode.
  336. (+) CEC_FLAG_BRE : to indicate a bit rising error generated during receive mode.
  337. (+) CEC_FLAG_RXOVR : to indicate if an overrun error occur while receiving a CEC message.
  338. A byte is not yet received while a new byte is stored in the RXDR register.
  339. (+) CEC_FLAG_RXEND : to indicate the end Of reception
  340. (+) CEC_FLAG_RXBR : to indicate a new byte has been received from the CEC line and
  341. stored into the RXDR buffer.
  342. [..]
  343. (@)In this Mode, it is advised to use the following functions:
  344. FlagStatus CEC_GetFlagStatus(uint16_t CEC_FLAG);
  345. void CEC_ClearFlag(uint16_t CEC_FLAG);
  346. [..] In Interrupt mode, the CEC can be managed by the following interrupt sources:
  347. (+) CEC_IT_TXACKE : to indicate a TX Missing acknowledge
  348. (+) CEC_IT_TXACKE : to indicate a missing acknowledge in transmission mode.
  349. (+) CEC_IT_TXERR : to indicate an error occurs during transmission mode.
  350. The initiator detects low impedance in the CEC line.
  351. (+) CEC_IT_TXUDR : to indicate if an underrun error occurs in transmission mode.
  352. The transmission is enabled while the software has not yet
  353. loaded any value into the TXDR register.
  354. (+) CEC_IT_TXEND : to indicate the end of successful transmission.
  355. (+) CEC_IT_TXBR : to indicate the next transmission data has to be written to TXDR register.
  356. (+) CEC_IT_ARBLST : to indicate arbitration lost in the case of two CEC devices
  357. starting at the same time.
  358. (+) CEC_IT_RXACKE : to indicate a missing acknowledge in receive mode.
  359. (+) CEC_IT_LBPE : to indicate a long bit period error generated during receive mode.
  360. (+) CEC_IT_SBPE : to indicate a short bit period error generated during receive mode.
  361. (+) CEC_IT_BRE : to indicate a bit rising error generated during receive mode.
  362. (+) CEC_IT_RXOVR : to indicate if an overrun error occur while receiving a CEC message.
  363. A byte is not yet received while a new byte is stored in the RXDR register.
  364. (+) CEC_IT_RXEND : to indicate the end Of reception
  365. (+) CEC_IT_RXBR : to indicate a new byte has been received from the CEC line and
  366. stored into the RXDR buffer.
  367. [..]
  368. (@)In this Mode it is advised to use the following functions:
  369. void CEC_ITConfig( uint16_t CEC_IT, FunctionalState NewState);
  370. ITStatus CEC_GetITStatus(uint16_t CEC_IT);
  371. void CEC_ClearITPendingBit(uint16_t CEC_IT);
  372. @endverbatim
  373. * @{
  374. */
  375. /**
  376. * @brief Enables or disables the selected CEC interrupts.
  377. * @param CEC_IT: specifies the CEC interrupt source to be enabled.
  378. * This parameter can be any combination of the following values:
  379. * @arg CEC_IT_TXACKE: Tx Missing acknowledge Error
  380. * @arg CEC_IT_TXERR: Tx Error.
  381. * @arg CEC_IT_TXUDR: Tx-Buffer Underrun.
  382. * @arg CEC_IT_TXEND: End of Transmission (successful transmission of the last byte).
  383. * @arg CEC_IT_TXBR: Tx-Byte Request.
  384. * @arg CEC_IT_ARBLST: Arbitration Lost
  385. * @arg CEC_IT_RXACKE: Rx-Missing Acknowledge
  386. * @arg CEC_IT_LBPE: Rx Long period Error
  387. * @arg CEC_IT_SBPE: Rx Short period Error
  388. * @arg CEC_IT_BRE: Rx Bit Rising Error
  389. * @arg CEC_IT_RXOVR: Rx Overrun.
  390. * @arg CEC_IT_RXEND: End Of Reception
  391. * @arg CEC_IT_RXBR: Rx-Byte Received
  392. * @param NewState: new state of the selected CEC interrupts.
  393. * This parameter can be: ENABLE or DISABLE.
  394. * @retval None
  395. */
  396. void CEC_ITConfig(uint16_t CEC_IT, FunctionalState NewState)
  397. {
  398. assert_param(IS_FUNCTIONAL_STATE(NewState));
  399. assert_param(IS_CEC_IT(CEC_IT));
  400. if (NewState != DISABLE)
  401. {
  402. /* Enable the selected CEC interrupt */
  403. CEC->IER |= CEC_IT;
  404. }
  405. else
  406. {
  407. CEC_IT =~CEC_IT;
  408. /* Disable the selected CEC interrupt */
  409. CEC->IER &= CEC_IT;
  410. }
  411. }
  412. /**
  413. * @brief Gets the CEC flag status.
  414. * @param CEC_FLAG: specifies the CEC flag to check.
  415. * This parameter can be one of the following values:
  416. * @arg CEC_FLAG_TXACKE: Tx Missing acknowledge Error
  417. * @arg CEC_FLAG_TXERR: Tx Error.
  418. * @arg CEC_FLAG_TXUDR: Tx-Buffer Underrun.
  419. * @arg CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte).
  420. * @arg CEC_FLAG_TXBR: Tx-Byte Request.
  421. * @arg CEC_FLAG_ARBLST: Arbitration Lost
  422. * @arg CEC_FLAG_RXACKE: Rx-Missing Acknowledge
  423. * @arg CEC_FLAG_LBPE: Rx Long period Error
  424. * @arg CEC_FLAG_SBPE: Rx Short period Error
  425. * @arg CEC_FLAG_BRE: Rx Bit Rissing Error
  426. * @arg CEC_FLAG_RXOVR: Rx Overrun.
  427. * @arg CEC_FLAG_RXEND: End Of Reception.
  428. * @arg CEC_FLAG_RXBR: Rx-Byte Received.
  429. * @retval The new state of CEC_FLAG (SET or RESET)
  430. */
  431. FlagStatus CEC_GetFlagStatus(uint16_t CEC_FLAG)
  432. {
  433. FlagStatus bitstatus = RESET;
  434. assert_param(IS_CEC_GET_FLAG(CEC_FLAG));
  435. /* Check the status of the specified CEC flag */
  436. if ((CEC->ISR & CEC_FLAG) != (uint16_t)RESET)
  437. {
  438. /* CEC flag is set */
  439. bitstatus = SET;
  440. }
  441. else
  442. {
  443. /* CEC flag is reset */
  444. bitstatus = RESET;
  445. }
  446. /* Return the CEC flag status */
  447. return bitstatus;
  448. }
  449. /**
  450. * @brief Clears the CEC's pending flags.
  451. * @param CEC_FLAG: specifies the flag to clear.
  452. * This parameter can be any combination of the following values:
  453. * @arg CEC_FLAG_TXACKE: Tx Missing acknowledge Error
  454. * @arg CEC_FLAG_TXERR: Tx Error
  455. * @arg CEC_FLAG_TXUDR: Tx-Buffer Underrun
  456. * @arg CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte).
  457. * @arg CEC_FLAG_TXBR: Tx-Byte Request
  458. * @arg CEC_FLAG_ARBLST: Arbitration Lost
  459. * @arg CEC_FLAG_RXACKE: Rx Missing Acknowledge
  460. * @arg CEC_FLAG_LBPE: Rx Long period Error
  461. * @arg CEC_FLAG_SBPE: Rx Short period Error
  462. * @arg CEC_FLAG_BRE: Rx Bit Rising Error
  463. * @arg CEC_FLAG_RXOVR: Rx Overrun
  464. * @arg CEC_FLAG_RXEND: End Of Reception
  465. * @arg CEC_FLAG_RXBR: Rx-Byte Received
  466. * @retval None
  467. */
  468. void CEC_ClearFlag(uint32_t CEC_FLAG)
  469. {
  470. assert_param(IS_CEC_CLEAR_FLAG(CEC_FLAG));
  471. /* Clear the selected CEC flag */
  472. CEC->ISR = CEC_FLAG;
  473. }
  474. /**
  475. * @brief Checks whether the specified CEC interrupt has occurred or not.
  476. * @param CEC_IT: specifies the CEC interrupt source to check.
  477. * This parameter can be one of the following values:
  478. * @arg CEC_IT_TXACKE: Tx Missing acknowledge Error
  479. * @arg CEC_IT_TXERR: Tx Error.
  480. * @arg CEC_IT_TXUDR: Tx-Buffer Underrun.
  481. * @arg CEC_IT_TXEND: End of transmission (successful transmission of the last byte).
  482. * @arg CEC_IT_TXBR: Tx-Byte Request.
  483. * @arg CEC_IT_ARBLST: Arbitration Lost.
  484. * @arg CEC_IT_RXACKE: Rx-Missing Acknowledge.
  485. * @arg CEC_IT_LBPE: Rx Long period Error.
  486. * @arg CEC_IT_SBPE: Rx Short period Error.
  487. * @arg CEC_IT_BRE: Rx Bit Rising Error.
  488. * @arg CEC_IT_RXOVR: Rx Overrun.
  489. * @arg CEC_IT_RXEND: End Of Reception.
  490. * @arg CEC_IT_RXBR: Rx-Byte Received
  491. * @retval The new state of CEC_IT (SET or RESET).
  492. */
  493. ITStatus CEC_GetITStatus(uint16_t CEC_IT)
  494. {
  495. ITStatus bitstatus = RESET;
  496. uint32_t enablestatus = 0;
  497. /* Check the parameters */
  498. assert_param(IS_CEC_GET_IT(CEC_IT));
  499. /* Get the CEC IT enable bit status */
  500. enablestatus = (CEC->IER & CEC_IT);
  501. /* Check the status of the specified CEC interrupt */
  502. if (((CEC->ISR & CEC_IT) != (uint32_t)RESET) && enablestatus)
  503. {
  504. /* CEC interrupt is set */
  505. bitstatus = SET;
  506. }
  507. else
  508. {
  509. /* CEC interrupt is reset */
  510. bitstatus = RESET;
  511. }
  512. /* Return the CEC interrupt status */
  513. return bitstatus;
  514. }
  515. /**
  516. * @brief Clears the CEC's interrupt pending bits.
  517. * @param CEC_IT: specifies the CEC interrupt pending bit to clear.
  518. * This parameter can be any combination of the following values:
  519. * @arg CEC_IT_TXACKE: Tx Missing acknowledge Error
  520. * @arg CEC_IT_TXERR: Tx Error
  521. * @arg CEC_IT_TXUDR: Tx-Buffer Underrun
  522. * @arg CEC_IT_TXEND: End of Transmission
  523. * @arg CEC_IT_TXBR: Tx-Byte Request
  524. * @arg CEC_IT_ARBLST: Arbitration Lost
  525. * @arg CEC_IT_RXACKE: Rx-Missing Acknowledge
  526. * @arg CEC_IT_LBPE: Rx Long period Error
  527. * @arg CEC_IT_SBPE: Rx Short period Error
  528. * @arg CEC_IT_BRE: Rx Bit Rising Error
  529. * @arg CEC_IT_RXOVR: Rx Overrun
  530. * @arg CEC_IT_RXEND: End Of Reception
  531. * @arg CEC_IT_RXBR: Rx-Byte Received
  532. * @retval None
  533. */
  534. void CEC_ClearITPendingBit(uint16_t CEC_IT)
  535. {
  536. assert_param(IS_CEC_IT(CEC_IT));
  537. /* Clear the selected CEC interrupt pending bits */
  538. CEC->ISR = CEC_IT;
  539. }
  540. /**
  541. * @}
  542. */
  543. /**
  544. * @}
  545. */
  546. /**
  547. * @}
  548. */
  549. /**
  550. * @}
  551. */
  552. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/