mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Mon Feb 03 09:30:05 2014 +0000
Revision:
84:f54042cbc282
Parent:
70:c1fbde68b492
Synchronized with git revision bbbd8699601c42149ccf0c37bc42bb6856ccc4c6

Full URL: https://github.com/mbedmicro/mbed/commit/bbbd8699601c42149ccf0c37bc42bb6856ccc4c6/

[NUCLEO_L152RE/F030_R8] SPI, I2C, Ticker, PWM updates

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