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