stm32f4xx_cec.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_cec.h
  4. * @author MCD Application Team
  5. * @version V1.8.1
  6. * @date 27-January-2022
  7. * @brief This file contains all the functions prototypes for the CEC firmware
  8. * library, applicable only for STM32F466xx devices.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * Copyright (c) 2016 STMicroelectronics.
  13. * All rights reserved.
  14. *
  15. * This software is licensed under terms that can be found in the LICENSE file
  16. * in the root directory of this software component.
  17. * If no LICENSE file comes with this software, it is provided AS-IS.
  18. *
  19. ******************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __STM32F4XX_CEC_H
  23. #define __STM32F4XX_CEC_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f4xx.h"
  29. /** @addtogroup STM32F4xx_StdPeriph_Driver
  30. * @{
  31. */
  32. /** @addtogroup CEC
  33. * @{
  34. */
  35. #if defined(STM32F446xx)
  36. /* Exported types ------------------------------------------------------------*/
  37. /**
  38. * @brief CEC Init structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t CEC_SignalFreeTime; /*!< Specifies the CEC Signal Free Time configuration.
  43. This parameter can be a value of @ref CEC_Signal_Free_Time */
  44. uint32_t CEC_RxTolerance; /*!< Specifies the CEC Reception Tolerance.
  45. This parameter can be a value of @ref CEC_RxTolerance */
  46. uint32_t CEC_StopReception; /*!< Specifies the CEC Stop Reception.
  47. This parameter can be a value of @ref CEC_Stop_Reception */
  48. uint32_t CEC_BitRisingError; /*!< Specifies the CEC Bit Rising Error generation.
  49. This parameter can be a value of @ref CEC_Bit_Rising_Error_Generation */
  50. uint32_t CEC_LongBitPeriodError; /*!< Specifies the CEC Long Bit Error generation.
  51. This parameter can be a value of @ref CEC_Long_Bit_Error_Generation */
  52. uint32_t CEC_BRDNoGen; /*!< Specifies the CEC Broadcast Error generation.
  53. This parameter can be a value of @ref CEC_BDR_No_Gen */
  54. uint32_t CEC_SFTOption; /*!< Specifies the CEC Signal Free Time option.
  55. This parameter can be a value of @ref CEC_SFT_Option */
  56. }CEC_InitTypeDef;
  57. /* Exported constants --------------------------------------------------------*/
  58. /** @defgroup CEC_Exported_Constants
  59. * @{
  60. */
  61. /** @defgroup CEC_Signal_Free_Time
  62. * @{
  63. */
  64. #define CEC_SignalFreeTime_Standard ((uint32_t)0x00000000) /*!< CEC Signal Free Time Standard */
  65. #define CEC_SignalFreeTime_1T ((uint32_t)0x00000001) /*!< CEC 1.5 nominal data bit periods */
  66. #define CEC_SignalFreeTime_2T ((uint32_t)0x00000002) /*!< CEC 2.5 nominal data bit periods */
  67. #define CEC_SignalFreeTime_3T ((uint32_t)0x00000003) /*!< CEC 3.5 nominal data bit periods */
  68. #define CEC_SignalFreeTime_4T ((uint32_t)0x00000004) /*!< CEC 4.5 nominal data bit periods */
  69. #define CEC_SignalFreeTime_5T ((uint32_t)0x00000005) /*!< CEC 5.5 nominal data bit periods */
  70. #define CEC_SignalFreeTime_6T ((uint32_t)0x00000006) /*!< CEC 6.5 nominal data bit periods */
  71. #define CEC_SignalFreeTime_7T ((uint32_t)0x00000007) /*!< CEC 7.5 nominal data bit periods */
  72. #define IS_CEC_SIGNAL_FREE_TIME(TIME) (((TIME) == CEC_SignalFreeTime_Standard) || \
  73. ((TIME) == CEC_SignalFreeTime_1T)|| \
  74. ((TIME) == CEC_SignalFreeTime_2T)|| \
  75. ((TIME) == CEC_SignalFreeTime_3T)|| \
  76. ((TIME) == CEC_SignalFreeTime_4T)|| \
  77. ((TIME) == CEC_SignalFreeTime_5T)|| \
  78. ((TIME) == CEC_SignalFreeTime_6T)|| \
  79. ((TIME) == CEC_SignalFreeTime_7T))
  80. /**
  81. * @}
  82. */
  83. /** @defgroup CEC_RxTolerance
  84. * @{
  85. */
  86. #define CEC_RxTolerance_Standard ((uint32_t)0x00000000) /*!< Standard Tolerance Margin */
  87. #define CEC_RxTolerance_Extended CEC_CFGR_RXTOL /*!< Extended Tolerance Margin */
  88. #define IS_CEC_RX_TOLERANCE(TOLERANCE) (((TOLERANCE) == CEC_RxTolerance_Standard) || \
  89. ((TOLERANCE) == CEC_RxTolerance_Extended))
  90. /**
  91. * @}
  92. */
  93. /** @defgroup CEC_Stop_Reception
  94. * @{
  95. */
  96. #define CEC_StopReception_Off ((uint32_t)0x00000000) /*!< No RX Stop on bit Rising Error (BRE) */
  97. #define CEC_StopReception_On CEC_CFGR_BRESTP /*!< RX Stop on bit Rising Error (BRE) */
  98. #define IS_CEC_STOP_RECEPTION(RECEPTION) (((RECEPTION) == CEC_StopReception_On) || \
  99. ((RECEPTION) == CEC_StopReception_Off))
  100. /**
  101. * @}
  102. */
  103. /** @defgroup CEC_Bit_Rising_Error_Generation
  104. * @{
  105. */
  106. #define CEC_BitRisingError_Off ((uint32_t)0x00000000) /*!< Bit Rising Error generation turned Off */
  107. #define CEC_BitRisingError_On CEC_CFGR_BREGEN /*!< Bit Rising Error generation turned On */
  108. #define IS_CEC_BIT_RISING_ERROR(ERROR) (((ERROR) == CEC_BitRisingError_Off) || \
  109. ((ERROR) == CEC_BitRisingError_On))
  110. /**
  111. * @}
  112. */
  113. /** @defgroup CEC_Long_Bit_Error_Generation
  114. * @{
  115. */
  116. #define CEC_LongBitPeriodError_Off ((uint32_t)0x00000000) /*!< Long Bit Period Error generation turned Off */
  117. #define CEC_LongBitPeriodError_On CEC_CFGR_LREGEN /*!< Long Bit Period Error generation turned On */
  118. #define IS_CEC_LONG_BIT_PERIOD_ERROR(ERROR) (((ERROR) == CEC_LongBitPeriodError_Off) || \
  119. ((ERROR) == CEC_LongBitPeriodError_On))
  120. /**
  121. * @}
  122. */
  123. /** @defgroup CEC_BDR_No_Gen
  124. * @{
  125. */
  126. #define CEC_BRDNoGen_Off ((uint32_t)0x00000000) /*!< Broadcast Bit Rising Error generation turned Off */
  127. #define CEC_BRDNoGen_On CEC_CFGR_BRDNOGEN /*!< Broadcast Bit Rising Error generation turned On */
  128. #define IS_CEC_BDR_NO_GEN_ERROR(ERROR) (((ERROR) == CEC_BRDNoGen_Off) || \
  129. ((ERROR) == CEC_BRDNoGen_On))
  130. /**
  131. * @}
  132. */
  133. /** @defgroup CEC_SFT_Option
  134. * @{
  135. */
  136. #define CEC_SFTOption_Off ((uint32_t)0x00000000) /*!< SFT option turned Off */
  137. #define CEC_SFTOption_On CEC_CFGR_SFTOPT /*!< SFT option turned On */
  138. #define IS_CEC_SFT_OPTION(OPTION) (((OPTION) == CEC_SFTOption_Off) || \
  139. ((OPTION) == CEC_SFTOption_On))
  140. /**
  141. * @}
  142. */
  143. /** @defgroup CEC_Own_Address
  144. * @{
  145. */
  146. #define IS_CEC_ADDRESS(ADDRESS) ((ADDRESS) < 0x10)
  147. /**
  148. * @}
  149. */
  150. /** @defgroup CEC_Interrupt_Configuration_definition
  151. * @{
  152. */
  153. #define CEC_IT_TXACKE CEC_IER_TXACKEIE
  154. #define CEC_IT_TXERR CEC_IER_TXERRIE
  155. #define CEC_IT_TXUDR CEC_IER_TXUDRIE
  156. #define CEC_IT_TXEND CEC_IER_TXENDIE
  157. #define CEC_IT_TXBR CEC_IER_TXBRIE
  158. #define CEC_IT_ARBLST CEC_IER_ARBLSTIE
  159. #define CEC_IT_RXACKE CEC_IER_RXACKEIE
  160. #define CEC_IT_LBPE CEC_IER_LBPEIE
  161. #define CEC_IT_SBPE CEC_IER_SBPEIE
  162. #define CEC_IT_BRE CEC_IER_BREIEIE
  163. #define CEC_IT_RXOVR CEC_IER_RXOVRIE
  164. #define CEC_IT_RXEND CEC_IER_RXENDIE
  165. #define CEC_IT_RXBR CEC_IER_RXBRIE
  166. #define IS_CEC_IT(IT) ((((IT) & (uint32_t)0xFFFFE000) == 0x00) && ((IT) != 0x00))
  167. #define IS_CEC_GET_IT(IT) (((IT) == CEC_IT_TXACKE) || \
  168. ((IT) == CEC_IT_TXERR)|| \
  169. ((IT) == CEC_IT_TXUDR)|| \
  170. ((IT) == CEC_IT_TXEND)|| \
  171. ((IT) == CEC_IT_TXBR)|| \
  172. ((IT) == CEC_IT_ARBLST)|| \
  173. ((IT) == CEC_IT_RXACKE)|| \
  174. ((IT) == CEC_IT_LBPE)|| \
  175. ((IT) == CEC_IT_SBPE)|| \
  176. ((IT) == CEC_IT_BRE)|| \
  177. ((IT) == CEC_IT_RXOVR)|| \
  178. ((IT) == CEC_IT_RXEND)|| \
  179. ((IT) == CEC_IT_RXBR))
  180. /**
  181. * @}
  182. */
  183. /** @defgroup CEC_ISR_register_flags_definition
  184. * @{
  185. */
  186. #define CEC_FLAG_TXACKE CEC_ISR_TXACKE
  187. #define CEC_FLAG_TXERR CEC_ISR_TXERR
  188. #define CEC_FLAG_TXUDR CEC_ISR_TXUDR
  189. #define CEC_FLAG_TXEND CEC_ISR_TXEND
  190. #define CEC_FLAG_TXBR CEC_ISR_TXBR
  191. #define CEC_FLAG_ARBLST CEC_ISR_ARBLST
  192. #define CEC_FLAG_RXACKE CEC_ISR_RXACKE
  193. #define CEC_FLAG_LBPE CEC_ISR_LBPE
  194. #define CEC_FLAG_SBPE CEC_ISR_SBPE
  195. #define CEC_FLAG_BRE CEC_ISR_BRE
  196. #define CEC_FLAG_RXOVR CEC_ISR_RXOVR
  197. #define CEC_FLAG_RXEND CEC_ISR_RXEND
  198. #define CEC_FLAG_RXBR CEC_ISR_RXBR
  199. #define IS_CEC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFE000) == 0x00) && ((FLAG) != 0x00))
  200. #define IS_CEC_GET_FLAG(FLAG) (((FLAG) == CEC_FLAG_TXACKE) || \
  201. ((FLAG) == CEC_FLAG_TXERR)|| \
  202. ((FLAG) == CEC_FLAG_TXUDR)|| \
  203. ((FLAG) == CEC_FLAG_TXEND)|| \
  204. ((FLAG) == CEC_FLAG_TXBR)|| \
  205. ((FLAG) == CEC_FLAG_ARBLST)|| \
  206. ((FLAG) == CEC_FLAG_RXACKE)|| \
  207. ((FLAG) == CEC_FLAG_LBPE)|| \
  208. ((FLAG) == CEC_FLAG_SBPE)|| \
  209. ((FLAG) == CEC_FLAG_BRE)|| \
  210. ((FLAG) == CEC_FLAG_RXOVR)|| \
  211. ((FLAG) == CEC_FLAG_RXEND)|| \
  212. ((FLAG) == CEC_FLAG_RXBR))
  213. /**
  214. * @}
  215. */
  216. /**
  217. * @}
  218. */
  219. /* Exported macro ------------------------------------------------------------*/
  220. /* Exported functions ------------------------------------------------------- */
  221. /* Function used to set the CEC configuration to the default reset state *****/
  222. void CEC_DeInit(void);
  223. /* CEC_Initialization and Configuration functions *****************************/
  224. void CEC_Init(CEC_InitTypeDef* CEC_InitStruct);
  225. void CEC_StructInit(CEC_InitTypeDef* CEC_InitStruct);
  226. void CEC_Cmd(FunctionalState NewState);
  227. void CEC_ListenModeCmd(FunctionalState NewState);
  228. void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress);
  229. void CEC_OwnAddressClear(void);
  230. /* CEC_Data transfers functions ***********************************************/
  231. void CEC_SendData(uint8_t Data);
  232. uint8_t CEC_ReceiveData(void);
  233. void CEC_StartOfMessage(void);
  234. void CEC_EndOfMessage(void);
  235. /* CEC_Interrupts and flags management functions ******************************/
  236. void CEC_ITConfig(uint16_t CEC_IT, FunctionalState NewState);
  237. FlagStatus CEC_GetFlagStatus(uint16_t CEC_FLAG);
  238. void CEC_ClearFlag(uint32_t CEC_FLAG);
  239. ITStatus CEC_GetITStatus(uint16_t CEC_IT);
  240. void CEC_ClearITPendingBit(uint16_t CEC_IT);
  241. #endif /* STM32F446xx */
  242. /**
  243. * @}
  244. */
  245. /**
  246. * @}
  247. */
  248. #ifdef __cplusplus
  249. }
  250. #endif
  251. #endif /*__STM32F4xx_CEC_H */