stm32f0xx_cec.h 12 KB

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