apm32f0xx_cec.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*!
  2. * @file apm32f0xx_cec.h
  3. *
  4. * @brief This file contains all the functions prototypes for the CEC firmware library
  5. *
  6. * @version V1.0.3
  7. *
  8. * @date 2022-09-20
  9. *
  10. * @attention
  11. *
  12. * Copyright (C) 2020-2022 Geehy Semiconductor
  13. *
  14. * You may not use this file except in compliance with the
  15. * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
  16. *
  17. * The program is only for reference, which is distributed in the hope
  18. * that it will be useful and instructional for customers to develop
  19. * their software. Unless required by applicable law or agreed to in
  20. * writing, the program is distributed on an "AS IS" BASIS, WITHOUT
  21. * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
  23. * and limitations under the License.
  24. */
  25. /* Define to prevent recursive inclusion */
  26. #ifndef __APM32F0XX_CEC_H
  27. #define __APM32F0XX_CEC_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* Includes */
  32. #include "apm32f0xx.h"
  33. /** @addtogroup APM32F0xx_StdPeriphDriver
  34. @{
  35. */
  36. /** @addtogroup CEC_Driver
  37. @{
  38. */
  39. /** @defgroup CEC_Macros Macros
  40. @{
  41. */
  42. /**@} end of group CEC_Macros */
  43. /** @defgroup CEC_Enumerations Enumerations
  44. @{
  45. */
  46. /**
  47. * @brief CEC_Signal_Free_Time
  48. */
  49. typedef enum
  50. {
  51. CEC_SINGANL_FREETIME_STANDARD = 0x00, /*!< none nominal data bit periods */
  52. CEC_SINGANL_FREETIME_1T = 0x01, /*!< 0.5 nominal data bit periods */
  53. CEC_SINGANL_FREETIME_2T = 0x02, /*!< 1.5 nominal data bit periods */
  54. CEC_SINGANL_FREETIME_3T = 0x03, /*!< 2.5 nominal data bit periods */
  55. CEC_SINGANL_FREETIME_4T = 0x04, /*!< 3.5 nominal data bit periods */
  56. CEC_SINGANL_FREETIME_5T = 0x05, /*!< 4.5 nominal data bit periods */
  57. CEC_SINGANL_FREETIME_6T = 0x06, /*!< 5.5 nominal data bit periods */
  58. CEC_SINGANL_FREETIME_7T = 0x07, /*!< 6.5 nominal data bit periods */
  59. } CEC_SIGNAL_FREETIME_T;
  60. /**
  61. * @brief CEC_RxTolerance
  62. */
  63. typedef enum
  64. {
  65. CEC_RX_TOLERANCE_STANDARD = 0x00, /*!< Standard tolerance margin */
  66. CEC_RX_TOLERANCE_EXTENDED = 0x01 /*!< Extended Tolerance */
  67. } CEC_RX_TOLERANCE_T;
  68. /**
  69. * @brief CEC_Stop_Reception
  70. */
  71. typedef enum
  72. {
  73. CEC_STOP_RECEPTION_OFF, /*!< CEC Stop Reception Off */
  74. CEC_STOP_RECEPTION_ON /*!< CEC Stop Reception On */
  75. } CEC_STOP_RECEPTION_T;
  76. /**
  77. * @brief CEC_Bit_Rising_Error_Generation
  78. */
  79. typedef enum
  80. {
  81. CEC_BIT_RISING_ERR_OFF, /*!< BRE detection does not generate an Error-Bit on the CEC line */
  82. CEC_BIT_RISING_ERR_ON /*!< BRE detection generates an Error-Bit on the CEC line (if BRESTP is set) */
  83. } CEC_BIT_RISING_ERR_T;
  84. /**
  85. * @brief CEC_Long_Bit_Error_Generation
  86. */
  87. typedef enum
  88. {
  89. CEC_LONG_PERIOD_ERR_OFF, /*!< LBPE detection does not generate an Error-Bit on the CEC line */
  90. CEC_LONG_PERIOD_ERR_ON /*!< LBPE detection generates an Error-Bit on the CEC line */
  91. } CEC_LONG_PERIOD_ERR_T;
  92. /**
  93. * @brief CEC_BDR_No_Gen
  94. */
  95. typedef enum
  96. {
  97. CEC_BROADCAST_NO_ERR_OFF, /*!< Broadcast Bit Rising Error generation turned Off */
  98. CEC_BROADCAST_NO_ERR_ON /*!< Broadcast Bit Rising Error generation turned On */
  99. } CEC_BROADCAST_NO_ERR_T;
  100. /**
  101. * @brief CEC_SFT_Option
  102. */
  103. typedef enum
  104. {
  105. CEC_SIGNAL_FREETIME_OPTION_OFF, /*!< SFTCFG timer starts when TXSOM is set by software */
  106. CEC_SIGNAL_FREETIME_OPTION_ON /*!< SFTCFG timer starts automatically at the end of message transmission/reception */
  107. } CEC_SIGNAL_FREETIME_OPTION_T;
  108. /**
  109. * @brief CEC_Interrupt_Configuration_definition
  110. */
  111. typedef enum
  112. {
  113. CEC_INT_RXBR = ((uint32_t)0x00000001), /*!< Rx-Byte Received Interrupt */
  114. CEC_INT_RXEND = ((uint32_t)0x00000002), /*!< End Of Reception Interrupt */
  115. CEC_INT_RXOVR = ((uint32_t)0x00000004), /*!< Rx-Buffer Overrun Interrupt */
  116. CEC_INT_BRE = ((uint32_t)0x00000008), /*!< Bit Rising Error Interrupt */
  117. CEC_INT_SBPE = ((uint32_t)0x00000010), /*!< Short Bit Period Error Interrupt */
  118. CEC_INT_LBPE = ((uint32_t)0x00000020), /*!< Long Bit Period Error Interrupt */
  119. CEC_INT_RXACKE = ((uint32_t)0x00000040), /*!< Rx-Missing Acknowledge Error Interrupt */
  120. CEC_INT_ARBLST = ((uint32_t)0x00000080), /*!< Arbitration Lost Interrupt */
  121. CEC_INT_TXBR = ((uint32_t)0x00000100), /*!< Tx-Byte Request Interrupt */
  122. CEC_INT_TXEND = ((uint32_t)0x00000200), /*!< Tx-End Of Message Interrupt */
  123. CEC_INT_TXUDR = ((uint32_t)0x00000400), /*!< Tx-Underrun Interrupt */
  124. CEC_INT_TXERR = ((uint32_t)0x00000800), /*!< Tx-Error Interrupt */
  125. CEC_INT_TXACKE = ((uint32_t)0x00001000), /*!< Tx-Missing Acknowledge Error Interrupt */
  126. } CEC_INT_T;
  127. /**
  128. * @brief CEC_STS_register_flags_definition
  129. */
  130. typedef enum
  131. {
  132. CEC_FLAG_RXBR = ((uint32_t)0x00000001), /*!< Rx-Byte Received Flag */
  133. CEC_FLAG_RXEND = ((uint32_t)0x00000002), /*!< End Of Reception Flag */
  134. CEC_FLAG_RXOVR = ((uint32_t)0x00000004), /*!< Rx-Buffer Overrun Flag */
  135. CEC_FLAG_BRE = ((uint32_t)0x00000008), /*!< Bit Rising Error Flag */
  136. CEC_FLAG_SBPE = ((uint32_t)0x00000010), /*!< Short Bit Period Error Flag */
  137. CEC_FLAG_LBPE = ((uint32_t)0x00000020), /*!< Long Bit Period Error Flag */
  138. CEC_FLAG_RXACKE = ((uint32_t)0x00000040), /*!< Rx-Missing Acknowledge Error Flag */
  139. CEC_FLAG_ARBLST = ((uint32_t)0x00000080), /*!< Arbitration Lost Flag */
  140. CEC_FLAG_TXBR = ((uint32_t)0x00000100), /*!< Tx-Byte Request Flag */
  141. CEC_FLAG_TXEND = ((uint32_t)0x00000200), /*!< Tx-End Of Message Flag */
  142. CEC_FLAG_TXUDR = ((uint32_t)0x00000400), /*!< Tx-Underrun Flag */
  143. CEC_FLAG_TXERR = ((uint32_t)0x00000800), /*!< Tx-Error Flag */
  144. CEC_FLAG_TXACKE = ((uint32_t)0x00001000), /*!< Tx-Missing Acknowledge Error Flag */
  145. } CEC_FLAG_T;
  146. /**@} end of group CEC_Enumerations */
  147. /** @defgroup CEC_Structures Structures
  148. @{
  149. */
  150. /**
  151. * @brief CEC Init structure definition
  152. */
  153. typedef struct
  154. {
  155. CEC_SIGNAL_FREETIME_T signalFreeTime; /*!< Signal Free Time */
  156. CEC_RX_TOLERANCE_T RxTolerance; /*!< Rx-Tolerance */
  157. CEC_STOP_RECEPTION_T stopReception; /*!< Rx-Stop on Bit Rising Error */
  158. CEC_BIT_RISING_ERR_T bitRisingError; /*!< Generate Error-Bit on Bit Rising Error */
  159. CEC_LONG_PERIOD_ERR_T longPeriodError; /*!< Generate Error-Bit on Long Bit Period Error */
  160. CEC_BROADCAST_NO_ERR_T broadcastrNoGen; /*!< Avoid Error-Bit Generation in Broadcast */
  161. CEC_SIGNAL_FREETIME_OPTION_T signalFreeTimeOption;/*!< Signal Free Time optional */
  162. } CEC_Config_T;
  163. /**@} end of group CEC_Structures */
  164. /** @defgroup CEC_Variables Variables
  165. @{
  166. */
  167. /**@} end of group CEC_Variables */
  168. /** @defgroup CEC_Functions Functions
  169. @{
  170. */
  171. /* CEC reset and configuration */
  172. void CEC_Reset(void);
  173. void CEC_Config(CEC_Config_T* cecConfig);
  174. void CEC_ConfigStructInit(CEC_Config_T* cecConfig);
  175. void CEC_Enable(void);
  176. void CEC_Disable(void);
  177. void CEC_EnableListenMode(void);
  178. void CEC_DisableListenMode(void);
  179. void CEC_ConfigOwnAddress(uint8_t ownAddress);
  180. void CEC_ClearQwnAddress(void);
  181. /* Transmit and receive */
  182. void CEC_TxData(uint8_t Data);
  183. uint8_t CEC_RxData(void);
  184. /* Config Message */
  185. void CEC_StartNewMessage(void);
  186. void CEC_CompleteMessage(void);
  187. /* Interrupt and Flag*/
  188. void CEC_EnableInterrupt(uint32_t interrupt);
  189. void CEC_DisableInterrupt(uint32_t interrupt);
  190. uint8_t CEC_ReadStatusFlag(uint32_t flag);
  191. void CEC_ClearStatusFlag(uint32_t flag);
  192. uint8_t CEC_ReadIntFlag(uint16_t flag);
  193. void CEC_ClearIntFlag(uint16_t flag);
  194. #ifdef __cplusplus
  195. }
  196. #endif
  197. #endif /* __APM32F0XX_CEC_H */
  198. /**@} end of group CEC_Functions */
  199. /**@} end of group CEC_Driver */
  200. /**@} end of group APM32F0xx_StdPeriphDriver */