stm32f4xx_cec.h 12 KB

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