inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NYX 0:85b3fd62ea1a 1 /**
NYX 0:85b3fd62ea1a 2 ******************************************************************************
NYX 0:85b3fd62ea1a 3 * @file stm32f4xx_hal_cec.c
NYX 0:85b3fd62ea1a 4 * @author MCD Application Team
NYX 0:85b3fd62ea1a 5 * @version V1.7.1
NYX 0:85b3fd62ea1a 6 * @date 14-April-2017
NYX 0:85b3fd62ea1a 7 * @brief CEC HAL module driver.
NYX 0:85b3fd62ea1a 8 * This file provides firmware functions to manage the following
NYX 0:85b3fd62ea1a 9 * functionalities of the High Definition Multimedia Interface
NYX 0:85b3fd62ea1a 10 * Consumer Electronics Control Peripheral (CEC).
NYX 0:85b3fd62ea1a 11 * + Initialization and de-initialization functions
NYX 0:85b3fd62ea1a 12 * + IO operation functions
NYX 0:85b3fd62ea1a 13 * + Peripheral Control functions
NYX 0:85b3fd62ea1a 14 *
NYX 0:85b3fd62ea1a 15 *
NYX 0:85b3fd62ea1a 16 @verbatim
NYX 0:85b3fd62ea1a 17 ===============================================================================
NYX 0:85b3fd62ea1a 18 ##### How to use this driver #####
NYX 0:85b3fd62ea1a 19 ===============================================================================
NYX 0:85b3fd62ea1a 20 [..]
NYX 0:85b3fd62ea1a 21 The CEC HAL driver can be used as follow:
NYX 0:85b3fd62ea1a 22
NYX 0:85b3fd62ea1a 23 (#) Declare a CEC_HandleTypeDef handle structure.
NYX 0:85b3fd62ea1a 24 (#) Initialize the CEC low level resources by implementing the HAL_CEC_MspInit ()API:
NYX 0:85b3fd62ea1a 25 (##) Enable the CEC interface clock.
NYX 0:85b3fd62ea1a 26 (##) CEC pins configuration:
NYX 0:85b3fd62ea1a 27 (+++) Enable the clock for the CEC GPIOs.
NYX 0:85b3fd62ea1a 28 (+++) Configure these CEC pins as alternate function pull-up.
NYX 0:85b3fd62ea1a 29 (##) NVIC configuration if you need to use interrupt process (HAL_CEC_Transmit_IT()
NYX 0:85b3fd62ea1a 30 and HAL_CEC_Receive_IT() APIs):
NYX 0:85b3fd62ea1a 31 (+++) Configure the CEC interrupt priority.
NYX 0:85b3fd62ea1a 32 (+++) Enable the NVIC CEC IRQ handle.
NYX 0:85b3fd62ea1a 33 (+++) The specific CEC interrupts (Transmission complete interrupt,
NYX 0:85b3fd62ea1a 34 RXNE interrupt and Error Interrupts) will be managed using the macros
NYX 0:85b3fd62ea1a 35 __HAL_CEC_ENABLE_IT() and __HAL_CEC_DISABLE_IT() inside the transmit
NYX 0:85b3fd62ea1a 36 and receive process.
NYX 0:85b3fd62ea1a 37
NYX 0:85b3fd62ea1a 38 (#) Program the Signal Free Time (SFT) and SFT option, Tolerance, reception stop in
NYX 0:85b3fd62ea1a 39 in case of Bit Rising Error, Error-Bit generation conditions, device logical
NYX 0:85b3fd62ea1a 40 address and Listen mode in the hcec Init structure.
NYX 0:85b3fd62ea1a 41
NYX 0:85b3fd62ea1a 42 (#) Initialize the CEC registers by calling the HAL_CEC_Init() API.
NYX 0:85b3fd62ea1a 43
NYX 0:85b3fd62ea1a 44 [..]
NYX 0:85b3fd62ea1a 45 (@) This API (HAL_CEC_Init()) configures also the low level Hardware (GPIO, CLOCK, CORTEX...)
NYX 0:85b3fd62ea1a 46 by calling the customed HAL_CEC_MspInit() API.
NYX 0:85b3fd62ea1a 47
NYX 0:85b3fd62ea1a 48 @endverbatim
NYX 0:85b3fd62ea1a 49 ******************************************************************************
NYX 0:85b3fd62ea1a 50 * @attention
NYX 0:85b3fd62ea1a 51 *
NYX 0:85b3fd62ea1a 52 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
NYX 0:85b3fd62ea1a 53 *
NYX 0:85b3fd62ea1a 54 * Redistribution and use in source and binary forms, with or without modification,
NYX 0:85b3fd62ea1a 55 * are permitted provided that the following conditions are met:
NYX 0:85b3fd62ea1a 56 * 1. Redistributions of source code must retain the above copyright notice,
NYX 0:85b3fd62ea1a 57 * this list of conditions and the following disclaimer.
NYX 0:85b3fd62ea1a 58 * 2. Redistributions in binary form must reproduce the above copyright notice,
NYX 0:85b3fd62ea1a 59 * this list of conditions and the following disclaimer in the documentation
NYX 0:85b3fd62ea1a 60 * and/or other materials provided with the distribution.
NYX 0:85b3fd62ea1a 61 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NYX 0:85b3fd62ea1a 62 * may be used to endorse or promote products derived from this software
NYX 0:85b3fd62ea1a 63 * without specific prior written permission.
NYX 0:85b3fd62ea1a 64 *
NYX 0:85b3fd62ea1a 65 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NYX 0:85b3fd62ea1a 66 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NYX 0:85b3fd62ea1a 67 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NYX 0:85b3fd62ea1a 68 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NYX 0:85b3fd62ea1a 69 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NYX 0:85b3fd62ea1a 70 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NYX 0:85b3fd62ea1a 71 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NYX 0:85b3fd62ea1a 72 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NYX 0:85b3fd62ea1a 73 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NYX 0:85b3fd62ea1a 74 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NYX 0:85b3fd62ea1a 75 *
NYX 0:85b3fd62ea1a 76 ******************************************************************************
NYX 0:85b3fd62ea1a 77 */
NYX 0:85b3fd62ea1a 78
NYX 0:85b3fd62ea1a 79 /* Includes ------------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 80 #include "stm32f4xx_hal.h"
NYX 0:85b3fd62ea1a 81
NYX 0:85b3fd62ea1a 82 /** @addtogroup STM32F4xx_HAL_Driver
NYX 0:85b3fd62ea1a 83 * @{
NYX 0:85b3fd62ea1a 84 */
NYX 0:85b3fd62ea1a 85
NYX 0:85b3fd62ea1a 86 /** @defgroup CEC CEC
NYX 0:85b3fd62ea1a 87 * @brief HAL CEC module driver
NYX 0:85b3fd62ea1a 88 * @{
NYX 0:85b3fd62ea1a 89 */
NYX 0:85b3fd62ea1a 90 #ifdef HAL_CEC_MODULE_ENABLED
NYX 0:85b3fd62ea1a 91
NYX 0:85b3fd62ea1a 92 #if defined(STM32F446xx)
NYX 0:85b3fd62ea1a 93
NYX 0:85b3fd62ea1a 94 /* Private typedef -----------------------------------------------------------*/
NYX 0:85b3fd62ea1a 95 /* Private define ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 96 /** @defgroup CEC_Private_Constants CEC Private Constants
NYX 0:85b3fd62ea1a 97 * @{
NYX 0:85b3fd62ea1a 98 */
NYX 0:85b3fd62ea1a 99 /**
NYX 0:85b3fd62ea1a 100 * @}
NYX 0:85b3fd62ea1a 101 */
NYX 0:85b3fd62ea1a 102
NYX 0:85b3fd62ea1a 103 /* Private macro -------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 104 /* Private variables ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 105 /* Private function prototypes -----------------------------------------------*/
NYX 0:85b3fd62ea1a 106 /** @defgroup CEC_Private_Functions CEC Private Functions
NYX 0:85b3fd62ea1a 107 * @{
NYX 0:85b3fd62ea1a 108 */
NYX 0:85b3fd62ea1a 109 /**
NYX 0:85b3fd62ea1a 110 * @}
NYX 0:85b3fd62ea1a 111 */
NYX 0:85b3fd62ea1a 112
NYX 0:85b3fd62ea1a 113 /* Exported functions ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 114
NYX 0:85b3fd62ea1a 115 /** @defgroup CEC_Exported_Functions CEC Exported Functions
NYX 0:85b3fd62ea1a 116 * @{
NYX 0:85b3fd62ea1a 117 */
NYX 0:85b3fd62ea1a 118
NYX 0:85b3fd62ea1a 119 /** @defgroup CEC_Exported_Functions_Group1 Initialization and de-initialization functions
NYX 0:85b3fd62ea1a 120 * @brief Initialization and Configuration functions
NYX 0:85b3fd62ea1a 121 *
NYX 0:85b3fd62ea1a 122 @verbatim
NYX 0:85b3fd62ea1a 123 ===============================================================================
NYX 0:85b3fd62ea1a 124 ##### Initialization and Configuration functions #####
NYX 0:85b3fd62ea1a 125 ===============================================================================
NYX 0:85b3fd62ea1a 126 [..]
NYX 0:85b3fd62ea1a 127 This subsection provides a set of functions allowing to initialize the CEC
NYX 0:85b3fd62ea1a 128 (+) The following parameters need to be configured:
NYX 0:85b3fd62ea1a 129 (++) SignalFreeTime
NYX 0:85b3fd62ea1a 130 (++) Tolerance
NYX 0:85b3fd62ea1a 131 (++) BRERxStop (RX stopped or not upon Bit Rising Error)
NYX 0:85b3fd62ea1a 132 (++) BREErrorBitGen (Error-Bit generation in case of Bit Rising Error)
NYX 0:85b3fd62ea1a 133 (++) LBPEErrorBitGen (Error-Bit generation in case of Long Bit Period Error)
NYX 0:85b3fd62ea1a 134 (++) BroadcastMsgNoErrorBitGen (Error-bit generation in case of broadcast message error)
NYX 0:85b3fd62ea1a 135 (++) SignalFreeTimeOption (SFT Timer start definition)
NYX 0:85b3fd62ea1a 136 (++) OwnAddress (CEC device address)
NYX 0:85b3fd62ea1a 137 (++) ListenMode
NYX 0:85b3fd62ea1a 138
NYX 0:85b3fd62ea1a 139 @endverbatim
NYX 0:85b3fd62ea1a 140 * @{
NYX 0:85b3fd62ea1a 141 */
NYX 0:85b3fd62ea1a 142
NYX 0:85b3fd62ea1a 143 /**
NYX 0:85b3fd62ea1a 144 * @brief Initializes the CEC mode according to the specified
NYX 0:85b3fd62ea1a 145 * parameters in the CEC_InitTypeDef and creates the associated handle .
NYX 0:85b3fd62ea1a 146 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 147 * @retval HAL status
NYX 0:85b3fd62ea1a 148 */
NYX 0:85b3fd62ea1a 149 HAL_StatusTypeDef HAL_CEC_Init(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 150 {
NYX 0:85b3fd62ea1a 151 /* Check the CEC handle allocation */
NYX 0:85b3fd62ea1a 152 if((hcec == NULL) ||(hcec->Init.RxBuffer == NULL))
NYX 0:85b3fd62ea1a 153 {
NYX 0:85b3fd62ea1a 154 return HAL_ERROR;
NYX 0:85b3fd62ea1a 155 }
NYX 0:85b3fd62ea1a 156
NYX 0:85b3fd62ea1a 157 /* Check the parameters */
NYX 0:85b3fd62ea1a 158 assert_param(IS_CEC_ALL_INSTANCE(hcec->Instance));
NYX 0:85b3fd62ea1a 159 assert_param(IS_CEC_SIGNALFREETIME(hcec->Init.SignalFreeTime));
NYX 0:85b3fd62ea1a 160 assert_param(IS_CEC_TOLERANCE(hcec->Init.Tolerance));
NYX 0:85b3fd62ea1a 161 assert_param(IS_CEC_BRERXSTOP(hcec->Init.BRERxStop));
NYX 0:85b3fd62ea1a 162 assert_param(IS_CEC_BREERRORBITGEN(hcec->Init.BREErrorBitGen));
NYX 0:85b3fd62ea1a 163 assert_param(IS_CEC_LBPEERRORBITGEN(hcec->Init.LBPEErrorBitGen));
NYX 0:85b3fd62ea1a 164 assert_param(IS_CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION(hcec->Init.BroadcastMsgNoErrorBitGen));
NYX 0:85b3fd62ea1a 165 assert_param(IS_CEC_SFTOP(hcec->Init.SignalFreeTimeOption));
NYX 0:85b3fd62ea1a 166 assert_param(IS_CEC_LISTENING_MODE(hcec->Init.ListenMode));
NYX 0:85b3fd62ea1a 167 assert_param(IS_CEC_OWN_ADDRESS(hcec->Init.OwnAddress));
NYX 0:85b3fd62ea1a 168
NYX 0:85b3fd62ea1a 169 if(hcec->gState == HAL_CEC_STATE_RESET)
NYX 0:85b3fd62ea1a 170 {
NYX 0:85b3fd62ea1a 171 /* Allocate lock resource and initialize it */
NYX 0:85b3fd62ea1a 172 hcec->Lock = HAL_UNLOCKED;
NYX 0:85b3fd62ea1a 173 /* Init the low level hardware : GPIO, CLOCK */
NYX 0:85b3fd62ea1a 174 HAL_CEC_MspInit(hcec);
NYX 0:85b3fd62ea1a 175 }
NYX 0:85b3fd62ea1a 176 hcec->gState = HAL_CEC_STATE_BUSY;
NYX 0:85b3fd62ea1a 177
NYX 0:85b3fd62ea1a 178 /* Disable the Peripheral */
NYX 0:85b3fd62ea1a 179 __HAL_CEC_DISABLE(hcec);
NYX 0:85b3fd62ea1a 180
NYX 0:85b3fd62ea1a 181 /* Write to CEC Control Register */
NYX 0:85b3fd62ea1a 182 hcec->Instance->CFGR = hcec->Init.SignalFreeTime | hcec->Init.Tolerance | hcec->Init.BRERxStop|\
NYX 0:85b3fd62ea1a 183 hcec->Init.BREErrorBitGen | hcec->Init.LBPEErrorBitGen | hcec->Init.BroadcastMsgNoErrorBitGen |\
NYX 0:85b3fd62ea1a 184 hcec->Init.SignalFreeTimeOption |((uint32_t)(hcec->Init.OwnAddress)<<16U) |\
NYX 0:85b3fd62ea1a 185 hcec->Init.ListenMode;
NYX 0:85b3fd62ea1a 186
NYX 0:85b3fd62ea1a 187 /* Enable the following CEC Transmission/Reception interrupts as
NYX 0:85b3fd62ea1a 188 * well as the following CEC Transmission/Reception Errors interrupts
NYX 0:85b3fd62ea1a 189 * Rx Byte Received IT
NYX 0:85b3fd62ea1a 190 * End of Reception IT
NYX 0:85b3fd62ea1a 191 * Rx overrun
NYX 0:85b3fd62ea1a 192 * Rx bit rising error
NYX 0:85b3fd62ea1a 193 * Rx short bit period error
NYX 0:85b3fd62ea1a 194 * Rx long bit period error
NYX 0:85b3fd62ea1a 195 * Rx missing acknowledge
NYX 0:85b3fd62ea1a 196 * Tx Byte Request IT
NYX 0:85b3fd62ea1a 197 * End of Transmission IT
NYX 0:85b3fd62ea1a 198 * Tx Missing Acknowledge IT
NYX 0:85b3fd62ea1a 199 * Tx-Error IT
NYX 0:85b3fd62ea1a 200 * Tx-Buffer Underrun IT
NYX 0:85b3fd62ea1a 201 * Tx arbitration lost */
NYX 0:85b3fd62ea1a 202 __HAL_CEC_ENABLE_IT(hcec, CEC_IT_RXBR|CEC_IT_RXEND|CEC_IER_RX_ALL_ERR|CEC_IT_TXBR|CEC_IT_TXEND|CEC_IER_TX_ALL_ERR);
NYX 0:85b3fd62ea1a 203
NYX 0:85b3fd62ea1a 204 /* Enable the CEC Peripheral */
NYX 0:85b3fd62ea1a 205 __HAL_CEC_ENABLE(hcec);
NYX 0:85b3fd62ea1a 206
NYX 0:85b3fd62ea1a 207 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
NYX 0:85b3fd62ea1a 208 hcec->gState = HAL_CEC_STATE_READY;
NYX 0:85b3fd62ea1a 209 hcec->RxState = HAL_CEC_STATE_READY;
NYX 0:85b3fd62ea1a 210
NYX 0:85b3fd62ea1a 211 return HAL_OK;
NYX 0:85b3fd62ea1a 212 }
NYX 0:85b3fd62ea1a 213
NYX 0:85b3fd62ea1a 214 /**
NYX 0:85b3fd62ea1a 215 * @brief DeInitializes the CEC peripheral
NYX 0:85b3fd62ea1a 216 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 217 * @retval HAL status
NYX 0:85b3fd62ea1a 218 */
NYX 0:85b3fd62ea1a 219 HAL_StatusTypeDef HAL_CEC_DeInit(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 220 {
NYX 0:85b3fd62ea1a 221 /* Check the CEC handle allocation */
NYX 0:85b3fd62ea1a 222 if(hcec == NULL)
NYX 0:85b3fd62ea1a 223 {
NYX 0:85b3fd62ea1a 224 return HAL_ERROR;
NYX 0:85b3fd62ea1a 225 }
NYX 0:85b3fd62ea1a 226
NYX 0:85b3fd62ea1a 227 /* Check the parameters */
NYX 0:85b3fd62ea1a 228 assert_param(IS_CEC_ALL_INSTANCE(hcec->Instance));
NYX 0:85b3fd62ea1a 229
NYX 0:85b3fd62ea1a 230 hcec->gState = HAL_CEC_STATE_BUSY;
NYX 0:85b3fd62ea1a 231
NYX 0:85b3fd62ea1a 232 /* DeInit the low level hardware */
NYX 0:85b3fd62ea1a 233 HAL_CEC_MspDeInit(hcec);
NYX 0:85b3fd62ea1a 234 /* Disable the Peripheral */
NYX 0:85b3fd62ea1a 235 __HAL_CEC_DISABLE(hcec);
NYX 0:85b3fd62ea1a 236
NYX 0:85b3fd62ea1a 237 /* Clear Flags */
NYX 0:85b3fd62ea1a 238 __HAL_CEC_CLEAR_FLAG(hcec,CEC_FLAG_TXEND|CEC_FLAG_TXBR|CEC_FLAG_RXBR|CEC_FLAG_RXEND|CEC_ISR_ALL_ERROR);
NYX 0:85b3fd62ea1a 239
NYX 0:85b3fd62ea1a 240 /* Disable the following CEC Transmission/Reception interrupts as
NYX 0:85b3fd62ea1a 241 * well as the following CEC Transmission/Reception Errors interrupts
NYX 0:85b3fd62ea1a 242 * Rx Byte Received IT
NYX 0:85b3fd62ea1a 243 * End of Reception IT
NYX 0:85b3fd62ea1a 244 * Rx overrun
NYX 0:85b3fd62ea1a 245 * Rx bit rising error
NYX 0:85b3fd62ea1a 246 * Rx short bit period error
NYX 0:85b3fd62ea1a 247 * Rx long bit period error
NYX 0:85b3fd62ea1a 248 * Rx missing acknowledge
NYX 0:85b3fd62ea1a 249 * Tx Byte Request IT
NYX 0:85b3fd62ea1a 250 * End of Transmission IT
NYX 0:85b3fd62ea1a 251 * Tx Missing Acknowledge IT
NYX 0:85b3fd62ea1a 252 * Tx-Error IT
NYX 0:85b3fd62ea1a 253 * Tx-Buffer Underrun IT
NYX 0:85b3fd62ea1a 254 * Tx arbitration lost */
NYX 0:85b3fd62ea1a 255 __HAL_CEC_DISABLE_IT(hcec, CEC_IT_RXBR|CEC_IT_RXEND|CEC_IER_RX_ALL_ERR|CEC_IT_TXBR|CEC_IT_TXEND|CEC_IER_TX_ALL_ERR);
NYX 0:85b3fd62ea1a 256
NYX 0:85b3fd62ea1a 257 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
NYX 0:85b3fd62ea1a 258 hcec->gState = HAL_CEC_STATE_RESET;
NYX 0:85b3fd62ea1a 259 hcec->RxState = HAL_CEC_STATE_RESET;
NYX 0:85b3fd62ea1a 260
NYX 0:85b3fd62ea1a 261 /* Process Unlock */
NYX 0:85b3fd62ea1a 262 __HAL_UNLOCK(hcec);
NYX 0:85b3fd62ea1a 263
NYX 0:85b3fd62ea1a 264 return HAL_OK;
NYX 0:85b3fd62ea1a 265 }
NYX 0:85b3fd62ea1a 266
NYX 0:85b3fd62ea1a 267 /**
NYX 0:85b3fd62ea1a 268 * @brief Initializes the Own Address of the CEC device
NYX 0:85b3fd62ea1a 269 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 270 * @param CEC_OwnAddress: The CEC own address.
NYX 0:85b3fd62ea1a 271 * @retval HAL status
NYX 0:85b3fd62ea1a 272 */
NYX 0:85b3fd62ea1a 273 HAL_StatusTypeDef HAL_CEC_SetDeviceAddress(CEC_HandleTypeDef *hcec, uint16_t CEC_OwnAddress)
NYX 0:85b3fd62ea1a 274 {
NYX 0:85b3fd62ea1a 275 /* Check the parameters */
NYX 0:85b3fd62ea1a 276 assert_param(IS_CEC_OWN_ADDRESS(CEC_OwnAddress));
NYX 0:85b3fd62ea1a 277
NYX 0:85b3fd62ea1a 278 if ((hcec->gState == HAL_CEC_STATE_READY) && (hcec->RxState == HAL_CEC_STATE_READY))
NYX 0:85b3fd62ea1a 279 {
NYX 0:85b3fd62ea1a 280 /* Process Locked */
NYX 0:85b3fd62ea1a 281 __HAL_LOCK(hcec);
NYX 0:85b3fd62ea1a 282
NYX 0:85b3fd62ea1a 283 hcec->gState = HAL_CEC_STATE_BUSY;
NYX 0:85b3fd62ea1a 284
NYX 0:85b3fd62ea1a 285 /* Disable the Peripheral */
NYX 0:85b3fd62ea1a 286 __HAL_CEC_DISABLE(hcec);
NYX 0:85b3fd62ea1a 287
NYX 0:85b3fd62ea1a 288 if(CEC_OwnAddress != CEC_OWN_ADDRESS_NONE)
NYX 0:85b3fd62ea1a 289 {
NYX 0:85b3fd62ea1a 290 hcec->Instance->CFGR |= ((uint32_t)CEC_OwnAddress<<16U);
NYX 0:85b3fd62ea1a 291 }
NYX 0:85b3fd62ea1a 292 else
NYX 0:85b3fd62ea1a 293 {
NYX 0:85b3fd62ea1a 294 hcec->Instance->CFGR &= ~(CEC_CFGR_OAR);
NYX 0:85b3fd62ea1a 295 }
NYX 0:85b3fd62ea1a 296
NYX 0:85b3fd62ea1a 297 hcec->gState = HAL_CEC_STATE_READY;
NYX 0:85b3fd62ea1a 298 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
NYX 0:85b3fd62ea1a 299
NYX 0:85b3fd62ea1a 300 /* Process Unlocked */
NYX 0:85b3fd62ea1a 301 __HAL_UNLOCK(hcec);
NYX 0:85b3fd62ea1a 302
NYX 0:85b3fd62ea1a 303 /* Enable the Peripheral */
NYX 0:85b3fd62ea1a 304 __HAL_CEC_ENABLE(hcec);
NYX 0:85b3fd62ea1a 305
NYX 0:85b3fd62ea1a 306 return HAL_OK;
NYX 0:85b3fd62ea1a 307 }
NYX 0:85b3fd62ea1a 308 else
NYX 0:85b3fd62ea1a 309 {
NYX 0:85b3fd62ea1a 310 return HAL_BUSY;
NYX 0:85b3fd62ea1a 311 }
NYX 0:85b3fd62ea1a 312 }
NYX 0:85b3fd62ea1a 313
NYX 0:85b3fd62ea1a 314 /**
NYX 0:85b3fd62ea1a 315 * @brief CEC MSP Init
NYX 0:85b3fd62ea1a 316 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 317 * @retval None
NYX 0:85b3fd62ea1a 318 */
NYX 0:85b3fd62ea1a 319 __weak void HAL_CEC_MspInit(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 320 {
NYX 0:85b3fd62ea1a 321 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 322 UNUSED(hcec);
NYX 0:85b3fd62ea1a 323 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 324 the HAL_CEC_MspInit can be implemented in the user file
NYX 0:85b3fd62ea1a 325 */
NYX 0:85b3fd62ea1a 326 }
NYX 0:85b3fd62ea1a 327
NYX 0:85b3fd62ea1a 328 /**
NYX 0:85b3fd62ea1a 329 * @brief CEC MSP DeInit
NYX 0:85b3fd62ea1a 330 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 331 * @retval None
NYX 0:85b3fd62ea1a 332 */
NYX 0:85b3fd62ea1a 333 __weak void HAL_CEC_MspDeInit(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 334 {
NYX 0:85b3fd62ea1a 335 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 336 UNUSED(hcec);
NYX 0:85b3fd62ea1a 337 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 338 the HAL_CEC_MspDeInit can be implemented in the user file
NYX 0:85b3fd62ea1a 339 */
NYX 0:85b3fd62ea1a 340 }
NYX 0:85b3fd62ea1a 341
NYX 0:85b3fd62ea1a 342 /**
NYX 0:85b3fd62ea1a 343 * @}
NYX 0:85b3fd62ea1a 344 */
NYX 0:85b3fd62ea1a 345
NYX 0:85b3fd62ea1a 346 /** @defgroup CEC_Exported_Functions_Group2 Input and Output operation functions
NYX 0:85b3fd62ea1a 347 * @brief CEC Transmit/Receive functions
NYX 0:85b3fd62ea1a 348 *
NYX 0:85b3fd62ea1a 349 @verbatim
NYX 0:85b3fd62ea1a 350 ===============================================================================
NYX 0:85b3fd62ea1a 351 ##### IO operation functions #####
NYX 0:85b3fd62ea1a 352 ===============================================================================
NYX 0:85b3fd62ea1a 353 This subsection provides a set of functions allowing to manage the CEC data transfers.
NYX 0:85b3fd62ea1a 354
NYX 0:85b3fd62ea1a 355 (#) The CEC handle must contain the initiator (TX side) and the destination (RX side)
NYX 0:85b3fd62ea1a 356 logical addresses (4-bit long addresses, 0x0F for broadcast messages destination)
NYX 0:85b3fd62ea1a 357
NYX 0:85b3fd62ea1a 358 (#) The communication is performed using Interrupts.
NYX 0:85b3fd62ea1a 359 These API's return the HAL status.
NYX 0:85b3fd62ea1a 360 The end of the data processing will be indicated through the
NYX 0:85b3fd62ea1a 361 dedicated CEC IRQ when using Interrupt mode.
NYX 0:85b3fd62ea1a 362 The HAL_CEC_TxCpltCallback(), HAL_CEC_RxCpltCallback() user callbacks
NYX 0:85b3fd62ea1a 363 will be executed respectivelly at the end of the transmit or Receive process
NYX 0:85b3fd62ea1a 364 The HAL_CEC_ErrorCallback()user callback will be executed when a communication
NYX 0:85b3fd62ea1a 365 error is detected
NYX 0:85b3fd62ea1a 366
NYX 0:85b3fd62ea1a 367 (#) API's with Interrupt are :
NYX 0:85b3fd62ea1a 368 (+) HAL_CEC_Transmit_IT()
NYX 0:85b3fd62ea1a 369 (+) HAL_CEC_IRQHandler()
NYX 0:85b3fd62ea1a 370
NYX 0:85b3fd62ea1a 371 (#) A set of User Callbacks are provided:
NYX 0:85b3fd62ea1a 372 (+) HAL_CEC_TxCpltCallback()
NYX 0:85b3fd62ea1a 373 (+) HAL_CEC_RxCpltCallback()
NYX 0:85b3fd62ea1a 374 (+) HAL_CEC_ErrorCallback()
NYX 0:85b3fd62ea1a 375
NYX 0:85b3fd62ea1a 376 @endverbatim
NYX 0:85b3fd62ea1a 377 * @{
NYX 0:85b3fd62ea1a 378 */
NYX 0:85b3fd62ea1a 379
NYX 0:85b3fd62ea1a 380 /**
NYX 0:85b3fd62ea1a 381 * @brief Send data in interrupt mode
NYX 0:85b3fd62ea1a 382 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 383 * @param InitiatorAddress: Initiator logical address
NYX 0:85b3fd62ea1a 384 * @param DestinationAddress: destination logical address
NYX 0:85b3fd62ea1a 385 * @param pData: pointer to input byte data buffer
NYX 0:85b3fd62ea1a 386 * @param Size: amount of data to be sent in bytes (without counting the header).
NYX 0:85b3fd62ea1a 387 * 0 means only the header is sent (ping operation).
NYX 0:85b3fd62ea1a 388 * Maximum TX size is 15 bytes (1 opcode and up to 14 operands).
NYX 0:85b3fd62ea1a 389 * @retval HAL status
NYX 0:85b3fd62ea1a 390 */
NYX 0:85b3fd62ea1a 391 HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t InitiatorAddress, uint8_t DestinationAddress, uint8_t *pData, uint32_t Size)
NYX 0:85b3fd62ea1a 392 {
NYX 0:85b3fd62ea1a 393 /* if the IP isn't already busy and if there is no previous transmission
NYX 0:85b3fd62ea1a 394 already pending due to arbitration lost */
NYX 0:85b3fd62ea1a 395 if (hcec->gState == HAL_CEC_STATE_READY)
NYX 0:85b3fd62ea1a 396 {
NYX 0:85b3fd62ea1a 397 if((pData == NULL ) && (Size > 0U))
NYX 0:85b3fd62ea1a 398 {
NYX 0:85b3fd62ea1a 399 return HAL_ERROR;
NYX 0:85b3fd62ea1a 400 }
NYX 0:85b3fd62ea1a 401
NYX 0:85b3fd62ea1a 402 assert_param(IS_CEC_ADDRESS(DestinationAddress));
NYX 0:85b3fd62ea1a 403 assert_param(IS_CEC_ADDRESS(InitiatorAddress));
NYX 0:85b3fd62ea1a 404 assert_param(IS_CEC_MSGSIZE(Size));
NYX 0:85b3fd62ea1a 405
NYX 0:85b3fd62ea1a 406 /* Process Locked */
NYX 0:85b3fd62ea1a 407 __HAL_LOCK(hcec);
NYX 0:85b3fd62ea1a 408 hcec->pTxBuffPtr = pData;
NYX 0:85b3fd62ea1a 409 hcec->gState = HAL_CEC_STATE_BUSY_TX;
NYX 0:85b3fd62ea1a 410 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
NYX 0:85b3fd62ea1a 411
NYX 0:85b3fd62ea1a 412 /* initialize the number of bytes to send,
NYX 0:85b3fd62ea1a 413 * 0 means only one header is sent (ping operation) */
NYX 0:85b3fd62ea1a 414 hcec->TxXferCount = Size;
NYX 0:85b3fd62ea1a 415
NYX 0:85b3fd62ea1a 416 /* in case of no payload (Size = 0), sender is only pinging the system;
NYX 0:85b3fd62ea1a 417 Set TX End of Message (TXEOM) bit, must be set before writing data to TXDR */
NYX 0:85b3fd62ea1a 418 if (Size == 0U)
NYX 0:85b3fd62ea1a 419 {
NYX 0:85b3fd62ea1a 420 __HAL_CEC_LAST_BYTE_TX_SET(hcec);
NYX 0:85b3fd62ea1a 421 }
NYX 0:85b3fd62ea1a 422
NYX 0:85b3fd62ea1a 423 /* send header block */
NYX 0:85b3fd62ea1a 424 hcec->Instance->TXDR = ((uint8_t)(InitiatorAddress << CEC_INITIATOR_LSB_POS) |(uint8_t) DestinationAddress);
NYX 0:85b3fd62ea1a 425 /* Set TX Start of Message (TXSOM) bit */
NYX 0:85b3fd62ea1a 426 __HAL_CEC_FIRST_BYTE_TX_SET(hcec);
NYX 0:85b3fd62ea1a 427
NYX 0:85b3fd62ea1a 428 /* Process Unlocked */
NYX 0:85b3fd62ea1a 429 __HAL_UNLOCK(hcec);
NYX 0:85b3fd62ea1a 430
NYX 0:85b3fd62ea1a 431 return HAL_OK;
NYX 0:85b3fd62ea1a 432
NYX 0:85b3fd62ea1a 433 }
NYX 0:85b3fd62ea1a 434 else
NYX 0:85b3fd62ea1a 435 {
NYX 0:85b3fd62ea1a 436 return HAL_BUSY;
NYX 0:85b3fd62ea1a 437 }
NYX 0:85b3fd62ea1a 438 }
NYX 0:85b3fd62ea1a 439
NYX 0:85b3fd62ea1a 440 /**
NYX 0:85b3fd62ea1a 441 * @brief Get size of the received frame.
NYX 0:85b3fd62ea1a 442 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 443 * @retval Frame size
NYX 0:85b3fd62ea1a 444 */
NYX 0:85b3fd62ea1a 445 uint32_t HAL_CEC_GetLastReceivedFrameSize(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 446 {
NYX 0:85b3fd62ea1a 447 return hcec->RxXferSize;
NYX 0:85b3fd62ea1a 448 }
NYX 0:85b3fd62ea1a 449
NYX 0:85b3fd62ea1a 450 /**
NYX 0:85b3fd62ea1a 451 * @brief Change Rx Buffer.
NYX 0:85b3fd62ea1a 452 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 453 * @param Rxbuffer: Rx Buffer
NYX 0:85b3fd62ea1a 454 * @note This function can be called only inside the HAL_CEC_RxCpltCallback()
NYX 0:85b3fd62ea1a 455 * @retval Frame size
NYX 0:85b3fd62ea1a 456 */
NYX 0:85b3fd62ea1a 457 void HAL_CEC_ChangeRxBuffer(CEC_HandleTypeDef *hcec, uint8_t* Rxbuffer)
NYX 0:85b3fd62ea1a 458 {
NYX 0:85b3fd62ea1a 459 hcec->Init.RxBuffer = Rxbuffer;
NYX 0:85b3fd62ea1a 460 }
NYX 0:85b3fd62ea1a 461
NYX 0:85b3fd62ea1a 462 /**
NYX 0:85b3fd62ea1a 463 * @brief This function handles CEC interrupt requests.
NYX 0:85b3fd62ea1a 464 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 465 * @retval None
NYX 0:85b3fd62ea1a 466 */
NYX 0:85b3fd62ea1a 467 void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 468 {
NYX 0:85b3fd62ea1a 469
NYX 0:85b3fd62ea1a 470 /* save interrupts register for further error or interrupts handling purposes */
NYX 0:85b3fd62ea1a 471 uint32_t reg = 0U;
NYX 0:85b3fd62ea1a 472 reg = hcec->Instance->ISR;
NYX 0:85b3fd62ea1a 473
NYX 0:85b3fd62ea1a 474
NYX 0:85b3fd62ea1a 475 /* ----------------------------Arbitration Lost Management----------------------------------*/
NYX 0:85b3fd62ea1a 476 /* CEC TX arbitration error interrupt occurred --------------------------------------*/
NYX 0:85b3fd62ea1a 477 if((reg & CEC_FLAG_ARBLST) != RESET)
NYX 0:85b3fd62ea1a 478 {
NYX 0:85b3fd62ea1a 479 hcec->ErrorCode = HAL_CEC_ERROR_ARBLST;
NYX 0:85b3fd62ea1a 480 __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_ARBLST);
NYX 0:85b3fd62ea1a 481 }
NYX 0:85b3fd62ea1a 482
NYX 0:85b3fd62ea1a 483 /* ----------------------------Rx Management----------------------------------*/
NYX 0:85b3fd62ea1a 484 /* CEC RX byte received interrupt ---------------------------------------------------*/
NYX 0:85b3fd62ea1a 485 if((reg & CEC_FLAG_RXBR) != RESET)
NYX 0:85b3fd62ea1a 486 {
NYX 0:85b3fd62ea1a 487 /* reception is starting */
NYX 0:85b3fd62ea1a 488 hcec->RxState = HAL_CEC_STATE_BUSY_RX;
NYX 0:85b3fd62ea1a 489 hcec->RxXferSize++;
NYX 0:85b3fd62ea1a 490 /* read received byte */
NYX 0:85b3fd62ea1a 491 *hcec->Init.RxBuffer++ = hcec->Instance->RXDR;
NYX 0:85b3fd62ea1a 492 __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_RXBR);
NYX 0:85b3fd62ea1a 493 }
NYX 0:85b3fd62ea1a 494
NYX 0:85b3fd62ea1a 495 /* CEC RX end received interrupt ---------------------------------------------------*/
NYX 0:85b3fd62ea1a 496 if((reg & CEC_FLAG_RXEND) != RESET)
NYX 0:85b3fd62ea1a 497 {
NYX 0:85b3fd62ea1a 498 /* clear IT */
NYX 0:85b3fd62ea1a 499 __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_RXEND);
NYX 0:85b3fd62ea1a 500
NYX 0:85b3fd62ea1a 501 /* Rx process is completed, restore hcec->RxState to Ready */
NYX 0:85b3fd62ea1a 502 hcec->RxState = HAL_CEC_STATE_READY;
NYX 0:85b3fd62ea1a 503 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
NYX 0:85b3fd62ea1a 504 hcec->Init.RxBuffer -= hcec->RxXferSize;
NYX 0:85b3fd62ea1a 505 HAL_CEC_RxCpltCallback(hcec, hcec->RxXferSize);
NYX 0:85b3fd62ea1a 506 hcec->RxXferSize = 0U;
NYX 0:85b3fd62ea1a 507 }
NYX 0:85b3fd62ea1a 508
NYX 0:85b3fd62ea1a 509 /* ----------------------------Tx Management----------------------------------*/
NYX 0:85b3fd62ea1a 510 /* CEC TX byte request interrupt ------------------------------------------------*/
NYX 0:85b3fd62ea1a 511 if((reg & CEC_FLAG_TXBR) != RESET)
NYX 0:85b3fd62ea1a 512 {
NYX 0:85b3fd62ea1a 513 if (hcec->TxXferCount == 0U)
NYX 0:85b3fd62ea1a 514 {
NYX 0:85b3fd62ea1a 515 /* if this is the last byte transmission, set TX End of Message (TXEOM) bit */
NYX 0:85b3fd62ea1a 516 __HAL_CEC_LAST_BYTE_TX_SET(hcec);
NYX 0:85b3fd62ea1a 517 hcec->Instance->TXDR = *hcec->pTxBuffPtr++;
NYX 0:85b3fd62ea1a 518 }
NYX 0:85b3fd62ea1a 519 else
NYX 0:85b3fd62ea1a 520 {
NYX 0:85b3fd62ea1a 521 hcec->Instance->TXDR = *hcec->pTxBuffPtr++;
NYX 0:85b3fd62ea1a 522 hcec->TxXferCount--;
NYX 0:85b3fd62ea1a 523 }
NYX 0:85b3fd62ea1a 524 /* clear Tx-Byte request flag */
NYX 0:85b3fd62ea1a 525 __HAL_CEC_CLEAR_FLAG(hcec,CEC_FLAG_TXBR);
NYX 0:85b3fd62ea1a 526 }
NYX 0:85b3fd62ea1a 527
NYX 0:85b3fd62ea1a 528 /* CEC TX end interrupt ------------------------------------------------*/
NYX 0:85b3fd62ea1a 529 if((reg & CEC_FLAG_TXEND) != RESET)
NYX 0:85b3fd62ea1a 530 {
NYX 0:85b3fd62ea1a 531 __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_TXEND);
NYX 0:85b3fd62ea1a 532
NYX 0:85b3fd62ea1a 533 /* Tx process is ended, restore hcec->gState to Ready */
NYX 0:85b3fd62ea1a 534 hcec->gState = HAL_CEC_STATE_READY;
NYX 0:85b3fd62ea1a 535 /* Call the Process Unlocked before calling the Tx call back API to give the possibility to
NYX 0:85b3fd62ea1a 536 start again the Transmission under the Tx call back API */
NYX 0:85b3fd62ea1a 537 __HAL_UNLOCK(hcec);
NYX 0:85b3fd62ea1a 538 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
NYX 0:85b3fd62ea1a 539 HAL_CEC_TxCpltCallback(hcec);
NYX 0:85b3fd62ea1a 540 }
NYX 0:85b3fd62ea1a 541
NYX 0:85b3fd62ea1a 542 /* ----------------------------Rx/Tx Error Management----------------------------------*/
NYX 0:85b3fd62ea1a 543 if ((reg & (CEC_ISR_RXOVR|CEC_ISR_BRE|CEC_ISR_SBPE|CEC_ISR_LBPE|CEC_ISR_RXACKE|CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)) != 0U)
NYX 0:85b3fd62ea1a 544 {
NYX 0:85b3fd62ea1a 545 hcec->ErrorCode = reg;
NYX 0:85b3fd62ea1a 546 __HAL_CEC_CLEAR_FLAG(hcec, HAL_CEC_ERROR_RXOVR|HAL_CEC_ERROR_BRE|CEC_FLAG_LBPE|CEC_FLAG_SBPE|HAL_CEC_ERROR_RXACKE|HAL_CEC_ERROR_TXUDR|HAL_CEC_ERROR_TXERR|HAL_CEC_ERROR_TXACKE);
NYX 0:85b3fd62ea1a 547
NYX 0:85b3fd62ea1a 548
NYX 0:85b3fd62ea1a 549 if((reg & (CEC_ISR_RXOVR|CEC_ISR_BRE|CEC_ISR_SBPE|CEC_ISR_LBPE|CEC_ISR_RXACKE)) != RESET)
NYX 0:85b3fd62ea1a 550 {
NYX 0:85b3fd62ea1a 551 hcec->Init.RxBuffer-=hcec->RxXferSize;
NYX 0:85b3fd62ea1a 552 hcec->RxXferSize = 0U;
NYX 0:85b3fd62ea1a 553 hcec->RxState = HAL_CEC_STATE_READY;
NYX 0:85b3fd62ea1a 554 }
NYX 0:85b3fd62ea1a 555 else if (((reg & (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)) != RESET) && ((reg & CEC_ISR_ARBLST) == RESET))
NYX 0:85b3fd62ea1a 556 {
NYX 0:85b3fd62ea1a 557 /* Set the CEC state ready to be able to start again the process */
NYX 0:85b3fd62ea1a 558 hcec->gState = HAL_CEC_STATE_READY;
NYX 0:85b3fd62ea1a 559 }
NYX 0:85b3fd62ea1a 560
NYX 0:85b3fd62ea1a 561 /* Error Call Back */
NYX 0:85b3fd62ea1a 562 HAL_CEC_ErrorCallback(hcec);
NYX 0:85b3fd62ea1a 563 }
NYX 0:85b3fd62ea1a 564
NYX 0:85b3fd62ea1a 565 }
NYX 0:85b3fd62ea1a 566
NYX 0:85b3fd62ea1a 567 /**
NYX 0:85b3fd62ea1a 568 * @brief Tx Transfer completed callback
NYX 0:85b3fd62ea1a 569 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 570 * @retval None
NYX 0:85b3fd62ea1a 571 */
NYX 0:85b3fd62ea1a 572 __weak void HAL_CEC_TxCpltCallback(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 573 {
NYX 0:85b3fd62ea1a 574 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 575 UNUSED(hcec);
NYX 0:85b3fd62ea1a 576 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 577 the HAL_CEC_TxCpltCallback can be implemented in the user file
NYX 0:85b3fd62ea1a 578 */
NYX 0:85b3fd62ea1a 579 }
NYX 0:85b3fd62ea1a 580
NYX 0:85b3fd62ea1a 581 /**
NYX 0:85b3fd62ea1a 582 * @brief Rx Transfer completed callback
NYX 0:85b3fd62ea1a 583 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 584 * @param RxFrameSize: Size of frame
NYX 0:85b3fd62ea1a 585 * @retval None
NYX 0:85b3fd62ea1a 586 */
NYX 0:85b3fd62ea1a 587 __weak void HAL_CEC_RxCpltCallback(CEC_HandleTypeDef *hcec, uint32_t RxFrameSize)
NYX 0:85b3fd62ea1a 588 {
NYX 0:85b3fd62ea1a 589 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 590 UNUSED(hcec);
NYX 0:85b3fd62ea1a 591 UNUSED(RxFrameSize);
NYX 0:85b3fd62ea1a 592 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 593 the HAL_CEC_RxCpltCallback can be implemented in the user file
NYX 0:85b3fd62ea1a 594 */
NYX 0:85b3fd62ea1a 595 }
NYX 0:85b3fd62ea1a 596
NYX 0:85b3fd62ea1a 597 /**
NYX 0:85b3fd62ea1a 598 * @brief CEC error callbacks
NYX 0:85b3fd62ea1a 599 * @param hcec: CEC handle
NYX 0:85b3fd62ea1a 600 * @retval None
NYX 0:85b3fd62ea1a 601 */
NYX 0:85b3fd62ea1a 602 __weak void HAL_CEC_ErrorCallback(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 603 {
NYX 0:85b3fd62ea1a 604 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 605 UNUSED(hcec);
NYX 0:85b3fd62ea1a 606 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 607 the HAL_CEC_ErrorCallback can be implemented in the user file
NYX 0:85b3fd62ea1a 608 */
NYX 0:85b3fd62ea1a 609 }
NYX 0:85b3fd62ea1a 610 /**
NYX 0:85b3fd62ea1a 611 * @}
NYX 0:85b3fd62ea1a 612 */
NYX 0:85b3fd62ea1a 613
NYX 0:85b3fd62ea1a 614 /** @defgroup CEC_Exported_Functions_Group3 Peripheral Control function
NYX 0:85b3fd62ea1a 615 * @brief CEC control functions
NYX 0:85b3fd62ea1a 616 *
NYX 0:85b3fd62ea1a 617 @verbatim
NYX 0:85b3fd62ea1a 618 ===============================================================================
NYX 0:85b3fd62ea1a 619 ##### Peripheral Control function #####
NYX 0:85b3fd62ea1a 620 ===============================================================================
NYX 0:85b3fd62ea1a 621 [..]
NYX 0:85b3fd62ea1a 622 This subsection provides a set of functions allowing to control the CEC.
NYX 0:85b3fd62ea1a 623 (+) HAL_CEC_GetState() API can be helpful to check in run-time the state of the CEC peripheral.
NYX 0:85b3fd62ea1a 624 (+) HAL_CEC_GetError() API can be helpful to check in run-time the error of the CEC peripheral.
NYX 0:85b3fd62ea1a 625 @endverbatim
NYX 0:85b3fd62ea1a 626 * @{
NYX 0:85b3fd62ea1a 627 */
NYX 0:85b3fd62ea1a 628 /**
NYX 0:85b3fd62ea1a 629 * @brief return the CEC state
NYX 0:85b3fd62ea1a 630 * @param hcec: pointer to a CEC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 631 * the configuration information for the specified CEC module.
NYX 0:85b3fd62ea1a 632 * @retval HAL state
NYX 0:85b3fd62ea1a 633 */
NYX 0:85b3fd62ea1a 634 HAL_CEC_StateTypeDef HAL_CEC_GetState(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 635 {
NYX 0:85b3fd62ea1a 636 uint32_t temp1 = 0x00U, temp2 = 0x00U;
NYX 0:85b3fd62ea1a 637 temp1 = hcec->gState;
NYX 0:85b3fd62ea1a 638 temp2 = hcec->RxState;
NYX 0:85b3fd62ea1a 639
NYX 0:85b3fd62ea1a 640 return (HAL_CEC_StateTypeDef)(temp1 | temp2);
NYX 0:85b3fd62ea1a 641 }
NYX 0:85b3fd62ea1a 642
NYX 0:85b3fd62ea1a 643 /**
NYX 0:85b3fd62ea1a 644 * @brief Return the CEC error code
NYX 0:85b3fd62ea1a 645 * @param hcec : pointer to a CEC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 646 * the configuration information for the specified CEC.
NYX 0:85b3fd62ea1a 647 * @retval CEC Error Code
NYX 0:85b3fd62ea1a 648 */
NYX 0:85b3fd62ea1a 649 uint32_t HAL_CEC_GetError(CEC_HandleTypeDef *hcec)
NYX 0:85b3fd62ea1a 650 {
NYX 0:85b3fd62ea1a 651 return hcec->ErrorCode;
NYX 0:85b3fd62ea1a 652 }
NYX 0:85b3fd62ea1a 653
NYX 0:85b3fd62ea1a 654 /**
NYX 0:85b3fd62ea1a 655 * @}
NYX 0:85b3fd62ea1a 656 */
NYX 0:85b3fd62ea1a 657
NYX 0:85b3fd62ea1a 658 /**
NYX 0:85b3fd62ea1a 659 * @}
NYX 0:85b3fd62ea1a 660 */
NYX 0:85b3fd62ea1a 661
NYX 0:85b3fd62ea1a 662 #endif /* STM32F446xx */
NYX 0:85b3fd62ea1a 663
NYX 0:85b3fd62ea1a 664 #endif /* HAL_CEC_MODULE_ENABLED */
NYX 0:85b3fd62ea1a 665 /**
NYX 0:85b3fd62ea1a 666 * @}
NYX 0:85b3fd62ea1a 667 */
NYX 0:85b3fd62ea1a 668
NYX 0:85b3fd62ea1a 669 /**
NYX 0:85b3fd62ea1a 670 * @}
NYX 0:85b3fd62ea1a 671 */
NYX 0:85b3fd62ea1a 672
NYX 0:85b3fd62ea1a 673 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/