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