stm32f4xx_hal_cec.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_cec.h
  4. * @author MCD Application Team
  5. * @version V1.4.3
  6. * @date 11-December-2015
  7. * @brief Header file of CEC HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F4xx_HAL_CEC_H
  39. #define __STM32F4xx_HAL_CEC_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #if defined(STM32F446xx)
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "stm32f4xx_hal_def.h"
  46. /** @addtogroup STM32F4xx_HAL_Driver
  47. * @{
  48. */
  49. /** @addtogroup CEC
  50. * @{
  51. */
  52. /* Exported types ------------------------------------------------------------*/
  53. /** @defgroup CEC_Exported_Types CEC Exported Types
  54. * @{
  55. */
  56. /**
  57. * @brief CEC Init Structure definition
  58. */
  59. typedef struct
  60. {
  61. uint32_t SignalFreeTime; /*!< Set SFT field, specifies the Signal Free Time.
  62. It can be one of @ref CEC_Signal_Free_Time
  63. and belongs to the set {0,...,7} where
  64. 0x0 is the default configuration
  65. else means 0.5 + (SignalFreeTime - 1) nominal data bit periods */
  66. uint32_t Tolerance; /*!< Set RXTOL bit, specifies the tolerance accepted on the received waveforms,
  67. it can be a value of @ref CEC_Tolerance : it is either CEC_STANDARD_TOLERANCE
  68. or CEC_EXTENDED_TOLERANCE */
  69. uint32_t BRERxStop; /*!< Set BRESTP bit @ref CEC_BRERxStop : specifies whether or not a Bit Rising Error stops the reception.
  70. CEC_NO_RX_STOP_ON_BRE: reception is not stopped.
  71. CEC_RX_STOP_ON_BRE: reception is stopped. */
  72. uint32_t BREErrorBitGen; /*!< Set BREGEN bit @ref CEC_BREErrorBitGen : specifies whether or not an Error-Bit is generated on the
  73. CEC line upon Bit Rising Error detection.
  74. CEC_BRE_ERRORBIT_NO_GENERATION: no error-bit generation.
  75. CEC_BRE_ERRORBIT_GENERATION: error-bit generation if BRESTP is set. */
  76. uint32_t LBPEErrorBitGen; /*!< Set LBPEGEN bit @ref CEC_LBPEErrorBitGen : specifies whether or not an Error-Bit is generated on the
  77. CEC line upon Long Bit Period Error detection.
  78. CEC_LBPE_ERRORBIT_NO_GENERATION: no error-bit generation.
  79. CEC_LBPE_ERRORBIT_GENERATION: error-bit generation. */
  80. uint32_t BroadcastMsgNoErrorBitGen; /*!< Set BRDNOGEN bit @ref CEC_BroadCastMsgErrorBitGen : allows to avoid an Error-Bit generation on the CEC line
  81. upon an error detected on a broadcast message.
  82. It supersedes BREGEN and LBPEGEN bits for a broadcast message error handling. It can take two values:
  83. 1) CEC_BROADCASTERROR_ERRORBIT_GENERATION.
  84. a) BRE detection: error-bit generation on the CEC line if BRESTP=CEC_RX_STOP_ON_BRE
  85. and BREGEN=CEC_BRE_ERRORBIT_NO_GENERATION.
  86. b) LBPE detection: error-bit generation on the CEC line
  87. if LBPGEN=CEC_LBPE_ERRORBIT_NO_GENERATION.
  88. 2) CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION.
  89. no error-bit generation in case neither a) nor b) are satisfied. Additionally,
  90. there is no error-bit generation in case of Short Bit Period Error detection in
  91. a broadcast message while LSTN bit is set. */
  92. uint32_t SignalFreeTimeOption; /*!< Set SFTOP bit @ref CEC_SFT_Option : specifies when SFT timer starts.
  93. CEC_SFT_START_ON_TXSOM SFT: timer starts when TXSOM is set by software.
  94. CEC_SFT_START_ON_TX_RX_END: SFT timer starts automatically at the end of message transmission/reception. */
  95. uint32_t OwnAddress; /*!< Set OAR field, specifies CEC device address within a 15-bit long field */
  96. uint32_t ListenMode; /*!< Set LSTN bit @ref CEC_Listening_Mode : specifies device listening mode. It can take two values:
  97. CEC_REDUCED_LISTENING_MODE: CEC peripheral receives only message addressed to its
  98. own address (OAR). Messages addressed to different destination are ignored.
  99. Broadcast messages are always received.
  100. CEC_FULL_LISTENING_MODE: CEC peripheral receives messages addressed to its own
  101. address (OAR) with positive acknowledge. Messages addressed to different destination
  102. are received, but without interfering with the CEC bus: no acknowledge sent. */
  103. uint8_t InitiatorAddress; /* Initiator address (source logical address, sent in each header) */
  104. }CEC_InitTypeDef;
  105. /**
  106. * @brief HAL CEC State structures definition
  107. */
  108. typedef enum
  109. {
  110. HAL_CEC_STATE_RESET = 0x00, /*!< Peripheral Reset state */
  111. HAL_CEC_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
  112. HAL_CEC_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
  113. HAL_CEC_STATE_BUSY_TX = 0x03, /*!< Data Transmission process is ongoing */
  114. HAL_CEC_STATE_BUSY_RX = 0x04, /*!< Data Reception process is ongoing */
  115. HAL_CEC_STATE_STANDBY_RX = 0x05, /*!< IP ready to receive, doesn't prevent IP to transmit */
  116. HAL_CEC_STATE_TIMEOUT = 0x06, /*!< Timeout state */
  117. HAL_CEC_STATE_ERROR = 0x07 /*!< State Error */
  118. }HAL_CEC_StateTypeDef;
  119. /**
  120. * @brief CEC handle Structure definition
  121. */
  122. typedef struct
  123. {
  124. CEC_TypeDef *Instance; /* CEC registers base address */
  125. CEC_InitTypeDef Init; /* CEC communication parameters */
  126. uint8_t *pTxBuffPtr; /* Pointer to CEC Tx transfer Buffer */
  127. uint16_t TxXferCount; /* CEC Tx Transfer Counter */
  128. uint8_t *pRxBuffPtr; /* Pointer to CEC Rx transfer Buffer */
  129. uint16_t RxXferSize; /* CEC Rx Transfer size, 0: header received only */
  130. uint32_t ErrorCode; /* For errors handling purposes, copy of ISR register
  131. in case error is reported */
  132. HAL_LockTypeDef Lock; /* Locking object */
  133. HAL_CEC_StateTypeDef State; /* CEC communication state */
  134. }CEC_HandleTypeDef;
  135. /**
  136. * @}
  137. */
  138. /* Exported constants --------------------------------------------------------*/
  139. /** @defgroup CEC_Exported_Constants CEC Exported Constants
  140. * @{
  141. */
  142. /** @defgroup CEC_Error_Code CEC Error Code
  143. * @{
  144. */
  145. #define HAL_CEC_ERROR_NONE (uint32_t) 0x0 /*!< no error */
  146. #define HAL_CEC_ERROR_RXOVR CEC_ISR_RXOVR /*!< CEC Rx-Overrun */
  147. #define HAL_CEC_ERROR_BRE CEC_ISR_BRE /*!< CEC Rx Bit Rising Error */
  148. #define HAL_CEC_ERROR_SBPE CEC_ISR_SBPE /*!< CEC Rx Short Bit period Error */
  149. #define HAL_CEC_ERROR_LBPE CEC_ISR_LBPE /*!< CEC Rx Long Bit period Error */
  150. #define HAL_CEC_ERROR_RXACKE CEC_ISR_RXACKE /*!< CEC Rx Missing Acknowledge */
  151. #define HAL_CEC_ERROR_ARBLST CEC_ISR_ARBLST /*!< CEC Arbitration Lost */
  152. #define HAL_CEC_ERROR_TXUDR CEC_ISR_TXUDR /*!< CEC Tx-Buffer Underrun */
  153. #define HAL_CEC_ERROR_TXERR CEC_ISR_TXERR /*!< CEC Tx-Error */
  154. #define HAL_CEC_ERROR_TXACKE CEC_ISR_TXACKE /*!< CEC Tx Missing Acknowledge */
  155. /**
  156. * @}
  157. */
  158. /** @defgroup CEC_Signal_Free_Time CEC Signal Free Time setting parameter
  159. * @{
  160. */
  161. #define CEC_DEFAULT_SFT ((uint32_t)0x00000000)
  162. #define CEC_0_5_BITPERIOD_SFT ((uint32_t)0x00000001)
  163. #define CEC_1_5_BITPERIOD_SFT ((uint32_t)0x00000002)
  164. #define CEC_2_5_BITPERIOD_SFT ((uint32_t)0x00000003)
  165. #define CEC_3_5_BITPERIOD_SFT ((uint32_t)0x00000004)
  166. #define CEC_4_5_BITPERIOD_SFT ((uint32_t)0x00000005)
  167. #define CEC_5_5_BITPERIOD_SFT ((uint32_t)0x00000006)
  168. #define CEC_6_5_BITPERIOD_SFT ((uint32_t)0x00000007)
  169. /**
  170. * @}
  171. */
  172. /** @defgroup CEC_Tolerance CEC Receiver Tolerance
  173. * @{
  174. */
  175. #define CEC_STANDARD_TOLERANCE ((uint32_t)0x00000000)
  176. #define CEC_EXTENDED_TOLERANCE ((uint32_t)CEC_CFGR_RXTOL)
  177. /**
  178. * @}
  179. */
  180. /** @defgroup CEC_BRERxStop CEC Reception Stop on Error
  181. * @{
  182. */
  183. #define CEC_NO_RX_STOP_ON_BRE ((uint32_t)0x00000000)
  184. #define CEC_RX_STOP_ON_BRE ((uint32_t)CEC_CFGR_BRESTP)
  185. /**
  186. * @}
  187. */
  188. /** @defgroup CEC_BREErrorBitGen CEC Error Bit Generation if Bit Rise Error reported
  189. * @{
  190. */
  191. #define CEC_BRE_ERRORBIT_NO_GENERATION ((uint32_t)0x00000000)
  192. #define CEC_BRE_ERRORBIT_GENERATION ((uint32_t)CEC_CFGR_BREGEN)
  193. /**
  194. * @}
  195. */
  196. /** @defgroup CEC_LBPEErrorBitGen CEC Error Bit Generation if Long Bit Period Error reported
  197. * @{
  198. */
  199. #define CEC_LBPE_ERRORBIT_NO_GENERATION ((uint32_t)0x00000000)
  200. #define CEC_LBPE_ERRORBIT_GENERATION ((uint32_t)CEC_CFGR_LBPEGEN)
  201. /**
  202. * @}
  203. */
  204. /** @defgroup CEC_BroadCastMsgErrorBitGen CEC Error Bit Generation on Broadcast message
  205. * @{
  206. */
  207. #define CEC_BROADCASTERROR_ERRORBIT_GENERATION ((uint32_t)0x00000000)
  208. #define CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION ((uint32_t)CEC_CFGR_BRDNOGEN)
  209. /**
  210. * @}
  211. */
  212. /** @defgroup CEC_SFT_Option CEC Signal Free Time start option
  213. * @{
  214. */
  215. #define CEC_SFT_START_ON_TXSOM ((uint32_t)0x00000000)
  216. #define CEC_SFT_START_ON_TX_RX_END ((uint32_t)CEC_CFGR_SFTOPT)
  217. /**
  218. * @}
  219. */
  220. /** @defgroup CEC_Listening_Mode CEC Listening mode option
  221. * @{
  222. */
  223. #define CEC_REDUCED_LISTENING_MODE ((uint32_t)0x00000000)
  224. #define CEC_FULL_LISTENING_MODE ((uint32_t)CEC_CFGR_LSTN)
  225. /**
  226. * @}
  227. */
  228. /** @defgroup CEC_OAR_Position CEC Device Own Address position in CEC CFGR register
  229. * @{
  230. */
  231. #define CEC_CFGR_OAR_LSB_POS ((uint32_t) 16)
  232. /**
  233. * @}
  234. */
  235. /** @defgroup CEC_Initiator_Position CEC Initiator logical address position in message header
  236. * @{
  237. */
  238. #define CEC_INITIATOR_LSB_POS ((uint32_t) 4)
  239. /**
  240. * @}
  241. */
  242. /** @defgroup CEC_Interrupts_Definitions CEC Interrupts definition
  243. * @{
  244. */
  245. #define CEC_IT_TXACKE CEC_IER_TXACKEIE
  246. #define CEC_IT_TXERR CEC_IER_TXERRIE
  247. #define CEC_IT_TXUDR CEC_IER_TXUDRIE
  248. #define CEC_IT_TXEND CEC_IER_TXENDIE
  249. #define CEC_IT_TXBR CEC_IER_TXBRIE
  250. #define CEC_IT_ARBLST CEC_IER_ARBLSTIE
  251. #define CEC_IT_RXACKE CEC_IER_RXACKEIE
  252. #define CEC_IT_LBPE CEC_IER_LBPEIE
  253. #define CEC_IT_SBPE CEC_IER_SBPEIE
  254. #define CEC_IT_BRE CEC_IER_BREIE
  255. #define CEC_IT_RXOVR CEC_IER_RXOVRIE
  256. #define CEC_IT_RXEND CEC_IER_RXENDIE
  257. #define CEC_IT_RXBR CEC_IER_RXBRIE
  258. /**
  259. * @}
  260. */
  261. /** @defgroup CEC_Flags_Definitions CEC Flags definition
  262. * @{
  263. */
  264. #define CEC_FLAG_TXACKE CEC_ISR_TXACKE
  265. #define CEC_FLAG_TXERR CEC_ISR_TXERR
  266. #define CEC_FLAG_TXUDR CEC_ISR_TXUDR
  267. #define CEC_FLAG_TXEND CEC_ISR_TXEND
  268. #define CEC_FLAG_TXBR CEC_ISR_TXBR
  269. #define CEC_FLAG_ARBLST CEC_ISR_ARBLST
  270. #define CEC_FLAG_RXACKE CEC_ISR_RXACKE
  271. #define CEC_FLAG_LBPE CEC_ISR_LBPE
  272. #define CEC_FLAG_SBPE CEC_ISR_SBPE
  273. #define CEC_FLAG_BRE CEC_ISR_BRE
  274. #define CEC_FLAG_RXOVR CEC_ISR_RXOVR
  275. #define CEC_FLAG_RXEND CEC_ISR_RXEND
  276. #define CEC_FLAG_RXBR CEC_ISR_RXBR
  277. /**
  278. * @}
  279. */
  280. /** @defgroup CEC_ALL_ERROR CEC all RX or TX errors flags
  281. * @{
  282. */
  283. #define CEC_ISR_ALL_ERROR ((uint32_t)CEC_ISR_RXOVR|CEC_ISR_BRE|CEC_ISR_SBPE|CEC_ISR_LBPE|CEC_ISR_RXACKE|\
  284. CEC_ISR_ARBLST|CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)
  285. /**
  286. * @}
  287. */
  288. /** @defgroup CEC_IER_ALL_RX CEC all RX errors interrupts enabling flag
  289. * @{
  290. */
  291. #define CEC_IER_RX_ALL_ERR ((uint32_t)CEC_IER_RXACKEIE|CEC_IER_LBPEIE|CEC_IER_SBPEIE|CEC_IER_BREIE|CEC_IER_RXOVRIE)
  292. /**
  293. * @}
  294. */
  295. /** @defgroup CEC_IER_ALL_TX CEC all TX errors interrupts enabling flag
  296. * @{
  297. */
  298. #define CEC_IER_TX_ALL_ERR ((uint32_t)CEC_IER_TXACKEIE|CEC_IER_TXERRIE|CEC_IER_TXUDRIE|CEC_IER_ARBLSTIE)
  299. /**
  300. * @}
  301. */
  302. /**
  303. * @}
  304. */
  305. /* Exported macros -----------------------------------------------------------*/
  306. /** @defgroup CEC_Exported_Macros CEC Exported Macros
  307. * @{
  308. */
  309. /** @brief Reset CEC handle state
  310. * @param __HANDLE__: CEC handle.
  311. * @retval None
  312. */
  313. #define __HAL_CEC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CEC_STATE_RESET)
  314. /** @brief Checks whether or not the specified CEC interrupt flag is set.
  315. * @param __HANDLE__: specifies the CEC Handle.
  316. * @param __FLAG__: specifies the interrupt to check.
  317. * @arg CEC_FLAG_TXACKE: Tx Missing acknowledge Error
  318. * @arg CEC_FLAG_TXERR: Tx Error.
  319. * @arg CEC_FLAG_TXUDR: Tx-Buffer Underrun.
  320. * @arg CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte).
  321. * @arg CEC_FLAG_TXBR: Tx-Byte Request.
  322. * @arg CEC_FLAG_ARBLST: Arbitration Lost
  323. * @arg CEC_FLAG_RXACKE: Rx-Missing Acknowledge
  324. * @arg CEC_FLAG_LBPE: Rx Long period Error
  325. * @arg CEC_FLAG_SBPE: Rx Short period Error
  326. * @arg CEC_FLAG_BRE: Rx Bit Rissing Error
  327. * @arg CEC_FLAG_RXOVR: Rx Overrun.
  328. * @arg CEC_FLAG_RXEND: End Of Reception.
  329. * @arg CEC_FLAG_RXBR: Rx-Byte Received.
  330. * @retval ITStatus
  331. */
  332. #define __HAL_CEC_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR & (__FLAG__))
  333. /** @brief Clears the interrupt or status flag when raised (write at 1)
  334. * @param __HANDLE__: specifies the CEC Handle.
  335. * @param __FLAG__: specifies the interrupt/status flag to clear.
  336. * This parameter can be one of the following values:
  337. * @arg CEC_FLAG_TXACKE: Tx Missing acknowledge Error
  338. * @arg CEC_FLAG_TXERR: Tx Error.
  339. * @arg CEC_FLAG_TXUDR: Tx-Buffer Underrun.
  340. * @arg CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte).
  341. * @arg CEC_FLAG_TXBR: Tx-Byte Request.
  342. * @arg CEC_FLAG_ARBLST: Arbitration Lost
  343. * @arg CEC_FLAG_RXACKE: Rx-Missing Acknowledge
  344. * @arg CEC_FLAG_LBPE: Rx Long period Error
  345. * @arg CEC_FLAG_SBPE: Rx Short period Error
  346. * @arg CEC_FLAG_BRE: Rx Bit Rissing Error
  347. * @arg CEC_FLAG_RXOVR: Rx Overrun.
  348. * @arg CEC_FLAG_RXEND: End Of Reception.
  349. * @arg CEC_FLAG_RXBR: Rx-Byte Received.
  350. * @retval none
  351. */
  352. #define __HAL_CEC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR |= (__FLAG__))
  353. /** @brief Enables the specified CEC interrupt.
  354. * @param __HANDLE__: specifies the CEC Handle.
  355. * @param __INTERRUPT__: specifies the CEC interrupt to enable.
  356. * This parameter can be one of the following values:
  357. * @arg CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable
  358. * @arg CEC_IT_TXERR: Tx Error IT Enable
  359. * @arg CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable
  360. * @arg CEC_IT_TXEND: End of transmission IT Enable
  361. * @arg CEC_IT_TXBR: Tx-Byte Request IT Enable
  362. * @arg CEC_IT_ARBLST: Arbitration Lost IT Enable
  363. * @arg CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable
  364. * @arg CEC_IT_LBPE: Rx Long period Error IT Enable
  365. * @arg CEC_IT_SBPE: Rx Short period Error IT Enable
  366. * @arg CEC_IT_BRE: Rx Bit Rising Error IT Enable
  367. * @arg CEC_IT_RXOVR: Rx Overrun IT Enable
  368. * @arg CEC_IT_RXEND: End Of Reception IT Enable
  369. * @arg CEC_IT_RXBR: Rx-Byte Received IT Enable
  370. * @retval none
  371. */
  372. #define __HAL_CEC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
  373. /** @brief Disables the specified CEC interrupt.
  374. * @param __HANDLE__: specifies the CEC Handle.
  375. * @param __INTERRUPT__: specifies the CEC interrupt to disable.
  376. * This parameter can be one of the following values:
  377. * @arg CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable
  378. * @arg CEC_IT_TXERR: Tx Error IT Enable
  379. * @arg CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable
  380. * @arg CEC_IT_TXEND: End of transmission IT Enable
  381. * @arg CEC_IT_TXBR: Tx-Byte Request IT Enable
  382. * @arg CEC_IT_ARBLST: Arbitration Lost IT Enable
  383. * @arg CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable
  384. * @arg CEC_IT_LBPE: Rx Long period Error IT Enable
  385. * @arg CEC_IT_SBPE: Rx Short period Error IT Enable
  386. * @arg CEC_IT_BRE: Rx Bit Rising Error IT Enable
  387. * @arg CEC_IT_RXOVR: Rx Overrun IT Enable
  388. * @arg CEC_IT_RXEND: End Of Reception IT Enable
  389. * @arg CEC_IT_RXBR: Rx-Byte Received IT Enable
  390. * @retval none
  391. */
  392. #define __HAL_CEC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
  393. /** @brief Checks whether or not the specified CEC interrupt is enabled.
  394. * @param __HANDLE__: specifies the CEC Handle.
  395. * @param __INTERRUPT__: specifies the CEC interrupt to check.
  396. * This parameter can be one of the following values:
  397. * @arg CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable
  398. * @arg CEC_IT_TXERR: Tx Error IT Enable
  399. * @arg CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable
  400. * @arg CEC_IT_TXEND: End of transmission IT Enable
  401. * @arg CEC_IT_TXBR: Tx-Byte Request IT Enable
  402. * @arg CEC_IT_ARBLST: Arbitration Lost IT Enable
  403. * @arg CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable
  404. * @arg CEC_IT_LBPE: Rx Long period Error IT Enable
  405. * @arg CEC_IT_SBPE: Rx Short period Error IT Enable
  406. * @arg CEC_IT_BRE: Rx Bit Rising Error IT Enable
  407. * @arg CEC_IT_RXOVR: Rx Overrun IT Enable
  408. * @arg CEC_IT_RXEND: End Of Reception IT Enable
  409. * @arg CEC_IT_RXBR: Rx-Byte Received IT Enable
  410. * @retval FlagStatus
  411. */
  412. #define __HAL_CEC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER & (__INTERRUPT__))
  413. /** @brief Enables the CEC device
  414. * @param __HANDLE__: specifies the CEC Handle.
  415. * @retval none
  416. */
  417. #define __HAL_CEC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CEC_CR_CECEN)
  418. /** @brief Disables the CEC device
  419. * @param __HANDLE__: specifies the CEC Handle.
  420. * @retval none
  421. */
  422. #define __HAL_CEC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~CEC_CR_CECEN)
  423. /** @brief Set Transmission Start flag
  424. * @param __HANDLE__: specifies the CEC Handle.
  425. * @retval none
  426. */
  427. #define __HAL_CEC_FIRST_BYTE_TX_SET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CEC_CR_TXSOM)
  428. /** @brief Set Transmission End flag
  429. * @param __HANDLE__: specifies the CEC Handle.
  430. * @retval none
  431. * If the CEC message consists of only one byte, TXEOM must be set before of TXSOM.
  432. */
  433. #define __HAL_CEC_LAST_BYTE_TX_SET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CEC_CR_TXEOM)
  434. /** @brief Get Transmission Start flag
  435. * @param __HANDLE__: specifies the CEC Handle.
  436. * @retval FlagStatus
  437. */
  438. #define __HAL_CEC_GET_TRANSMISSION_START_FLAG(__HANDLE__) ((__HANDLE__)->Instance->CR & CEC_CR_TXSOM)
  439. /** @brief Get Transmission End flag
  440. * @param __HANDLE__: specifies the CEC Handle.
  441. * @retval FlagStatus
  442. */
  443. #define __HAL_CEC_GET_TRANSMISSION_END_FLAG(__HANDLE__) ((__HANDLE__)->Instance->CR & CEC_CR_TXEOM)
  444. /** @brief Clear OAR register
  445. * @param __HANDLE__: specifies the CEC Handle.
  446. * @retval none
  447. */
  448. #define __HAL_CEC_CLEAR_OAR(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CFGR, CEC_CFGR_OAR)
  449. /** @brief Set OAR register (without resetting previously set address in case of multi-address mode)
  450. * To reset OAR, __HAL_CEC_CLEAR_OAR() needs to be called beforehand
  451. * @param __HANDLE__: specifies the CEC Handle.
  452. * @param __ADDRESS__: Own Address value (CEC logical address is identified by bit position)
  453. * @retval none
  454. */
  455. #define __HAL_CEC_SET_OAR(__HANDLE__,__ADDRESS__) SET_BIT((__HANDLE__)->Instance->CFGR, (__ADDRESS__)<< CEC_CFGR_OAR_LSB_POS)
  456. /**
  457. * @}
  458. */
  459. /* Exported functions --------------------------------------------------------*/
  460. /** @addtogroup CEC_Exported_Functions
  461. * @{
  462. */
  463. /** @addtogroup CEC_Exported_Functions_Group1
  464. * @{
  465. */
  466. /* Initialization and de-initialization functions ****************************/
  467. HAL_StatusTypeDef HAL_CEC_Init(CEC_HandleTypeDef *hcec);
  468. HAL_StatusTypeDef HAL_CEC_DeInit(CEC_HandleTypeDef *hcec);
  469. void HAL_CEC_MspInit(CEC_HandleTypeDef *hcec);
  470. void HAL_CEC_MspDeInit(CEC_HandleTypeDef *hcec);
  471. /**
  472. * @}
  473. */
  474. /** @addtogroup CEC_Exported_Functions_Group2
  475. * @{
  476. */
  477. /* I/O operation functions ***************************************************/
  478. HAL_StatusTypeDef HAL_CEC_Transmit(CEC_HandleTypeDef *hcec, uint8_t DestinationAddress, uint8_t *pData, uint32_t Size, uint32_t Timeout);
  479. HAL_StatusTypeDef HAL_CEC_Receive(CEC_HandleTypeDef *hcec, uint8_t *pData, uint32_t Timeout);
  480. HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t DestinationAddress, uint8_t *pData, uint32_t Size);
  481. HAL_StatusTypeDef HAL_CEC_Receive_IT(CEC_HandleTypeDef *hcec, uint8_t *pData);
  482. uint32_t HAL_CEC_GetReceivedFrameSize(CEC_HandleTypeDef *hcec);
  483. void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec);
  484. void HAL_CEC_TxCpltCallback(CEC_HandleTypeDef *hcec);
  485. void HAL_CEC_RxCpltCallback(CEC_HandleTypeDef *hcec);
  486. void HAL_CEC_ErrorCallback(CEC_HandleTypeDef *hcec);
  487. /**
  488. * @}
  489. */
  490. /** @addtogroup CEC_Exported_Functions_Group3
  491. * @{
  492. */
  493. /* Peripheral State functions ************************************************/
  494. HAL_CEC_StateTypeDef HAL_CEC_GetState(CEC_HandleTypeDef *hcec);
  495. uint32_t HAL_CEC_GetError(CEC_HandleTypeDef *hcec);
  496. /**
  497. * @}
  498. */
  499. /**
  500. * @}
  501. */
  502. /* Private types -------------------------------------------------------------*/
  503. /** @defgroup CEC_Private_Types CEC Private Types
  504. * @{
  505. */
  506. /**
  507. * @}
  508. */
  509. /* Private variables ---------------------------------------------------------*/
  510. /** @defgroup CEC_Private_Variables CEC Private Variables
  511. * @{
  512. */
  513. /**
  514. * @}
  515. */
  516. /* Private constants ---------------------------------------------------------*/
  517. /** @defgroup CEC_Private_Constants CEC Private Constants
  518. * @{
  519. */
  520. /**
  521. * @}
  522. */
  523. /* Private macros ------------------------------------------------------------*/
  524. /** @defgroup CEC_Private_Macros CEC Private Macros
  525. * @{
  526. */
  527. #define IS_CEC_SIGNALFREETIME(__SFT__) ((__SFT__) <= CEC_CFGR_SFT)
  528. #define IS_CEC_TOLERANCE(__RXTOL__) (((__RXTOL__) == CEC_STANDARD_TOLERANCE) || \
  529. ((__RXTOL__) == CEC_EXTENDED_TOLERANCE))
  530. #define IS_CEC_BRERXSTOP(__BRERXSTOP__) (((__BRERXSTOP__) == CEC_NO_RX_STOP_ON_BRE) || \
  531. ((__BRERXSTOP__) == CEC_RX_STOP_ON_BRE))
  532. #define IS_CEC_BREERRORBITGEN(__ERRORBITGEN__) (((__ERRORBITGEN__) == CEC_BRE_ERRORBIT_NO_GENERATION) || \
  533. ((__ERRORBITGEN__) == CEC_BRE_ERRORBIT_GENERATION))
  534. #define IS_CEC_LBPEERRORBITGEN(__ERRORBITGEN__) (((__ERRORBITGEN__) == CEC_LBPE_ERRORBIT_NO_GENERATION) || \
  535. ((__ERRORBITGEN__) == CEC_LBPE_ERRORBIT_GENERATION))
  536. #define IS_CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION(__ERRORBITGEN__) (((__ERRORBITGEN__) == CEC_BROADCASTERROR_ERRORBIT_GENERATION) || \
  537. ((__ERRORBITGEN__) == CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION))
  538. #define IS_CEC_SFTOP(__SFTOP__) (((__SFTOP__) == CEC_SFT_START_ON_TXSOM) || \
  539. ((__SFTOP__) == CEC_SFT_START_ON_TX_RX_END))
  540. #define IS_CEC_LISTENING_MODE(__MODE__) (((__MODE__) == CEC_REDUCED_LISTENING_MODE) || \
  541. ((__MODE__) == CEC_FULL_LISTENING_MODE))
  542. /** @brief Check CEC device Own Address Register (OAR) setting.
  543. * OAR address is written in a 15-bit field within CEC_CFGR register.
  544. * @param __ADDRESS__: CEC own address.
  545. * @retval Test result (TRUE or FALSE).
  546. */
  547. #define IS_CEC_OAR_ADDRESS(__ADDRESS__) ((__ADDRESS__) <= 0x07FFF)
  548. /** @brief Check CEC initiator or destination logical address setting.
  549. * Initiator and destination addresses are coded over 4 bits.
  550. * @param __ADDRESS__: CEC initiator or logical address.
  551. * @retval Test result (TRUE or FALSE).
  552. */
  553. #define IS_CEC_ADDRESS(__ADDRESS__) ((__ADDRESS__) <= 0xF)
  554. /** @brief Check CEC message size.
  555. * The message size is the payload size: without counting the header,
  556. * it varies from 0 byte (ping operation, one header only, no payload) to
  557. * 15 bytes (1 opcode and up to 14 operands following the header).
  558. * @param __SIZE__: CEC message size.
  559. * @retval Test result (TRUE or FALSE).
  560. */
  561. #define IS_CEC_MSGSIZE(__SIZE__) ((__SIZE__) <= 0xF)
  562. /**
  563. * @}
  564. */
  565. /* Private functions ---------------------------------------------------------*/
  566. /** @defgroup CEC_Private_Functions CEC Private Functions
  567. * @{
  568. */
  569. /**
  570. * @}
  571. */
  572. /**
  573. * @}
  574. */
  575. /**
  576. * @}
  577. */
  578. #endif /* STM32F446xx */
  579. #ifdef __cplusplus
  580. }
  581. #endif
  582. #endif /* __STM32F4xx_HAL_CEC_H */
  583. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/