1 /** 2 ****************************************************************************** 3 * @file stm32f4xx_cec.h 4 * @author MCD Application Team 5 * @version V1.5.1 6 * @date 22-May-2015 7 * @brief This file contains all the functions prototypes for the CEC firmware 8 * library, applicable only for STM32F466xx devices. 9 ****************************************************************************** 10 * @attention 11 * 12 * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2> 13 * 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 * You may not use this file except in compliance with the License. 16 * You may obtain a copy of the License at: 17 * 18 * http://www.st.com/software_license_agreement_liberty_v2 19 * 20 * Unless required by applicable law or agreed to in writing, software 21 * distributed under the License is distributed on an "AS IS" BASIS, 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 * See the License for the specific language governing permissions and 24 * limitations under the License. 25 * 26 ****************************************************************************** 27 */ 28 29 /* Define to prevent recursive inclusion -------------------------------------*/ 30 #ifndef __STM32F4XX_CEC_H 31 #define __STM32F4XX_CEC_H 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* Includes ------------------------------------------------------------------*/ 38 #include "stm32f4xx.h" 39 40 /** @addtogroup STM32F4xx_StdPeriph_Driver 41 * @{ 42 */ 43 44 /** @addtogroup CEC 45 * @{ 46 */ 47 #if defined(STM32F446xx) 48 /* Exported types ------------------------------------------------------------*/ 49 50 /** 51 * @brief CEC Init structure definition 52 */ 53 typedef struct 54 { 55 uint32_t CEC_SignalFreeTime; /*!< Specifies the CEC Signal Free Time configuration. 56 This parameter can be a value of @ref CEC_Signal_Free_Time */ 57 uint32_t CEC_RxTolerance; /*!< Specifies the CEC Reception Tolerance. 58 This parameter can be a value of @ref CEC_RxTolerance */ 59 uint32_t CEC_StopReception; /*!< Specifies the CEC Stop Reception. 60 This parameter can be a value of @ref CEC_Stop_Reception */ 61 uint32_t CEC_BitRisingError; /*!< Specifies the CEC Bit Rising Error generation. 62 This parameter can be a value of @ref CEC_Bit_Rising_Error_Generation */ 63 uint32_t CEC_LongBitPeriodError; /*!< Specifies the CEC Long Bit Error generation. 64 This parameter can be a value of @ref CEC_Long_Bit_Error_Generation */ 65 uint32_t CEC_BRDNoGen; /*!< Specifies the CEC Broadcast Error generation. 66 This parameter can be a value of @ref CEC_BDR_No_Gen */ 67 uint32_t CEC_SFTOption; /*!< Specifies the CEC Signal Free Time option. 68 This parameter can be a value of @ref CEC_SFT_Option */ 69 70 }CEC_InitTypeDef; 71 72 /* Exported constants --------------------------------------------------------*/ 73 74 /** @defgroup CEC_Exported_Constants 75 * @{ 76 */ 77 78 /** @defgroup CEC_Signal_Free_Time 79 * @{ 80 */ 81 #define CEC_SignalFreeTime_Standard ((uint32_t)0x00000000) /*!< CEC Signal Free Time Standard */ 82 #define CEC_SignalFreeTime_1T ((uint32_t)0x00000001) /*!< CEC 1.5 nominal data bit periods */ 83 #define CEC_SignalFreeTime_2T ((uint32_t)0x00000002) /*!< CEC 2.5 nominal data bit periods */ 84 #define CEC_SignalFreeTime_3T ((uint32_t)0x00000003) /*!< CEC 3.5 nominal data bit periods */ 85 #define CEC_SignalFreeTime_4T ((uint32_t)0x00000004) /*!< CEC 4.5 nominal data bit periods */ 86 #define CEC_SignalFreeTime_5T ((uint32_t)0x00000005) /*!< CEC 5.5 nominal data bit periods */ 87 #define CEC_SignalFreeTime_6T ((uint32_t)0x00000006) /*!< CEC 6.5 nominal data bit periods */ 88 #define CEC_SignalFreeTime_7T ((uint32_t)0x00000007) /*!< CEC 7.5 nominal data bit periods */ 89 90 #define IS_CEC_SIGNAL_FREE_TIME(TIME) (((TIME) == CEC_SignalFreeTime_Standard) || \ 91 ((TIME) == CEC_SignalFreeTime_1T)|| \ 92 ((TIME) == CEC_SignalFreeTime_2T)|| \ 93 ((TIME) == CEC_SignalFreeTime_3T)|| \ 94 ((TIME) == CEC_SignalFreeTime_4T)|| \ 95 ((TIME) == CEC_SignalFreeTime_5T)|| \ 96 ((TIME) == CEC_SignalFreeTime_6T)|| \ 97 ((TIME) == CEC_SignalFreeTime_7T)) 98 /** 99 * @} 100 */ 101 102 /** @defgroup CEC_RxTolerance 103 * @{ 104 */ 105 #define CEC_RxTolerance_Standard ((uint32_t)0x00000000) /*!< Standard Tolerance Margin */ 106 #define CEC_RxTolerance_Extended CEC_CFGR_RXTOL /*!< Extended Tolerance Margin */ 107 108 #define IS_CEC_RX_TOLERANCE(TOLERANCE) (((TOLERANCE) == CEC_RxTolerance_Standard) || \ 109 ((TOLERANCE) == CEC_RxTolerance_Extended)) 110 /** 111 * @} 112 */ 113 114 /** @defgroup CEC_Stop_Reception 115 * @{ 116 */ 117 #define CEC_StopReception_Off ((uint32_t)0x00000000) /*!< No RX Stop on bit Rising Error (BRE) */ 118 #define CEC_StopReception_On CEC_CFGR_BRESTP /*!< RX Stop on bit Rising Error (BRE) */ 119 120 #define IS_CEC_STOP_RECEPTION(RECEPTION) (((RECEPTION) == CEC_StopReception_On) || \ 121 ((RECEPTION) == CEC_StopReception_Off)) 122 /** 123 * @} 124 */ 125 126 /** @defgroup CEC_Bit_Rising_Error_Generation 127 * @{ 128 */ 129 #define CEC_BitRisingError_Off ((uint32_t)0x00000000) /*!< Bit Rising Error generation turned Off */ 130 #define CEC_BitRisingError_On CEC_CFGR_BREGEN /*!< Bit Rising Error generation turned On */ 131 132 #define IS_CEC_BIT_RISING_ERROR(ERROR) (((ERROR) == CEC_BitRisingError_Off) || \ 133 ((ERROR) == CEC_BitRisingError_On)) 134 /** 135 * @} 136 */ 137 138 /** @defgroup CEC_Long_Bit_Error_Generation 139 * @{ 140 */ 141 #define CEC_LongBitPeriodError_Off ((uint32_t)0x00000000) /*!< Long Bit Period Error generation turned Off */ 142 #define CEC_LongBitPeriodError_On CEC_CFGR_LREGEN /*!< Long Bit Period Error generation turned On */ 143 144 #define IS_CEC_LONG_BIT_PERIOD_ERROR(ERROR) (((ERROR) == CEC_LongBitPeriodError_Off) || \ 145 ((ERROR) == CEC_LongBitPeriodError_On)) 146 /** 147 * @} 148 */ 149 150 /** @defgroup CEC_BDR_No_Gen 151 * @{ 152 */ 153 154 #define CEC_BRDNoGen_Off ((uint32_t)0x00000000) /*!< Broadcast Bit Rising Error generation turned Off */ 155 #define CEC_BRDNoGen_On CEC_CFGR_BRDNOGEN /*!< Broadcast Bit Rising Error generation turned On */ 156 157 #define IS_CEC_BDR_NO_GEN_ERROR(ERROR) (((ERROR) == CEC_BRDNoGen_Off) || \ 158 ((ERROR) == CEC_BRDNoGen_On)) 159 /** 160 * @} 161 */ 162 163 /** @defgroup CEC_SFT_Option 164 * @{ 165 */ 166 #define CEC_SFTOption_Off ((uint32_t)0x00000000) /*!< SFT option turned Off */ 167 #define CEC_SFTOption_On CEC_CFGR_SFTOPT /*!< SFT option turned On */ 168 169 #define IS_CEC_SFT_OPTION(OPTION) (((OPTION) == CEC_SFTOption_Off) || \ 170 ((OPTION) == CEC_SFTOption_On)) 171 /** 172 * @} 173 */ 174 175 /** @defgroup CEC_Own_Address 176 * @{ 177 */ 178 #define IS_CEC_ADDRESS(ADDRESS) ((ADDRESS) < 0x10) 179 180 /** 181 * @} 182 */ 183 184 /** @defgroup CEC_Interrupt_Configuration_definition 185 * @{ 186 */ 187 #define CEC_IT_TXACKE CEC_IER_TXACKEIE 188 #define CEC_IT_TXERR CEC_IER_TXERRIE 189 #define CEC_IT_TXUDR CEC_IER_TXUDRIE 190 #define CEC_IT_TXEND CEC_IER_TXENDIE 191 #define CEC_IT_TXBR CEC_IER_TXBRIE 192 #define CEC_IT_ARBLST CEC_IER_ARBLSTIE 193 #define CEC_IT_RXACKE CEC_IER_RXACKEIE 194 #define CEC_IT_LBPE CEC_IER_LBPEIE 195 #define CEC_IT_SBPE CEC_IER_SBPEIE 196 #define CEC_IT_BRE CEC_IER_BREIEIE 197 #define CEC_IT_RXOVR CEC_IER_RXOVRIE 198 #define CEC_IT_RXEND CEC_IER_RXENDIE 199 #define CEC_IT_RXBR CEC_IER_RXBRIE 200 201 #define IS_CEC_IT(IT) ((((IT) & (uint32_t)0xFFFFE000) == 0x00) && ((IT) != 0x00)) 202 203 #define IS_CEC_GET_IT(IT) (((IT) == CEC_IT_TXACKE) || \ 204 ((IT) == CEC_IT_TXERR)|| \ 205 ((IT) == CEC_IT_TXUDR)|| \ 206 ((IT) == CEC_IT_TXEND)|| \ 207 ((IT) == CEC_IT_TXBR)|| \ 208 ((IT) == CEC_IT_ARBLST)|| \ 209 ((IT) == CEC_IT_RXACKE)|| \ 210 ((IT) == CEC_IT_LBPE)|| \ 211 ((IT) == CEC_IT_SBPE)|| \ 212 ((IT) == CEC_IT_BRE)|| \ 213 ((IT) == CEC_IT_RXOVR)|| \ 214 ((IT) == CEC_IT_RXEND)|| \ 215 ((IT) == CEC_IT_RXBR)) 216 /** 217 * @} 218 */ 219 220 /** @defgroup CEC_ISR_register_flags_definition 221 * @{ 222 */ 223 #define CEC_FLAG_TXACKE CEC_ISR_TXACKE 224 #define CEC_FLAG_TXERR CEC_ISR_TXERR 225 #define CEC_FLAG_TXUDR CEC_ISR_TXUDR 226 #define CEC_FLAG_TXEND CEC_ISR_TXEND 227 #define CEC_FLAG_TXBR CEC_ISR_TXBR 228 #define CEC_FLAG_ARBLST CEC_ISR_ARBLST 229 #define CEC_FLAG_RXACKE CEC_ISR_RXACKE 230 #define CEC_FLAG_LBPE CEC_ISR_LBPE 231 #define CEC_FLAG_SBPE CEC_ISR_SBPE 232 #define CEC_FLAG_BRE CEC_ISR_BRE 233 #define CEC_FLAG_RXOVR CEC_ISR_RXOVR 234 #define CEC_FLAG_RXEND CEC_ISR_RXEND 235 #define CEC_FLAG_RXBR CEC_ISR_RXBR 236 237 #define IS_CEC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFE000) == 0x00) && ((FLAG) != 0x00)) 238 239 #define IS_CEC_GET_FLAG(FLAG) (((FLAG) == CEC_FLAG_TXACKE) || \ 240 ((FLAG) == CEC_FLAG_TXERR)|| \ 241 ((FLAG) == CEC_FLAG_TXUDR)|| \ 242 ((FLAG) == CEC_FLAG_TXEND)|| \ 243 ((FLAG) == CEC_FLAG_TXBR)|| \ 244 ((FLAG) == CEC_FLAG_ARBLST)|| \ 245 ((FLAG) == CEC_FLAG_RXACKE)|| \ 246 ((FLAG) == CEC_FLAG_LBPE)|| \ 247 ((FLAG) == CEC_FLAG_SBPE)|| \ 248 ((FLAG) == CEC_FLAG_BRE)|| \ 249 ((FLAG) == CEC_FLAG_RXOVR)|| \ 250 ((FLAG) == CEC_FLAG_RXEND)|| \ 251 ((FLAG) == CEC_FLAG_RXBR)) 252 /** 253 * @} 254 */ 255 256 /** 257 * @} 258 */ 259 260 /* Exported macro ------------------------------------------------------------*/ 261 /* Exported functions ------------------------------------------------------- */ 262 263 /* Function used to set the CEC configuration to the default reset state *****/ 264 void CEC_DeInit(void); 265 266 /* CEC_Initialization and Configuration functions *****************************/ 267 void CEC_Init(CEC_InitTypeDef* CEC_InitStruct); 268 void CEC_StructInit(CEC_InitTypeDef* CEC_InitStruct); 269 void CEC_Cmd(FunctionalState NewState); 270 void CEC_ListenModeCmd(FunctionalState NewState); 271 void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress); 272 void CEC_OwnAddressClear(void); 273 274 /* CEC_Data transfers functions ***********************************************/ 275 void CEC_SendData(uint8_t Data); 276 uint8_t CEC_ReceiveData(void); 277 void CEC_StartOfMessage(void); 278 void CEC_EndOfMessage(void); 279 280 /* CEC_Interrupts and flags management functions ******************************/ 281 void CEC_ITConfig(uint16_t CEC_IT, FunctionalState NewState); 282 FlagStatus CEC_GetFlagStatus(uint16_t CEC_FLAG); 283 void CEC_ClearFlag(uint32_t CEC_FLAG); 284 ITStatus CEC_GetITStatus(uint16_t CEC_IT); 285 void CEC_ClearITPendingBit(uint16_t CEC_IT); 286 287 #endif /* STM32F446xx */ 288 /** 289 * @} 290 */ 291 292 /** 293 * @} 294 */ 295 296 #ifdef __cplusplus 297 } 298 #endif 299 300 #endif /* __STM32F4XX_CEC_H */ 301 302 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 303