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