stm32f10x_cec.h 6.3 KB

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