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