STM32F479xx HAL User Manual
stm32f4xx_hal_cec.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_cec.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of CEC HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
00010   * All rights reserved.</center></h2>
00011   *
00012   * This software component is licensed by ST under BSD 3-Clause license,
00013   * the "License"; You may not use this file except in compliance with the
00014   * License. You may obtain a copy of the License at:
00015   *                        opensource.org/licenses/BSD-3-Clause
00016   *
00017   ******************************************************************************
00018   */
00019 
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef STM32F4xx_HAL_CEC_H
00022 #define STM32F4xx_HAL_CEC_H
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f4xx_hal_def.h"
00030 
00031 #if defined (CEC)
00032 
00033 /** @addtogroup STM32F4xx_HAL_Driver
00034   * @{
00035   */
00036 
00037 /** @addtogroup CEC
00038   * @{
00039   */
00040 
00041 /* Exported types ------------------------------------------------------------*/
00042 /** @defgroup CEC_Exported_Types CEC Exported Types
00043   * @{
00044   */
00045 
00046 /**
00047   * @brief CEC Init Structure definition
00048   */
00049 typedef struct
00050 {
00051   uint32_t SignalFreeTime;               /*!< Set SFT field, specifies the Signal Free Time.
00052                                               It can be one of @ref CEC_Signal_Free_Time
00053                                               and belongs to the set {0,...,7} where
00054                                               0x0 is the default configuration
00055                                               else means 0.5 + (SignalFreeTime - 1) nominal data bit periods */
00056 
00057   uint32_t Tolerance;                    /*!< Set RXTOL bit, specifies the tolerance accepted on the received waveforms,
00058                                               it can be a value of @ref CEC_Tolerance : it is either CEC_STANDARD_TOLERANCE
00059                                               or CEC_EXTENDED_TOLERANCE */
00060 
00061   uint32_t BRERxStop;                    /*!< Set BRESTP bit @ref CEC_BRERxStop : specifies whether or not a Bit Rising Error stops the reception.
00062                                               CEC_NO_RX_STOP_ON_BRE: reception is not stopped.
00063                                               CEC_RX_STOP_ON_BRE:    reception is stopped. */
00064 
00065   uint32_t BREErrorBitGen;               /*!< Set BREGEN bit @ref CEC_BREErrorBitGen : specifies whether or not an Error-Bit is generated on the
00066                                               CEC line upon Bit Rising Error detection.
00067                                               CEC_BRE_ERRORBIT_NO_GENERATION: no error-bit generation.
00068                                               CEC_BRE_ERRORBIT_GENERATION:    error-bit generation if BRESTP is set. */
00069 
00070   uint32_t LBPEErrorBitGen;              /*!< Set LBPEGEN bit @ref CEC_LBPEErrorBitGen : specifies whether or not an Error-Bit is generated on the
00071                                               CEC line upon Long Bit Period Error detection.
00072                                               CEC_LBPE_ERRORBIT_NO_GENERATION:  no error-bit generation.
00073                                               CEC_LBPE_ERRORBIT_GENERATION:     error-bit generation. */
00074 
00075   uint32_t BroadcastMsgNoErrorBitGen;    /*!< Set BRDNOGEN bit @ref CEC_BroadCastMsgErrorBitGen : allows to avoid an Error-Bit generation on the CEC line
00076                                               upon an error detected on a broadcast message.
00077 
00078                                               It supersedes BREGEN and LBPEGEN bits for a broadcast message error handling. It can take two values:
00079 
00080                                               1) CEC_BROADCASTERROR_ERRORBIT_GENERATION.
00081                                                  a) BRE detection: error-bit generation on the CEC line if BRESTP=CEC_RX_STOP_ON_BRE
00082                                                     and BREGEN=CEC_BRE_ERRORBIT_NO_GENERATION.
00083                                                  b) LBPE detection: error-bit generation on the CEC line
00084                                                     if LBPGEN=CEC_LBPE_ERRORBIT_NO_GENERATION.
00085 
00086                                               2) CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION.
00087                                                  no error-bit generation in case neither a) nor b) are satisfied. Additionally,
00088                                                  there is no error-bit generation in case of Short Bit Period Error detection in
00089                                                  a broadcast message while LSTN bit is set. */
00090 
00091   uint32_t SignalFreeTimeOption;         /*!< Set SFTOP bit @ref CEC_SFT_Option : specifies when SFT timer starts.
00092                                               CEC_SFT_START_ON_TXSOM SFT:    timer starts when TXSOM is set by software.
00093                                               CEC_SFT_START_ON_TX_RX_END:  SFT timer starts automatically at the end of message transmission/reception. */
00094 
00095   uint32_t ListenMode;                   /*!< Set LSTN bit @ref CEC_Listening_Mode : specifies device listening mode. It can take two values:
00096 
00097                                               CEC_REDUCED_LISTENING_MODE: CEC peripheral receives only message addressed to its
00098                                                 own address (OAR). Messages addressed to different destination are ignored.
00099                                                 Broadcast messages are always received.
00100 
00101                                               CEC_FULL_LISTENING_MODE: CEC peripheral receives messages addressed to its own
00102                                                 address (OAR) with positive acknowledge. Messages addressed to different destination
00103                                                 are received, but without interfering with the CEC bus: no acknowledge sent.  */
00104 
00105   uint16_t  OwnAddress;                 /*!< Own addresses configuration
00106                                              This parameter can be a value of @ref CEC_OWN_ADDRESS */
00107 
00108   uint8_t  *RxBuffer;                    /*!< CEC Rx buffer pointeur */
00109 
00110 
00111 } CEC_InitTypeDef;
00112 
00113 /**
00114   * @brief HAL CEC State definition
00115   * @note  HAL CEC State value is a combination of 2 different substates: gState and RxState (see @ref CEC_State_Definition).
00116   *        - gState contains CEC state information related to global Handle management
00117   *          and also information related to Tx operations.
00118   *          gState value coding follow below described bitmap :
00119   *          b7 (not used)
00120   *             x  : Should be set to 0
00121   *          b6  Error information
00122   *             0  : No Error
00123   *             1  : Error
00124   *          b5     CEC peripheral initialization status
00125   *             0  : Reset (peripheral not initialized)
00126   *             1  : Init done (peripheral initialized. HAL CEC Init function already called)
00127   *          b4-b3  (not used)
00128   *             xx : Should be set to 00
00129   *          b2     Intrinsic process state
00130   *             0  : Ready
00131   *             1  : Busy (peripheral busy with some configuration or internal operations)
00132   *          b1     (not used)
00133   *             x  : Should be set to 0
00134   *          b0     Tx state
00135   *             0  : Ready (no Tx operation ongoing)
00136   *             1  : Busy (Tx operation ongoing)
00137   *        - RxState contains information related to Rx operations.
00138   *          RxState value coding follow below described bitmap :
00139   *          b7-b6  (not used)
00140   *             xx : Should be set to 00
00141   *          b5     CEC peripheral initialization status
00142   *             0  : Reset (peripheral not initialized)
00143   *             1  : Init done (peripheral initialized)
00144   *          b4-b2  (not used)
00145   *            xxx : Should be set to 000
00146   *          b1     Rx state
00147   *             0  : Ready (no Rx operation ongoing)
00148   *             1  : Busy (Rx operation ongoing)
00149   *          b0     (not used)
00150   *             x  : Should be set to 0.
00151   */
00152 typedef uint32_t HAL_CEC_StateTypeDef;
00153 
00154 /**
00155   * @brief  CEC handle Structure definition
00156   */
00157 #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
00158 typedef struct __CEC_HandleTypeDef
00159 #else
00160 typedef struct
00161 #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
00162 {
00163   CEC_TypeDef             *Instance;      /*!< CEC registers base address */
00164 
00165   CEC_InitTypeDef         Init;           /*!< CEC communication parameters */
00166 
00167   uint8_t                 *pTxBuffPtr;    /*!< Pointer to CEC Tx transfer Buffer */
00168 
00169   uint16_t                TxXferCount;    /*!< CEC Tx Transfer Counter */
00170 
00171   uint16_t                RxXferSize;     /*!< CEC Rx Transfer size, 0: header received only */
00172 
00173   HAL_LockTypeDef         Lock;           /*!< Locking object */
00174 
00175   HAL_CEC_StateTypeDef    gState;         /*!< CEC state information related to global Handle management
00176                                                and also related to Tx operations.
00177                                                This parameter can be a value of @ref HAL_CEC_StateTypeDef */
00178 
00179   HAL_CEC_StateTypeDef    RxState;        /*!< CEC state information related to Rx operations.
00180                                                This parameter can be a value of @ref HAL_CEC_StateTypeDef */
00181 
00182   uint32_t                ErrorCode;      /*!< For errors handling purposes, copy of ISR register
00183                                                in case error is reported */
00184 
00185 #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
00186   void (* TxCpltCallback)(struct __CEC_HandleTypeDef
00187                           *hcec);                                /*!< CEC Tx Transfer completed callback */
00188   void (* RxCpltCallback)(struct __CEC_HandleTypeDef *hcec,
00189                           uint32_t RxFrameSize);          /*!< CEC Rx Transfer completed callback */
00190   void (* ErrorCallback)(struct __CEC_HandleTypeDef *hcec);                                 /*!< CEC error callback */
00191 
00192   void (* MspInitCallback)(struct __CEC_HandleTypeDef *hcec);               /*!< CEC Msp Init callback              */
00193   void (* MspDeInitCallback)(struct __CEC_HandleTypeDef *hcec);             /*!< CEC Msp DeInit callback            */
00194 
00195 #endif /* (USE_HAL_CEC_REGISTER_CALLBACKS) */
00196 } CEC_HandleTypeDef;
00197 
00198 #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
00199 /**
00200   * @brief  HAL CEC Callback ID enumeration definition
00201   */
00202 typedef enum
00203 {
00204   HAL_CEC_TX_CPLT_CB_ID      = 0x00U,    /*!< CEC Tx Transfer completed callback ID  */
00205   HAL_CEC_RX_CPLT_CB_ID      = 0x01U,    /*!< CEC Rx Transfer completed callback ID  */
00206   HAL_CEC_ERROR_CB_ID        = 0x02U,    /*!< CEC error callback ID                 */
00207   HAL_CEC_MSPINIT_CB_ID      = 0x03U,    /*!< CEC Msp Init callback ID               */
00208   HAL_CEC_MSPDEINIT_CB_ID    = 0x04U     /*!< CEC Msp DeInit callback ID             */
00209 } HAL_CEC_CallbackIDTypeDef;
00210 
00211 /**
00212   * @brief  HAL CEC Callback pointer definition
00213   */
00214 typedef  void (*pCEC_CallbackTypeDef)(CEC_HandleTypeDef *hcec);  /*!< pointer to an CEC callback function */
00215 typedef  void (*pCEC_RxCallbackTypeDef)(CEC_HandleTypeDef *hcec,
00216                                         uint32_t RxFrameSize);  /*!< pointer to an Rx Transfer completed callback function */
00217 #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
00218 /**
00219   * @}
00220   */
00221 
00222 /* Exported constants --------------------------------------------------------*/
00223 /** @defgroup CEC_Exported_Constants CEC Exported Constants
00224   * @{
00225   */
00226 /** @defgroup CEC_State_Definition CEC State Code Definition
00227   * @{
00228   */
00229 #define   HAL_CEC_STATE_RESET      ((uint32_t)0x00000000)   /*!< Peripheral is not yet Initialized
00230                                                                  Value is allowed for gState and RxState  */
00231 #define   HAL_CEC_STATE_READY      ((uint32_t)0x00000020)   /*!< Peripheral Initialized and ready for use
00232                                                                  Value is allowed for gState and RxState  */
00233 #define   HAL_CEC_STATE_BUSY       ((uint32_t)0x00000024)   /*!< an internal process is ongoing
00234                                                                  Value is allowed for gState only         */
00235 #define   HAL_CEC_STATE_BUSY_RX    ((uint32_t)0x00000022)   /*!< Data Reception process is ongoing
00236                                                                  Value is allowed for RxState only        */
00237 #define   HAL_CEC_STATE_BUSY_TX    ((uint32_t)0x00000021)   /*!< Data Transmission process is ongoing
00238                                                                  Value is allowed for gState only         */
00239 #define   HAL_CEC_STATE_BUSY_RX_TX ((uint32_t)0x00000023)   /*!< an internal process is ongoing
00240                                                                  Value is allowed for gState only         */
00241 #define   HAL_CEC_STATE_ERROR      ((uint32_t)0x00000050)   /*!< Error Value is allowed for gState only   */
00242 /**
00243   * @}
00244   */
00245 /** @defgroup CEC_Error_Code CEC Error Code
00246   * @{
00247   */
00248 #define HAL_CEC_ERROR_NONE    (uint32_t) 0x0000U     /*!< no error                      */
00249 #define HAL_CEC_ERROR_RXOVR   CEC_ISR_RXOVR          /*!< CEC Rx-Overrun                */
00250 #define HAL_CEC_ERROR_BRE     CEC_ISR_BRE            /*!< CEC Rx Bit Rising Error       */
00251 #define HAL_CEC_ERROR_SBPE    CEC_ISR_SBPE           /*!< CEC Rx Short Bit period Error */
00252 #define HAL_CEC_ERROR_LBPE    CEC_ISR_LBPE           /*!< CEC Rx Long Bit period Error  */
00253 #define HAL_CEC_ERROR_RXACKE  CEC_ISR_RXACKE         /*!< CEC Rx Missing Acknowledge    */
00254 #define HAL_CEC_ERROR_ARBLST  CEC_ISR_ARBLST         /*!< CEC Arbitration Lost          */
00255 #define HAL_CEC_ERROR_TXUDR   CEC_ISR_TXUDR          /*!< CEC Tx-Buffer Underrun        */
00256 #define HAL_CEC_ERROR_TXERR   CEC_ISR_TXERR          /*!< CEC Tx-Error                  */
00257 #define HAL_CEC_ERROR_TXACKE  CEC_ISR_TXACKE         /*!< CEC Tx Missing Acknowledge    */
00258 #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
00259 #define  HAL_CEC_ERROR_INVALID_CALLBACK ((uint32_t)0x00002000U) /*!< Invalid Callback Error  */
00260 #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
00261 /**
00262   * @}
00263   */
00264 
00265 /** @defgroup CEC_Signal_Free_Time  CEC Signal Free Time setting parameter
00266   * @{
00267   */
00268 #define CEC_DEFAULT_SFT                    ((uint32_t)0x00000000U)
00269 #define CEC_0_5_BITPERIOD_SFT              ((uint32_t)0x00000001U)
00270 #define CEC_1_5_BITPERIOD_SFT              ((uint32_t)0x00000002U)
00271 #define CEC_2_5_BITPERIOD_SFT              ((uint32_t)0x00000003U)
00272 #define CEC_3_5_BITPERIOD_SFT              ((uint32_t)0x00000004U)
00273 #define CEC_4_5_BITPERIOD_SFT              ((uint32_t)0x00000005U)
00274 #define CEC_5_5_BITPERIOD_SFT              ((uint32_t)0x00000006U)
00275 #define CEC_6_5_BITPERIOD_SFT              ((uint32_t)0x00000007U)
00276 /**
00277   * @}
00278   */
00279 
00280 /** @defgroup CEC_Tolerance CEC Receiver Tolerance
00281   * @{
00282   */
00283 #define CEC_STANDARD_TOLERANCE             ((uint32_t)0x00000000U)
00284 #define CEC_EXTENDED_TOLERANCE             ((uint32_t)CEC_CFGR_RXTOL)
00285 /**
00286   * @}
00287   */
00288 
00289 /** @defgroup CEC_BRERxStop CEC Reception Stop on Error
00290   * @{
00291   */
00292 #define CEC_NO_RX_STOP_ON_BRE             ((uint32_t)0x00000000U)
00293 #define CEC_RX_STOP_ON_BRE                ((uint32_t)CEC_CFGR_BRESTP)
00294 /**
00295   * @}
00296   */
00297 
00298 /** @defgroup CEC_BREErrorBitGen  CEC Error Bit Generation if Bit Rise Error reported
00299   * @{
00300   */
00301 #define CEC_BRE_ERRORBIT_NO_GENERATION     ((uint32_t)0x00000000U)
00302 #define CEC_BRE_ERRORBIT_GENERATION        ((uint32_t)CEC_CFGR_BREGEN)
00303 /**
00304   * @}
00305   */
00306 
00307 /** @defgroup CEC_LBPEErrorBitGen  CEC Error Bit Generation if Long Bit Period Error reported
00308   * @{
00309   */
00310 #define CEC_LBPE_ERRORBIT_NO_GENERATION     ((uint32_t)0x00000000U)
00311 #define CEC_LBPE_ERRORBIT_GENERATION        ((uint32_t)CEC_CFGR_LBPEGEN)
00312 /**
00313   * @}
00314   */
00315 
00316 /** @defgroup CEC_BroadCastMsgErrorBitGen  CEC Error Bit Generation on Broadcast message
00317   * @{
00318   */
00319 #define CEC_BROADCASTERROR_ERRORBIT_GENERATION     ((uint32_t)0x00000000U)
00320 #define CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION  ((uint32_t)CEC_CFGR_BRDNOGEN)
00321 /**
00322   * @}
00323   */
00324 
00325 /** @defgroup CEC_SFT_Option     CEC Signal Free Time start option
00326   * @{
00327   */
00328 #define CEC_SFT_START_ON_TXSOM           ((uint32_t)0x00000000U)
00329 #define CEC_SFT_START_ON_TX_RX_END       ((uint32_t)CEC_CFGR_SFTOPT)
00330 /**
00331   * @}
00332   */
00333 
00334 /** @defgroup CEC_Listening_Mode    CEC Listening mode option
00335   * @{
00336   */
00337 #define CEC_REDUCED_LISTENING_MODE          ((uint32_t)0x00000000U)
00338 #define CEC_FULL_LISTENING_MODE             ((uint32_t)CEC_CFGR_LSTN)
00339 /**
00340   * @}
00341   */
00342 
00343 /** @defgroup CEC_OAR_Position   CEC Device Own Address position in CEC CFGR register
00344   * @{
00345   */
00346 #define CEC_CFGR_OAR_LSB_POS            ((uint32_t) 16U)
00347 /**
00348   * @}
00349   */
00350 
00351 /** @defgroup CEC_Initiator_Position   CEC Initiator logical address position in message header
00352   * @{
00353   */
00354 #define CEC_INITIATOR_LSB_POS           ((uint32_t) 4U)
00355 /**
00356   * @}
00357   */
00358 
00359 /** @defgroup CEC_OWN_ADDRESS   CEC Own Address
00360   * @{
00361   */
00362 #define CEC_OWN_ADDRESS_NONE           ((uint16_t) 0x0000U)   /* Reset value */
00363 #define CEC_OWN_ADDRESS_0              ((uint16_t) 0x0001U)   /* Logical Address 0 */
00364 #define CEC_OWN_ADDRESS_1              ((uint16_t) 0x0002U)   /* Logical Address 1 */
00365 #define CEC_OWN_ADDRESS_2              ((uint16_t) 0x0004U)   /* Logical Address 2 */
00366 #define CEC_OWN_ADDRESS_3              ((uint16_t) 0x0008U)   /* Logical Address 3 */
00367 #define CEC_OWN_ADDRESS_4              ((uint16_t) 0x0010U)   /* Logical Address 4 */
00368 #define CEC_OWN_ADDRESS_5              ((uint16_t) 0x0020U)   /* Logical Address 5 */
00369 #define CEC_OWN_ADDRESS_6              ((uint16_t) 0x0040U)   /* Logical Address 6 */
00370 #define CEC_OWN_ADDRESS_7              ((uint16_t) 0x0080U)   /* Logical Address 7 */
00371 #define CEC_OWN_ADDRESS_8              ((uint16_t) 0x0100U)   /* Logical Address 9 */
00372 #define CEC_OWN_ADDRESS_9              ((uint16_t) 0x0200U)   /* Logical Address 10 */
00373 #define CEC_OWN_ADDRESS_10             ((uint16_t) 0x0400U)   /* Logical Address 11 */
00374 #define CEC_OWN_ADDRESS_11             ((uint16_t) 0x0800U)   /* Logical Address 12 */
00375 #define CEC_OWN_ADDRESS_12             ((uint16_t) 0x1000U)   /* Logical Address 13 */
00376 #define CEC_OWN_ADDRESS_13             ((uint16_t) 0x2000U)   /* Logical Address 14 */
00377 #define CEC_OWN_ADDRESS_14             ((uint16_t) 0x4000U)   /* Logical Address 15 */
00378 /**
00379   * @}
00380   */
00381 
00382 /** @defgroup CEC_Interrupts_Definitions  CEC Interrupts definition
00383   * @{
00384   */
00385 #define CEC_IT_TXACKE                   CEC_IER_TXACKEIE
00386 #define CEC_IT_TXERR                    CEC_IER_TXERRIE
00387 #define CEC_IT_TXUDR                    CEC_IER_TXUDRIE
00388 #define CEC_IT_TXEND                    CEC_IER_TXENDIE
00389 #define CEC_IT_TXBR                     CEC_IER_TXBRIE
00390 #define CEC_IT_ARBLST                   CEC_IER_ARBLSTIE
00391 #define CEC_IT_RXACKE                   CEC_IER_RXACKEIE
00392 #define CEC_IT_LBPE                     CEC_IER_LBPEIE
00393 #define CEC_IT_SBPE                     CEC_IER_SBPEIE
00394 #define CEC_IT_BRE                      CEC_IER_BREIE
00395 #define CEC_IT_RXOVR                    CEC_IER_RXOVRIE
00396 #define CEC_IT_RXEND                    CEC_IER_RXENDIE
00397 #define CEC_IT_RXBR                     CEC_IER_RXBRIE
00398 /**
00399   * @}
00400   */
00401 
00402 /** @defgroup CEC_Flags_Definitions  CEC Flags definition
00403   * @{
00404   */
00405 #define CEC_FLAG_TXACKE                 CEC_ISR_TXACKE
00406 #define CEC_FLAG_TXERR                  CEC_ISR_TXERR
00407 #define CEC_FLAG_TXUDR                  CEC_ISR_TXUDR
00408 #define CEC_FLAG_TXEND                  CEC_ISR_TXEND
00409 #define CEC_FLAG_TXBR                   CEC_ISR_TXBR
00410 #define CEC_FLAG_ARBLST                 CEC_ISR_ARBLST
00411 #define CEC_FLAG_RXACKE                 CEC_ISR_RXACKE
00412 #define CEC_FLAG_LBPE                   CEC_ISR_LBPE
00413 #define CEC_FLAG_SBPE                   CEC_ISR_SBPE
00414 #define CEC_FLAG_BRE                    CEC_ISR_BRE
00415 #define CEC_FLAG_RXOVR                  CEC_ISR_RXOVR
00416 #define CEC_FLAG_RXEND                  CEC_ISR_RXEND
00417 #define CEC_FLAG_RXBR                   CEC_ISR_RXBR
00418 /**
00419   * @}
00420   */
00421 
00422 /** @defgroup CEC_ALL_ERROR CEC all RX or TX errors flags
00423   * @{
00424   */
00425 #define CEC_ISR_ALL_ERROR              ((uint32_t)CEC_ISR_RXOVR|CEC_ISR_BRE|CEC_ISR_SBPE|CEC_ISR_LBPE|CEC_ISR_RXACKE|\
00426                                         CEC_ISR_ARBLST|CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)
00427 /**
00428   * @}
00429   */
00430 
00431 /** @defgroup CEC_IER_ALL_RX CEC all RX errors interrupts enabling flag
00432   * @{
00433   */
00434 #define CEC_IER_RX_ALL_ERR              ((uint32_t)CEC_IER_RXACKEIE|CEC_IER_LBPEIE|CEC_IER_SBPEIE|CEC_IER_BREIE|CEC_IER_RXOVRIE)
00435 /**
00436   * @}
00437   */
00438 
00439 /** @defgroup CEC_IER_ALL_TX CEC all TX errors interrupts enabling flag
00440   * @{
00441   */
00442 #define CEC_IER_TX_ALL_ERR              ((uint32_t)CEC_IER_TXACKEIE|CEC_IER_TXERRIE|CEC_IER_TXUDRIE|CEC_IER_ARBLSTIE)
00443 /**
00444   * @}
00445   */
00446 
00447 /**
00448   * @}
00449   */
00450 
00451 /* Exported macros -----------------------------------------------------------*/
00452 /** @defgroup CEC_Exported_Macros CEC Exported Macros
00453   * @{
00454   */
00455 
00456 /** @brief  Reset CEC handle gstate & RxState
00457   * @param  __HANDLE__ CEC handle.
00458   * @retval None
00459   */
00460 #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
00461 #define __HAL_CEC_RESET_HANDLE_STATE(__HANDLE__) do{                                                   \
00462                                                        (__HANDLE__)->gState = HAL_CEC_STATE_RESET;     \
00463                                                        (__HANDLE__)->RxState = HAL_CEC_STATE_RESET;    \
00464                                                        (__HANDLE__)->MspInitCallback = NULL;           \
00465                                                        (__HANDLE__)->MspDeInitCallback = NULL;         \
00466                                                      } while(0)
00467 #else
00468 #define __HAL_CEC_RESET_HANDLE_STATE(__HANDLE__) do{                                                   \
00469                                                        (__HANDLE__)->gState = HAL_CEC_STATE_RESET;     \
00470                                                        (__HANDLE__)->RxState = HAL_CEC_STATE_RESET;    \
00471                                                      } while(0)
00472 #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
00473 /** @brief  Checks whether or not the specified CEC interrupt flag is set.
00474   * @param  __HANDLE__ specifies the CEC Handle.
00475   * @param  __FLAG__ specifies the flag to check.
00476   *            @arg CEC_FLAG_TXACKE: Tx Missing acknowledge Error
00477   *            @arg CEC_FLAG_TXERR: Tx Error.
00478   *            @arg CEC_FLAG_TXUDR: Tx-Buffer Underrun.
00479   *            @arg CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte).
00480   *            @arg CEC_FLAG_TXBR: Tx-Byte Request.
00481   *            @arg CEC_FLAG_ARBLST: Arbitration Lost
00482   *            @arg CEC_FLAG_RXACKE: Rx-Missing Acknowledge
00483   *            @arg CEC_FLAG_LBPE: Rx Long period Error
00484   *            @arg CEC_FLAG_SBPE: Rx Short period Error
00485   *            @arg CEC_FLAG_BRE: Rx Bit Rising Error
00486   *            @arg CEC_FLAG_RXOVR: Rx Overrun.
00487   *            @arg CEC_FLAG_RXEND: End Of Reception.
00488   *            @arg CEC_FLAG_RXBR: Rx-Byte Received.
00489   * @retval ITStatus
00490   */
00491 #define __HAL_CEC_GET_FLAG(__HANDLE__, __FLAG__)        ((__HANDLE__)->Instance->ISR & (__FLAG__))
00492 
00493 /** @brief  Clears the interrupt or status flag when raised (write at 1)
00494   * @param  __HANDLE__ specifies the CEC Handle.
00495   * @param  __FLAG__ specifies the interrupt/status flag to clear.
00496   *        This parameter can be one of the following values:
00497   *            @arg CEC_FLAG_TXACKE: Tx Missing acknowledge Error
00498   *            @arg CEC_FLAG_TXERR: Tx Error.
00499   *            @arg CEC_FLAG_TXUDR: Tx-Buffer Underrun.
00500   *            @arg CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte).
00501   *            @arg CEC_FLAG_TXBR: Tx-Byte Request.
00502   *            @arg CEC_FLAG_ARBLST: Arbitration Lost
00503   *            @arg CEC_FLAG_RXACKE: Rx-Missing Acknowledge
00504   *            @arg CEC_FLAG_LBPE: Rx Long period Error
00505   *            @arg CEC_FLAG_SBPE: Rx Short period Error
00506   *            @arg CEC_FLAG_BRE: Rx Bit Rising Error
00507   *            @arg CEC_FLAG_RXOVR: Rx Overrun.
00508   *            @arg CEC_FLAG_RXEND: End Of Reception.
00509   *            @arg CEC_FLAG_RXBR: Rx-Byte Received.
00510   * @retval none
00511   */
00512 #define __HAL_CEC_CLEAR_FLAG(__HANDLE__, __FLAG__)         ((__HANDLE__)->Instance->ISR |= (__FLAG__))
00513 
00514 /** @brief  Enables the specified CEC interrupt.
00515   * @param  __HANDLE__ specifies the CEC Handle.
00516   * @param  __INTERRUPT__ specifies the CEC interrupt to enable.
00517   *          This parameter can be one of the following values:
00518   *            @arg CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable
00519   *            @arg CEC_IT_TXERR: Tx Error IT Enable
00520   *            @arg CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable
00521   *            @arg CEC_IT_TXEND: End of transmission IT Enable
00522   *            @arg CEC_IT_TXBR: Tx-Byte Request IT Enable
00523   *            @arg CEC_IT_ARBLST: Arbitration Lost IT Enable
00524   *            @arg CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable
00525   *            @arg CEC_IT_LBPE: Rx Long period Error IT Enable
00526   *            @arg CEC_IT_SBPE: Rx Short period Error IT Enable
00527   *            @arg CEC_IT_BRE: Rx Bit Rising Error IT Enable
00528   *            @arg CEC_IT_RXOVR: Rx Overrun IT Enable
00529   *            @arg CEC_IT_RXEND: End Of Reception IT Enable
00530   *            @arg CEC_IT_RXBR: Rx-Byte Received IT Enable
00531   * @retval none
00532   */
00533 #define __HAL_CEC_ENABLE_IT(__HANDLE__, __INTERRUPT__)     ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
00534 
00535 /** @brief  Disables the specified CEC interrupt.
00536   * @param  __HANDLE__ specifies the CEC Handle.
00537   * @param  __INTERRUPT__ specifies the CEC interrupt to disable.
00538   *          This parameter can be one of the following values:
00539   *            @arg CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable
00540   *            @arg CEC_IT_TXERR: Tx Error IT Enable
00541   *            @arg CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable
00542   *            @arg CEC_IT_TXEND: End of transmission IT Enable
00543   *            @arg CEC_IT_TXBR: Tx-Byte Request IT Enable
00544   *            @arg CEC_IT_ARBLST: Arbitration Lost IT Enable
00545   *            @arg CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable
00546   *            @arg CEC_IT_LBPE: Rx Long period Error IT Enable
00547   *            @arg CEC_IT_SBPE: Rx Short period Error IT Enable
00548   *            @arg CEC_IT_BRE: Rx Bit Rising Error IT Enable
00549   *            @arg CEC_IT_RXOVR: Rx Overrun IT Enable
00550   *            @arg CEC_IT_RXEND: End Of Reception IT Enable
00551   *            @arg CEC_IT_RXBR: Rx-Byte Received IT Enable
00552   * @retval none
00553   */
00554 #define __HAL_CEC_DISABLE_IT(__HANDLE__, __INTERRUPT__)    ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
00555 
00556 /** @brief  Checks whether or not the specified CEC interrupt is enabled.
00557   * @param  __HANDLE__ specifies the CEC Handle.
00558   * @param  __INTERRUPT__ specifies the CEC interrupt to check.
00559   *          This parameter can be one of the following values:
00560   *            @arg CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable
00561   *            @arg CEC_IT_TXERR: Tx Error IT Enable
00562   *            @arg CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable
00563   *            @arg CEC_IT_TXEND: End of transmission IT Enable
00564   *            @arg CEC_IT_TXBR: Tx-Byte Request IT Enable
00565   *            @arg CEC_IT_ARBLST: Arbitration Lost IT Enable
00566   *            @arg CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable
00567   *            @arg CEC_IT_LBPE: Rx Long period Error IT Enable
00568   *            @arg CEC_IT_SBPE: Rx Short period Error IT Enable
00569   *            @arg CEC_IT_BRE: Rx Bit Rising Error IT Enable
00570   *            @arg CEC_IT_RXOVR: Rx Overrun IT Enable
00571   *            @arg CEC_IT_RXEND: End Of Reception IT Enable
00572   *            @arg CEC_IT_RXBR: Rx-Byte Received IT Enable
00573   * @retval FlagStatus
00574   */
00575 #define __HAL_CEC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER & (__INTERRUPT__))
00576 
00577 /** @brief  Enables the CEC device
00578   * @param  __HANDLE__ specifies the CEC Handle.
00579   * @retval none
00580   */
00581 #define __HAL_CEC_ENABLE(__HANDLE__)                   ((__HANDLE__)->Instance->CR |=  CEC_CR_CECEN)
00582 
00583 /** @brief  Disables the CEC device
00584   * @param  __HANDLE__ specifies the CEC Handle.
00585   * @retval none
00586   */
00587 #define __HAL_CEC_DISABLE(__HANDLE__)                  ((__HANDLE__)->Instance->CR &=  ~CEC_CR_CECEN)
00588 
00589 /** @brief  Set Transmission Start flag
00590   * @param  __HANDLE__ specifies the CEC Handle.
00591   * @retval none
00592   */
00593 #define __HAL_CEC_FIRST_BYTE_TX_SET(__HANDLE__)        ((__HANDLE__)->Instance->CR |=  CEC_CR_TXSOM)
00594 
00595 /** @brief  Set Transmission End flag
00596   * @param  __HANDLE__ specifies the CEC Handle.
00597   * @retval none
00598   * If the CEC message consists of only one byte, TXEOM must be set before of TXSOM.
00599   */
00600 #define __HAL_CEC_LAST_BYTE_TX_SET(__HANDLE__)         ((__HANDLE__)->Instance->CR |=  CEC_CR_TXEOM)
00601 
00602 /** @brief  Get Transmission Start flag
00603   * @param  __HANDLE__ specifies the CEC Handle.
00604   * @retval FlagStatus
00605   */
00606 #define __HAL_CEC_GET_TRANSMISSION_START_FLAG(__HANDLE__) ((__HANDLE__)->Instance->CR & CEC_CR_TXSOM)
00607 
00608 /** @brief  Get Transmission End flag
00609   * @param  __HANDLE__ specifies the CEC Handle.
00610   * @retval FlagStatus
00611   */
00612 #define __HAL_CEC_GET_TRANSMISSION_END_FLAG(__HANDLE__)   ((__HANDLE__)->Instance->CR & CEC_CR_TXEOM)
00613 
00614 /** @brief  Clear OAR register
00615   * @param  __HANDLE__ specifies the CEC Handle.
00616   * @retval none
00617   */
00618 #define __HAL_CEC_CLEAR_OAR(__HANDLE__)   CLEAR_BIT((__HANDLE__)->Instance->CFGR, CEC_CFGR_OAR)
00619 
00620 /** @brief  Set OAR register (without resetting previously set address in case of multi-address mode)
00621   *          To reset OAR, __HAL_CEC_CLEAR_OAR() needs to be called beforehand
00622   * @param  __HANDLE__ specifies the CEC Handle.
00623   * @param  __ADDRESS__ Own Address value (CEC logical address is identified by bit position)
00624   * @retval none
00625   */
00626 #define __HAL_CEC_SET_OAR(__HANDLE__,__ADDRESS__)   SET_BIT((__HANDLE__)->Instance->CFGR, (__ADDRESS__)<< CEC_CFGR_OAR_LSB_POS)
00627 
00628 /**
00629   * @}
00630   */
00631 
00632 /* Exported functions --------------------------------------------------------*/
00633 /** @addtogroup CEC_Exported_Functions
00634   * @{
00635   */
00636 
00637 /** @addtogroup CEC_Exported_Functions_Group1
00638   * @{
00639   */
00640 /* Initialization and de-initialization functions  ****************************/
00641 HAL_StatusTypeDef HAL_CEC_Init(CEC_HandleTypeDef *hcec);
00642 HAL_StatusTypeDef HAL_CEC_DeInit(CEC_HandleTypeDef *hcec);
00643 HAL_StatusTypeDef HAL_CEC_SetDeviceAddress(CEC_HandleTypeDef *hcec, uint16_t CEC_OwnAddress);
00644 void HAL_CEC_MspInit(CEC_HandleTypeDef *hcec);
00645 void HAL_CEC_MspDeInit(CEC_HandleTypeDef *hcec);
00646 
00647 #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
00648 HAL_StatusTypeDef HAL_CEC_RegisterCallback(CEC_HandleTypeDef *hcec, HAL_CEC_CallbackIDTypeDef CallbackID,
00649                                            pCEC_CallbackTypeDef pCallback);
00650 HAL_StatusTypeDef HAL_CEC_UnRegisterCallback(CEC_HandleTypeDef *hcec, HAL_CEC_CallbackIDTypeDef CallbackID);
00651 
00652 HAL_StatusTypeDef HAL_CEC_RegisterRxCpltCallback(CEC_HandleTypeDef *hcec, pCEC_RxCallbackTypeDef pCallback);
00653 HAL_StatusTypeDef HAL_CEC_UnRegisterRxCpltCallback(CEC_HandleTypeDef *hcec);
00654 #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
00655 /**
00656   * @}
00657   */
00658 
00659 /** @addtogroup CEC_Exported_Functions_Group2
00660   * @{
00661   */
00662 /* I/O operation functions  ***************************************************/
00663 HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t InitiatorAddress, uint8_t DestinationAddress,
00664                                       uint8_t *pData, uint32_t Size);
00665 uint32_t HAL_CEC_GetLastReceivedFrameSize(CEC_HandleTypeDef *hcec);
00666 void HAL_CEC_ChangeRxBuffer(CEC_HandleTypeDef *hcec, uint8_t *Rxbuffer);
00667 void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec);
00668 void HAL_CEC_TxCpltCallback(CEC_HandleTypeDef *hcec);
00669 void HAL_CEC_RxCpltCallback(CEC_HandleTypeDef *hcec, uint32_t RxFrameSize);
00670 void HAL_CEC_ErrorCallback(CEC_HandleTypeDef *hcec);
00671 /**
00672   * @}
00673   */
00674 
00675 /** @addtogroup CEC_Exported_Functions_Group3
00676   * @{
00677   */
00678 /* Peripheral State functions  ************************************************/
00679 HAL_CEC_StateTypeDef HAL_CEC_GetState(CEC_HandleTypeDef *hcec);
00680 uint32_t HAL_CEC_GetError(CEC_HandleTypeDef *hcec);
00681 /**
00682   * @}
00683   */
00684 
00685 /**
00686   * @}
00687   */
00688 
00689 /* Private types -------------------------------------------------------------*/
00690 /** @defgroup CEC_Private_Types CEC Private Types
00691   * @{
00692   */
00693 
00694 /**
00695   * @}
00696   */
00697 
00698 /* Private variables ---------------------------------------------------------*/
00699 /** @defgroup CEC_Private_Variables CEC Private Variables
00700   * @{
00701   */
00702 
00703 /**
00704   * @}
00705   */
00706 
00707 /* Private constants ---------------------------------------------------------*/
00708 /** @defgroup CEC_Private_Constants CEC Private Constants
00709   * @{
00710   */
00711 
00712 /**
00713   * @}
00714   */
00715 
00716 /* Private macros ------------------------------------------------------------*/
00717 /** @defgroup CEC_Private_Macros CEC Private Macros
00718   * @{
00719   */
00720 
00721 #define IS_CEC_SIGNALFREETIME(__SFT__)     ((__SFT__) <= CEC_CFGR_SFT)
00722 
00723 #define IS_CEC_TOLERANCE(__RXTOL__)        (((__RXTOL__) == CEC_STANDARD_TOLERANCE) || \
00724                                             ((__RXTOL__) == CEC_EXTENDED_TOLERANCE))
00725 
00726 #define IS_CEC_BRERXSTOP(__BRERXSTOP__)   (((__BRERXSTOP__) == CEC_NO_RX_STOP_ON_BRE) || \
00727                                            ((__BRERXSTOP__) == CEC_RX_STOP_ON_BRE))
00728 
00729 #define IS_CEC_BREERRORBITGEN(__ERRORBITGEN__) (((__ERRORBITGEN__) == CEC_BRE_ERRORBIT_NO_GENERATION) || \
00730                                                 ((__ERRORBITGEN__) == CEC_BRE_ERRORBIT_GENERATION))
00731 
00732 #define IS_CEC_LBPEERRORBITGEN(__ERRORBITGEN__) (((__ERRORBITGEN__) == CEC_LBPE_ERRORBIT_NO_GENERATION) || \
00733                                                  ((__ERRORBITGEN__) == CEC_LBPE_ERRORBIT_GENERATION))
00734 
00735 #define IS_CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION(__ERRORBITGEN__) (((__ERRORBITGEN__) == CEC_BROADCASTERROR_ERRORBIT_GENERATION) || \
00736                                                                        ((__ERRORBITGEN__) == CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION))
00737 
00738 #define IS_CEC_SFTOP(__SFTOP__)          (((__SFTOP__) == CEC_SFT_START_ON_TXSOM) || \
00739                                           ((__SFTOP__) == CEC_SFT_START_ON_TX_RX_END))
00740 
00741 #define IS_CEC_LISTENING_MODE(__MODE__)     (((__MODE__) == CEC_REDUCED_LISTENING_MODE) || \
00742                                              ((__MODE__) == CEC_FULL_LISTENING_MODE))
00743 
00744 /** @brief Check CEC message size.
00745   *       The message size is the payload size: without counting the header,
00746   *       it varies from 0 byte (ping operation, one header only, no payload) to
00747   *       15 bytes (1 opcode and up to 14 operands following the header).
00748   * @param  __SIZE__ CEC message size.
00749   * @retval Test result (TRUE or FALSE).
00750   */
00751 #define IS_CEC_MSGSIZE(__SIZE__) ((__SIZE__) <= 0x10U)
00752 
00753 /** @brief Check CEC device Own Address Register (OAR) setting.
00754   *        OAR address is written in a 15-bit field within CEC_CFGR register.
00755   * @param  __ADDRESS__ CEC own address.
00756   * @retval Test result (TRUE or FALSE).
00757   */
00758 #define IS_CEC_OWN_ADDRESS(__ADDRESS__) ((__ADDRESS__) <= 0x7FFFU)
00759 
00760 /** @brief Check CEC initiator or destination logical address setting.
00761   *        Initiator and destination addresses are coded over 4 bits.
00762   * @param  __ADDRESS__ CEC initiator or logical address.
00763   * @retval Test result (TRUE or FALSE).
00764   */
00765 #define IS_CEC_ADDRESS(__ADDRESS__) ((__ADDRESS__) <= 0xFU)
00766 /**
00767   * @}
00768   */
00769 /* Private functions ---------------------------------------------------------*/
00770 /** @defgroup CEC_Private_Functions CEC Private Functions
00771   * @{
00772   */
00773 
00774 /**
00775   * @}
00776   */
00777 
00778 /**
00779   * @}
00780   */
00781 
00782 /**
00783   * @}
00784   */
00785 
00786 #endif /* CEC */
00787 
00788 #ifdef __cplusplus
00789 }
00790 #endif
00791 
00792 #endif /* STM32F4xxHAL_CEC_H */
00793 
00794 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/