mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Mon Dec 02 11:30:05 2013 +0000
Revision:
52:a51c77007319
Child:
70:c1fbde68b492
Synchronized with git revision 49df530ae72ce97ccc773d1f2c13b38e868e6abd

Full URL: https://github.com/mbedmicro/mbed/commit/49df530ae72ce97ccc773d1f2c13b38e868e6abd/

Add STMicroelectronics NUCLEO_F103RB target

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 52:a51c77007319 1 /**
mbed_official 52:a51c77007319 2 ******************************************************************************
mbed_official 52:a51c77007319 3 * @file stm32f10x_cec.c
mbed_official 52:a51c77007319 4 * @author MCD Application Team
mbed_official 52:a51c77007319 5 * @version V3.5.0
mbed_official 52:a51c77007319 6 * @date 11-March-2011
mbed_official 52:a51c77007319 7 * @brief This file provides all the CEC firmware functions.
mbed_official 52:a51c77007319 8 ******************************************************************************
mbed_official 52:a51c77007319 9 * @attention
mbed_official 52:a51c77007319 10 *
mbed_official 52:a51c77007319 11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
mbed_official 52:a51c77007319 12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
mbed_official 52:a51c77007319 13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
mbed_official 52:a51c77007319 14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
mbed_official 52:a51c77007319 15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
mbed_official 52:a51c77007319 16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
mbed_official 52:a51c77007319 17 *
mbed_official 52:a51c77007319 18 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
mbed_official 52:a51c77007319 19 ******************************************************************************
mbed_official 52:a51c77007319 20 */
mbed_official 52:a51c77007319 21
mbed_official 52:a51c77007319 22 /* Includes ------------------------------------------------------------------*/
mbed_official 52:a51c77007319 23 #include "stm32f10x_cec.h"
mbed_official 52:a51c77007319 24 #include "stm32f10x_rcc.h"
mbed_official 52:a51c77007319 25
mbed_official 52:a51c77007319 26 /** @addtogroup STM32F10x_StdPeriph_Driver
mbed_official 52:a51c77007319 27 * @{
mbed_official 52:a51c77007319 28 */
mbed_official 52:a51c77007319 29
mbed_official 52:a51c77007319 30 /** @defgroup CEC
mbed_official 52:a51c77007319 31 * @brief CEC driver modules
mbed_official 52:a51c77007319 32 * @{
mbed_official 52:a51c77007319 33 */
mbed_official 52:a51c77007319 34
mbed_official 52:a51c77007319 35 /** @defgroup CEC_Private_TypesDefinitions
mbed_official 52:a51c77007319 36 * @{
mbed_official 52:a51c77007319 37 */
mbed_official 52:a51c77007319 38
mbed_official 52:a51c77007319 39 /**
mbed_official 52:a51c77007319 40 * @}
mbed_official 52:a51c77007319 41 */
mbed_official 52:a51c77007319 42
mbed_official 52:a51c77007319 43
mbed_official 52:a51c77007319 44 /** @defgroup CEC_Private_Defines
mbed_official 52:a51c77007319 45 * @{
mbed_official 52:a51c77007319 46 */
mbed_official 52:a51c77007319 47
mbed_official 52:a51c77007319 48 /* ------------ CEC registers bit address in the alias region ----------- */
mbed_official 52:a51c77007319 49 #define CEC_OFFSET (CEC_BASE - PERIPH_BASE)
mbed_official 52:a51c77007319 50
mbed_official 52:a51c77007319 51 /* --- CFGR Register ---*/
mbed_official 52:a51c77007319 52
mbed_official 52:a51c77007319 53 /* Alias word address of PE bit */
mbed_official 52:a51c77007319 54 #define CFGR_OFFSET (CEC_OFFSET + 0x00)
mbed_official 52:a51c77007319 55 #define PE_BitNumber 0x00
mbed_official 52:a51c77007319 56 #define CFGR_PE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (PE_BitNumber * 4))
mbed_official 52:a51c77007319 57
mbed_official 52:a51c77007319 58 /* Alias word address of IE bit */
mbed_official 52:a51c77007319 59 #define IE_BitNumber 0x01
mbed_official 52:a51c77007319 60 #define CFGR_IE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (IE_BitNumber * 4))
mbed_official 52:a51c77007319 61
mbed_official 52:a51c77007319 62 /* --- CSR Register ---*/
mbed_official 52:a51c77007319 63
mbed_official 52:a51c77007319 64 /* Alias word address of TSOM bit */
mbed_official 52:a51c77007319 65 #define CSR_OFFSET (CEC_OFFSET + 0x10)
mbed_official 52:a51c77007319 66 #define TSOM_BitNumber 0x00
mbed_official 52:a51c77007319 67 #define CSR_TSOM_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TSOM_BitNumber * 4))
mbed_official 52:a51c77007319 68
mbed_official 52:a51c77007319 69 /* Alias word address of TEOM bit */
mbed_official 52:a51c77007319 70 #define TEOM_BitNumber 0x01
mbed_official 52:a51c77007319 71 #define CSR_TEOM_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TEOM_BitNumber * 4))
mbed_official 52:a51c77007319 72
mbed_official 52:a51c77007319 73 #define CFGR_CLEAR_Mask (uint8_t)(0xF3) /* CFGR register Mask */
mbed_official 52:a51c77007319 74 #define FLAG_Mask ((uint32_t)0x00FFFFFF) /* CEC FLAG mask */
mbed_official 52:a51c77007319 75
mbed_official 52:a51c77007319 76 /**
mbed_official 52:a51c77007319 77 * @}
mbed_official 52:a51c77007319 78 */
mbed_official 52:a51c77007319 79
mbed_official 52:a51c77007319 80
mbed_official 52:a51c77007319 81 /** @defgroup CEC_Private_Macros
mbed_official 52:a51c77007319 82 * @{
mbed_official 52:a51c77007319 83 */
mbed_official 52:a51c77007319 84
mbed_official 52:a51c77007319 85 /**
mbed_official 52:a51c77007319 86 * @}
mbed_official 52:a51c77007319 87 */
mbed_official 52:a51c77007319 88
mbed_official 52:a51c77007319 89
mbed_official 52:a51c77007319 90 /** @defgroup CEC_Private_Variables
mbed_official 52:a51c77007319 91 * @{
mbed_official 52:a51c77007319 92 */
mbed_official 52:a51c77007319 93
mbed_official 52:a51c77007319 94 /**
mbed_official 52:a51c77007319 95 * @}
mbed_official 52:a51c77007319 96 */
mbed_official 52:a51c77007319 97
mbed_official 52:a51c77007319 98
mbed_official 52:a51c77007319 99 /** @defgroup CEC_Private_FunctionPrototypes
mbed_official 52:a51c77007319 100 * @{
mbed_official 52:a51c77007319 101 */
mbed_official 52:a51c77007319 102
mbed_official 52:a51c77007319 103 /**
mbed_official 52:a51c77007319 104 * @}
mbed_official 52:a51c77007319 105 */
mbed_official 52:a51c77007319 106
mbed_official 52:a51c77007319 107
mbed_official 52:a51c77007319 108 /** @defgroup CEC_Private_Functions
mbed_official 52:a51c77007319 109 * @{
mbed_official 52:a51c77007319 110 */
mbed_official 52:a51c77007319 111
mbed_official 52:a51c77007319 112 /**
mbed_official 52:a51c77007319 113 * @brief Deinitializes the CEC peripheral registers to their default reset
mbed_official 52:a51c77007319 114 * values.
mbed_official 52:a51c77007319 115 * @param None
mbed_official 52:a51c77007319 116 * @retval None
mbed_official 52:a51c77007319 117 */
mbed_official 52:a51c77007319 118 void CEC_DeInit(void)
mbed_official 52:a51c77007319 119 {
mbed_official 52:a51c77007319 120 /* Enable CEC reset state */
mbed_official 52:a51c77007319 121 RCC_APB1PeriphResetCmd(RCC_APB1Periph_CEC, ENABLE);
mbed_official 52:a51c77007319 122 /* Release CEC from reset state */
mbed_official 52:a51c77007319 123 RCC_APB1PeriphResetCmd(RCC_APB1Periph_CEC, DISABLE);
mbed_official 52:a51c77007319 124 }
mbed_official 52:a51c77007319 125
mbed_official 52:a51c77007319 126
mbed_official 52:a51c77007319 127 /**
mbed_official 52:a51c77007319 128 * @brief Initializes the CEC peripheral according to the specified
mbed_official 52:a51c77007319 129 * parameters in the CEC_InitStruct.
mbed_official 52:a51c77007319 130 * @param CEC_InitStruct: pointer to an CEC_InitTypeDef structure that
mbed_official 52:a51c77007319 131 * contains the configuration information for the specified
mbed_official 52:a51c77007319 132 * CEC peripheral.
mbed_official 52:a51c77007319 133 * @retval None
mbed_official 52:a51c77007319 134 */
mbed_official 52:a51c77007319 135 void CEC_Init(CEC_InitTypeDef* CEC_InitStruct)
mbed_official 52:a51c77007319 136 {
mbed_official 52:a51c77007319 137 uint16_t tmpreg = 0;
mbed_official 52:a51c77007319 138
mbed_official 52:a51c77007319 139 /* Check the parameters */
mbed_official 52:a51c77007319 140 assert_param(IS_CEC_BIT_TIMING_ERROR_MODE(CEC_InitStruct->CEC_BitTimingMode));
mbed_official 52:a51c77007319 141 assert_param(IS_CEC_BIT_PERIOD_ERROR_MODE(CEC_InitStruct->CEC_BitPeriodMode));
mbed_official 52:a51c77007319 142
mbed_official 52:a51c77007319 143 /*---------------------------- CEC CFGR Configuration -----------------*/
mbed_official 52:a51c77007319 144 /* Get the CEC CFGR value */
mbed_official 52:a51c77007319 145 tmpreg = CEC->CFGR;
mbed_official 52:a51c77007319 146
mbed_official 52:a51c77007319 147 /* Clear BTEM and BPEM bits */
mbed_official 52:a51c77007319 148 tmpreg &= CFGR_CLEAR_Mask;
mbed_official 52:a51c77007319 149
mbed_official 52:a51c77007319 150 /* Configure CEC: Bit Timing Error and Bit Period Error */
mbed_official 52:a51c77007319 151 tmpreg |= (uint16_t)(CEC_InitStruct->CEC_BitTimingMode | CEC_InitStruct->CEC_BitPeriodMode);
mbed_official 52:a51c77007319 152
mbed_official 52:a51c77007319 153 /* Write to CEC CFGR register*/
mbed_official 52:a51c77007319 154 CEC->CFGR = tmpreg;
mbed_official 52:a51c77007319 155
mbed_official 52:a51c77007319 156 }
mbed_official 52:a51c77007319 157
mbed_official 52:a51c77007319 158 /**
mbed_official 52:a51c77007319 159 * @brief Enables or disables the specified CEC peripheral.
mbed_official 52:a51c77007319 160 * @param NewState: new state of the CEC peripheral.
mbed_official 52:a51c77007319 161 * This parameter can be: ENABLE or DISABLE.
mbed_official 52:a51c77007319 162 * @retval None
mbed_official 52:a51c77007319 163 */
mbed_official 52:a51c77007319 164 void CEC_Cmd(FunctionalState NewState)
mbed_official 52:a51c77007319 165 {
mbed_official 52:a51c77007319 166 /* Check the parameters */
mbed_official 52:a51c77007319 167 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 52:a51c77007319 168
mbed_official 52:a51c77007319 169 *(__IO uint32_t *) CFGR_PE_BB = (uint32_t)NewState;
mbed_official 52:a51c77007319 170
mbed_official 52:a51c77007319 171 if(NewState == DISABLE)
mbed_official 52:a51c77007319 172 {
mbed_official 52:a51c77007319 173 /* Wait until the PE bit is cleared by hardware (Idle Line detected) */
mbed_official 52:a51c77007319 174 while((CEC->CFGR & CEC_CFGR_PE) != (uint32_t)RESET)
mbed_official 52:a51c77007319 175 {
mbed_official 52:a51c77007319 176 }
mbed_official 52:a51c77007319 177 }
mbed_official 52:a51c77007319 178 }
mbed_official 52:a51c77007319 179
mbed_official 52:a51c77007319 180 /**
mbed_official 52:a51c77007319 181 * @brief Enables or disables the CEC interrupt.
mbed_official 52:a51c77007319 182 * @param NewState: new state of the CEC interrupt.
mbed_official 52:a51c77007319 183 * This parameter can be: ENABLE or DISABLE.
mbed_official 52:a51c77007319 184 * @retval None
mbed_official 52:a51c77007319 185 */
mbed_official 52:a51c77007319 186 void CEC_ITConfig(FunctionalState NewState)
mbed_official 52:a51c77007319 187 {
mbed_official 52:a51c77007319 188 /* Check the parameters */
mbed_official 52:a51c77007319 189 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 52:a51c77007319 190
mbed_official 52:a51c77007319 191 *(__IO uint32_t *) CFGR_IE_BB = (uint32_t)NewState;
mbed_official 52:a51c77007319 192 }
mbed_official 52:a51c77007319 193
mbed_official 52:a51c77007319 194 /**
mbed_official 52:a51c77007319 195 * @brief Defines the Own Address of the CEC device.
mbed_official 52:a51c77007319 196 * @param CEC_OwnAddress: The CEC own address
mbed_official 52:a51c77007319 197 * @retval None
mbed_official 52:a51c77007319 198 */
mbed_official 52:a51c77007319 199 void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress)
mbed_official 52:a51c77007319 200 {
mbed_official 52:a51c77007319 201 /* Check the parameters */
mbed_official 52:a51c77007319 202 assert_param(IS_CEC_ADDRESS(CEC_OwnAddress));
mbed_official 52:a51c77007319 203
mbed_official 52:a51c77007319 204 /* Set the CEC own address */
mbed_official 52:a51c77007319 205 CEC->OAR = CEC_OwnAddress;
mbed_official 52:a51c77007319 206 }
mbed_official 52:a51c77007319 207
mbed_official 52:a51c77007319 208 /**
mbed_official 52:a51c77007319 209 * @brief Sets the CEC prescaler value.
mbed_official 52:a51c77007319 210 * @param CEC_Prescaler: CEC prescaler new value
mbed_official 52:a51c77007319 211 * @retval None
mbed_official 52:a51c77007319 212 */
mbed_official 52:a51c77007319 213 void CEC_SetPrescaler(uint16_t CEC_Prescaler)
mbed_official 52:a51c77007319 214 {
mbed_official 52:a51c77007319 215 /* Check the parameters */
mbed_official 52:a51c77007319 216 assert_param(IS_CEC_PRESCALER(CEC_Prescaler));
mbed_official 52:a51c77007319 217
mbed_official 52:a51c77007319 218 /* Set the Prescaler value*/
mbed_official 52:a51c77007319 219 CEC->PRES = CEC_Prescaler;
mbed_official 52:a51c77007319 220 }
mbed_official 52:a51c77007319 221
mbed_official 52:a51c77007319 222 /**
mbed_official 52:a51c77007319 223 * @brief Transmits single data through the CEC peripheral.
mbed_official 52:a51c77007319 224 * @param Data: the data to transmit.
mbed_official 52:a51c77007319 225 * @retval None
mbed_official 52:a51c77007319 226 */
mbed_official 52:a51c77007319 227 void CEC_SendDataByte(uint8_t Data)
mbed_official 52:a51c77007319 228 {
mbed_official 52:a51c77007319 229 /* Transmit Data */
mbed_official 52:a51c77007319 230 CEC->TXD = Data ;
mbed_official 52:a51c77007319 231 }
mbed_official 52:a51c77007319 232
mbed_official 52:a51c77007319 233
mbed_official 52:a51c77007319 234 /**
mbed_official 52:a51c77007319 235 * @brief Returns the most recent received data by the CEC peripheral.
mbed_official 52:a51c77007319 236 * @param None
mbed_official 52:a51c77007319 237 * @retval The received data.
mbed_official 52:a51c77007319 238 */
mbed_official 52:a51c77007319 239 uint8_t CEC_ReceiveDataByte(void)
mbed_official 52:a51c77007319 240 {
mbed_official 52:a51c77007319 241 /* Receive Data */
mbed_official 52:a51c77007319 242 return (uint8_t)(CEC->RXD);
mbed_official 52:a51c77007319 243 }
mbed_official 52:a51c77007319 244
mbed_official 52:a51c77007319 245 /**
mbed_official 52:a51c77007319 246 * @brief Starts a new message.
mbed_official 52:a51c77007319 247 * @param None
mbed_official 52:a51c77007319 248 * @retval None
mbed_official 52:a51c77007319 249 */
mbed_official 52:a51c77007319 250 void CEC_StartOfMessage(void)
mbed_official 52:a51c77007319 251 {
mbed_official 52:a51c77007319 252 /* Starts of new message */
mbed_official 52:a51c77007319 253 *(__IO uint32_t *) CSR_TSOM_BB = (uint32_t)0x1;
mbed_official 52:a51c77007319 254 }
mbed_official 52:a51c77007319 255
mbed_official 52:a51c77007319 256 /**
mbed_official 52:a51c77007319 257 * @brief Transmits message with or without an EOM bit.
mbed_official 52:a51c77007319 258 * @param NewState: new state of the CEC Tx End Of Message.
mbed_official 52:a51c77007319 259 * This parameter can be: ENABLE or DISABLE.
mbed_official 52:a51c77007319 260 * @retval None
mbed_official 52:a51c77007319 261 */
mbed_official 52:a51c77007319 262 void CEC_EndOfMessageCmd(FunctionalState NewState)
mbed_official 52:a51c77007319 263 {
mbed_official 52:a51c77007319 264 /* Check the parameters */
mbed_official 52:a51c77007319 265 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 52:a51c77007319 266
mbed_official 52:a51c77007319 267 /* The data byte will be transmitted with or without an EOM bit*/
mbed_official 52:a51c77007319 268 *(__IO uint32_t *) CSR_TEOM_BB = (uint32_t)NewState;
mbed_official 52:a51c77007319 269 }
mbed_official 52:a51c77007319 270
mbed_official 52:a51c77007319 271 /**
mbed_official 52:a51c77007319 272 * @brief Gets the CEC flag status
mbed_official 52:a51c77007319 273 * @param CEC_FLAG: specifies the CEC flag to check.
mbed_official 52:a51c77007319 274 * This parameter can be one of the following values:
mbed_official 52:a51c77007319 275 * @arg CEC_FLAG_BTE: Bit Timing Error
mbed_official 52:a51c77007319 276 * @arg CEC_FLAG_BPE: Bit Period Error
mbed_official 52:a51c77007319 277 * @arg CEC_FLAG_RBTFE: Rx Block Transfer Finished Error
mbed_official 52:a51c77007319 278 * @arg CEC_FLAG_SBE: Start Bit Error
mbed_official 52:a51c77007319 279 * @arg CEC_FLAG_ACKE: Block Acknowledge Error
mbed_official 52:a51c77007319 280 * @arg CEC_FLAG_LINE: Line Error
mbed_official 52:a51c77007319 281 * @arg CEC_FLAG_TBTFE: Tx Block Transfer Finished Error
mbed_official 52:a51c77007319 282 * @arg CEC_FLAG_TEOM: Tx End Of Message
mbed_official 52:a51c77007319 283 * @arg CEC_FLAG_TERR: Tx Error
mbed_official 52:a51c77007319 284 * @arg CEC_FLAG_TBTRF: Tx Byte Transfer Request or Block Transfer Finished
mbed_official 52:a51c77007319 285 * @arg CEC_FLAG_RSOM: Rx Start Of Message
mbed_official 52:a51c77007319 286 * @arg CEC_FLAG_REOM: Rx End Of Message
mbed_official 52:a51c77007319 287 * @arg CEC_FLAG_RERR: Rx Error
mbed_official 52:a51c77007319 288 * @arg CEC_FLAG_RBTF: Rx Byte/Block Transfer Finished
mbed_official 52:a51c77007319 289 * @retval The new state of CEC_FLAG (SET or RESET)
mbed_official 52:a51c77007319 290 */
mbed_official 52:a51c77007319 291 FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG)
mbed_official 52:a51c77007319 292 {
mbed_official 52:a51c77007319 293 FlagStatus bitstatus = RESET;
mbed_official 52:a51c77007319 294 uint32_t cecreg = 0, cecbase = 0;
mbed_official 52:a51c77007319 295
mbed_official 52:a51c77007319 296 /* Check the parameters */
mbed_official 52:a51c77007319 297 assert_param(IS_CEC_GET_FLAG(CEC_FLAG));
mbed_official 52:a51c77007319 298
mbed_official 52:a51c77007319 299 /* Get the CEC peripheral base address */
mbed_official 52:a51c77007319 300 cecbase = (uint32_t)(CEC_BASE);
mbed_official 52:a51c77007319 301
mbed_official 52:a51c77007319 302 /* Read flag register index */
mbed_official 52:a51c77007319 303 cecreg = CEC_FLAG >> 28;
mbed_official 52:a51c77007319 304
mbed_official 52:a51c77007319 305 /* Get bit[23:0] of the flag */
mbed_official 52:a51c77007319 306 CEC_FLAG &= FLAG_Mask;
mbed_official 52:a51c77007319 307
mbed_official 52:a51c77007319 308 if(cecreg != 0)
mbed_official 52:a51c77007319 309 {
mbed_official 52:a51c77007319 310 /* Flag in CEC ESR Register */
mbed_official 52:a51c77007319 311 CEC_FLAG = (uint32_t)(CEC_FLAG >> 16);
mbed_official 52:a51c77007319 312
mbed_official 52:a51c77007319 313 /* Get the CEC ESR register address */
mbed_official 52:a51c77007319 314 cecbase += 0xC;
mbed_official 52:a51c77007319 315 }
mbed_official 52:a51c77007319 316 else
mbed_official 52:a51c77007319 317 {
mbed_official 52:a51c77007319 318 /* Get the CEC CSR register address */
mbed_official 52:a51c77007319 319 cecbase += 0x10;
mbed_official 52:a51c77007319 320 }
mbed_official 52:a51c77007319 321
mbed_official 52:a51c77007319 322 if(((*(__IO uint32_t *)cecbase) & CEC_FLAG) != (uint32_t)RESET)
mbed_official 52:a51c77007319 323 {
mbed_official 52:a51c77007319 324 /* CEC_FLAG is set */
mbed_official 52:a51c77007319 325 bitstatus = SET;
mbed_official 52:a51c77007319 326 }
mbed_official 52:a51c77007319 327 else
mbed_official 52:a51c77007319 328 {
mbed_official 52:a51c77007319 329 /* CEC_FLAG is reset */
mbed_official 52:a51c77007319 330 bitstatus = RESET;
mbed_official 52:a51c77007319 331 }
mbed_official 52:a51c77007319 332
mbed_official 52:a51c77007319 333 /* Return the CEC_FLAG status */
mbed_official 52:a51c77007319 334 return bitstatus;
mbed_official 52:a51c77007319 335 }
mbed_official 52:a51c77007319 336
mbed_official 52:a51c77007319 337 /**
mbed_official 52:a51c77007319 338 * @brief Clears the CEC's pending flags.
mbed_official 52:a51c77007319 339 * @param CEC_FLAG: specifies the flag to clear.
mbed_official 52:a51c77007319 340 * This parameter can be any combination of the following values:
mbed_official 52:a51c77007319 341 * @arg CEC_FLAG_TERR: Tx Error
mbed_official 52:a51c77007319 342 * @arg CEC_FLAG_TBTRF: Tx Byte Transfer Request or Block Transfer Finished
mbed_official 52:a51c77007319 343 * @arg CEC_FLAG_RSOM: Rx Start Of Message
mbed_official 52:a51c77007319 344 * @arg CEC_FLAG_REOM: Rx End Of Message
mbed_official 52:a51c77007319 345 * @arg CEC_FLAG_RERR: Rx Error
mbed_official 52:a51c77007319 346 * @arg CEC_FLAG_RBTF: Rx Byte/Block Transfer Finished
mbed_official 52:a51c77007319 347 * @retval None
mbed_official 52:a51c77007319 348 */
mbed_official 52:a51c77007319 349 void CEC_ClearFlag(uint32_t CEC_FLAG)
mbed_official 52:a51c77007319 350 {
mbed_official 52:a51c77007319 351 uint32_t tmp = 0x0;
mbed_official 52:a51c77007319 352
mbed_official 52:a51c77007319 353 /* Check the parameters */
mbed_official 52:a51c77007319 354 assert_param(IS_CEC_CLEAR_FLAG(CEC_FLAG));
mbed_official 52:a51c77007319 355
mbed_official 52:a51c77007319 356 tmp = CEC->CSR & 0x2;
mbed_official 52:a51c77007319 357
mbed_official 52:a51c77007319 358 /* Clear the selected CEC flags */
mbed_official 52:a51c77007319 359 CEC->CSR &= (uint32_t)(((~(uint32_t)CEC_FLAG) & 0xFFFFFFFC) | tmp);
mbed_official 52:a51c77007319 360 }
mbed_official 52:a51c77007319 361
mbed_official 52:a51c77007319 362 /**
mbed_official 52:a51c77007319 363 * @brief Checks whether the specified CEC interrupt has occurred or not.
mbed_official 52:a51c77007319 364 * @param CEC_IT: specifies the CEC interrupt source to check.
mbed_official 52:a51c77007319 365 * This parameter can be one of the following values:
mbed_official 52:a51c77007319 366 * @arg CEC_IT_TERR: Tx Error
mbed_official 52:a51c77007319 367 * @arg CEC_IT_TBTF: Tx Block Transfer Finished
mbed_official 52:a51c77007319 368 * @arg CEC_IT_RERR: Rx Error
mbed_official 52:a51c77007319 369 * @arg CEC_IT_RBTF: Rx Block Transfer Finished
mbed_official 52:a51c77007319 370 * @retval The new state of CEC_IT (SET or RESET).
mbed_official 52:a51c77007319 371 */
mbed_official 52:a51c77007319 372 ITStatus CEC_GetITStatus(uint8_t CEC_IT)
mbed_official 52:a51c77007319 373 {
mbed_official 52:a51c77007319 374 ITStatus bitstatus = RESET;
mbed_official 52:a51c77007319 375 uint32_t enablestatus = 0;
mbed_official 52:a51c77007319 376
mbed_official 52:a51c77007319 377 /* Check the parameters */
mbed_official 52:a51c77007319 378 assert_param(IS_CEC_GET_IT(CEC_IT));
mbed_official 52:a51c77007319 379
mbed_official 52:a51c77007319 380 /* Get the CEC IT enable bit status */
mbed_official 52:a51c77007319 381 enablestatus = (CEC->CFGR & (uint8_t)CEC_CFGR_IE) ;
mbed_official 52:a51c77007319 382
mbed_official 52:a51c77007319 383 /* Check the status of the specified CEC interrupt */
mbed_official 52:a51c77007319 384 if (((CEC->CSR & CEC_IT) != (uint32_t)RESET) && enablestatus)
mbed_official 52:a51c77007319 385 {
mbed_official 52:a51c77007319 386 /* CEC_IT is set */
mbed_official 52:a51c77007319 387 bitstatus = SET;
mbed_official 52:a51c77007319 388 }
mbed_official 52:a51c77007319 389 else
mbed_official 52:a51c77007319 390 {
mbed_official 52:a51c77007319 391 /* CEC_IT is reset */
mbed_official 52:a51c77007319 392 bitstatus = RESET;
mbed_official 52:a51c77007319 393 }
mbed_official 52:a51c77007319 394 /* Return the CEC_IT status */
mbed_official 52:a51c77007319 395 return bitstatus;
mbed_official 52:a51c77007319 396 }
mbed_official 52:a51c77007319 397
mbed_official 52:a51c77007319 398 /**
mbed_official 52:a51c77007319 399 * @brief Clears the CEC's interrupt pending bits.
mbed_official 52:a51c77007319 400 * @param CEC_IT: specifies the CEC interrupt pending bit to clear.
mbed_official 52:a51c77007319 401 * This parameter can be any combination of the following values:
mbed_official 52:a51c77007319 402 * @arg CEC_IT_TERR: Tx Error
mbed_official 52:a51c77007319 403 * @arg CEC_IT_TBTF: Tx Block Transfer Finished
mbed_official 52:a51c77007319 404 * @arg CEC_IT_RERR: Rx Error
mbed_official 52:a51c77007319 405 * @arg CEC_IT_RBTF: Rx Block Transfer Finished
mbed_official 52:a51c77007319 406 * @retval None
mbed_official 52:a51c77007319 407 */
mbed_official 52:a51c77007319 408 void CEC_ClearITPendingBit(uint16_t CEC_IT)
mbed_official 52:a51c77007319 409 {
mbed_official 52:a51c77007319 410 uint32_t tmp = 0x0;
mbed_official 52:a51c77007319 411
mbed_official 52:a51c77007319 412 /* Check the parameters */
mbed_official 52:a51c77007319 413 assert_param(IS_CEC_GET_IT(CEC_IT));
mbed_official 52:a51c77007319 414
mbed_official 52:a51c77007319 415 tmp = CEC->CSR & 0x2;
mbed_official 52:a51c77007319 416
mbed_official 52:a51c77007319 417 /* Clear the selected CEC interrupt pending bits */
mbed_official 52:a51c77007319 418 CEC->CSR &= (uint32_t)(((~(uint32_t)CEC_IT) & 0xFFFFFFFC) | tmp);
mbed_official 52:a51c77007319 419 }
mbed_official 52:a51c77007319 420
mbed_official 52:a51c77007319 421 /**
mbed_official 52:a51c77007319 422 * @}
mbed_official 52:a51c77007319 423 */
mbed_official 52:a51c77007319 424
mbed_official 52:a51c77007319 425 /**
mbed_official 52:a51c77007319 426 * @}
mbed_official 52:a51c77007319 427 */
mbed_official 52:a51c77007319 428
mbed_official 52:a51c77007319 429 /**
mbed_official 52:a51c77007319 430 * @}
mbed_official 52:a51c77007319 431 */
mbed_official 52:a51c77007319 432
mbed_official 52:a51c77007319 433 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/