stm32f10x_cec.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /**
  2. ******************************************************************************
  3. * @file stm32f10x_cec.h
  4. * @author MCD Application Team
  5. * @version V3.5.0
  6. * @date 11-March-2011
  7. * @brief This file contains all the functions prototypes for the CEC firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  13. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  14. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  15. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  16. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  17. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  18. *
  19. * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  20. ******************************************************************************
  21. */
  22. /* Define to prevent recursive inclusion -------------------------------------*/
  23. #ifndef __STM32F10x_CEC_H
  24. #define __STM32F10x_CEC_H
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* Includes ------------------------------------------------------------------*/
  29. #include "stm32f10x.h"
  30. /** @addtogroup STM32F10x_StdPeriph_Driver
  31. * @{
  32. */
  33. /** @addtogroup CEC
  34. * @{
  35. */
  36. /** @defgroup CEC_Exported_Types
  37. * @{
  38. */
  39. /**
  40. * @brief CEC Init structure definition
  41. */
  42. typedef struct
  43. {
  44. uint16_t CEC_BitTimingMode; /*!< Configures the CEC Bit Timing Error Mode.
  45. This parameter can be a value of @ref CEC_BitTiming_Mode */
  46. uint16_t CEC_BitPeriodMode; /*!< Configures the CEC Bit Period Error Mode.
  47. This parameter can be a value of @ref CEC_BitPeriod_Mode */
  48. }CEC_InitTypeDef;
  49. /**
  50. * @}
  51. */
  52. /** @defgroup CEC_Exported_Constants
  53. * @{
  54. */
  55. /** @defgroup CEC_BitTiming_Mode
  56. * @{
  57. */
  58. #define CEC_BitTimingStdMode ((uint16_t)0x00) /*!< Bit timing error Standard Mode */
  59. #define CEC_BitTimingErrFreeMode CEC_CFGR_BTEM /*!< Bit timing error Free Mode */
  60. #define IS_CEC_BIT_TIMING_ERROR_MODE(MODE) (((MODE) == CEC_BitTimingStdMode) || \
  61. ((MODE) == CEC_BitTimingErrFreeMode))
  62. /**
  63. * @}
  64. */
  65. /** @defgroup CEC_BitPeriod_Mode
  66. * @{
  67. */
  68. #define CEC_BitPeriodStdMode ((uint16_t)0x00) /*!< Bit period error Standard Mode */
  69. #define CEC_BitPeriodFlexibleMode CEC_CFGR_BPEM /*!< Bit period error Flexible Mode */
  70. #define IS_CEC_BIT_PERIOD_ERROR_MODE(MODE) (((MODE) == CEC_BitPeriodStdMode) || \
  71. ((MODE) == CEC_BitPeriodFlexibleMode))
  72. /**
  73. * @}
  74. */
  75. /** @defgroup CEC_interrupts_definition
  76. * @{
  77. */
  78. #define CEC_IT_TERR CEC_CSR_TERR
  79. #define CEC_IT_TBTRF CEC_CSR_TBTRF
  80. #define CEC_IT_RERR CEC_CSR_RERR
  81. #define CEC_IT_RBTF CEC_CSR_RBTF
  82. #define IS_CEC_GET_IT(IT) (((IT) == CEC_IT_TERR) || ((IT) == CEC_IT_TBTRF) || \
  83. ((IT) == CEC_IT_RERR) || ((IT) == CEC_IT_RBTF))
  84. /**
  85. * @}
  86. */
  87. /** @defgroup CEC_Own_Address
  88. * @{
  89. */
  90. #define IS_CEC_ADDRESS(ADDRESS) ((ADDRESS) < 0x10)
  91. /**
  92. * @}
  93. */
  94. /** @defgroup CEC_Prescaler
  95. * @{
  96. */
  97. #define IS_CEC_PRESCALER(PRESCALER) ((PRESCALER) <= 0x3FFF)
  98. /**
  99. * @}
  100. */
  101. /** @defgroup CEC_flags_definition
  102. * @{
  103. */
  104. /**
  105. * @brief ESR register flags
  106. */
  107. #define CEC_FLAG_BTE ((uint32_t)0x10010000)
  108. #define CEC_FLAG_BPE ((uint32_t)0x10020000)
  109. #define CEC_FLAG_RBTFE ((uint32_t)0x10040000)
  110. #define CEC_FLAG_SBE ((uint32_t)0x10080000)
  111. #define CEC_FLAG_ACKE ((uint32_t)0x10100000)
  112. #define CEC_FLAG_LINE ((uint32_t)0x10200000)
  113. #define CEC_FLAG_TBTFE ((uint32_t)0x10400000)
  114. /**
  115. * @brief CSR register flags
  116. */
  117. #define CEC_FLAG_TEOM ((uint32_t)0x00000002)
  118. #define CEC_FLAG_TERR ((uint32_t)0x00000004)
  119. #define CEC_FLAG_TBTRF ((uint32_t)0x00000008)
  120. #define CEC_FLAG_RSOM ((uint32_t)0x00000010)
  121. #define CEC_FLAG_REOM ((uint32_t)0x00000020)
  122. #define CEC_FLAG_RERR ((uint32_t)0x00000040)
  123. #define CEC_FLAG_RBTF ((uint32_t)0x00000080)
  124. #define IS_CEC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFF03) == 0x00) && ((FLAG) != 0x00))
  125. #define IS_CEC_GET_FLAG(FLAG) (((FLAG) == CEC_FLAG_BTE) || ((FLAG) == CEC_FLAG_BPE) || \
  126. ((FLAG) == CEC_FLAG_RBTFE) || ((FLAG)== CEC_FLAG_SBE) || \
  127. ((FLAG) == CEC_FLAG_ACKE) || ((FLAG) == CEC_FLAG_LINE) || \
  128. ((FLAG) == CEC_FLAG_TBTFE) || ((FLAG) == CEC_FLAG_TEOM) || \
  129. ((FLAG) == CEC_FLAG_TERR) || ((FLAG) == CEC_FLAG_TBTRF) || \
  130. ((FLAG) == CEC_FLAG_RSOM) || ((FLAG) == CEC_FLAG_REOM) || \
  131. ((FLAG) == CEC_FLAG_RERR) || ((FLAG) == CEC_FLAG_RBTF))
  132. /**
  133. * @}
  134. */
  135. /**
  136. * @}
  137. */
  138. /** @defgroup CEC_Exported_Macros
  139. * @{
  140. */
  141. /**
  142. * @}
  143. */
  144. /** @defgroup CEC_Exported_Functions
  145. * @{
  146. */
  147. void CEC_DeInit(void);
  148. void CEC_Init(CEC_InitTypeDef* CEC_InitStruct);
  149. void CEC_Cmd(FunctionalState NewState);
  150. void CEC_ITConfig(FunctionalState NewState);
  151. void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress);
  152. void CEC_SetPrescaler(uint16_t CEC_Prescaler);
  153. void CEC_SendDataByte(uint8_t Data);
  154. uint8_t CEC_ReceiveDataByte(void);
  155. void CEC_StartOfMessage(void);
  156. void CEC_EndOfMessageCmd(FunctionalState NewState);
  157. FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG);
  158. void CEC_ClearFlag(uint32_t CEC_FLAG);
  159. ITStatus CEC_GetITStatus(uint8_t CEC_IT);
  160. void CEC_ClearITPendingBit(uint16_t CEC_IT);
  161. #ifdef __cplusplus
  162. }
  163. #endif
  164. #endif /* __STM32F10x_CEC_H */
  165. /**
  166. * @}
  167. */
  168. /**
  169. * @}
  170. */
  171. /**
  172. * @}
  173. */
  174. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/