stm32f1xx_hal_cec.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_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 __STM32F1xx_HAL_CEC_H
  20. #define __STM32F1xx_HAL_CEC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f1xx_hal_def.h"
  26. #if defined (CEC)
  27. /** @addtogroup STM32F1xx_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 TimingErrorFree; /*!< Configures the CEC Bit Timing Error Mode.
  43. This parameter can be a value of CEC_BitTimingErrorMode */
  44. uint32_t PeriodErrorFree; /*!< Configures the CEC Bit Period Error Mode.
  45. This parameter can be a value of CEC_BitPeriodErrorMode */
  46. uint16_t OwnAddress; /*!< Own addresses configuration
  47. This parameter can be a value of @ref CEC_OWN_ADDRESS */
  48. uint8_t *RxBuffer; /*!< CEC Rx buffer pointer */
  49. } CEC_InitTypeDef;
  50. /**
  51. * @brief HAL CEC State definition
  52. * @note HAL CEC State value is a combination of 2 different substates: gState and RxState
  53. (see @ref CEC_State_Definition).
  54. * - gState contains CEC state information related to global Handle management
  55. * and also information related to Tx operations.
  56. * gState value coding follow below described bitmap :
  57. * b7 (not used)
  58. * x : Should be set to 0
  59. * b6 Error information
  60. * 0 : No Error
  61. * 1 : Error
  62. * b5 CEC peripheral initialization status
  63. * 0 : Reset (peripheral not initialized)
  64. * 1 : Init done (peripheral initialized. HAL CEC Init function already called)
  65. * b4-b3 (not used)
  66. * xx : Should be set to 00
  67. * b2 Intrinsic process state
  68. * 0 : Ready
  69. * 1 : Busy (peripheral busy with some configuration or internal operations)
  70. * b1 (not used)
  71. * x : Should be set to 0
  72. * b0 Tx state
  73. * 0 : Ready (no Tx operation ongoing)
  74. * 1 : Busy (Tx operation ongoing)
  75. * - RxState contains information related to Rx operations.
  76. * RxState value coding follow below described bitmap :
  77. * b7-b6 (not used)
  78. * xx : Should be set to 00
  79. * b5 CEC peripheral initialization status
  80. * 0 : Reset (peripheral not initialized)
  81. * 1 : Init done (peripheral initialized)
  82. * b4-b2 (not used)
  83. * xxx : Should be set to 000
  84. * b1 Rx state
  85. * 0 : Ready (no Rx operation ongoing)
  86. * 1 : Busy (Rx operation ongoing)
  87. * b0 (not used)
  88. * x : Should be set to 0.
  89. */
  90. typedef enum
  91. {
  92. HAL_CEC_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized
  93. Value is allowed for gState and RxState */
  94. HAL_CEC_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
  95. Value is allowed for gState and RxState */
  96. HAL_CEC_STATE_BUSY = 0x24U, /*!< an internal process is ongoing
  97. Value is allowed for gState only */
  98. HAL_CEC_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
  99. Value is allowed for RxState only */
  100. HAL_CEC_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
  101. Value is allowed for gState only */
  102. HAL_CEC_STATE_BUSY_RX_TX = 0x23U, /*!< an internal process is ongoing
  103. Value is allowed for gState only */
  104. HAL_CEC_STATE_ERROR = 0x60U /*!< Error Value is allowed for gState only */
  105. } HAL_CEC_StateTypeDef;
  106. /**
  107. * @brief CEC handle Structure definition
  108. */
  109. typedef struct __CEC_HandleTypeDef
  110. {
  111. CEC_TypeDef *Instance; /*!< CEC registers base address */
  112. CEC_InitTypeDef Init; /*!< CEC communication parameters */
  113. const uint8_t *pTxBuffPtr; /*!< Pointer to CEC Tx transfer Buffer */
  114. uint16_t TxXferCount; /*!< CEC Tx Transfer Counter */
  115. uint16_t RxXferSize; /*!< CEC Rx Transfer size, 0: header received only */
  116. HAL_LockTypeDef Lock; /*!< Locking object */
  117. HAL_CEC_StateTypeDef gState; /*!< CEC state information related to global Handle management
  118. and also related to Tx operations.
  119. This parameter can be a value of @ref HAL_CEC_StateTypeDef */
  120. HAL_CEC_StateTypeDef RxState; /*!< CEC state information related to Rx operations.
  121. This parameter can be a value of @ref HAL_CEC_StateTypeDef */
  122. uint32_t ErrorCode; /*!< For errors handling purposes, copy of ISR register
  123. in case error is reported */
  124. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  125. void (* TxCpltCallback)(struct __CEC_HandleTypeDef *hcec); /*!< CEC Tx Transfer completed callback */
  126. void (* RxCpltCallback)(struct __CEC_HandleTypeDef *hcec,
  127. uint32_t RxFrameSize); /*!< CEC Rx Transfer completed callback */
  128. void (* ErrorCallback)(struct __CEC_HandleTypeDef *hcec); /*!< CEC error callback */
  129. void (* MspInitCallback)(struct __CEC_HandleTypeDef *hcec); /*!< CEC Msp Init callback */
  130. void (* MspDeInitCallback)(struct __CEC_HandleTypeDef *hcec); /*!< CEC Msp DeInit callback */
  131. #endif /* (USE_HAL_CEC_REGISTER_CALLBACKS) */
  132. } CEC_HandleTypeDef;
  133. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  134. /**
  135. * @brief HAL CEC Callback ID enumeration definition
  136. */
  137. typedef enum
  138. {
  139. HAL_CEC_TX_CPLT_CB_ID = 0x00U, /*!< CEC Tx Transfer completed callback ID */
  140. HAL_CEC_RX_CPLT_CB_ID = 0x01U, /*!< CEC Rx Transfer completed callback ID */
  141. HAL_CEC_ERROR_CB_ID = 0x02U, /*!< CEC error callback ID */
  142. HAL_CEC_MSPINIT_CB_ID = 0x03U, /*!< CEC Msp Init callback ID */
  143. HAL_CEC_MSPDEINIT_CB_ID = 0x04U /*!< CEC Msp DeInit callback ID */
  144. } HAL_CEC_CallbackIDTypeDef;
  145. /**
  146. * @brief HAL CEC Callback pointer definition
  147. */
  148. typedef void (*pCEC_CallbackTypeDef)(CEC_HandleTypeDef *hcec); /*!< pointer to an CEC callback function */
  149. typedef void (*pCEC_RxCallbackTypeDef)(CEC_HandleTypeDef *hcec,
  150. uint32_t RxFrameSize); /*!< pointer to an Rx Transfer completed
  151. callback function */
  152. #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
  153. /**
  154. * @}
  155. */
  156. /* Exported constants --------------------------------------------------------*/
  157. /** @defgroup CEC_Exported_Constants CEC Exported Constants
  158. * @{
  159. */
  160. /** @defgroup CEC_Error_Code CEC Error Code
  161. * @{
  162. */
  163. #define HAL_CEC_ERROR_NONE 0x00000000U /*!< no error */
  164. #define HAL_CEC_ERROR_BTE CEC_ESR_BTE /*!< Bit Timing Error */
  165. #define HAL_CEC_ERROR_BPE CEC_ESR_BPE /*!< Bit Period Error */
  166. #define HAL_CEC_ERROR_RBTFE CEC_ESR_RBTFE /*!< Rx Block Transfer Finished Error */
  167. #define HAL_CEC_ERROR_SBE CEC_ESR_SBE /*!< Start Bit Error */
  168. #define HAL_CEC_ERROR_ACKE CEC_ESR_ACKE /*!< Block Acknowledge Error */
  169. #define HAL_CEC_ERROR_LINE CEC_ESR_LINE /*!< Line Error */
  170. #define HAL_CEC_ERROR_TBTFE CEC_ESR_TBTFE /*!< Tx Block Transfer Finished Error */
  171. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  172. #define HAL_CEC_ERROR_INVALID_CALLBACK ((uint32_t)0x00000080U) /*!< Invalid Callback Error */
  173. #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
  174. /**
  175. * @}
  176. */
  177. /** @defgroup CEC_BitTimingErrorMode Bit Timing Error Mode
  178. * @{
  179. */
  180. #define CEC_BIT_TIMING_ERROR_MODE_STANDARD 0x00000000U /*!< Bit timing error Standard Mode */
  181. #define CEC_BIT_TIMING_ERROR_MODE_ERRORFREE CEC_CFGR_BTEM /*!< Bit timing error Free Mode */
  182. /**
  183. * @}
  184. */
  185. /** @defgroup CEC_BitPeriodErrorMode Bit Period Error Mode
  186. * @{
  187. */
  188. #define CEC_BIT_PERIOD_ERROR_MODE_STANDARD 0x00000000U /*!< Bit period error Standard Mode */
  189. #define CEC_BIT_PERIOD_ERROR_MODE_FLEXIBLE CEC_CFGR_BPEM /*!< Bit period error Flexible Mode */
  190. /**
  191. * @}
  192. */
  193. /** @defgroup CEC_Initiator_Position CEC Initiator logical address position in message header
  194. * @{
  195. */
  196. #define CEC_INITIATOR_LSB_POS 4U
  197. /**
  198. * @}
  199. */
  200. /** @defgroup CEC_OWN_ADDRESS CEC Own Address
  201. * @{
  202. */
  203. #define CEC_OWN_ADDRESS_NONE CEC_OWN_ADDRESS_0 /* Reset value */
  204. #define CEC_OWN_ADDRESS_0 ((uint16_t)0x0000U) /* Logical Address 0 */
  205. #define CEC_OWN_ADDRESS_1 ((uint16_t)0x0001U) /* Logical Address 1 */
  206. #define CEC_OWN_ADDRESS_2 ((uint16_t)0x0002U) /* Logical Address 2 */
  207. #define CEC_OWN_ADDRESS_3 ((uint16_t)0x0003U) /* Logical Address 3 */
  208. #define CEC_OWN_ADDRESS_4 ((uint16_t)0x0004U) /* Logical Address 4 */
  209. #define CEC_OWN_ADDRESS_5 ((uint16_t)0x0005U) /* Logical Address 5 */
  210. #define CEC_OWN_ADDRESS_6 ((uint16_t)0x0006U) /* Logical Address 6 */
  211. #define CEC_OWN_ADDRESS_7 ((uint16_t)0x0007U) /* Logical Address 7 */
  212. #define CEC_OWN_ADDRESS_8 ((uint16_t)0x0008U) /* Logical Address 8 */
  213. #define CEC_OWN_ADDRESS_9 ((uint16_t)0x0009U) /* Logical Address 9 */
  214. #define CEC_OWN_ADDRESS_10 ((uint16_t)0x000AU) /* Logical Address 10 */
  215. #define CEC_OWN_ADDRESS_11 ((uint16_t)0x000BU) /* Logical Address 11 */
  216. #define CEC_OWN_ADDRESS_12 ((uint16_t)0x000CU) /* Logical Address 12 */
  217. #define CEC_OWN_ADDRESS_13 ((uint16_t)0x000DU) /* Logical Address 13 */
  218. #define CEC_OWN_ADDRESS_14 ((uint16_t)0x000EU) /* Logical Address 14 */
  219. #define CEC_OWN_ADDRESS_15 ((uint16_t)0x000FU) /* Logical Address 15 */
  220. /**
  221. * @}
  222. */
  223. /** @defgroup CEC_Interrupts_Definitions Interrupts definition
  224. * @{
  225. */
  226. #define CEC_IT_IE CEC_CFGR_IE
  227. /**
  228. * @}
  229. */
  230. /** @defgroup CEC_Flags_Definitions Flags definition
  231. * @{
  232. */
  233. #define CEC_FLAG_TSOM CEC_CSR_TSOM
  234. #define CEC_FLAG_TEOM CEC_CSR_TEOM
  235. #define CEC_FLAG_TERR CEC_CSR_TERR
  236. #define CEC_FLAG_TBTRF CEC_CSR_TBTRF
  237. #define CEC_FLAG_RSOM CEC_CSR_RSOM
  238. #define CEC_FLAG_REOM CEC_CSR_REOM
  239. #define CEC_FLAG_RERR CEC_CSR_RERR
  240. #define CEC_FLAG_RBTF CEC_CSR_RBTF
  241. /**
  242. * @}
  243. */
  244. /**
  245. * @}
  246. */
  247. /* Exported macros -----------------------------------------------------------*/
  248. /** @defgroup CEC_Exported_Macros CEC Exported Macros
  249. * @{
  250. */
  251. /** @brief Reset CEC handle gstate & RxState
  252. * @param __HANDLE__ CEC handle.
  253. * @retval None
  254. */
  255. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  256. #define __HAL_CEC_RESET_HANDLE_STATE(__HANDLE__) do{ \
  257. (__HANDLE__)->gState = HAL_CEC_STATE_RESET; \
  258. (__HANDLE__)->RxState = HAL_CEC_STATE_RESET; \
  259. (__HANDLE__)->MspInitCallback = NULL; \
  260. (__HANDLE__)->MspDeInitCallback = NULL; \
  261. } while(0)
  262. #else
  263. #define __HAL_CEC_RESET_HANDLE_STATE(__HANDLE__) do{ \
  264. (__HANDLE__)->gState = HAL_CEC_STATE_RESET; \
  265. (__HANDLE__)->RxState = HAL_CEC_STATE_RESET; \
  266. } while(0)
  267. #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
  268. /** @brief Checks whether or not the specified CEC interrupt flag is set.
  269. * @param __HANDLE__ specifies the CEC Handle.
  270. * @param __FLAG__ specifies the flag to check.
  271. * @arg CEC_FLAG_TERR: Tx Error
  272. * @arg CEC_FLAG_TBTRF:Tx Block Transfer Finished
  273. * @arg CEC_FLAG_RERR: Rx Error
  274. * @arg CEC_FLAG_RBTF: Rx Block Transfer Finished
  275. * @retval ITStatus
  276. */
  277. #define __HAL_CEC_GET_FLAG(__HANDLE__, __FLAG__) READ_BIT((__HANDLE__)->Instance->CSR,(__FLAG__))
  278. /** @brief Clears the CEC's pending flags.
  279. * @param __HANDLE__ specifies the CEC Handle.
  280. * @param __FLAG__ specifies the flag to clear.
  281. * This parameter can be any combination of the following values:
  282. * @arg CEC_CSR_TERR: Tx Error
  283. * @arg CEC_FLAG_TBTRF: Tx Block Transfer Finished
  284. * @arg CEC_CSR_RERR: Rx Error
  285. * @arg CEC_CSR_RBTF: Rx Block Transfer Finished
  286. * @retval none
  287. */
  288. #define __HAL_CEC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
  289. do { \
  290. uint32_t tmp = 0x0U; \
  291. tmp = (__HANDLE__)->Instance->CSR & 0x00000002U; \
  292. (__HANDLE__)->Instance->CSR &= (uint32_t)(((~(uint32_t)(__FLAG__)) & 0xFFFFFFFCU) | tmp);\
  293. } while(0U)
  294. /** @brief Enables the specified CEC interrupt.
  295. * @param __HANDLE__ specifies the CEC Handle.
  296. * @param __INTERRUPT__ specifies the CEC interrupt to enable.
  297. * This parameter can be one of the following values:
  298. * @arg CEC_IT_IE : Interrupt Enable.
  299. * @retval none
  300. */
  301. #define __HAL_CEC_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CFGR, (__INTERRUPT__))
  302. /** @brief Disables the specified CEC interrupt.
  303. * @param __HANDLE__ specifies the CEC Handle.
  304. * @param __INTERRUPT__ specifies the CEC interrupt to disable.
  305. * This parameter can be one of the following values:
  306. * @arg CEC_IT_IE : Interrupt Enable
  307. * @retval none
  308. */
  309. #define __HAL_CEC_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CFGR, (__INTERRUPT__))
  310. /** @brief Checks whether or not the specified CEC interrupt is enabled.
  311. * @param __HANDLE__ specifies the CEC Handle.
  312. * @param __INTERRUPT__ specifies the CEC interrupt to check.
  313. * This parameter can be one of the following values:
  314. * @arg CEC_IT_IE : Interrupt Enable
  315. * @retval FlagStatus
  316. */
  317. #define __HAL_CEC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) READ_BIT((__HANDLE__)->Instance->CFGR, (__INTERRUPT__))
  318. /** @brief Enables the CEC device
  319. * @param __HANDLE__ specifies the CEC Handle.
  320. * @retval none
  321. */
  322. #define __HAL_CEC_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CFGR, CEC_CFGR_PE)
  323. /** @brief Disables the CEC device
  324. * @param __HANDLE__ specifies the CEC Handle.
  325. * @retval none
  326. */
  327. #define __HAL_CEC_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CFGR, CEC_CFGR_PE)
  328. /** @brief Set Transmission Start flag
  329. * @param __HANDLE__ specifies the CEC Handle.
  330. * @retval none
  331. */
  332. #define __HAL_CEC_FIRST_BYTE_TX_SET(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, CEC_CSR_TSOM)
  333. /** @brief Set Transmission End flag
  334. * @param __HANDLE__ specifies the CEC Handle.
  335. * @retval none
  336. */
  337. #define __HAL_CEC_LAST_BYTE_TX_SET(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, CEC_CSR_TEOM)
  338. /** @brief Get Transmission Start flag
  339. * @param __HANDLE__ specifies the CEC Handle.
  340. * @retval FlagStatus
  341. */
  342. #define __HAL_CEC_GET_TRANSMISSION_START_FLAG(__HANDLE__) READ_BIT((__HANDLE__)->Instance->CSR, CEC_CSR_TSOM)
  343. /** @brief Get Transmission End flag
  344. * @param __HANDLE__ specifies the CEC Handle.
  345. * @retval FlagStatus
  346. */
  347. #define __HAL_CEC_GET_TRANSMISSION_END_FLAG(__HANDLE__) READ_BIT((__HANDLE__)->Instance->CSR, CEC_CSR_TEOM)
  348. /** @brief Clear OAR register
  349. * @param __HANDLE__ specifies the CEC Handle.
  350. * @retval none
  351. */
  352. #define __HAL_CEC_CLEAR_OAR(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->OAR, CEC_OAR_OA)
  353. /** @brief Set OAR register
  354. * @param __HANDLE__ specifies the CEC Handle.
  355. * @param __ADDRESS__ Own Address value.
  356. * @retval none
  357. */
  358. #define __HAL_CEC_SET_OAR(__HANDLE__,__ADDRESS__) MODIFY_REG((__HANDLE__)->Instance->OAR, CEC_OAR_OA, (__ADDRESS__));
  359. /**
  360. * @}
  361. */
  362. /* Exported functions --------------------------------------------------------*/
  363. /** @addtogroup CEC_Exported_Functions CEC Exported Functions
  364. * @{
  365. */
  366. /** @addtogroup CEC_Exported_Functions_Group1 Initialization and de-initialization functions
  367. * @brief Initialization and Configuration functions
  368. * @{
  369. */
  370. /* Initialization and de-initialization functions ****************************/
  371. HAL_StatusTypeDef HAL_CEC_Init(CEC_HandleTypeDef *hcec);
  372. HAL_StatusTypeDef HAL_CEC_DeInit(CEC_HandleTypeDef *hcec);
  373. HAL_StatusTypeDef HAL_CEC_SetDeviceAddress(CEC_HandleTypeDef *hcec, uint16_t CEC_OwnAddress);
  374. void HAL_CEC_MspInit(CEC_HandleTypeDef *hcec);
  375. void HAL_CEC_MspDeInit(CEC_HandleTypeDef *hcec);
  376. #if (USE_HAL_CEC_REGISTER_CALLBACKS == 1)
  377. HAL_StatusTypeDef HAL_CEC_RegisterCallback(CEC_HandleTypeDef *hcec, HAL_CEC_CallbackIDTypeDef CallbackID,
  378. pCEC_CallbackTypeDef pCallback);
  379. HAL_StatusTypeDef HAL_CEC_UnRegisterCallback(CEC_HandleTypeDef *hcec, HAL_CEC_CallbackIDTypeDef CallbackID);
  380. HAL_StatusTypeDef HAL_CEC_RegisterRxCpltCallback(CEC_HandleTypeDef *hcec, pCEC_RxCallbackTypeDef pCallback);
  381. HAL_StatusTypeDef HAL_CEC_UnRegisterRxCpltCallback(CEC_HandleTypeDef *hcec);
  382. #endif /* USE_HAL_CEC_REGISTER_CALLBACKS */
  383. /**
  384. * @}
  385. */
  386. /** @addtogroup CEC_Exported_Functions_Group2 Input and Output operation functions
  387. * @brief CEC Transmit/Receive functions
  388. * @{
  389. */
  390. /* I/O operation functions ***************************************************/
  391. HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t InitiatorAddress, uint8_t DestinationAddress,
  392. const uint8_t *pData, uint32_t Size);
  393. uint32_t HAL_CEC_GetLastReceivedFrameSize(const CEC_HandleTypeDef *hcec);
  394. void HAL_CEC_ChangeRxBuffer(CEC_HandleTypeDef *hcec, uint8_t *Rxbuffer);
  395. void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec);
  396. void HAL_CEC_TxCpltCallback(CEC_HandleTypeDef *hcec);
  397. void HAL_CEC_RxCpltCallback(CEC_HandleTypeDef *hcec, uint32_t RxFrameSize);
  398. void HAL_CEC_ErrorCallback(CEC_HandleTypeDef *hcec);
  399. /**
  400. * @}
  401. */
  402. /** @defgroup CEC_Exported_Functions_Group3 Peripheral Control functions
  403. * @brief CEC control functions
  404. * @{
  405. */
  406. /* Peripheral State functions ************************************************/
  407. HAL_CEC_StateTypeDef HAL_CEC_GetState(const CEC_HandleTypeDef *hcec);
  408. uint32_t HAL_CEC_GetError(const CEC_HandleTypeDef *hcec);
  409. /**
  410. * @}
  411. */
  412. /**
  413. * @}
  414. */
  415. /* Private types -------------------------------------------------------------*/
  416. /** @defgroup CEC_Private_Types CEC Private Types
  417. * @{
  418. */
  419. /**
  420. * @}
  421. */
  422. /* Private variables ---------------------------------------------------------*/
  423. /** @defgroup CEC_Private_Variables CEC Private Variables
  424. * @{
  425. */
  426. /**
  427. * @}
  428. */
  429. /* Private constants ---------------------------------------------------------*/
  430. /** @defgroup CEC_Private_Constants CEC Private Constants
  431. * @{
  432. */
  433. /**
  434. * @}
  435. */
  436. /* Private macros ------------------------------------------------------------*/
  437. /** @defgroup CEC_Private_Macros CEC Private Macros
  438. * @{
  439. */
  440. #define IS_CEC_BIT_TIMING_ERROR_MODE(MODE) (((MODE) == CEC_BIT_TIMING_ERROR_MODE_STANDARD) || \
  441. ((MODE) == CEC_BIT_TIMING_ERROR_MODE_ERRORFREE))
  442. #define IS_CEC_BIT_PERIOD_ERROR_MODE(MODE) (((MODE) == CEC_BIT_PERIOD_ERROR_MODE_STANDARD) || \
  443. ((MODE) == CEC_BIT_PERIOD_ERROR_MODE_FLEXIBLE))
  444. /** @brief Check CEC message size.
  445. * The message size is the payload size: without counting the header,
  446. * it varies from 0 byte (ping operation, one header only, no payload) to
  447. * 15 bytes (1 opcode and up to 14 operands following the header).
  448. * @param __SIZE__ CEC message size.
  449. * @retval Test result (TRUE or FALSE).
  450. */
  451. #define IS_CEC_MSGSIZE(__SIZE__) ((__SIZE__) <= 0x10U)
  452. /** @brief Check CEC device Own Address Register (OAR) setting.
  453. * @param __ADDRESS__ CEC own address.
  454. * @retval Test result (TRUE or FALSE).
  455. */
  456. #define IS_CEC_OWN_ADDRESS(__ADDRESS__) ((__ADDRESS__) <= 0x0000000FU)
  457. /** @brief Check CEC initiator or destination logical address setting.
  458. * Initiator and destination addresses are coded over 4 bits.
  459. * @param __ADDRESS__ CEC initiator or logical address.
  460. * @retval Test result (TRUE or FALSE).
  461. */
  462. #define IS_CEC_ADDRESS(__ADDRESS__) ((__ADDRESS__) <= 0x0000000FU)
  463. /**
  464. * @}
  465. */
  466. /* Private functions ---------------------------------------------------------*/
  467. /** @defgroup CEC_Private_Functions CEC Private Functions
  468. * @{
  469. */
  470. /**
  471. * @}
  472. */
  473. /**
  474. * @}
  475. */
  476. /**
  477. * @}
  478. */
  479. #endif /* CEC */
  480. #ifdef __cplusplus
  481. }
  482. #endif
  483. #endif /* __STM32F1xx_HAL_CEC_H */