mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F334R8/stm32f3xx_hal_cec.c@310:6188e0254baa, 2014-09-16 (annotated)
- Committer:
- janekm
- Date:
- Tue Sep 16 22:42:01 2014 +0000
- Revision:
- 310:6188e0254baa
- Parent:
- 237:f3da66175598
N/A
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 237:f3da66175598 | 1 | /** |
mbed_official | 237:f3da66175598 | 2 | ****************************************************************************** |
mbed_official | 237:f3da66175598 | 3 | * @file stm32f3xx_hal_cec.c |
mbed_official | 237:f3da66175598 | 4 | * @author MCD Application Team |
mbed_official | 237:f3da66175598 | 5 | * @version V1.0.1 |
mbed_official | 237:f3da66175598 | 6 | * @date 18-June-2014 |
mbed_official | 237:f3da66175598 | 7 | * @brief CEC HAL module driver. |
mbed_official | 237:f3da66175598 | 8 | * |
mbed_official | 237:f3da66175598 | 9 | * This file provides firmware functions to manage the following |
mbed_official | 237:f3da66175598 | 10 | * functionalities of the High Definition Multimedia Interface |
mbed_official | 237:f3da66175598 | 11 | * Consumer Electronics Control Peripheral (CEC). |
mbed_official | 237:f3da66175598 | 12 | * + Initialization and de-initialization functions |
mbed_official | 237:f3da66175598 | 13 | * + IO operation functions |
mbed_official | 237:f3da66175598 | 14 | * + Peripheral Control functions |
mbed_official | 237:f3da66175598 | 15 | * |
mbed_official | 237:f3da66175598 | 16 | * |
mbed_official | 237:f3da66175598 | 17 | @verbatim |
mbed_official | 237:f3da66175598 | 18 | =============================================================================== |
mbed_official | 237:f3da66175598 | 19 | ##### How to use this driver ##### |
mbed_official | 237:f3da66175598 | 20 | =============================================================================== |
mbed_official | 237:f3da66175598 | 21 | [..] |
mbed_official | 237:f3da66175598 | 22 | The CEC HAL driver can be used as follows: |
mbed_official | 237:f3da66175598 | 23 | |
mbed_official | 237:f3da66175598 | 24 | (#) Declare a CEC_HandleTypeDef handle structure. |
mbed_official | 237:f3da66175598 | 25 | (#) Initialize the CEC low level resources by implementing the HAL_CEC_MspInit ()API: |
mbed_official | 237:f3da66175598 | 26 | (##) Enable the CEC interface clock. |
mbed_official | 237:f3da66175598 | 27 | (##) CEC pins configuration: |
mbed_official | 237:f3da66175598 | 28 | (+) Enable the clock for the CEC GPIOs. |
mbed_official | 237:f3da66175598 | 29 | (+) Configure these CEC pins as alternate function pull-up. |
mbed_official | 237:f3da66175598 | 30 | (##) NVIC configuration if you need to use interrupt process (HAL_CEC_Transmit_IT() |
mbed_official | 237:f3da66175598 | 31 | and HAL_CEC_Receive_IT() APIs): |
mbed_official | 237:f3da66175598 | 32 | (+) Configure the CEC interrupt priority. |
mbed_official | 237:f3da66175598 | 33 | (+) Enable the NVIC CEC IRQ handle. |
mbed_official | 237:f3da66175598 | 34 | (@) The specific CEC interrupts (Transmission complete interrupt, |
mbed_official | 237:f3da66175598 | 35 | RXNE interrupt and Error Interrupts) will be managed using the macros |
mbed_official | 237:f3da66175598 | 36 | __HAL_CEC_ENABLE_IT() and __HAL_CEC_DISABLE_IT() inside the transmit |
mbed_official | 237:f3da66175598 | 37 | and receive process. |
mbed_official | 237:f3da66175598 | 38 | |
mbed_official | 237:f3da66175598 | 39 | (#) Program the Signal Free Time (SFT) and SFT option, Tolerance, reception stop in |
mbed_official | 237:f3da66175598 | 40 | in case of Bit Rising Error, Error-Bit generation conditions, device logical |
mbed_official | 237:f3da66175598 | 41 | address and Listen mode in the hcec Init structure. |
mbed_official | 237:f3da66175598 | 42 | |
mbed_official | 237:f3da66175598 | 43 | (#) Initialize the CEC registers by calling the HAL_CEC_Init() API. |
mbed_official | 237:f3da66175598 | 44 | |
mbed_official | 237:f3da66175598 | 45 | (@) This API (HAL_CEC_Init()) configures also the low level Hardware GPIO, CLOCK, CORTEX...etc) |
mbed_official | 237:f3da66175598 | 46 | by calling the customed HAL_CEC_MspInit() API. |
mbed_official | 237:f3da66175598 | 47 | |
mbed_official | 237:f3da66175598 | 48 | @endverbatim |
mbed_official | 237:f3da66175598 | 49 | ****************************************************************************** |
mbed_official | 237:f3da66175598 | 50 | * @attention |
mbed_official | 237:f3da66175598 | 51 | * |
mbed_official | 237:f3da66175598 | 52 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 237:f3da66175598 | 53 | * |
mbed_official | 237:f3da66175598 | 54 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 237:f3da66175598 | 55 | * are permitted provided that the following conditions are met: |
mbed_official | 237:f3da66175598 | 56 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 237:f3da66175598 | 57 | * this list of conditions and the following disclaimer. |
mbed_official | 237:f3da66175598 | 58 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 237:f3da66175598 | 59 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 237:f3da66175598 | 60 | * and/or other materials provided with the distribution. |
mbed_official | 237:f3da66175598 | 61 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 237:f3da66175598 | 62 | * may be used to endorse or promote products derived from this software |
mbed_official | 237:f3da66175598 | 63 | * without specific prior written permission. |
mbed_official | 237:f3da66175598 | 64 | * |
mbed_official | 237:f3da66175598 | 65 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 237:f3da66175598 | 66 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 237:f3da66175598 | 67 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 237:f3da66175598 | 68 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 237:f3da66175598 | 69 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 237:f3da66175598 | 70 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 237:f3da66175598 | 71 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 237:f3da66175598 | 72 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 237:f3da66175598 | 73 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 237:f3da66175598 | 74 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 237:f3da66175598 | 75 | * |
mbed_official | 237:f3da66175598 | 76 | ****************************************************************************** |
mbed_official | 237:f3da66175598 | 77 | */ |
mbed_official | 237:f3da66175598 | 78 | |
mbed_official | 237:f3da66175598 | 79 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 80 | #include "stm32f3xx_hal.h" |
mbed_official | 237:f3da66175598 | 81 | |
mbed_official | 237:f3da66175598 | 82 | /** @addtogroup STM32F3xx_HAL_Driver |
mbed_official | 237:f3da66175598 | 83 | * @{ |
mbed_official | 237:f3da66175598 | 84 | */ |
mbed_official | 237:f3da66175598 | 85 | |
mbed_official | 237:f3da66175598 | 86 | /** @defgroup CEC |
mbed_official | 237:f3da66175598 | 87 | * @brief HAL CEC module driver |
mbed_official | 237:f3da66175598 | 88 | * @{ |
mbed_official | 237:f3da66175598 | 89 | */ |
mbed_official | 237:f3da66175598 | 90 | #ifdef HAL_CEC_MODULE_ENABLED |
mbed_official | 237:f3da66175598 | 91 | |
mbed_official | 237:f3da66175598 | 92 | #if defined(STM32F373xC) || defined(STM32F378xx) |
mbed_official | 237:f3da66175598 | 93 | |
mbed_official | 237:f3da66175598 | 94 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 95 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 96 | #define CEC_CFGR_FIELDS (CEC_CFGR_SFT | CEC_CFGR_RXTOL | CEC_CFGR_BRESTP \ |
mbed_official | 237:f3da66175598 | 97 | | CEC_CFGR_BREGEN | CEC_CFGR_LBPEGEN | CEC_CFGR_SFTOPT \ |
mbed_official | 237:f3da66175598 | 98 | | CEC_CFGR_BRDNOGEN | CEC_CFGR_OAR | CEC_CFGR_LSTN) |
mbed_official | 237:f3da66175598 | 99 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 100 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 101 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 102 | static HAL_StatusTypeDef CEC_Transmit_IT(CEC_HandleTypeDef *hcec); |
mbed_official | 237:f3da66175598 | 103 | static HAL_StatusTypeDef CEC_Receive_IT(CEC_HandleTypeDef *hcec); |
mbed_official | 237:f3da66175598 | 104 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 105 | |
mbed_official | 237:f3da66175598 | 106 | /** @defgroup CEC_Private_Functions |
mbed_official | 237:f3da66175598 | 107 | * @{ |
mbed_official | 237:f3da66175598 | 108 | */ |
mbed_official | 237:f3da66175598 | 109 | |
mbed_official | 237:f3da66175598 | 110 | /** @defgroup HAL_CEC_Group1 Initialization/de-initialization functions |
mbed_official | 237:f3da66175598 | 111 | * @brief Initialization and Configuration functions |
mbed_official | 237:f3da66175598 | 112 | * |
mbed_official | 237:f3da66175598 | 113 | @verbatim |
mbed_official | 237:f3da66175598 | 114 | =============================================================================== |
mbed_official | 237:f3da66175598 | 115 | ##### Initialization and Configuration functions ##### |
mbed_official | 237:f3da66175598 | 116 | =============================================================================== |
mbed_official | 237:f3da66175598 | 117 | [..] |
mbed_official | 237:f3da66175598 | 118 | This subsection provides a set of functions allowing to initialize the CEC |
mbed_official | 237:f3da66175598 | 119 | (+) The following parameters need to be configured: |
mbed_official | 237:f3da66175598 | 120 | (++) SignalFreeTime |
mbed_official | 237:f3da66175598 | 121 | (++) Tolerance |
mbed_official | 237:f3da66175598 | 122 | (++) BRERxStop (RX stopped or not upon Bit Rising Error) |
mbed_official | 237:f3da66175598 | 123 | (++) BREErrorBitGen (Error-Bit generation in case of Bit Rising Error) |
mbed_official | 237:f3da66175598 | 124 | (++) LBPEErrorBitGen (Error-Bit generation in case of Long Bit Period Error) |
mbed_official | 237:f3da66175598 | 125 | (++) BroadcastMsgNoErrorBitGen (Error-bit generation in case of broadcast message error) |
mbed_official | 237:f3da66175598 | 126 | (++) SignalFreeTimeOption (SFT Timer start definition) |
mbed_official | 237:f3da66175598 | 127 | (++) OwnAddress (CEC device address) |
mbed_official | 237:f3da66175598 | 128 | (++) ListenMode |
mbed_official | 237:f3da66175598 | 129 | |
mbed_official | 237:f3da66175598 | 130 | @endverbatim |
mbed_official | 237:f3da66175598 | 131 | * @{ |
mbed_official | 237:f3da66175598 | 132 | */ |
mbed_official | 237:f3da66175598 | 133 | |
mbed_official | 237:f3da66175598 | 134 | /** |
mbed_official | 237:f3da66175598 | 135 | * @brief Initializes the CEC mode according to the specified |
mbed_official | 237:f3da66175598 | 136 | * parameters in the CEC_InitTypeDef and creates the associated handle . |
mbed_official | 237:f3da66175598 | 137 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 138 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 139 | */ |
mbed_official | 237:f3da66175598 | 140 | HAL_StatusTypeDef HAL_CEC_Init(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 141 | { |
mbed_official | 237:f3da66175598 | 142 | uint32_t tmpreg = 0x0; |
mbed_official | 237:f3da66175598 | 143 | |
mbed_official | 237:f3da66175598 | 144 | /* Check the CEC handle allocation */ |
mbed_official | 237:f3da66175598 | 145 | if(hcec == NULL) |
mbed_official | 237:f3da66175598 | 146 | { |
mbed_official | 237:f3da66175598 | 147 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 148 | } |
mbed_official | 237:f3da66175598 | 149 | |
mbed_official | 237:f3da66175598 | 150 | /* Check the parameters */ |
mbed_official | 237:f3da66175598 | 151 | assert_param(IS_CEC_ALL_INSTANCE(hcec->Instance)); |
mbed_official | 237:f3da66175598 | 152 | assert_param(IS_CEC_SIGNALFREETIME(hcec->Init.SignalFreeTime)); |
mbed_official | 237:f3da66175598 | 153 | assert_param(IS_CEC_TOLERANCE(hcec->Init.Tolerance)); |
mbed_official | 237:f3da66175598 | 154 | assert_param(IS_CEC_BRERXSTOP(hcec->Init.BRERxStop)); |
mbed_official | 237:f3da66175598 | 155 | assert_param(IS_CEC_BREERRORBITGEN(hcec->Init.BREErrorBitGen)); |
mbed_official | 237:f3da66175598 | 156 | assert_param(IS_CEC_LBPEERRORBITGEN(hcec->Init.LBPEErrorBitGen)); |
mbed_official | 237:f3da66175598 | 157 | assert_param(IS_CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION(hcec->Init.BroadcastMsgNoErrorBitGen)); |
mbed_official | 237:f3da66175598 | 158 | assert_param(IS_CEC_SFTOP(hcec->Init.SignalFreeTimeOption)); |
mbed_official | 237:f3da66175598 | 159 | assert_param(IS_CEC_OAR_ADDRESS(hcec->Init.OwnAddress)); |
mbed_official | 237:f3da66175598 | 160 | assert_param(IS_CEC_LISTENING_MODE(hcec->Init.ListenMode)); |
mbed_official | 237:f3da66175598 | 161 | assert_param(IS_CEC_ADDRESS(hcec->Init.InitiatorAddress)); |
mbed_official | 237:f3da66175598 | 162 | |
mbed_official | 237:f3da66175598 | 163 | |
mbed_official | 237:f3da66175598 | 164 | if(hcec->State == HAL_CEC_STATE_RESET) |
mbed_official | 237:f3da66175598 | 165 | { |
mbed_official | 237:f3da66175598 | 166 | /* Init the low level hardware : GPIO, CLOCK */ |
mbed_official | 237:f3da66175598 | 167 | HAL_CEC_MspInit(hcec); |
mbed_official | 237:f3da66175598 | 168 | } |
mbed_official | 237:f3da66175598 | 169 | |
mbed_official | 237:f3da66175598 | 170 | hcec->State = HAL_CEC_STATE_BUSY; |
mbed_official | 237:f3da66175598 | 171 | |
mbed_official | 237:f3da66175598 | 172 | /* Disable the Peripheral */ |
mbed_official | 237:f3da66175598 | 173 | __HAL_CEC_DISABLE(hcec); |
mbed_official | 237:f3da66175598 | 174 | |
mbed_official | 237:f3da66175598 | 175 | tmpreg = hcec->Init.SignalFreeTime; |
mbed_official | 237:f3da66175598 | 176 | tmpreg |= hcec->Init.Tolerance; |
mbed_official | 237:f3da66175598 | 177 | tmpreg |= hcec->Init.BRERxStop; |
mbed_official | 237:f3da66175598 | 178 | tmpreg |= hcec->Init.BREErrorBitGen; |
mbed_official | 237:f3da66175598 | 179 | tmpreg |= hcec->Init.LBPEErrorBitGen; |
mbed_official | 237:f3da66175598 | 180 | tmpreg |= hcec->Init.BroadcastMsgNoErrorBitGen; |
mbed_official | 237:f3da66175598 | 181 | tmpreg |= hcec->Init.SignalFreeTimeOption; |
mbed_official | 237:f3da66175598 | 182 | tmpreg |= (hcec->Init.OwnAddress << CEC_CFGR_OAR_LSB_POS); |
mbed_official | 237:f3da66175598 | 183 | tmpreg |= hcec->Init.ListenMode; |
mbed_official | 237:f3da66175598 | 184 | |
mbed_official | 237:f3da66175598 | 185 | /* Write to CEC Control Register */ |
mbed_official | 237:f3da66175598 | 186 | MODIFY_REG(hcec->Instance->CFGR, CEC_CFGR_FIELDS, tmpreg); |
mbed_official | 237:f3da66175598 | 187 | |
mbed_official | 237:f3da66175598 | 188 | /* Enable the Peripheral */ |
mbed_official | 237:f3da66175598 | 189 | __HAL_CEC_ENABLE(hcec); |
mbed_official | 237:f3da66175598 | 190 | |
mbed_official | 237:f3da66175598 | 191 | hcec->State = HAL_CEC_STATE_READY; |
mbed_official | 237:f3da66175598 | 192 | |
mbed_official | 237:f3da66175598 | 193 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 194 | } |
mbed_official | 237:f3da66175598 | 195 | |
mbed_official | 237:f3da66175598 | 196 | |
mbed_official | 237:f3da66175598 | 197 | |
mbed_official | 237:f3da66175598 | 198 | /** |
mbed_official | 237:f3da66175598 | 199 | * @brief DeInitializes the CEC peripheral |
mbed_official | 237:f3da66175598 | 200 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 201 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 202 | */ |
mbed_official | 237:f3da66175598 | 203 | HAL_StatusTypeDef HAL_CEC_DeInit(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 204 | { |
mbed_official | 237:f3da66175598 | 205 | /* Check the CEC handle allocation */ |
mbed_official | 237:f3da66175598 | 206 | if(hcec == NULL) |
mbed_official | 237:f3da66175598 | 207 | { |
mbed_official | 237:f3da66175598 | 208 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 209 | } |
mbed_official | 237:f3da66175598 | 210 | |
mbed_official | 237:f3da66175598 | 211 | /* Check the parameters */ |
mbed_official | 237:f3da66175598 | 212 | assert_param(IS_CEC_ALL_INSTANCE(hcec->Instance)); |
mbed_official | 237:f3da66175598 | 213 | |
mbed_official | 237:f3da66175598 | 214 | hcec->State = HAL_CEC_STATE_BUSY; |
mbed_official | 237:f3da66175598 | 215 | |
mbed_official | 237:f3da66175598 | 216 | /* DeInit the low level hardware */ |
mbed_official | 237:f3da66175598 | 217 | HAL_CEC_MspDeInit(hcec); |
mbed_official | 237:f3da66175598 | 218 | /* Disable the Peripheral */ |
mbed_official | 237:f3da66175598 | 219 | __HAL_CEC_DISABLE(hcec); |
mbed_official | 237:f3da66175598 | 220 | |
mbed_official | 237:f3da66175598 | 221 | hcec->ErrorCode = HAL_CEC_ERROR_NONE; |
mbed_official | 237:f3da66175598 | 222 | hcec->State = HAL_CEC_STATE_RESET; |
mbed_official | 237:f3da66175598 | 223 | |
mbed_official | 237:f3da66175598 | 224 | /* Process Unlock */ |
mbed_official | 237:f3da66175598 | 225 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 226 | |
mbed_official | 237:f3da66175598 | 227 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 228 | } |
mbed_official | 237:f3da66175598 | 229 | |
mbed_official | 237:f3da66175598 | 230 | /** |
mbed_official | 237:f3da66175598 | 231 | * @brief CEC MSP Init |
mbed_official | 237:f3da66175598 | 232 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 233 | * @retval None |
mbed_official | 237:f3da66175598 | 234 | */ |
mbed_official | 237:f3da66175598 | 235 | __weak void HAL_CEC_MspInit(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 236 | { |
mbed_official | 237:f3da66175598 | 237 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 237:f3da66175598 | 238 | the HAL_CEC_MspInit can be implemented in the user file |
mbed_official | 237:f3da66175598 | 239 | */ |
mbed_official | 237:f3da66175598 | 240 | } |
mbed_official | 237:f3da66175598 | 241 | |
mbed_official | 237:f3da66175598 | 242 | /** |
mbed_official | 237:f3da66175598 | 243 | * @brief CEC MSP DeInit |
mbed_official | 237:f3da66175598 | 244 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 245 | * @retval None |
mbed_official | 237:f3da66175598 | 246 | */ |
mbed_official | 237:f3da66175598 | 247 | __weak void HAL_CEC_MspDeInit(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 248 | { |
mbed_official | 237:f3da66175598 | 249 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 237:f3da66175598 | 250 | the HAL_CEC_MspDeInit can be implemented in the user file |
mbed_official | 237:f3da66175598 | 251 | */ |
mbed_official | 237:f3da66175598 | 252 | } |
mbed_official | 237:f3da66175598 | 253 | |
mbed_official | 237:f3da66175598 | 254 | /** |
mbed_official | 237:f3da66175598 | 255 | * @} |
mbed_official | 237:f3da66175598 | 256 | */ |
mbed_official | 237:f3da66175598 | 257 | |
mbed_official | 237:f3da66175598 | 258 | /** @defgroup HAL_CEC_Group2 IO operation functions |
mbed_official | 237:f3da66175598 | 259 | * @brief CEC Transmit/Receive functions |
mbed_official | 237:f3da66175598 | 260 | * |
mbed_official | 237:f3da66175598 | 261 | @verbatim |
mbed_official | 237:f3da66175598 | 262 | =============================================================================== |
mbed_official | 237:f3da66175598 | 263 | ##### I/O operation functions ##### |
mbed_official | 237:f3da66175598 | 264 | =============================================================================== |
mbed_official | 237:f3da66175598 | 265 | This subsection provides a set of functions allowing to manage the CEC data transfers. |
mbed_official | 237:f3da66175598 | 266 | |
mbed_official | 237:f3da66175598 | 267 | (#) The CEC handle must contain the initiator (TX side) and the destination (RX side) |
mbed_official | 237:f3da66175598 | 268 | logical addresses (4-bit long addresses, 0xF for broadcast messages destination) |
mbed_official | 237:f3da66175598 | 269 | |
mbed_official | 237:f3da66175598 | 270 | (#) There are two mode of transfer: |
mbed_official | 237:f3da66175598 | 271 | (+) Blocking mode: The communication is performed in polling mode. |
mbed_official | 237:f3da66175598 | 272 | The HAL status of all data processing is returned by the same function |
mbed_official | 237:f3da66175598 | 273 | after finishing transfer. |
mbed_official | 237:f3da66175598 | 274 | (+) No-Blocking mode: The communication is performed using Interrupts. |
mbed_official | 237:f3da66175598 | 275 | These API's return the HAL status. |
mbed_official | 237:f3da66175598 | 276 | The end of the data processing will be indicated through the |
mbed_official | 237:f3da66175598 | 277 | dedicated CEC IRQ when using Interrupt mode. |
mbed_official | 237:f3da66175598 | 278 | The HAL_CEC_TxCpltCallback(), HAL_CEC_RxCpltCallback() user callbacks |
mbed_official | 237:f3da66175598 | 279 | will be executed respectivelly at the end of the transmit or Receive process |
mbed_official | 237:f3da66175598 | 280 | The HAL_CEC_ErrorCallback()user callback will be executed when a communication |
mbed_official | 237:f3da66175598 | 281 | error is detected |
mbed_official | 237:f3da66175598 | 282 | |
mbed_official | 237:f3da66175598 | 283 | (#) Blocking mode API's are : |
mbed_official | 237:f3da66175598 | 284 | (+) HAL_CEC_Transmit() |
mbed_official | 237:f3da66175598 | 285 | (+) HAL_CEC_Receive() |
mbed_official | 237:f3da66175598 | 286 | |
mbed_official | 237:f3da66175598 | 287 | (#) Non-Blocking mode API's with Interrupt are : |
mbed_official | 237:f3da66175598 | 288 | (+) HAL_CEC_Transmit_IT() |
mbed_official | 237:f3da66175598 | 289 | (+) HAL_CEC_Receive_IT() |
mbed_official | 237:f3da66175598 | 290 | (+) HAL_CEC_IRQHandler() |
mbed_official | 237:f3da66175598 | 291 | |
mbed_official | 237:f3da66175598 | 292 | (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: |
mbed_official | 237:f3da66175598 | 293 | (+) HAL_CEC_TxCpltCallback() |
mbed_official | 237:f3da66175598 | 294 | (+) HAL_CEC_RxCpltCallback() |
mbed_official | 237:f3da66175598 | 295 | (+) HAL_CEC_ErrorCallback() |
mbed_official | 237:f3da66175598 | 296 | |
mbed_official | 237:f3da66175598 | 297 | @endverbatim |
mbed_official | 237:f3da66175598 | 298 | * @{ |
mbed_official | 237:f3da66175598 | 299 | */ |
mbed_official | 237:f3da66175598 | 300 | |
mbed_official | 237:f3da66175598 | 301 | /** |
mbed_official | 237:f3da66175598 | 302 | * @brief Send data in blocking mode |
mbed_official | 237:f3da66175598 | 303 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 304 | * @param DestinationAddress: destination logical address |
mbed_official | 237:f3da66175598 | 305 | * @param pData: pointer to input byte data buffer |
mbed_official | 237:f3da66175598 | 306 | * @param Size: amount of data to be sent in bytes (without counting the header). |
mbed_official | 237:f3da66175598 | 307 | * 0 means only the header is sent (ping operation). |
mbed_official | 237:f3da66175598 | 308 | * Maximum TX size is 15 bytes (1 opcode and up to 14 operands). |
mbed_official | 237:f3da66175598 | 309 | * @param Timeout: Timeout duration. |
mbed_official | 237:f3da66175598 | 310 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 311 | */ |
mbed_official | 237:f3da66175598 | 312 | HAL_StatusTypeDef HAL_CEC_Transmit(CEC_HandleTypeDef *hcec, uint8_t DestinationAddress, uint8_t *pData, uint32_t Size, uint32_t Timeout) |
mbed_official | 237:f3da66175598 | 313 | { |
mbed_official | 237:f3da66175598 | 314 | uint8_t temp = 0; |
mbed_official | 237:f3da66175598 | 315 | uint32_t tempisr = 0; |
mbed_official | 237:f3da66175598 | 316 | uint32_t tickstart = 0; |
mbed_official | 237:f3da66175598 | 317 | |
mbed_official | 237:f3da66175598 | 318 | if((hcec->State == HAL_CEC_STATE_READY) && (__HAL_CEC_GET_TRANSMISSION_START_FLAG(hcec) == RESET)) |
mbed_official | 237:f3da66175598 | 319 | { |
mbed_official | 237:f3da66175598 | 320 | hcec->ErrorCode = HAL_CEC_ERROR_NONE; |
mbed_official | 237:f3da66175598 | 321 | if((pData == NULL) && (Size > 0)) |
mbed_official | 237:f3da66175598 | 322 | { |
mbed_official | 237:f3da66175598 | 323 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 324 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 325 | } |
mbed_official | 237:f3da66175598 | 326 | |
mbed_official | 237:f3da66175598 | 327 | assert_param(IS_CEC_ADDRESS(DestinationAddress)); |
mbed_official | 237:f3da66175598 | 328 | assert_param(IS_CEC_MSGSIZE(Size)); |
mbed_official | 237:f3da66175598 | 329 | |
mbed_official | 237:f3da66175598 | 330 | /* Process Locked */ |
mbed_official | 237:f3da66175598 | 331 | __HAL_LOCK(hcec); |
mbed_official | 237:f3da66175598 | 332 | |
mbed_official | 237:f3da66175598 | 333 | hcec->State = HAL_CEC_STATE_BUSY_TX; |
mbed_official | 237:f3da66175598 | 334 | |
mbed_official | 237:f3da66175598 | 335 | hcec->TxXferCount = Size; |
mbed_official | 237:f3da66175598 | 336 | |
mbed_official | 237:f3da66175598 | 337 | /* case no data to be sent, sender is only pinging the system */ |
mbed_official | 237:f3da66175598 | 338 | if (Size == 0) |
mbed_official | 237:f3da66175598 | 339 | { |
mbed_official | 237:f3da66175598 | 340 | /* Set TX End of Message (TXEOM) bit, must be set before writing data to TXDR */ |
mbed_official | 237:f3da66175598 | 341 | __HAL_CEC_LAST_BYTE_TX_SET(hcec); |
mbed_official | 237:f3da66175598 | 342 | } |
mbed_official | 237:f3da66175598 | 343 | |
mbed_official | 237:f3da66175598 | 344 | /* send header block */ |
mbed_official | 237:f3da66175598 | 345 | temp = (uint8_t)((uint32_t)(hcec->Init.InitiatorAddress) << CEC_INITIATOR_LSB_POS) | DestinationAddress; |
mbed_official | 237:f3da66175598 | 346 | hcec->Instance->TXDR = temp; |
mbed_official | 237:f3da66175598 | 347 | /* Set TX Start of Message (TXSOM) bit */ |
mbed_official | 237:f3da66175598 | 348 | __HAL_CEC_FIRST_BYTE_TX_SET(hcec); |
mbed_official | 237:f3da66175598 | 349 | |
mbed_official | 237:f3da66175598 | 350 | while (hcec->TxXferCount > 0) |
mbed_official | 237:f3da66175598 | 351 | { |
mbed_official | 237:f3da66175598 | 352 | hcec->TxXferCount--; |
mbed_official | 237:f3da66175598 | 353 | |
mbed_official | 237:f3da66175598 | 354 | tickstart = HAL_GetTick(); |
mbed_official | 237:f3da66175598 | 355 | while(HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_TXBR)) |
mbed_official | 237:f3da66175598 | 356 | { |
mbed_official | 237:f3da66175598 | 357 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 237:f3da66175598 | 358 | { |
mbed_official | 237:f3da66175598 | 359 | if((Timeout == 0) || ((HAL_GetTick()-tickstart) > Timeout)) |
mbed_official | 237:f3da66175598 | 360 | { |
mbed_official | 237:f3da66175598 | 361 | hcec->State = HAL_CEC_STATE_TIMEOUT; |
mbed_official | 237:f3da66175598 | 362 | /* Process Unlocked */ |
mbed_official | 237:f3da66175598 | 363 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 364 | return HAL_TIMEOUT; |
mbed_official | 237:f3da66175598 | 365 | } |
mbed_official | 237:f3da66175598 | 366 | } |
mbed_official | 237:f3da66175598 | 367 | |
mbed_official | 237:f3da66175598 | 368 | /* check whether error occured while waiting for TXBR to be set: |
mbed_official | 237:f3da66175598 | 369 | * has Tx underrun occurred ? |
mbed_official | 237:f3da66175598 | 370 | * has Tx error occurred ? |
mbed_official | 237:f3da66175598 | 371 | * has Tx Missing Acknowledge error occurred ? |
mbed_official | 237:f3da66175598 | 372 | * has Arbitration Loss error occurred ? */ |
mbed_official | 237:f3da66175598 | 373 | tempisr = hcec->Instance->ISR; |
mbed_official | 237:f3da66175598 | 374 | if ((tempisr & (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE|CEC_ISR_ARBLST)) != 0) |
mbed_official | 237:f3da66175598 | 375 | { |
mbed_official | 237:f3da66175598 | 376 | /* copy ISR for error handling purposes */ |
mbed_official | 237:f3da66175598 | 377 | hcec->ErrorCode = tempisr; |
mbed_official | 237:f3da66175598 | 378 | /* clear all error flags by default */ |
mbed_official | 237:f3da66175598 | 379 | __HAL_CEC_CLEAR_FLAG(hcec, (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE|CEC_ISR_ARBLST)); |
mbed_official | 237:f3da66175598 | 380 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 381 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 382 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 383 | } |
mbed_official | 237:f3da66175598 | 384 | } |
mbed_official | 237:f3da66175598 | 385 | /* TXBR to clear BEFORE writing TXDR register */ |
mbed_official | 237:f3da66175598 | 386 | __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR); |
mbed_official | 237:f3da66175598 | 387 | if (hcec->TxXferCount == 0) |
mbed_official | 237:f3da66175598 | 388 | { |
mbed_official | 237:f3da66175598 | 389 | /* if last byte transmission, set TX End of Message (TXEOM) bit */ |
mbed_official | 237:f3da66175598 | 390 | __HAL_CEC_LAST_BYTE_TX_SET(hcec); |
mbed_official | 237:f3da66175598 | 391 | } |
mbed_official | 237:f3da66175598 | 392 | hcec->Instance->TXDR = *pData++; |
mbed_official | 237:f3da66175598 | 393 | |
mbed_official | 237:f3da66175598 | 394 | /* error check after TX byte write up */ |
mbed_official | 237:f3da66175598 | 395 | tempisr = hcec->Instance->ISR; |
mbed_official | 237:f3da66175598 | 396 | if ((tempisr & (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE|CEC_ISR_ARBLST)) != 0) |
mbed_official | 237:f3da66175598 | 397 | { |
mbed_official | 237:f3da66175598 | 398 | /* copy ISR for error handling purposes */ |
mbed_official | 237:f3da66175598 | 399 | hcec->ErrorCode = tempisr; |
mbed_official | 237:f3da66175598 | 400 | /* clear all error flags by default */ |
mbed_official | 237:f3da66175598 | 401 | __HAL_CEC_CLEAR_FLAG(hcec, (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE|CEC_ISR_ARBLST)); |
mbed_official | 237:f3da66175598 | 402 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 403 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 404 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 405 | } |
mbed_official | 237:f3da66175598 | 406 | } /* end while (while (hcec->TxXferCount > 0)) */ |
mbed_official | 237:f3da66175598 | 407 | |
mbed_official | 237:f3da66175598 | 408 | |
mbed_official | 237:f3da66175598 | 409 | /* if no error up to this point, check that transmission is |
mbed_official | 237:f3da66175598 | 410 | * complete, that is wait until TXEOM is reset */ |
mbed_official | 237:f3da66175598 | 411 | tickstart = HAL_GetTick(); |
mbed_official | 237:f3da66175598 | 412 | |
mbed_official | 237:f3da66175598 | 413 | while (HAL_IS_BIT_SET(hcec->Instance->CR, CEC_CR_TXEOM)) |
mbed_official | 237:f3da66175598 | 414 | { |
mbed_official | 237:f3da66175598 | 415 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 237:f3da66175598 | 416 | { |
mbed_official | 237:f3da66175598 | 417 | if((Timeout == 0) || ((HAL_GetTick()-tickstart) > Timeout)) |
mbed_official | 237:f3da66175598 | 418 | { |
mbed_official | 237:f3da66175598 | 419 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 420 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 421 | return HAL_TIMEOUT; |
mbed_official | 237:f3da66175598 | 422 | } |
mbed_official | 237:f3da66175598 | 423 | } |
mbed_official | 237:f3da66175598 | 424 | } |
mbed_official | 237:f3da66175598 | 425 | |
mbed_official | 237:f3da66175598 | 426 | /* Final error check once all bytes have been transmitted */ |
mbed_official | 237:f3da66175598 | 427 | tempisr = hcec->Instance->ISR; |
mbed_official | 237:f3da66175598 | 428 | if ((tempisr & (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)) != 0) |
mbed_official | 237:f3da66175598 | 429 | { |
mbed_official | 237:f3da66175598 | 430 | /* copy ISR for error handling purposes */ |
mbed_official | 237:f3da66175598 | 431 | hcec->ErrorCode = tempisr; |
mbed_official | 237:f3da66175598 | 432 | /* clear all error flags by default */ |
mbed_official | 237:f3da66175598 | 433 | __HAL_CEC_CLEAR_FLAG(hcec, (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)); |
mbed_official | 237:f3da66175598 | 434 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 435 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 436 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 437 | } |
mbed_official | 237:f3da66175598 | 438 | |
mbed_official | 237:f3da66175598 | 439 | hcec->State = HAL_CEC_STATE_READY; |
mbed_official | 237:f3da66175598 | 440 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 441 | |
mbed_official | 237:f3da66175598 | 442 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 443 | } |
mbed_official | 237:f3da66175598 | 444 | else |
mbed_official | 237:f3da66175598 | 445 | { |
mbed_official | 237:f3da66175598 | 446 | return HAL_BUSY; |
mbed_official | 237:f3da66175598 | 447 | } |
mbed_official | 237:f3da66175598 | 448 | } |
mbed_official | 237:f3da66175598 | 449 | |
mbed_official | 237:f3da66175598 | 450 | /** |
mbed_official | 237:f3da66175598 | 451 | * @brief Receive data in blocking mode. Must be invoked when RXBR has been set. |
mbed_official | 237:f3da66175598 | 452 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 453 | * @param pData: pointer to received data buffer. |
mbed_official | 237:f3da66175598 | 454 | * @param Timeout: Timeout duration. |
mbed_official | 237:f3da66175598 | 455 | * Note that the received data size is not known beforehand, the latter is known |
mbed_official | 237:f3da66175598 | 456 | * when the reception is complete and is stored in hcec->RxXferSize. |
mbed_official | 237:f3da66175598 | 457 | * hcec->RxXferSize is the sum of opcodes + operands (0 to 14 operands max). |
mbed_official | 237:f3da66175598 | 458 | * If only a header is received, hcec->RxXferSize = 0 |
mbed_official | 237:f3da66175598 | 459 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 460 | */ |
mbed_official | 237:f3da66175598 | 461 | HAL_StatusTypeDef HAL_CEC_Receive(CEC_HandleTypeDef *hcec, uint8_t *pData, uint32_t Timeout) |
mbed_official | 237:f3da66175598 | 462 | { |
mbed_official | 237:f3da66175598 | 463 | uint32_t temp; |
mbed_official | 237:f3da66175598 | 464 | uint32_t tickstart = 0; |
mbed_official | 237:f3da66175598 | 465 | |
mbed_official | 237:f3da66175598 | 466 | if (hcec->State == HAL_CEC_STATE_READY) |
mbed_official | 237:f3da66175598 | 467 | { |
mbed_official | 237:f3da66175598 | 468 | hcec->ErrorCode = HAL_CEC_ERROR_NONE; |
mbed_official | 237:f3da66175598 | 469 | if (pData == NULL) |
mbed_official | 237:f3da66175598 | 470 | { |
mbed_official | 237:f3da66175598 | 471 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 472 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 473 | } |
mbed_official | 237:f3da66175598 | 474 | |
mbed_official | 237:f3da66175598 | 475 | hcec->RxXferSize = 0; |
mbed_official | 237:f3da66175598 | 476 | /* Process Locked */ |
mbed_official | 237:f3da66175598 | 477 | __HAL_LOCK(hcec); |
mbed_official | 237:f3da66175598 | 478 | |
mbed_official | 237:f3da66175598 | 479 | |
mbed_official | 237:f3da66175598 | 480 | /* Rx loop until CEC_ISR_RXEND is set */ |
mbed_official | 237:f3da66175598 | 481 | while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXEND)) |
mbed_official | 237:f3da66175598 | 482 | { |
mbed_official | 237:f3da66175598 | 483 | tickstart = HAL_GetTick(); |
mbed_official | 237:f3da66175598 | 484 | /* Wait for next byte to be received */ |
mbed_official | 237:f3da66175598 | 485 | while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXBR)) |
mbed_official | 237:f3da66175598 | 486 | { |
mbed_official | 237:f3da66175598 | 487 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 237:f3da66175598 | 488 | { |
mbed_official | 237:f3da66175598 | 489 | if((Timeout == 0) || ((HAL_GetTick()-tickstart) > Timeout)) |
mbed_official | 237:f3da66175598 | 490 | { |
mbed_official | 237:f3da66175598 | 491 | hcec->State = HAL_CEC_STATE_TIMEOUT; |
mbed_official | 237:f3da66175598 | 492 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 493 | return HAL_TIMEOUT; |
mbed_official | 237:f3da66175598 | 494 | } |
mbed_official | 237:f3da66175598 | 495 | } |
mbed_official | 237:f3da66175598 | 496 | /* any error so far ? |
mbed_official | 237:f3da66175598 | 497 | * has Rx Missing Acknowledge occurred ? |
mbed_official | 237:f3da66175598 | 498 | * has Rx Long Bit Period error occurred ? |
mbed_official | 237:f3da66175598 | 499 | * has Rx Short Bit Period error occurred ? |
mbed_official | 237:f3da66175598 | 500 | * has Rx Bit Rising error occurred ? |
mbed_official | 237:f3da66175598 | 501 | * has Rx Overrun error occurred ? */ |
mbed_official | 237:f3da66175598 | 502 | temp = (uint32_t) (hcec->Instance->ISR); |
mbed_official | 237:f3da66175598 | 503 | if ((temp & (CEC_ISR_RXACKE|CEC_ISR_LBPE|CEC_ISR_SBPE|CEC_ISR_BRE|CEC_ISR_RXOVR)) != 0) |
mbed_official | 237:f3da66175598 | 504 | { |
mbed_official | 237:f3da66175598 | 505 | /* copy ISR for error handling purposes */ |
mbed_official | 237:f3da66175598 | 506 | hcec->ErrorCode = temp; |
mbed_official | 237:f3da66175598 | 507 | /* clear all error flags by default */ |
mbed_official | 237:f3da66175598 | 508 | __HAL_CEC_CLEAR_FLAG(hcec, (CEC_ISR_RXACKE|CEC_ISR_LBPE|CEC_ISR_SBPE|CEC_ISR_BRE|CEC_ISR_RXOVR)); |
mbed_official | 237:f3da66175598 | 509 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 510 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 511 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 512 | } |
mbed_official | 237:f3da66175598 | 513 | } /* while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXBR)) */ |
mbed_official | 237:f3da66175598 | 514 | |
mbed_official | 237:f3da66175598 | 515 | |
mbed_official | 237:f3da66175598 | 516 | /* read received data */ |
mbed_official | 237:f3da66175598 | 517 | *pData++ = hcec->Instance->RXDR; |
mbed_official | 237:f3da66175598 | 518 | temp = (uint32_t) (hcec->Instance->ISR); |
mbed_official | 237:f3da66175598 | 519 | /* end of message ? */ |
mbed_official | 237:f3da66175598 | 520 | if ((temp & CEC_ISR_RXEND) != 0) |
mbed_official | 237:f3da66175598 | 521 | { |
mbed_official | 237:f3da66175598 | 522 | assert_param(IS_CEC_MSGSIZE(hcec->RxXferSize)); |
mbed_official | 237:f3da66175598 | 523 | __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_RXEND); |
mbed_official | 237:f3da66175598 | 524 | hcec->State = HAL_CEC_STATE_READY; |
mbed_official | 237:f3da66175598 | 525 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 526 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 527 | } |
mbed_official | 237:f3da66175598 | 528 | |
mbed_official | 237:f3da66175598 | 529 | /* clear Rx-Byte Received flag */ |
mbed_official | 237:f3da66175598 | 530 | __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_RXBR); |
mbed_official | 237:f3da66175598 | 531 | /* increment payload byte counter */ |
mbed_official | 237:f3da66175598 | 532 | hcec->RxXferSize++; |
mbed_official | 237:f3da66175598 | 533 | } /* while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXEND)) */ |
mbed_official | 237:f3da66175598 | 534 | |
mbed_official | 237:f3da66175598 | 535 | /* if the instructions below are executed, it means RXEND was set when RXBR was |
mbed_official | 237:f3da66175598 | 536 | * set for the first time: |
mbed_official | 237:f3da66175598 | 537 | * the code within the "while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXEND))" |
mbed_official | 237:f3da66175598 | 538 | * loop has not been executed and this means a single byte has been sent */ |
mbed_official | 237:f3da66175598 | 539 | *pData++ = hcec->Instance->RXDR; |
mbed_official | 237:f3da66175598 | 540 | /* only one header is received: RxXferSize is set to 0 (no operand, no opcode) */ |
mbed_official | 237:f3da66175598 | 541 | hcec->RxXferSize = 0; |
mbed_official | 237:f3da66175598 | 542 | __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_RXEND); |
mbed_official | 237:f3da66175598 | 543 | |
mbed_official | 237:f3da66175598 | 544 | hcec->State = HAL_CEC_STATE_READY; |
mbed_official | 237:f3da66175598 | 545 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 546 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 547 | } |
mbed_official | 237:f3da66175598 | 548 | else |
mbed_official | 237:f3da66175598 | 549 | { |
mbed_official | 237:f3da66175598 | 550 | return HAL_BUSY; |
mbed_official | 237:f3da66175598 | 551 | } |
mbed_official | 237:f3da66175598 | 552 | } |
mbed_official | 237:f3da66175598 | 553 | |
mbed_official | 237:f3da66175598 | 554 | |
mbed_official | 237:f3da66175598 | 555 | /** |
mbed_official | 237:f3da66175598 | 556 | * @brief Send data in interrupt mode |
mbed_official | 237:f3da66175598 | 557 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 558 | * @param DestinationAddress: destination logical address |
mbed_official | 237:f3da66175598 | 559 | * @param pData: pointer to input byte data buffer |
mbed_official | 237:f3da66175598 | 560 | * @param Size: amount of data to be sent in bytes (without counting the header). |
mbed_official | 237:f3da66175598 | 561 | * 0 means only the header is sent (ping operation). |
mbed_official | 237:f3da66175598 | 562 | * Maximum TX size is 15 bytes (1 opcode and up to 14 operands). |
mbed_official | 237:f3da66175598 | 563 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 564 | */ |
mbed_official | 237:f3da66175598 | 565 | HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t DestinationAddress, uint8_t *pData, uint32_t Size) |
mbed_official | 237:f3da66175598 | 566 | { |
mbed_official | 237:f3da66175598 | 567 | uint8_t temp = 0; |
mbed_official | 237:f3da66175598 | 568 | /* if the IP isn't already busy and if there is no previous transmission |
mbed_official | 237:f3da66175598 | 569 | already pending due to arbitration lost */ |
mbed_official | 237:f3da66175598 | 570 | if (((hcec->State == HAL_CEC_STATE_READY) || (hcec->State == HAL_CEC_STATE_STANDBY_RX)) |
mbed_official | 237:f3da66175598 | 571 | && (__HAL_CEC_GET_TRANSMISSION_START_FLAG(hcec) == RESET)) |
mbed_official | 237:f3da66175598 | 572 | { |
mbed_official | 237:f3da66175598 | 573 | if((pData == NULL) && (Size > 0)) |
mbed_official | 237:f3da66175598 | 574 | { |
mbed_official | 237:f3da66175598 | 575 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 576 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 577 | } |
mbed_official | 237:f3da66175598 | 578 | |
mbed_official | 237:f3da66175598 | 579 | assert_param(IS_CEC_ADDRESS(DestinationAddress)); |
mbed_official | 237:f3da66175598 | 580 | assert_param(IS_CEC_MSGSIZE(Size)); |
mbed_official | 237:f3da66175598 | 581 | |
mbed_official | 237:f3da66175598 | 582 | /* Process Locked */ |
mbed_official | 237:f3da66175598 | 583 | __HAL_LOCK(hcec); |
mbed_official | 237:f3da66175598 | 584 | hcec->pTxBuffPtr = pData; |
mbed_official | 237:f3da66175598 | 585 | hcec->State = HAL_CEC_STATE_BUSY_TX; |
mbed_official | 237:f3da66175598 | 586 | hcec->ErrorCode = HAL_CEC_ERROR_NONE; |
mbed_official | 237:f3da66175598 | 587 | |
mbed_official | 237:f3da66175598 | 588 | /* Disable Peripheral to write CEC_IER register */ |
mbed_official | 237:f3da66175598 | 589 | __HAL_CEC_DISABLE(hcec); |
mbed_official | 237:f3da66175598 | 590 | |
mbed_official | 237:f3da66175598 | 591 | /* Enable the following two CEC Transmission interrupts as |
mbed_official | 237:f3da66175598 | 592 | * well as the following CEC Transmission Errors interrupts: |
mbed_official | 237:f3da66175598 | 593 | * Tx Byte Request IT |
mbed_official | 237:f3da66175598 | 594 | * End of Transmission IT |
mbed_official | 237:f3da66175598 | 595 | * Tx Missing Acknowledge IT |
mbed_official | 237:f3da66175598 | 596 | * Tx-Error IT |
mbed_official | 237:f3da66175598 | 597 | * Tx-Buffer Underrun IT |
mbed_official | 237:f3da66175598 | 598 | * Tx arbitration lost */ |
mbed_official | 237:f3da66175598 | 599 | __HAL_CEC_ENABLE_IT(hcec, CEC_IER_TXBRIE|CEC_IER_TXENDIE|CEC_IER_TX_ALL_ERR); |
mbed_official | 237:f3da66175598 | 600 | |
mbed_official | 237:f3da66175598 | 601 | /* Enable the Peripheral */ |
mbed_official | 237:f3da66175598 | 602 | __HAL_CEC_ENABLE(hcec); |
mbed_official | 237:f3da66175598 | 603 | |
mbed_official | 237:f3da66175598 | 604 | /* initialize the number of bytes to send, |
mbed_official | 237:f3da66175598 | 605 | * 0 means only one header is sent (ping operation) */ |
mbed_official | 237:f3da66175598 | 606 | hcec->TxXferCount = Size; |
mbed_official | 237:f3da66175598 | 607 | |
mbed_official | 237:f3da66175598 | 608 | /* Process Unlocked */ |
mbed_official | 237:f3da66175598 | 609 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 610 | |
mbed_official | 237:f3da66175598 | 611 | /* in case of no payload (Size = 0), sender is only pinging the system; |
mbed_official | 237:f3da66175598 | 612 | * Set TX End of Message (TXEOM) bit, must be set before writing data to TXDR */ |
mbed_official | 237:f3da66175598 | 613 | if (Size == 0) |
mbed_official | 237:f3da66175598 | 614 | { |
mbed_official | 237:f3da66175598 | 615 | __HAL_CEC_LAST_BYTE_TX_SET(hcec); |
mbed_official | 237:f3da66175598 | 616 | } |
mbed_official | 237:f3da66175598 | 617 | |
mbed_official | 237:f3da66175598 | 618 | /* send header block */ |
mbed_official | 237:f3da66175598 | 619 | temp = (uint8_t)((uint32_t)(hcec->Init.InitiatorAddress) << CEC_INITIATOR_LSB_POS) | DestinationAddress; |
mbed_official | 237:f3da66175598 | 620 | hcec->Instance->TXDR = temp; |
mbed_official | 237:f3da66175598 | 621 | /* Set TX Start of Message (TXSOM) bit */ |
mbed_official | 237:f3da66175598 | 622 | __HAL_CEC_FIRST_BYTE_TX_SET(hcec); |
mbed_official | 237:f3da66175598 | 623 | |
mbed_official | 237:f3da66175598 | 624 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 625 | } |
mbed_official | 237:f3da66175598 | 626 | /* if the IP is already busy or if there is a previous transmission |
mbed_official | 237:f3da66175598 | 627 | already pending due to arbitration loss */ |
mbed_official | 237:f3da66175598 | 628 | else if ((hcec->State == HAL_CEC_STATE_BUSY_TX) |
mbed_official | 237:f3da66175598 | 629 | || (__HAL_CEC_GET_TRANSMISSION_START_FLAG(hcec) != RESET)) |
mbed_official | 237:f3da66175598 | 630 | { |
mbed_official | 237:f3da66175598 | 631 | __HAL_LOCK(hcec); |
mbed_official | 237:f3da66175598 | 632 | /* set state to BUSY TX, in case it wasn't set already (case |
mbed_official | 237:f3da66175598 | 633 | * of transmission new attempt after arbitration loss) */ |
mbed_official | 237:f3da66175598 | 634 | if (hcec->State != HAL_CEC_STATE_BUSY_TX) |
mbed_official | 237:f3da66175598 | 635 | { |
mbed_official | 237:f3da66175598 | 636 | hcec->State = HAL_CEC_STATE_BUSY_TX; |
mbed_official | 237:f3da66175598 | 637 | } |
mbed_official | 237:f3da66175598 | 638 | |
mbed_official | 237:f3da66175598 | 639 | /* if all data have been sent */ |
mbed_official | 237:f3da66175598 | 640 | if(hcec->TxXferCount == 0) |
mbed_official | 237:f3da66175598 | 641 | { |
mbed_official | 237:f3da66175598 | 642 | /* Disable Peripheral to write CEC_IER register */ |
mbed_official | 237:f3da66175598 | 643 | __HAL_CEC_DISABLE(hcec); |
mbed_official | 237:f3da66175598 | 644 | |
mbed_official | 237:f3da66175598 | 645 | /* Disable the CEC Transmission Interrupts */ |
mbed_official | 237:f3da66175598 | 646 | __HAL_CEC_DISABLE_IT(hcec, CEC_IER_TXBRIE|CEC_IER_TXENDIE); |
mbed_official | 237:f3da66175598 | 647 | /* Disable the CEC Transmission Error Interrupts */ |
mbed_official | 237:f3da66175598 | 648 | __HAL_CEC_DISABLE_IT(hcec, CEC_IER_TX_ALL_ERR); |
mbed_official | 237:f3da66175598 | 649 | |
mbed_official | 237:f3da66175598 | 650 | /* Enable the Peripheral */ |
mbed_official | 237:f3da66175598 | 651 | __HAL_CEC_ENABLE(hcec); |
mbed_official | 237:f3da66175598 | 652 | |
mbed_official | 237:f3da66175598 | 653 | __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR|CEC_ISR_TXEND); |
mbed_official | 237:f3da66175598 | 654 | |
mbed_official | 237:f3da66175598 | 655 | hcec->State = HAL_CEC_STATE_READY; |
mbed_official | 237:f3da66175598 | 656 | /* Call the Process Unlocked before calling the Tx call back API to give the possibility to |
mbed_official | 237:f3da66175598 | 657 | start again the Transmission under the Tx call back API */ |
mbed_official | 237:f3da66175598 | 658 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 659 | |
mbed_official | 237:f3da66175598 | 660 | HAL_CEC_TxCpltCallback(hcec); |
mbed_official | 237:f3da66175598 | 661 | |
mbed_official | 237:f3da66175598 | 662 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 663 | } |
mbed_official | 237:f3da66175598 | 664 | else |
mbed_official | 237:f3da66175598 | 665 | { |
mbed_official | 237:f3da66175598 | 666 | if (hcec->TxXferCount == 1) |
mbed_official | 237:f3da66175598 | 667 | { |
mbed_official | 237:f3da66175598 | 668 | /* if this is the last byte transmission, set TX End of Message (TXEOM) bit */ |
mbed_official | 237:f3da66175598 | 669 | __HAL_CEC_LAST_BYTE_TX_SET(hcec); |
mbed_official | 237:f3da66175598 | 670 | } |
mbed_official | 237:f3da66175598 | 671 | /* clear Tx-Byte request flag */ |
mbed_official | 237:f3da66175598 | 672 | __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR); |
mbed_official | 237:f3da66175598 | 673 | hcec->Instance->TXDR = *hcec->pTxBuffPtr++; |
mbed_official | 237:f3da66175598 | 674 | hcec->TxXferCount--; |
mbed_official | 237:f3da66175598 | 675 | |
mbed_official | 237:f3da66175598 | 676 | /* Process Unlocked */ |
mbed_official | 237:f3da66175598 | 677 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 678 | |
mbed_official | 237:f3da66175598 | 679 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 680 | } |
mbed_official | 237:f3da66175598 | 681 | } |
mbed_official | 237:f3da66175598 | 682 | else |
mbed_official | 237:f3da66175598 | 683 | { |
mbed_official | 237:f3da66175598 | 684 | return HAL_BUSY; |
mbed_official | 237:f3da66175598 | 685 | } |
mbed_official | 237:f3da66175598 | 686 | } |
mbed_official | 237:f3da66175598 | 687 | |
mbed_official | 237:f3da66175598 | 688 | |
mbed_official | 237:f3da66175598 | 689 | /** |
mbed_official | 237:f3da66175598 | 690 | * @brief Receive data in interrupt mode. |
mbed_official | 237:f3da66175598 | 691 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 692 | * @param pData: pointer to received data buffer. |
mbed_official | 237:f3da66175598 | 693 | * Note that the received data size is not known beforehand, the latter is known |
mbed_official | 237:f3da66175598 | 694 | * when the reception is complete and is stored in hcec->RxXferSize. |
mbed_official | 237:f3da66175598 | 695 | * hcec->RxXferSize is the sum of opcodes + operands (0 to 14 operands max). |
mbed_official | 237:f3da66175598 | 696 | * If only a header is received, hcec->RxXferSize = 0 |
mbed_official | 237:f3da66175598 | 697 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 698 | */ |
mbed_official | 237:f3da66175598 | 699 | HAL_StatusTypeDef HAL_CEC_Receive_IT(CEC_HandleTypeDef *hcec, uint8_t *pData) |
mbed_official | 237:f3da66175598 | 700 | { |
mbed_official | 237:f3da66175598 | 701 | if(hcec->State == HAL_CEC_STATE_READY) |
mbed_official | 237:f3da66175598 | 702 | { |
mbed_official | 237:f3da66175598 | 703 | if(pData == NULL) |
mbed_official | 237:f3da66175598 | 704 | { |
mbed_official | 237:f3da66175598 | 705 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 706 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 707 | } |
mbed_official | 237:f3da66175598 | 708 | |
mbed_official | 237:f3da66175598 | 709 | /* Process Locked */ |
mbed_official | 237:f3da66175598 | 710 | __HAL_LOCK(hcec); |
mbed_official | 237:f3da66175598 | 711 | hcec->RxXferSize = 0; |
mbed_official | 237:f3da66175598 | 712 | hcec->pRxBuffPtr = pData; |
mbed_official | 237:f3da66175598 | 713 | hcec->ErrorCode = HAL_CEC_ERROR_NONE; |
mbed_official | 237:f3da66175598 | 714 | /* the IP is moving to a ready to receive state */ |
mbed_official | 237:f3da66175598 | 715 | hcec->State = HAL_CEC_STATE_STANDBY_RX; |
mbed_official | 237:f3da66175598 | 716 | |
mbed_official | 237:f3da66175598 | 717 | /* Disable Peripheral to write CEC_IER register */ |
mbed_official | 237:f3da66175598 | 718 | __HAL_CEC_DISABLE(hcec); |
mbed_official | 237:f3da66175598 | 719 | |
mbed_official | 237:f3da66175598 | 720 | /* Enable the following CEC Reception Error Interrupts: |
mbed_official | 237:f3da66175598 | 721 | * Rx overrun |
mbed_official | 237:f3da66175598 | 722 | * Rx bit rising error |
mbed_official | 237:f3da66175598 | 723 | * Rx short bit period error |
mbed_official | 237:f3da66175598 | 724 | * Rx long bit period error |
mbed_official | 237:f3da66175598 | 725 | * Rx missing acknowledge */ |
mbed_official | 237:f3da66175598 | 726 | __HAL_CEC_ENABLE_IT(hcec, CEC_IER_RX_ALL_ERR); |
mbed_official | 237:f3da66175598 | 727 | |
mbed_official | 237:f3da66175598 | 728 | /* Process Unlocked */ |
mbed_official | 237:f3da66175598 | 729 | __HAL_UNLOCK(hcec); |
mbed_official | 237:f3da66175598 | 730 | |
mbed_official | 237:f3da66175598 | 731 | /* Enable the following two CEC Reception interrupts: |
mbed_official | 237:f3da66175598 | 732 | * Rx Byte Received IT |
mbed_official | 237:f3da66175598 | 733 | * End of Reception IT */ |
mbed_official | 237:f3da66175598 | 734 | __HAL_CEC_ENABLE_IT(hcec, CEC_IER_RXBRIE|CEC_IER_RXENDIE); |
mbed_official | 237:f3da66175598 | 735 | |
mbed_official | 237:f3da66175598 | 736 | __HAL_CEC_ENABLE(hcec); |
mbed_official | 237:f3da66175598 | 737 | |
mbed_official | 237:f3da66175598 | 738 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 739 | } |
mbed_official | 237:f3da66175598 | 740 | else |
mbed_official | 237:f3da66175598 | 741 | { |
mbed_official | 237:f3da66175598 | 742 | return HAL_BUSY; |
mbed_official | 237:f3da66175598 | 743 | } |
mbed_official | 237:f3da66175598 | 744 | } |
mbed_official | 237:f3da66175598 | 745 | |
mbed_official | 237:f3da66175598 | 746 | |
mbed_official | 237:f3da66175598 | 747 | |
mbed_official | 237:f3da66175598 | 748 | /** |
mbed_official | 237:f3da66175598 | 749 | * @brief This function handles CEC interrupt requests. |
mbed_official | 237:f3da66175598 | 750 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 751 | * @retval None |
mbed_official | 237:f3da66175598 | 752 | */ |
mbed_official | 237:f3da66175598 | 753 | void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 754 | { |
mbed_official | 237:f3da66175598 | 755 | /* save interrupts register for further error or interrupts handling purposes */ |
mbed_official | 237:f3da66175598 | 756 | hcec->ErrorCode = hcec->Instance->ISR; |
mbed_official | 237:f3da66175598 | 757 | /* CEC TX missing acknowledge error interrupt occurred -------------------------------------*/ |
mbed_official | 237:f3da66175598 | 758 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXACKE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXACKEIE) != RESET)) |
mbed_official | 237:f3da66175598 | 759 | { |
mbed_official | 237:f3da66175598 | 760 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_TXACKE); |
mbed_official | 237:f3da66175598 | 761 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 762 | } |
mbed_official | 237:f3da66175598 | 763 | |
mbed_official | 237:f3da66175598 | 764 | /* CEC transmit error interrupt occured --------------------------------------*/ |
mbed_official | 237:f3da66175598 | 765 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXERR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXERRIE) != RESET)) |
mbed_official | 237:f3da66175598 | 766 | { |
mbed_official | 237:f3da66175598 | 767 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_TXERR); |
mbed_official | 237:f3da66175598 | 768 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 769 | } |
mbed_official | 237:f3da66175598 | 770 | |
mbed_official | 237:f3da66175598 | 771 | /* CEC TX underrun error interrupt occured --------------------------------------*/ |
mbed_official | 237:f3da66175598 | 772 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXUDR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXUDRIE) != RESET)) |
mbed_official | 237:f3da66175598 | 773 | { |
mbed_official | 237:f3da66175598 | 774 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_TXUDR); |
mbed_official | 237:f3da66175598 | 775 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 776 | } |
mbed_official | 237:f3da66175598 | 777 | |
mbed_official | 237:f3da66175598 | 778 | /* CEC TX arbitration error interrupt occured --------------------------------------*/ |
mbed_official | 237:f3da66175598 | 779 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_ARBLST) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_ARBLSTIE) != RESET)) |
mbed_official | 237:f3da66175598 | 780 | { |
mbed_official | 237:f3da66175598 | 781 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_ARBLST); |
mbed_official | 237:f3da66175598 | 782 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 783 | } |
mbed_official | 237:f3da66175598 | 784 | |
mbed_official | 237:f3da66175598 | 785 | /* CEC RX overrun error interrupt occured --------------------------------------*/ |
mbed_official | 237:f3da66175598 | 786 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_RXOVR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_RXOVRIE) != RESET)) |
mbed_official | 237:f3da66175598 | 787 | { |
mbed_official | 237:f3da66175598 | 788 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_RXOVR); |
mbed_official | 237:f3da66175598 | 789 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 790 | } |
mbed_official | 237:f3da66175598 | 791 | |
mbed_official | 237:f3da66175598 | 792 | /* CEC RX bit rising error interrupt occured --------------------------------------*/ |
mbed_official | 237:f3da66175598 | 793 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_BRE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_BREIE) != RESET)) |
mbed_official | 237:f3da66175598 | 794 | { |
mbed_official | 237:f3da66175598 | 795 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_BRE); |
mbed_official | 237:f3da66175598 | 796 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 797 | } |
mbed_official | 237:f3da66175598 | 798 | |
mbed_official | 237:f3da66175598 | 799 | /* CEC RX short bit period error interrupt occured --------------------------------------*/ |
mbed_official | 237:f3da66175598 | 800 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_SBPE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_SBPEIE) != RESET)) |
mbed_official | 237:f3da66175598 | 801 | { |
mbed_official | 237:f3da66175598 | 802 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_SBPE); |
mbed_official | 237:f3da66175598 | 803 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 804 | } |
mbed_official | 237:f3da66175598 | 805 | |
mbed_official | 237:f3da66175598 | 806 | /* CEC RX long bit period error interrupt occured --------------------------------------*/ |
mbed_official | 237:f3da66175598 | 807 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_LBPE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_LBPEIE) != RESET)) |
mbed_official | 237:f3da66175598 | 808 | { |
mbed_official | 237:f3da66175598 | 809 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_LBPE); |
mbed_official | 237:f3da66175598 | 810 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 811 | } |
mbed_official | 237:f3da66175598 | 812 | |
mbed_official | 237:f3da66175598 | 813 | /* CEC RX missing acknowledge error interrupt occured --------------------------------------*/ |
mbed_official | 237:f3da66175598 | 814 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_RXACKE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_RXACKEIE) != RESET)) |
mbed_official | 237:f3da66175598 | 815 | { |
mbed_official | 237:f3da66175598 | 816 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_RXACKE); |
mbed_official | 237:f3da66175598 | 817 | hcec->State = HAL_CEC_STATE_ERROR; |
mbed_official | 237:f3da66175598 | 818 | } |
mbed_official | 237:f3da66175598 | 819 | |
mbed_official | 237:f3da66175598 | 820 | if ((hcec->ErrorCode & CEC_ISR_ALL_ERROR) != 0) |
mbed_official | 237:f3da66175598 | 821 | { |
mbed_official | 237:f3da66175598 | 822 | HAL_CEC_ErrorCallback(hcec); |
mbed_official | 237:f3da66175598 | 823 | } |
mbed_official | 237:f3da66175598 | 824 | |
mbed_official | 237:f3da66175598 | 825 | /* CEC RX byte received interrupt ---------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 826 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_RXBR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_RXBRIE) != RESET)) |
mbed_official | 237:f3da66175598 | 827 | { |
mbed_official | 237:f3da66175598 | 828 | /* RXBR IT is cleared during HAL_CEC_Transmit_IT processing */ |
mbed_official | 237:f3da66175598 | 829 | CEC_Receive_IT(hcec); |
mbed_official | 237:f3da66175598 | 830 | } |
mbed_official | 237:f3da66175598 | 831 | |
mbed_official | 237:f3da66175598 | 832 | /* CEC RX end received interrupt ---------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 833 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_RXEND) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_RXENDIE) != RESET)) |
mbed_official | 237:f3da66175598 | 834 | { |
mbed_official | 237:f3da66175598 | 835 | /* RXBR IT is cleared during HAL_CEC_Transmit_IT processing */ |
mbed_official | 237:f3da66175598 | 836 | CEC_Receive_IT(hcec); |
mbed_official | 237:f3da66175598 | 837 | } |
mbed_official | 237:f3da66175598 | 838 | |
mbed_official | 237:f3da66175598 | 839 | |
mbed_official | 237:f3da66175598 | 840 | /* CEC TX byte request interrupt ------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 841 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXBR) != RESET) &&(__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXBRIE) != RESET)) |
mbed_official | 237:f3da66175598 | 842 | { |
mbed_official | 237:f3da66175598 | 843 | /* TXBR IT is cleared during HAL_CEC_Transmit_IT processing */ |
mbed_official | 237:f3da66175598 | 844 | CEC_Transmit_IT(hcec); |
mbed_official | 237:f3da66175598 | 845 | } |
mbed_official | 237:f3da66175598 | 846 | |
mbed_official | 237:f3da66175598 | 847 | /* CEC TX end interrupt ------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 848 | if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXEND) != RESET) &&(__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXENDIE) != RESET)) |
mbed_official | 237:f3da66175598 | 849 | { |
mbed_official | 237:f3da66175598 | 850 | /* TXEND IT is cleared during HAL_CEC_Transmit_IT processing */ |
mbed_official | 237:f3da66175598 | 851 | CEC_Transmit_IT(hcec); |
mbed_official | 237:f3da66175598 | 852 | } |
mbed_official | 237:f3da66175598 | 853 | |
mbed_official | 237:f3da66175598 | 854 | } |
mbed_official | 237:f3da66175598 | 855 | |
mbed_official | 237:f3da66175598 | 856 | |
mbed_official | 237:f3da66175598 | 857 | /** |
mbed_official | 237:f3da66175598 | 858 | * @brief Tx Transfer completed callback |
mbed_official | 237:f3da66175598 | 859 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 860 | * @retval None |
mbed_official | 237:f3da66175598 | 861 | */ |
mbed_official | 237:f3da66175598 | 862 | __weak void HAL_CEC_TxCpltCallback(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 863 | { |
mbed_official | 237:f3da66175598 | 864 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 237:f3da66175598 | 865 | the HAL_CEC_TxCpltCallback can be implemented in the user file |
mbed_official | 237:f3da66175598 | 866 | */ |
mbed_official | 237:f3da66175598 | 867 | } |
mbed_official | 237:f3da66175598 | 868 | |
mbed_official | 237:f3da66175598 | 869 | /** |
mbed_official | 237:f3da66175598 | 870 | * @brief Rx Transfer completed callback |
mbed_official | 237:f3da66175598 | 871 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 872 | * @retval None |
mbed_official | 237:f3da66175598 | 873 | */ |
mbed_official | 237:f3da66175598 | 874 | __weak void HAL_CEC_RxCpltCallback(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 875 | { |
mbed_official | 237:f3da66175598 | 876 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 237:f3da66175598 | 877 | the HAL_CEC_TxCpltCallback can be implemented in the user file |
mbed_official | 237:f3da66175598 | 878 | */ |
mbed_official | 237:f3da66175598 | 879 | } |
mbed_official | 237:f3da66175598 | 880 | |
mbed_official | 237:f3da66175598 | 881 | /** |
mbed_official | 237:f3da66175598 | 882 | * @brief CEC error callbacks |
mbed_official | 237:f3da66175598 | 883 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 884 | * @retval None |
mbed_official | 237:f3da66175598 | 885 | */ |
mbed_official | 237:f3da66175598 | 886 | __weak void HAL_CEC_ErrorCallback(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 887 | { |
mbed_official | 237:f3da66175598 | 888 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 237:f3da66175598 | 889 | the HAL_CEC_ErrorCallback can be implemented in the user file |
mbed_official | 237:f3da66175598 | 890 | */ |
mbed_official | 237:f3da66175598 | 891 | } |
mbed_official | 237:f3da66175598 | 892 | |
mbed_official | 237:f3da66175598 | 893 | |
mbed_official | 237:f3da66175598 | 894 | /** |
mbed_official | 237:f3da66175598 | 895 | * @brief Send data in interrupt mode |
mbed_official | 237:f3da66175598 | 896 | * @param hcec: CEC handle. |
mbed_official | 237:f3da66175598 | 897 | * Function called under interruption only, once |
mbed_official | 237:f3da66175598 | 898 | * interruptions have been enabled by HAL_CEC_Transmit_IT() |
mbed_official | 237:f3da66175598 | 899 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 900 | */ |
mbed_official | 237:f3da66175598 | 901 | static HAL_StatusTypeDef CEC_Transmit_IT(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 902 | { |
mbed_official | 237:f3da66175598 | 903 | /* if the IP is already busy or if there is a previous transmission |
mbed_official | 237:f3da66175598 | 904 | already pending due to arbitration loss */ |
mbed_official | 237:f3da66175598 | 905 | if ((hcec->State == HAL_CEC_STATE_BUSY_TX) |
mbed_official | 237:f3da66175598 | 906 | || (__HAL_CEC_GET_TRANSMISSION_START_FLAG(hcec) != RESET)) |
mbed_official | 237:f3da66175598 | 907 | { |
mbed_official | 237:f3da66175598 | 908 | |
mbed_official | 237:f3da66175598 | 909 | /* set state to BUSY TX, in case it wasn't set already (case |
mbed_official | 237:f3da66175598 | 910 | * of transmission new attempt after arbitration loss) */ |
mbed_official | 237:f3da66175598 | 911 | if (hcec->State != HAL_CEC_STATE_BUSY_TX) |
mbed_official | 237:f3da66175598 | 912 | { |
mbed_official | 237:f3da66175598 | 913 | hcec->State = HAL_CEC_STATE_BUSY_TX; |
mbed_official | 237:f3da66175598 | 914 | } |
mbed_official | 237:f3da66175598 | 915 | |
mbed_official | 237:f3da66175598 | 916 | /* if all data have been sent */ |
mbed_official | 237:f3da66175598 | 917 | if(hcec->TxXferCount == 0) |
mbed_official | 237:f3da66175598 | 918 | { |
mbed_official | 237:f3da66175598 | 919 | /* Disable Peripheral to write CEC_IER register */ |
mbed_official | 237:f3da66175598 | 920 | __HAL_CEC_DISABLE(hcec); |
mbed_official | 237:f3da66175598 | 921 | |
mbed_official | 237:f3da66175598 | 922 | /* Disable the CEC Transmission Interrupts */ |
mbed_official | 237:f3da66175598 | 923 | __HAL_CEC_DISABLE_IT(hcec, CEC_IER_TXBRIE|CEC_IER_TXENDIE); |
mbed_official | 237:f3da66175598 | 924 | /* Disable the CEC Transmission Error Interrupts */ |
mbed_official | 237:f3da66175598 | 925 | __HAL_CEC_DISABLE_IT(hcec, CEC_IER_TX_ALL_ERR); |
mbed_official | 237:f3da66175598 | 926 | |
mbed_official | 237:f3da66175598 | 927 | /* Enable the Peripheral */ |
mbed_official | 237:f3da66175598 | 928 | __HAL_CEC_ENABLE(hcec); |
mbed_official | 237:f3da66175598 | 929 | |
mbed_official | 237:f3da66175598 | 930 | __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR|CEC_ISR_TXEND); |
mbed_official | 237:f3da66175598 | 931 | |
mbed_official | 237:f3da66175598 | 932 | hcec->State = HAL_CEC_STATE_READY; |
mbed_official | 237:f3da66175598 | 933 | |
mbed_official | 237:f3da66175598 | 934 | HAL_CEC_TxCpltCallback(hcec); |
mbed_official | 237:f3da66175598 | 935 | |
mbed_official | 237:f3da66175598 | 936 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 937 | } |
mbed_official | 237:f3da66175598 | 938 | else |
mbed_official | 237:f3da66175598 | 939 | { |
mbed_official | 237:f3da66175598 | 940 | if (hcec->TxXferCount == 1) |
mbed_official | 237:f3da66175598 | 941 | { |
mbed_official | 237:f3da66175598 | 942 | /* if this is the last byte transmission, set TX End of Message (TXEOM) bit */ |
mbed_official | 237:f3da66175598 | 943 | __HAL_CEC_LAST_BYTE_TX_SET(hcec); |
mbed_official | 237:f3da66175598 | 944 | } |
mbed_official | 237:f3da66175598 | 945 | /* clear Tx-Byte request flag */ |
mbed_official | 237:f3da66175598 | 946 | __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR); |
mbed_official | 237:f3da66175598 | 947 | hcec->Instance->TXDR = *hcec->pTxBuffPtr++; |
mbed_official | 237:f3da66175598 | 948 | hcec->TxXferCount--; |
mbed_official | 237:f3da66175598 | 949 | |
mbed_official | 237:f3da66175598 | 950 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 951 | } |
mbed_official | 237:f3da66175598 | 952 | } |
mbed_official | 237:f3da66175598 | 953 | else |
mbed_official | 237:f3da66175598 | 954 | { |
mbed_official | 237:f3da66175598 | 955 | return HAL_BUSY; |
mbed_official | 237:f3da66175598 | 956 | } |
mbed_official | 237:f3da66175598 | 957 | } |
mbed_official | 237:f3da66175598 | 958 | |
mbed_official | 237:f3da66175598 | 959 | |
mbed_official | 237:f3da66175598 | 960 | /** |
mbed_official | 237:f3da66175598 | 961 | * @brief Receive data in interrupt mode. |
mbed_official | 237:f3da66175598 | 962 | * @param hcec: CEC handle. |
mbed_official | 237:f3da66175598 | 963 | * Function called under interruption only, once |
mbed_official | 237:f3da66175598 | 964 | * interruptions have been enabled by HAL_CEC_Receive_IT() |
mbed_official | 237:f3da66175598 | 965 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 966 | */ |
mbed_official | 237:f3da66175598 | 967 | static HAL_StatusTypeDef CEC_Receive_IT(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 968 | { |
mbed_official | 237:f3da66175598 | 969 | uint32_t tempisr; |
mbed_official | 237:f3da66175598 | 970 | |
mbed_official | 237:f3da66175598 | 971 | /* Three different conditions are tested to carry out the RX IT processing: |
mbed_official | 237:f3da66175598 | 972 | * - the IP is in reception stand-by (the IP state is HAL_CEC_STATE_STANDBY_RX) and |
mbed_official | 237:f3da66175598 | 973 | * the reception of the first byte is starting |
mbed_official | 237:f3da66175598 | 974 | * - a message reception is already on-going (the IP state is HAL_CEC_STATE_BUSY_RX) |
mbed_official | 237:f3da66175598 | 975 | * and a new byte is being received |
mbed_official | 237:f3da66175598 | 976 | * - a transmission has just been started (the IP state is HAL_CEC_STATE_BUSY_TX) |
mbed_official | 237:f3da66175598 | 977 | * but has been interrupted by a new message reception or discarded due to |
mbed_official | 237:f3da66175598 | 978 | * arbitration loss: the reception of the first or higher priority message |
mbed_official | 237:f3da66175598 | 979 | * (the arbitration winner) is starting */ |
mbed_official | 237:f3da66175598 | 980 | if ((hcec->State == HAL_CEC_STATE_STANDBY_RX) |
mbed_official | 237:f3da66175598 | 981 | || (hcec->State == HAL_CEC_STATE_BUSY_RX) |
mbed_official | 237:f3da66175598 | 982 | || (hcec->State == HAL_CEC_STATE_BUSY_TX)) |
mbed_official | 237:f3da66175598 | 983 | { |
mbed_official | 237:f3da66175598 | 984 | /* reception is starting */ |
mbed_official | 237:f3da66175598 | 985 | hcec->State = HAL_CEC_STATE_BUSY_RX; |
mbed_official | 237:f3da66175598 | 986 | tempisr = (uint32_t) (hcec->Instance->ISR); |
mbed_official | 237:f3da66175598 | 987 | if ((tempisr & CEC_ISR_RXBR) != 0) |
mbed_official | 237:f3da66175598 | 988 | { |
mbed_official | 237:f3da66175598 | 989 | /* read received byte */ |
mbed_official | 237:f3da66175598 | 990 | *hcec->pRxBuffPtr++ = hcec->Instance->RXDR; |
mbed_official | 237:f3da66175598 | 991 | /* if last byte has been received */ |
mbed_official | 237:f3da66175598 | 992 | if ((tempisr & CEC_ISR_RXEND) != 0) |
mbed_official | 237:f3da66175598 | 993 | { |
mbed_official | 237:f3da66175598 | 994 | /* clear IT */ |
mbed_official | 237:f3da66175598 | 995 | __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_RXBR|CEC_ISR_RXEND); |
mbed_official | 237:f3da66175598 | 996 | /* RX interrupts are not disabled at this point. |
mbed_official | 237:f3da66175598 | 997 | * Indeed, to disable the IT, the IP must be disabled first |
mbed_official | 237:f3da66175598 | 998 | * which resets the TXSOM flag. In case of arbitration loss, |
mbed_official | 237:f3da66175598 | 999 | * this leads to a transmission abort. |
mbed_official | 237:f3da66175598 | 1000 | * Therefore, RX interruptions disabling if so required, |
mbed_official | 237:f3da66175598 | 1001 | * is done in HAL_CEC_RxCpltCallback */ |
mbed_official | 237:f3da66175598 | 1002 | |
mbed_official | 237:f3da66175598 | 1003 | /* IP state is moved to READY. |
mbed_official | 237:f3da66175598 | 1004 | * If the IP must remain in standby mode to listen |
mbed_official | 237:f3da66175598 | 1005 | * any new message, it is up to HAL_CEC_RxCpltCallback |
mbed_official | 237:f3da66175598 | 1006 | * to move it again to HAL_CEC_STATE_STANDBY_RX */ |
mbed_official | 237:f3da66175598 | 1007 | hcec->State = HAL_CEC_STATE_READY; |
mbed_official | 237:f3da66175598 | 1008 | |
mbed_official | 237:f3da66175598 | 1009 | HAL_CEC_RxCpltCallback(hcec); |
mbed_official | 237:f3da66175598 | 1010 | |
mbed_official | 237:f3da66175598 | 1011 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 1012 | } |
mbed_official | 237:f3da66175598 | 1013 | __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_RXBR); |
mbed_official | 237:f3da66175598 | 1014 | |
mbed_official | 237:f3da66175598 | 1015 | hcec->RxXferSize++; |
mbed_official | 237:f3da66175598 | 1016 | |
mbed_official | 237:f3da66175598 | 1017 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 1018 | } |
mbed_official | 237:f3da66175598 | 1019 | else |
mbed_official | 237:f3da66175598 | 1020 | { |
mbed_official | 237:f3da66175598 | 1021 | return HAL_BUSY; |
mbed_official | 237:f3da66175598 | 1022 | } |
mbed_official | 237:f3da66175598 | 1023 | } |
mbed_official | 237:f3da66175598 | 1024 | else |
mbed_official | 237:f3da66175598 | 1025 | { |
mbed_official | 237:f3da66175598 | 1026 | return HAL_BUSY; |
mbed_official | 237:f3da66175598 | 1027 | } |
mbed_official | 237:f3da66175598 | 1028 | } |
mbed_official | 237:f3da66175598 | 1029 | |
mbed_official | 237:f3da66175598 | 1030 | |
mbed_official | 237:f3da66175598 | 1031 | |
mbed_official | 237:f3da66175598 | 1032 | /** |
mbed_official | 237:f3da66175598 | 1033 | * @} |
mbed_official | 237:f3da66175598 | 1034 | */ |
mbed_official | 237:f3da66175598 | 1035 | |
mbed_official | 237:f3da66175598 | 1036 | /** @defgroup HAL_CEC_Group3 Peripheral Control functions |
mbed_official | 237:f3da66175598 | 1037 | * @brief CEC control functions |
mbed_official | 237:f3da66175598 | 1038 | * |
mbed_official | 237:f3da66175598 | 1039 | @verbatim |
mbed_official | 237:f3da66175598 | 1040 | =============================================================================== |
mbed_official | 237:f3da66175598 | 1041 | ##### Peripheral Control functions ##### |
mbed_official | 237:f3da66175598 | 1042 | =============================================================================== |
mbed_official | 237:f3da66175598 | 1043 | [..] |
mbed_official | 237:f3da66175598 | 1044 | This subsection provides a set of functions allowing to control the CEC. |
mbed_official | 237:f3da66175598 | 1045 | (+) HAL_CEC_GetState() API can be helpful to check in run-time the state of the CEC peripheral. |
mbed_official | 237:f3da66175598 | 1046 | @endverbatim |
mbed_official | 237:f3da66175598 | 1047 | * @{ |
mbed_official | 237:f3da66175598 | 1048 | */ |
mbed_official | 237:f3da66175598 | 1049 | |
mbed_official | 237:f3da66175598 | 1050 | |
mbed_official | 237:f3da66175598 | 1051 | |
mbed_official | 237:f3da66175598 | 1052 | |
mbed_official | 237:f3da66175598 | 1053 | |
mbed_official | 237:f3da66175598 | 1054 | /** |
mbed_official | 237:f3da66175598 | 1055 | * @brief return the CEC state |
mbed_official | 237:f3da66175598 | 1056 | * @param hcec: CEC handle |
mbed_official | 237:f3da66175598 | 1057 | * @retval HAL state |
mbed_official | 237:f3da66175598 | 1058 | */ |
mbed_official | 237:f3da66175598 | 1059 | HAL_CEC_StateTypeDef HAL_CEC_GetState(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 1060 | { |
mbed_official | 237:f3da66175598 | 1061 | return hcec->State; |
mbed_official | 237:f3da66175598 | 1062 | } |
mbed_official | 237:f3da66175598 | 1063 | |
mbed_official | 237:f3da66175598 | 1064 | /** |
mbed_official | 237:f3da66175598 | 1065 | * @brief Return the CEC error code |
mbed_official | 237:f3da66175598 | 1066 | * @param hcec : pointer to a CEC_HandleTypeDef structure that contains |
mbed_official | 237:f3da66175598 | 1067 | * the configuration information for the specified CEC. |
mbed_official | 237:f3da66175598 | 1068 | * @retval CEC Error Code |
mbed_official | 237:f3da66175598 | 1069 | */ |
mbed_official | 237:f3da66175598 | 1070 | uint32_t HAL_CEC_GetError(CEC_HandleTypeDef *hcec) |
mbed_official | 237:f3da66175598 | 1071 | { |
mbed_official | 237:f3da66175598 | 1072 | return hcec->ErrorCode; |
mbed_official | 237:f3da66175598 | 1073 | } |
mbed_official | 237:f3da66175598 | 1074 | |
mbed_official | 237:f3da66175598 | 1075 | /** |
mbed_official | 237:f3da66175598 | 1076 | * @} |
mbed_official | 237:f3da66175598 | 1077 | */ |
mbed_official | 237:f3da66175598 | 1078 | |
mbed_official | 237:f3da66175598 | 1079 | /** |
mbed_official | 237:f3da66175598 | 1080 | * @} |
mbed_official | 237:f3da66175598 | 1081 | */ |
mbed_official | 237:f3da66175598 | 1082 | |
mbed_official | 237:f3da66175598 | 1083 | #endif /* defined(STM32F373xC) || defined(STM32F378xx) */ |
mbed_official | 237:f3da66175598 | 1084 | |
mbed_official | 237:f3da66175598 | 1085 | #endif /* HAL_CEC_MODULE_ENABLED */ |
mbed_official | 237:f3da66175598 | 1086 | /** |
mbed_official | 237:f3da66175598 | 1087 | * @} |
mbed_official | 237:f3da66175598 | 1088 | */ |
mbed_official | 237:f3da66175598 | 1089 | |
mbed_official | 237:f3da66175598 | 1090 | /** |
mbed_official | 237:f3da66175598 | 1091 | * @} |
mbed_official | 237:f3da66175598 | 1092 | */ |
mbed_official | 237:f3da66175598 | 1093 | |
mbed_official | 237:f3da66175598 | 1094 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |