stm32f7xx_hal_cec.h 29 KB

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