Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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