1 /* Define to prevent recursive inclusion -------------------------------------*/ 2 #ifndef __AIR32F10x_CEC_H 3 #define __AIR32F10x_CEC_H 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 /* Includes ------------------------------------------------------------------*/ 10 #include "air32f10x.h" 11 12 /** @addtogroup air32f10x_StdPeriph_Driver 13 * @{ 14 */ 15 16 /** @addtogroup CEC 17 * @{ 18 */ 19 20 21 /** @defgroup CEC_Exported_Types 22 * @{ 23 */ 24 25 /** 26 * @brief CEC Init structure definition 27 */ 28 typedef struct 29 { 30 uint16_t CEC_BitTimingMode; /*!< Configures the CEC Bit Timing Error Mode. 31 This parameter can be a value of @ref CEC_BitTiming_Mode */ 32 uint16_t CEC_BitPeriodMode; /*!< Configures the CEC Bit Period Error Mode. 33 This parameter can be a value of @ref CEC_BitPeriod_Mode */ 34 }CEC_InitTypeDef; 35 36 /** 37 * @} 38 */ 39 40 /** @defgroup CEC_Exported_Constants 41 * @{ 42 */ 43 44 /** @defgroup CEC_BitTiming_Mode 45 * @{ 46 */ 47 #define CEC_BitTimingStdMode ((uint16_t)0x00) /*!< Bit timing error Standard Mode */ 48 #define CEC_BitTimingErrFreeMode CEC_CFGR_BTEM /*!< Bit timing error Free Mode */ 49 50 #define IS_CEC_BIT_TIMING_ERROR_MODE(MODE) (((MODE) == CEC_BitTimingStdMode) || \ 51 ((MODE) == CEC_BitTimingErrFreeMode)) 52 /** 53 * @} 54 */ 55 56 /** @defgroup CEC_BitPeriod_Mode 57 * @{ 58 */ 59 #define CEC_BitPeriodStdMode ((uint16_t)0x00) /*!< Bit period error Standard Mode */ 60 #define CEC_BitPeriodFlexibleMode CEC_CFGR_BPEM /*!< Bit period error Flexible Mode */ 61 62 #define IS_CEC_BIT_PERIOD_ERROR_MODE(MODE) (((MODE) == CEC_BitPeriodStdMode) || \ 63 ((MODE) == CEC_BitPeriodFlexibleMode)) 64 /** 65 * @} 66 */ 67 68 69 /** @defgroup CEC_interrupts_definition 70 * @{ 71 */ 72 #define CEC_IT_TERR CEC_CSR_TERR 73 #define CEC_IT_TBTRF CEC_CSR_TBTRF 74 #define CEC_IT_RERR CEC_CSR_RERR 75 #define CEC_IT_RBTF CEC_CSR_RBTF 76 #define IS_CEC_GET_IT(IT) (((IT) == CEC_IT_TERR) || ((IT) == CEC_IT_TBTRF) || \ 77 ((IT) == CEC_IT_RERR) || ((IT) == CEC_IT_RBTF)) 78 /** 79 * @} 80 */ 81 82 83 /** @defgroup CEC_Own_Address 84 * @{ 85 */ 86 #define IS_CEC_ADDRESS(ADDRESS) ((ADDRESS) < 0x10) 87 /** 88 * @} 89 */ 90 91 /** @defgroup CEC_Prescaler 92 * @{ 93 */ 94 #define IS_CEC_PRESCALER(PRESCALER) ((PRESCALER) <= 0x3FFF) 95 96 /** 97 * @} 98 */ 99 100 /** @defgroup CEC_flags_definition 101 * @{ 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 /** 116 * @brief CSR register flags 117 */ 118 #define CEC_FLAG_TEOM ((uint32_t)0x00000002) 119 #define CEC_FLAG_TERR ((uint32_t)0x00000004) 120 #define CEC_FLAG_TBTRF ((uint32_t)0x00000008) 121 #define CEC_FLAG_RSOM ((uint32_t)0x00000010) 122 #define CEC_FLAG_REOM ((uint32_t)0x00000020) 123 #define CEC_FLAG_RERR ((uint32_t)0x00000040) 124 #define CEC_FLAG_RBTF ((uint32_t)0x00000080) 125 126 #define IS_CEC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFF03) == 0x00) && ((FLAG) != 0x00)) 127 128 #define IS_CEC_GET_FLAG(FLAG) (((FLAG) == CEC_FLAG_BTE) || ((FLAG) == CEC_FLAG_BPE) || \ 129 ((FLAG) == CEC_FLAG_RBTFE) || ((FLAG)== CEC_FLAG_SBE) || \ 130 ((FLAG) == CEC_FLAG_ACKE) || ((FLAG) == CEC_FLAG_LINE) || \ 131 ((FLAG) == CEC_FLAG_TBTFE) || ((FLAG) == CEC_FLAG_TEOM) || \ 132 ((FLAG) == CEC_FLAG_TERR) || ((FLAG) == CEC_FLAG_TBTRF) || \ 133 ((FLAG) == CEC_FLAG_RSOM) || ((FLAG) == CEC_FLAG_REOM) || \ 134 ((FLAG) == CEC_FLAG_RERR) || ((FLAG) == CEC_FLAG_RBTF)) 135 136 /** 137 * @} 138 */ 139 140 /** 141 * @} 142 */ 143 144 /** @defgroup CEC_Exported_Macros 145 * @{ 146 */ 147 148 /** 149 * @} 150 */ 151 152 /** @defgroup CEC_Exported_Functions 153 * @{ 154 */ 155 void CEC_DeInit(void); 156 void CEC_Init(CEC_InitTypeDef* CEC_InitStruct); 157 void CEC_Cmd(FunctionalState NewState); 158 void CEC_ITConfig(FunctionalState NewState); 159 void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress); 160 void CEC_SetPrescaler(uint16_t CEC_Prescaler); 161 void CEC_SendDataByte(uint8_t Data); 162 uint8_t CEC_ReceiveDataByte(void); 163 void CEC_StartOfMessage(void); 164 void CEC_EndOfMessageCmd(FunctionalState NewState); 165 FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG); 166 void CEC_ClearFlag(uint32_t CEC_FLAG); 167 ITStatus CEC_GetITStatus(uint8_t CEC_IT); 168 void CEC_ClearITPendingBit(uint16_t CEC_IT); 169 170 #ifdef __cplusplus 171 } 172 #endif 173 174 #endif /* __AIR32F10x_CEC_H */ 175 176 /** 177 * @} 178 */ 179 180 /** 181 * @} 182 */ 183 184 /** 185 * @} 186 */ 187 188