训练营PLSR题目
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

793 lignes
34 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_cec.h
  4. * @author MCD Application Team
  5. * @brief Header file of CEC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32F4xx_HAL_CEC_H
  20. #define STM32F4xx_HAL_CEC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f4xx_hal_def.h"
  26. #if defined (CEC)
  27. /** @addtogroup STM32F4xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup CEC
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup CEC_Exported_Types CEC Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief CEC Init Structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t SignalFreeTime; /*!< Set SFT field, specifies the Signal Free Time.
  43. It can be one of @ref CEC_Signal_Free_Time
  44. and belongs to the set {0,...,7} where
  45. 0x0 is the default configuration
  46. else means 0.5 + (SignalFreeTime - 1) nominal data bit periods */
  47. uint32_t Tolerance; /*!< Set RXTOL bit, specifies the tolerance accepted on the received waveforms,
  48. it can be a value of @ref CEC_Tolerance : it is either CEC_STANDARD_TOLERANCE
  49. or CEC_EXTENDED_TOLERANCE */
  50. uint32_t BRERxStop; /*!< Set BRESTP bit @ref CEC_BRERxStop : specifies whether or not a Bit Rising Error stops the reception.
  51. CEC_NO_RX_STOP_ON_BRE: reception is not stopped.
  52. CEC_RX_STOP_ON_BRE: reception is stopped. */
  53. uint32_t BREErrorBitGen; /*!< Set BREGEN bit @ref CEC_BREErrorBitGen : specifies whether or not an Error-Bit is generated on the
  54. CEC line upon Bit Rising Error detection.
  55. CEC_BRE_ERRORBIT_NO_GENERATION: no error-bit generation.
  56. CEC_BRE_ERRORBIT_GENERATION: error-bit generation if BRESTP is set. */
  57. uint32_t LBPEErrorBitGen; /*!< Set LBPEGEN bit @ref CEC_LBPEErrorBitGen : specifies whether or not an Error-Bit is generated on the
  58. CEC line upon Long Bit Period Error detection.
  59. CEC_LBPE_ERRORBIT_NO_GENERATION: no error-bit generation.
  60. CEC_LBPE_ERRORBIT_GENERATION: error-bit generation. */
  61. uint32_t BroadcastMsgNoErrorBitGen; /*!< Set BRDNOGEN bit @ref CEC_BroadCastMsgErrorBitGen : allows to avoid an Error-Bit generation on the CEC line
  62. upon an error detected on a broadcast message.
  63. It supersedes BREGEN and LBPEGEN bits for a broadcast message error handling. It can take two values:
  64. 1) CEC_BROADCASTERROR_ERRORBIT_GENERATION.
  65. a) BRE detection: error-bit generation on the CEC line if BRESTP=CEC_RX_STOP_ON_BRE
  66. and BREGEN=CEC_BRE_ERRORBIT_NO_GENERATION.
  67. b) LBPE detection: error-bit generation on the CEC line
  68. if LBPGEN=CEC_LBPE_ERRORBIT_NO_GENERATION.
  69. 2) CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION.
  70. no error-bit generation in case neither a) nor b) are satisfied. Additionally,
  71. there is no error-bit generation in case of Short Bit Period Error detection in
  72. a broadcast message while LSTN bit is set. */
  73. uint32_t SignalFreeTimeOption; /*!< Set SFTOP bit @ref CEC_SFT_Option : specifies when SFT timer starts.
  74. CEC_SFT_START_ON_TXSOM SFT: timer starts when TXSOM is set by software.
  75. CEC_SFT_START_ON_TX_RX_END: SFT timer starts automatically at the end of message transmission/reception. */
  76. uint32_t ListenMode; /*!< Set LSTN bit @ref CEC_Listening_Mode : specifies device listening mode. It can take two values:
  77. CEC_REDUCED_LISTENING_MODE: CEC peripheral receives only message addressed to its
  78. own address (OAR). Messages addressed to different destination are ignored.
  79. Broadcast messages are always received.
  80. CEC_FULL_LISTENING_MODE: CEC peripheral receives messages addressed to its own
  81. address (OAR) with positive acknowledge. Messages addressed to different destination
  82. are received, but without interfering with the CEC bus: no acknowledge sent. */
  83. uint16_t OwnAddress; /*!< Own addresses configuration
  84. This parameter can be a value of @ref CEC_OWN_ADDRESS */
  85. uint8_t *RxBuffer; /*!< CEC Rx buffer pointer */
  86. } CEC_InitTypeDef;
  87. /**
  88. * @brief HAL CEC State definition
  89. * @note HAL CEC State value is a combination of 2 different substates: gState and RxState (see @ref CEC_State_Definition).
  90. * - gState contains CEC state information related to global Handle management
  91. * and also information related to Tx operations.
  92. * gState value coding follow below described bitmap :
  93. * b7 (not used)
  94. * x : Should be set to 0
  95. * b6 Error information
  96. * 0 : No Error
  97. * 1 : Error
  98. * b5 CEC peripheral initialization status
  99. * 0 : Reset (peripheral not initialized)
  100. * 1 : Init done (peripheral initialized. HAL CEC Init function already called)
  101. * b4-b3 (not used)
  102. * xx : Should be set to 00
  103. * b2 Intrinsic process state
  104. * 0 : Ready
  105. * 1 : Busy (peripheral busy with some configuration or internal operations)
  106. * b1 (not used)
  107. * x : Should be set to 0
  108. * b0 Tx state
  109. * 0 : Ready (no Tx operation ongoing)
  110. * 1 : Busy (Tx operation ongoing)
  111. * - RxState contains information related to Rx operations.
  112. * RxState value coding follow below described bitmap :
  113. * b7-b6 (not used)
  114. * xx : Should be set to 00
  115. * b5 CEC peripheral initialization status
  116. * 0 : Reset (peripheral not initialized)
  117. * 1 : Init done (peripheral initialized)
  118. * b4-b2 (not used)
  119. * xxx : Should be set to 000
  120. * b1 Rx state
  121. * 0 : Ready (no Rx operation ongoing)
  122. * 1 : Busy (Rx operation ongoing)
  123. * b0 (not used)
  124. * x : Should be set to 0.
  125. */
  126. typedef uint32_t HAL_CEC_StateTypeDef;
  127. /**
  128. * @brief CEC handle Structure definition
  129. */
  130. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  131. typedef struct __CEC_HandleTypeDef
  132. #else
  133. typedef struct
  134. #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
  135. {
  136. CEC_TypeDef *Instance; /*!< CEC registers base address */
  137. CEC_InitTypeDef Init; /*!< CEC communication parameters */
  138. uint8_t *pTxBuffPtr; /*!< Pointer to CEC Tx transfer Buffer */
  139. uint16_t TxXferCount; /*!< CEC Tx Transfer Counter */
  140. uint16_t RxXferSize; /*!< CEC Rx Transfer size, 0: header received only */
  141. HAL_LockTypeDef Lock; /*!< Locking object */
  142. HAL_CEC_StateTypeDef gState; /*!< CEC state information related to global Handle management
  143. and also related to Tx operations.
  144. This parameter can be a value of @ref HAL_CEC_StateTypeDef */
  145. HAL_CEC_StateTypeDef RxState; /*!< CEC state information related to Rx operations.
  146. This parameter can be a value of @ref HAL_CEC_StateTypeDef */
  147. uint32_t ErrorCode; /*!< For errors handling purposes, copy of ISR register
  148. in case error is reported */
  149. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  150. void (* TxCpltCallback)(struct __CEC_HandleTypeDef
  151. *hcec); /*!< CEC Tx Transfer completed callback */
  152. void (* RxCpltCallback)(struct __CEC_HandleTypeDef *hcec,
  153. uint32_t RxFrameSize); /*!< CEC Rx Transfer completed callback */
  154. void (* ErrorCallback)(struct __CEC_HandleTypeDef *hcec); /*!< CEC error callback */
  155. void (* MspInitCallback)(struct __CEC_HandleTypeDef *hcec); /*!< CEC Msp Init callback */
  156. void (* MspDeInitCallback)(struct __CEC_HandleTypeDef *hcec); /*!< CEC Msp DeInit callback */
  157. #endif /* (USE_HAL_CEC_REGISTER_CALLBACKS) */
  158. } CEC_HandleTypeDef;
  159. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  160. /**
  161. * @brief HAL CEC Callback ID enumeration definition
  162. */
  163. typedef enum
  164. {
  165. HAL_CEC_TX_CPLT_CB_ID = 0x00U, /*!< CEC Tx Transfer completed callback ID */
  166. HAL_CEC_RX_CPLT_CB_ID = 0x01U, /*!< CEC Rx Transfer completed callback ID */
  167. HAL_CEC_ERROR_CB_ID = 0x02U, /*!< CEC error callback ID */
  168. HAL_CEC_MSPINIT_CB_ID = 0x03U, /*!< CEC Msp Init callback ID */
  169. HAL_CEC_MSPDEINIT_CB_ID = 0x04U /*!< CEC Msp DeInit callback ID */
  170. } HAL_CEC_CallbackIDTypeDef;
  171. /**
  172. * @brief HAL CEC Callback pointer definition
  173. */
  174. typedef void (*pCEC_CallbackTypeDef)(CEC_HandleTypeDef *hcec); /*!< pointer to an CEC callback function */
  175. typedef void (*pCEC_RxCallbackTypeDef)(CEC_HandleTypeDef *hcec,
  176. uint32_t RxFrameSize); /*!< pointer to an Rx Transfer completed callback function */
  177. #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
  178. /**
  179. * @}
  180. */
  181. /* Exported constants --------------------------------------------------------*/
  182. /** @defgroup CEC_Exported_Constants CEC Exported Constants
  183. * @{
  184. */
  185. /** @defgroup CEC_State_Definition CEC State Code Definition
  186. * @{
  187. */
  188. #define HAL_CEC_STATE_RESET ((uint32_t)0x00000000) /*!< Peripheral is not yet Initialized
  189. Value is allowed for gState and RxState */
  190. #define HAL_CEC_STATE_READY ((uint32_t)0x00000020) /*!< Peripheral Initialized and ready for use
  191. Value is allowed for gState and RxState */
  192. #define HAL_CEC_STATE_BUSY ((uint32_t)0x00000024) /*!< an internal process is ongoing
  193. Value is allowed for gState only */
  194. #define HAL_CEC_STATE_BUSY_RX ((uint32_t)0x00000022) /*!< Data Reception process is ongoing
  195. Value is allowed for RxState only */
  196. #define HAL_CEC_STATE_BUSY_TX ((uint32_t)0x00000021) /*!< Data Transmission process is ongoing
  197. Value is allowed for gState only */
  198. #define HAL_CEC_STATE_BUSY_RX_TX ((uint32_t)0x00000023) /*!< an internal process is ongoing
  199. Value is allowed for gState only */
  200. #define HAL_CEC_STATE_ERROR ((uint32_t)0x00000050) /*!< Error Value is allowed for gState only */
  201. /**
  202. * @}
  203. */
  204. /** @defgroup CEC_Error_Code CEC Error Code
  205. * @{
  206. */
  207. #define HAL_CEC_ERROR_NONE (uint32_t) 0x0000U /*!< no error */
  208. #define HAL_CEC_ERROR_RXOVR CEC_ISR_RXOVR /*!< CEC Rx-Overrun */
  209. #define HAL_CEC_ERROR_BRE CEC_ISR_BRE /*!< CEC Rx Bit Rising Error */
  210. #define HAL_CEC_ERROR_SBPE CEC_ISR_SBPE /*!< CEC Rx Short Bit period Error */
  211. #define HAL_CEC_ERROR_LBPE CEC_ISR_LBPE /*!< CEC Rx Long Bit period Error */
  212. #define HAL_CEC_ERROR_RXACKE CEC_ISR_RXACKE /*!< CEC Rx Missing Acknowledge */
  213. #define HAL_CEC_ERROR_ARBLST CEC_ISR_ARBLST /*!< CEC Arbitration Lost */
  214. #define HAL_CEC_ERROR_TXUDR CEC_ISR_TXUDR /*!< CEC Tx-Buffer Underrun */
  215. #define HAL_CEC_ERROR_TXERR CEC_ISR_TXERR /*!< CEC Tx-Error */
  216. #define HAL_CEC_ERROR_TXACKE CEC_ISR_TXACKE /*!< CEC Tx Missing Acknowledge */
  217. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  218. #define HAL_CEC_ERROR_INVALID_CALLBACK ((uint32_t)0x00002000U) /*!< Invalid Callback Error */
  219. #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
  220. /**
  221. * @}
  222. */
  223. /** @defgroup CEC_Signal_Free_Time CEC Signal Free Time setting parameter
  224. * @{
  225. */
  226. #define CEC_DEFAULT_SFT ((uint32_t)0x00000000U)
  227. #define CEC_0_5_BITPERIOD_SFT ((uint32_t)0x00000001U)
  228. #define CEC_1_5_BITPERIOD_SFT ((uint32_t)0x00000002U)
  229. #define CEC_2_5_BITPERIOD_SFT ((uint32_t)0x00000003U)
  230. #define CEC_3_5_BITPERIOD_SFT ((uint32_t)0x00000004U)
  231. #define CEC_4_5_BITPERIOD_SFT ((uint32_t)0x00000005U)
  232. #define CEC_5_5_BITPERIOD_SFT ((uint32_t)0x00000006U)
  233. #define CEC_6_5_BITPERIOD_SFT ((uint32_t)0x00000007U)
  234. /**
  235. * @}
  236. */
  237. /** @defgroup CEC_Tolerance CEC Receiver Tolerance
  238. * @{
  239. */
  240. #define CEC_STANDARD_TOLERANCE ((uint32_t)0x00000000U)
  241. #define CEC_EXTENDED_TOLERANCE ((uint32_t)CEC_CFGR_RXTOL)
  242. /**
  243. * @}
  244. */
  245. /** @defgroup CEC_BRERxStop CEC Reception Stop on Error
  246. * @{
  247. */
  248. #define CEC_NO_RX_STOP_ON_BRE ((uint32_t)0x00000000U)
  249. #define CEC_RX_STOP_ON_BRE ((uint32_t)CEC_CFGR_BRESTP)
  250. /**
  251. * @}
  252. */
  253. /** @defgroup CEC_BREErrorBitGen CEC Error Bit Generation if Bit Rise Error reported
  254. * @{
  255. */
  256. #define CEC_BRE_ERRORBIT_NO_GENERATION ((uint32_t)0x00000000U)
  257. #define CEC_BRE_ERRORBIT_GENERATION ((uint32_t)CEC_CFGR_BREGEN)
  258. /**
  259. * @}
  260. */
  261. /** @defgroup CEC_LBPEErrorBitGen CEC Error Bit Generation if Long Bit Period Error reported
  262. * @{
  263. */
  264. #define CEC_LBPE_ERRORBIT_NO_GENERATION ((uint32_t)0x00000000U)
  265. #define CEC_LBPE_ERRORBIT_GENERATION ((uint32_t)CEC_CFGR_LBPEGEN)
  266. /**
  267. * @}
  268. */
  269. /** @defgroup CEC_BroadCastMsgErrorBitGen CEC Error Bit Generation on Broadcast message
  270. * @{
  271. */
  272. #define CEC_BROADCASTERROR_ERRORBIT_GENERATION ((uint32_t)0x00000000U)
  273. #define CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION ((uint32_t)CEC_CFGR_BRDNOGEN)
  274. /**
  275. * @}
  276. */
  277. /** @defgroup CEC_SFT_Option CEC Signal Free Time start option
  278. * @{
  279. */
  280. #define CEC_SFT_START_ON_TXSOM ((uint32_t)0x00000000U)
  281. #define CEC_SFT_START_ON_TX_RX_END ((uint32_t)CEC_CFGR_SFTOPT)
  282. /**
  283. * @}
  284. */
  285. /** @defgroup CEC_Listening_Mode CEC Listening mode option
  286. * @{
  287. */
  288. #define CEC_REDUCED_LISTENING_MODE ((uint32_t)0x00000000U)
  289. #define CEC_FULL_LISTENING_MODE ((uint32_t)CEC_CFGR_LSTN)
  290. /**
  291. * @}
  292. */
  293. /** @defgroup CEC_OAR_Position CEC Device Own Address position in CEC CFGR register
  294. * @{
  295. */
  296. #define CEC_CFGR_OAR_LSB_POS ((uint32_t) 16U)
  297. /**
  298. * @}
  299. */
  300. /** @defgroup CEC_Initiator_Position CEC Initiator logical address position in message header
  301. * @{
  302. */
  303. #define CEC_INITIATOR_LSB_POS ((uint32_t) 4U)
  304. /**
  305. * @}
  306. */
  307. /** @defgroup CEC_OWN_ADDRESS CEC Own Address
  308. * @{
  309. */
  310. #define CEC_OWN_ADDRESS_NONE ((uint16_t) 0x0000U) /* Reset value */
  311. #define CEC_OWN_ADDRESS_0 ((uint16_t) 0x0001U) /* Logical Address 0 */
  312. #define CEC_OWN_ADDRESS_1 ((uint16_t) 0x0002U) /* Logical Address 1 */
  313. #define CEC_OWN_ADDRESS_2 ((uint16_t) 0x0004U) /* Logical Address 2 */
  314. #define CEC_OWN_ADDRESS_3 ((uint16_t) 0x0008U) /* Logical Address 3 */
  315. #define CEC_OWN_ADDRESS_4 ((uint16_t) 0x0010U) /* Logical Address 4 */
  316. #define CEC_OWN_ADDRESS_5 ((uint16_t) 0x0020U) /* Logical Address 5 */
  317. #define CEC_OWN_ADDRESS_6 ((uint16_t) 0x0040U) /* Logical Address 6 */
  318. #define CEC_OWN_ADDRESS_7 ((uint16_t) 0x0080U) /* Logical Address 7 */
  319. #define CEC_OWN_ADDRESS_8 ((uint16_t) 0x0100U) /* Logical Address 9 */
  320. #define CEC_OWN_ADDRESS_9 ((uint16_t) 0x0200U) /* Logical Address 10 */
  321. #define CEC_OWN_ADDRESS_10 ((uint16_t) 0x0400U) /* Logical Address 11 */
  322. #define CEC_OWN_ADDRESS_11 ((uint16_t) 0x0800U) /* Logical Address 12 */
  323. #define CEC_OWN_ADDRESS_12 ((uint16_t) 0x1000U) /* Logical Address 13 */
  324. #define CEC_OWN_ADDRESS_13 ((uint16_t) 0x2000U) /* Logical Address 14 */
  325. #define CEC_OWN_ADDRESS_14 ((uint16_t) 0x4000U) /* Logical Address 15 */
  326. /**
  327. * @}
  328. */
  329. /** @defgroup CEC_Interrupts_Definitions CEC Interrupts definition
  330. * @{
  331. */
  332. #define CEC_IT_TXACKE CEC_IER_TXACKEIE
  333. #define CEC_IT_TXERR CEC_IER_TXERRIE
  334. #define CEC_IT_TXUDR CEC_IER_TXUDRIE
  335. #define CEC_IT_TXEND CEC_IER_TXENDIE
  336. #define CEC_IT_TXBR CEC_IER_TXBRIE
  337. #define CEC_IT_ARBLST CEC_IER_ARBLSTIE
  338. #define CEC_IT_RXACKE CEC_IER_RXACKEIE
  339. #define CEC_IT_LBPE CEC_IER_LBPEIE
  340. #define CEC_IT_SBPE CEC_IER_SBPEIE
  341. #define CEC_IT_BRE CEC_IER_BREIE
  342. #define CEC_IT_RXOVR CEC_IER_RXOVRIE
  343. #define CEC_IT_RXEND CEC_IER_RXENDIE
  344. #define CEC_IT_RXBR CEC_IER_RXBRIE
  345. /**
  346. * @}
  347. */
  348. /** @defgroup CEC_Flags_Definitions CEC Flags definition
  349. * @{
  350. */
  351. #define CEC_FLAG_TXACKE CEC_ISR_TXACKE
  352. #define CEC_FLAG_TXERR CEC_ISR_TXERR
  353. #define CEC_FLAG_TXUDR CEC_ISR_TXUDR
  354. #define CEC_FLAG_TXEND CEC_ISR_TXEND
  355. #define CEC_FLAG_TXBR CEC_ISR_TXBR
  356. #define CEC_FLAG_ARBLST CEC_ISR_ARBLST
  357. #define CEC_FLAG_RXACKE CEC_ISR_RXACKE
  358. #define CEC_FLAG_LBPE CEC_ISR_LBPE
  359. #define CEC_FLAG_SBPE CEC_ISR_SBPE
  360. #define CEC_FLAG_BRE CEC_ISR_BRE
  361. #define CEC_FLAG_RXOVR CEC_ISR_RXOVR
  362. #define CEC_FLAG_RXEND CEC_ISR_RXEND
  363. #define CEC_FLAG_RXBR CEC_ISR_RXBR
  364. /**
  365. * @}
  366. */
  367. /** @defgroup CEC_ALL_ERROR CEC all RX or TX errors flags
  368. * @{
  369. */
  370. #define CEC_ISR_ALL_ERROR ((uint32_t)CEC_ISR_RXOVR|CEC_ISR_BRE|CEC_ISR_SBPE|CEC_ISR_LBPE|CEC_ISR_RXACKE|\
  371. CEC_ISR_ARBLST|CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)
  372. /**
  373. * @}
  374. */
  375. /** @defgroup CEC_IER_ALL_RX CEC all RX errors interrupts enabling flag
  376. * @{
  377. */
  378. #define CEC_IER_RX_ALL_ERR ((uint32_t)CEC_IER_RXACKEIE|CEC_IER_LBPEIE|CEC_IER_SBPEIE|CEC_IER_BREIE|CEC_IER_RXOVRIE)
  379. /**
  380. * @}
  381. */
  382. /** @defgroup CEC_IER_ALL_TX CEC all TX errors interrupts enabling flag
  383. * @{
  384. */
  385. #define CEC_IER_TX_ALL_ERR ((uint32_t)CEC_IER_TXACKEIE|CEC_IER_TXERRIE|CEC_IER_TXUDRIE|CEC_IER_ARBLSTIE)
  386. /**
  387. * @}
  388. */
  389. /**
  390. * @}
  391. */
  392. /* Exported macros -----------------------------------------------------------*/
  393. /** @defgroup CEC_Exported_Macros CEC Exported Macros
  394. * @{
  395. */
  396. /** @brief Reset CEC handle gstate & RxState
  397. * @param __HANDLE__ CEC handle.
  398. * @retval None
  399. */
  400. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  401. #define __HAL_CEC_RESET_HANDLE_STATE(__HANDLE__) do{ \
  402. (__HANDLE__)->gState = HAL_CEC_STATE_RESET; \
  403. (__HANDLE__)->RxState = HAL_CEC_STATE_RESET; \
  404. (__HANDLE__)->MspInitCallback = NULL; \
  405. (__HANDLE__)->MspDeInitCallback = NULL; \
  406. } while(0)
  407. #else
  408. #define __HAL_CEC_RESET_HANDLE_STATE(__HANDLE__) do{ \
  409. (__HANDLE__)->gState = HAL_CEC_STATE_RESET; \
  410. (__HANDLE__)->RxState = HAL_CEC_STATE_RESET; \
  411. } while(0)
  412. #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
  413. /** @brief Checks whether or not the specified CEC interrupt flag is set.
  414. * @param __HANDLE__ specifies the CEC Handle.
  415. * @param __FLAG__ specifies the flag to check.
  416. * @arg CEC_FLAG_TXACKE: Tx Missing acknowledge Error
  417. * @arg CEC_FLAG_TXERR: Tx Error.
  418. * @arg CEC_FLAG_TXUDR: Tx-Buffer Underrun.
  419. * @arg CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte).
  420. * @arg CEC_FLAG_TXBR: Tx-Byte Request.
  421. * @arg CEC_FLAG_ARBLST: Arbitration Lost
  422. * @arg CEC_FLAG_RXACKE: Rx-Missing Acknowledge
  423. * @arg CEC_FLAG_LBPE: Rx Long period Error
  424. * @arg CEC_FLAG_SBPE: Rx Short period Error
  425. * @arg CEC_FLAG_BRE: Rx Bit Rising Error
  426. * @arg CEC_FLAG_RXOVR: Rx Overrun.
  427. * @arg CEC_FLAG_RXEND: End Of Reception.
  428. * @arg CEC_FLAG_RXBR: Rx-Byte Received.
  429. * @retval ITStatus
  430. */
  431. #define __HAL_CEC_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR & (__FLAG__))
  432. /** @brief Clears the interrupt or status flag when raised (write at 1)
  433. * @param __HANDLE__ specifies the CEC Handle.
  434. * @param __FLAG__ specifies the interrupt/status flag to clear.
  435. * This parameter can be one of the following values:
  436. * @arg CEC_FLAG_TXACKE: Tx Missing acknowledge Error
  437. * @arg CEC_FLAG_TXERR: Tx Error.
  438. * @arg CEC_FLAG_TXUDR: Tx-Buffer Underrun.
  439. * @arg CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte).
  440. * @arg CEC_FLAG_TXBR: Tx-Byte Request.
  441. * @arg CEC_FLAG_ARBLST: Arbitration Lost
  442. * @arg CEC_FLAG_RXACKE: Rx-Missing Acknowledge
  443. * @arg CEC_FLAG_LBPE: Rx Long period Error
  444. * @arg CEC_FLAG_SBPE: Rx Short period Error
  445. * @arg CEC_FLAG_BRE: Rx Bit Rising Error
  446. * @arg CEC_FLAG_RXOVR: Rx Overrun.
  447. * @arg CEC_FLAG_RXEND: End Of Reception.
  448. * @arg CEC_FLAG_RXBR: Rx-Byte Received.
  449. * @retval none
  450. */
  451. #define __HAL_CEC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR |= (__FLAG__))
  452. /** @brief Enables the specified CEC interrupt.
  453. * @param __HANDLE__ specifies the CEC Handle.
  454. * @param __INTERRUPT__ specifies the CEC interrupt to enable.
  455. * This parameter can be one of the following values:
  456. * @arg CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable
  457. * @arg CEC_IT_TXERR: Tx Error IT Enable
  458. * @arg CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable
  459. * @arg CEC_IT_TXEND: End of transmission IT Enable
  460. * @arg CEC_IT_TXBR: Tx-Byte Request IT Enable
  461. * @arg CEC_IT_ARBLST: Arbitration Lost IT Enable
  462. * @arg CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable
  463. * @arg CEC_IT_LBPE: Rx Long period Error IT Enable
  464. * @arg CEC_IT_SBPE: Rx Short period Error IT Enable
  465. * @arg CEC_IT_BRE: Rx Bit Rising Error IT Enable
  466. * @arg CEC_IT_RXOVR: Rx Overrun IT Enable
  467. * @arg CEC_IT_RXEND: End Of Reception IT Enable
  468. * @arg CEC_IT_RXBR: Rx-Byte Received IT Enable
  469. * @retval none
  470. */
  471. #define __HAL_CEC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
  472. /** @brief Disables the specified CEC interrupt.
  473. * @param __HANDLE__ specifies the CEC Handle.
  474. * @param __INTERRUPT__ specifies the CEC interrupt to disable.
  475. * This parameter can be one of the following values:
  476. * @arg CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable
  477. * @arg CEC_IT_TXERR: Tx Error IT Enable
  478. * @arg CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable
  479. * @arg CEC_IT_TXEND: End of transmission IT Enable
  480. * @arg CEC_IT_TXBR: Tx-Byte Request IT Enable
  481. * @arg CEC_IT_ARBLST: Arbitration Lost IT Enable
  482. * @arg CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable
  483. * @arg CEC_IT_LBPE: Rx Long period Error IT Enable
  484. * @arg CEC_IT_SBPE: Rx Short period Error IT Enable
  485. * @arg CEC_IT_BRE: Rx Bit Rising Error IT Enable
  486. * @arg CEC_IT_RXOVR: Rx Overrun IT Enable
  487. * @arg CEC_IT_RXEND: End Of Reception IT Enable
  488. * @arg CEC_IT_RXBR: Rx-Byte Received IT Enable
  489. * @retval none
  490. */
  491. #define __HAL_CEC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
  492. /** @brief Checks whether or not the specified CEC interrupt is enabled.
  493. * @param __HANDLE__ specifies the CEC Handle.
  494. * @param __INTERRUPT__ specifies the CEC interrupt to check.
  495. * This parameter can be one of the following values:
  496. * @arg CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable
  497. * @arg CEC_IT_TXERR: Tx Error IT Enable
  498. * @arg CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable
  499. * @arg CEC_IT_TXEND: End of transmission IT Enable
  500. * @arg CEC_IT_TXBR: Tx-Byte Request IT Enable
  501. * @arg CEC_IT_ARBLST: Arbitration Lost IT Enable
  502. * @arg CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable
  503. * @arg CEC_IT_LBPE: Rx Long period Error IT Enable
  504. * @arg CEC_IT_SBPE: Rx Short period Error IT Enable
  505. * @arg CEC_IT_BRE: Rx Bit Rising Error IT Enable
  506. * @arg CEC_IT_RXOVR: Rx Overrun IT Enable
  507. * @arg CEC_IT_RXEND: End Of Reception IT Enable
  508. * @arg CEC_IT_RXBR: Rx-Byte Received IT Enable
  509. * @retval FlagStatus
  510. */
  511. #define __HAL_CEC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER & (__INTERRUPT__))
  512. /** @brief Enables the CEC device
  513. * @param __HANDLE__ specifies the CEC Handle.
  514. * @retval none
  515. */
  516. #define __HAL_CEC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CEC_CR_CECEN)
  517. /** @brief Disables the CEC device
  518. * @param __HANDLE__ specifies the CEC Handle.
  519. * @retval none
  520. */
  521. #define __HAL_CEC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~CEC_CR_CECEN)
  522. /** @brief Set Transmission Start flag
  523. * @param __HANDLE__ specifies the CEC Handle.
  524. * @retval none
  525. */
  526. #define __HAL_CEC_FIRST_BYTE_TX_SET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CEC_CR_TXSOM)
  527. /** @brief Set Transmission End flag
  528. * @param __HANDLE__ specifies the CEC Handle.
  529. * @retval none
  530. * If the CEC message consists of only one byte, TXEOM must be set before of TXSOM.
  531. */
  532. #define __HAL_CEC_LAST_BYTE_TX_SET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CEC_CR_TXEOM)
  533. /** @brief Get Transmission Start flag
  534. * @param __HANDLE__ specifies the CEC Handle.
  535. * @retval FlagStatus
  536. */
  537. #define __HAL_CEC_GET_TRANSMISSION_START_FLAG(__HANDLE__) ((__HANDLE__)->Instance->CR & CEC_CR_TXSOM)
  538. /** @brief Get Transmission End flag
  539. * @param __HANDLE__ specifies the CEC Handle.
  540. * @retval FlagStatus
  541. */
  542. #define __HAL_CEC_GET_TRANSMISSION_END_FLAG(__HANDLE__) ((__HANDLE__)->Instance->CR & CEC_CR_TXEOM)
  543. /** @brief Clear OAR register
  544. * @param __HANDLE__ specifies the CEC Handle.
  545. * @retval none
  546. */
  547. #define __HAL_CEC_CLEAR_OAR(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CFGR, CEC_CFGR_OAR)
  548. /** @brief Set OAR register (without resetting previously set address in case of multi-address mode)
  549. * To reset OAR, __HAL_CEC_CLEAR_OAR() needs to be called beforehand
  550. * @param __HANDLE__ specifies the CEC Handle.
  551. * @param __ADDRESS__ Own Address value (CEC logical address is identified by bit position)
  552. * @retval none
  553. */
  554. #define __HAL_CEC_SET_OAR(__HANDLE__,__ADDRESS__) SET_BIT((__HANDLE__)->Instance->CFGR, (__ADDRESS__)<< CEC_CFGR_OAR_LSB_POS)
  555. /**
  556. * @}
  557. */
  558. /* Exported functions --------------------------------------------------------*/
  559. /** @addtogroup CEC_Exported_Functions
  560. * @{
  561. */
  562. /** @addtogroup CEC_Exported_Functions_Group1
  563. * @{
  564. */
  565. /* Initialization and de-initialization functions ****************************/
  566. HAL_StatusTypeDef HAL_CEC_Init(CEC_HandleTypeDef *hcec);
  567. HAL_StatusTypeDef HAL_CEC_DeInit(CEC_HandleTypeDef *hcec);
  568. HAL_StatusTypeDef HAL_CEC_SetDeviceAddress(CEC_HandleTypeDef *hcec, uint16_t CEC_OwnAddress);
  569. void HAL_CEC_MspInit(CEC_HandleTypeDef *hcec);
  570. void HAL_CEC_MspDeInit(CEC_HandleTypeDef *hcec);
  571. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  572. HAL_StatusTypeDef HAL_CEC_RegisterCallback(CEC_HandleTypeDef *hcec, HAL_CEC_CallbackIDTypeDef CallbackID,
  573. pCEC_CallbackTypeDef pCallback);
  574. HAL_StatusTypeDef HAL_CEC_UnRegisterCallback(CEC_HandleTypeDef *hcec, HAL_CEC_CallbackIDTypeDef CallbackID);
  575. HAL_StatusTypeDef HAL_CEC_RegisterRxCpltCallback(CEC_HandleTypeDef *hcec, pCEC_RxCallbackTypeDef pCallback);
  576. HAL_StatusTypeDef HAL_CEC_UnRegisterRxCpltCallback(CEC_HandleTypeDef *hcec);
  577. #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
  578. /**
  579. * @}
  580. */
  581. /** @addtogroup CEC_Exported_Functions_Group2
  582. * @{
  583. */
  584. /* I/O operation functions ***************************************************/
  585. HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t InitiatorAddress, uint8_t DestinationAddress,
  586. uint8_t *pData, uint32_t Size);
  587. uint32_t HAL_CEC_GetLastReceivedFrameSize(CEC_HandleTypeDef *hcec);
  588. void HAL_CEC_ChangeRxBuffer(CEC_HandleTypeDef *hcec, uint8_t *Rxbuffer);
  589. void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec);
  590. void HAL_CEC_TxCpltCallback(CEC_HandleTypeDef *hcec);
  591. void HAL_CEC_RxCpltCallback(CEC_HandleTypeDef *hcec, uint32_t RxFrameSize);
  592. void HAL_CEC_ErrorCallback(CEC_HandleTypeDef *hcec);
  593. /**
  594. * @}
  595. */
  596. /** @addtogroup CEC_Exported_Functions_Group3
  597. * @{
  598. */
  599. /* Peripheral State functions ************************************************/
  600. HAL_CEC_StateTypeDef HAL_CEC_GetState(CEC_HandleTypeDef *hcec);
  601. uint32_t HAL_CEC_GetError(CEC_HandleTypeDef *hcec);
  602. /**
  603. * @}
  604. */
  605. /**
  606. * @}
  607. */
  608. /* Private types -------------------------------------------------------------*/
  609. /** @defgroup CEC_Private_Types CEC Private Types
  610. * @{
  611. */
  612. /**
  613. * @}
  614. */
  615. /* Private variables ---------------------------------------------------------*/
  616. /** @defgroup CEC_Private_Variables CEC Private Variables
  617. * @{
  618. */
  619. /**
  620. * @}
  621. */
  622. /* Private constants ---------------------------------------------------------*/
  623. /** @defgroup CEC_Private_Constants CEC Private Constants
  624. * @{
  625. */
  626. /**
  627. * @}
  628. */
  629. /* Private macros ------------------------------------------------------------*/
  630. /** @defgroup CEC_Private_Macros CEC Private Macros
  631. * @{
  632. */
  633. #define IS_CEC_SIGNALFREETIME(__SFT__) ((__SFT__) <= CEC_CFGR_SFT)
  634. #define IS_CEC_TOLERANCE(__RXTOL__) (((__RXTOL__) == CEC_STANDARD_TOLERANCE) || \
  635. ((__RXTOL__) == CEC_EXTENDED_TOLERANCE))
  636. #define IS_CEC_BRERXSTOP(__BRERXSTOP__) (((__BRERXSTOP__) == CEC_NO_RX_STOP_ON_BRE) || \
  637. ((__BRERXSTOP__) == CEC_RX_STOP_ON_BRE))
  638. #define IS_CEC_BREERRORBITGEN(__ERRORBITGEN__) (((__ERRORBITGEN__) == CEC_BRE_ERRORBIT_NO_GENERATION) || \
  639. ((__ERRORBITGEN__) == CEC_BRE_ERRORBIT_GENERATION))
  640. #define IS_CEC_LBPEERRORBITGEN(__ERRORBITGEN__) (((__ERRORBITGEN__) == CEC_LBPE_ERRORBIT_NO_GENERATION) || \
  641. ((__ERRORBITGEN__) == CEC_LBPE_ERRORBIT_GENERATION))
  642. #define IS_CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION(__ERRORBITGEN__) (((__ERRORBITGEN__) == CEC_BROADCASTERROR_ERRORBIT_GENERATION) || \
  643. ((__ERRORBITGEN__) == CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION))
  644. #define IS_CEC_SFTOP(__SFTOP__) (((__SFTOP__) == CEC_SFT_START_ON_TXSOM) || \
  645. ((__SFTOP__) == CEC_SFT_START_ON_TX_RX_END))
  646. #define IS_CEC_LISTENING_MODE(__MODE__) (((__MODE__) == CEC_REDUCED_LISTENING_MODE) || \
  647. ((__MODE__) == CEC_FULL_LISTENING_MODE))
  648. /** @brief Check CEC message size.
  649. * The message size is the payload size: without counting the header,
  650. * it varies from 0 byte (ping operation, one header only, no payload) to
  651. * 15 bytes (1 opcode and up to 14 operands following the header).
  652. * @param __SIZE__ CEC message size.
  653. * @retval Test result (TRUE or FALSE).
  654. */
  655. #define IS_CEC_MSGSIZE(__SIZE__) ((__SIZE__) <= 0x10U)
  656. /** @brief Check CEC device Own Address Register (OAR) setting.
  657. * OAR address is written in a 15-bit field within CEC_CFGR register.
  658. * @param __ADDRESS__ CEC own address.
  659. * @retval Test result (TRUE or FALSE).
  660. */
  661. #define IS_CEC_OWN_ADDRESS(__ADDRESS__) ((__ADDRESS__) <= 0x7FFFU)
  662. /** @brief Check CEC initiator or destination logical address setting.
  663. * Initiator and destination addresses are coded over 4 bits.
  664. * @param __ADDRESS__ CEC initiator or logical address.
  665. * @retval Test result (TRUE or FALSE).
  666. */
  667. #define IS_CEC_ADDRESS(__ADDRESS__) ((__ADDRESS__) <= 0xFU)
  668. /**
  669. * @}
  670. */
  671. /* Private functions ---------------------------------------------------------*/
  672. /** @defgroup CEC_Private_Functions CEC Private Functions
  673. * @{
  674. */
  675. /**
  676. * @}
  677. */
  678. /**
  679. * @}
  680. */
  681. /**
  682. * @}
  683. */
  684. #endif /* CEC */
  685. #ifdef __cplusplus
  686. }
  687. #endif
  688. #endif /* STM32F4xxHAL_CEC_H */