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