1 /** 2 ****************************************************************************** 3 * @file stm32l4xx_hal_irda.h 4 * @author MCD Application Team 5 * @brief Header file of IRDA HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 10 * 11 * Redistribution and use in source and binary forms, with or without modification, 12 * are permitted provided that the following conditions are met: 13 * 1. Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 ****************************************************************************** 34 */ 35 36 /* Define to prevent recursive inclusion -------------------------------------*/ 37 #ifndef STM32L4xx_HAL_IRDA_H 38 #define STM32L4xx_HAL_IRDA_H 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* Includes ------------------------------------------------------------------*/ 45 #include "stm32l4xx_hal_def.h" 46 47 /** @addtogroup STM32L4xx_HAL_Driver 48 * @{ 49 */ 50 51 /** @addtogroup IRDA 52 * @{ 53 */ 54 55 /* Exported types ------------------------------------------------------------*/ 56 /** @defgroup IRDA_Exported_Types IRDA Exported Types 57 * @{ 58 */ 59 60 /** 61 * @brief IRDA Init Structure definition 62 */ 63 typedef struct 64 { 65 uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate. 66 The baud rate register is computed using the following formula: 67 Baud Rate Register = ((usart_ker_ckpres) / ((hirda->Init.BaudRate))) 68 where usart_ker_ckpres is the IRDA input clock divided by a prescaler */ 69 70 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. 71 This parameter can be a value of @ref IRDA_Word_Length */ 72 73 uint32_t Parity; /*!< Specifies the parity mode. 74 This parameter can be a value of @ref IRDA_Parity 75 @note When parity is enabled, the computed parity is inserted 76 at the MSB position of the transmitted data (9th bit when 77 the word length is set to 9 data bits; 8th bit when the 78 word length is set to 8 data bits). */ 79 80 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. 81 This parameter can be a value of @ref IRDA_Transfer_Mode */ 82 83 uint8_t Prescaler; /*!< Specifies the Prescaler value for dividing the UART/USART source clock 84 to achieve low-power frequency. 85 @note Prescaler value 0 is forbidden */ 86 87 uint16_t PowerMode; /*!< Specifies the IRDA power mode. 88 This parameter can be a value of @ref IRDA_Low_Power */ 89 90 #if defined(USART_PRESC_PRESCALER) 91 uint32_t ClockPrescaler; /*!< Specifies the prescaler value used to divide the IRDA clock source. 92 This parameter can be a value of @ref IRDA_ClockPrescaler. */ 93 #endif 94 95 } IRDA_InitTypeDef; 96 97 /** 98 * @brief HAL IRDA State definition 99 * @note HAL IRDA State value is a combination of 2 different substates: gState and RxState (see @ref IRDA_State_Definition). 100 * - gState contains IRDA state information related to global Handle management 101 * and also information related to Tx operations. 102 * gState value coding follow below described bitmap : 103 * b7-b6 Error information 104 * 00 : No Error 105 * 01 : (Not Used) 106 * 10 : Timeout 107 * 11 : Error 108 * b5 IP initilisation status 109 * 0 : Reset (IP not initialized) 110 * 1 : Init done (IP not initialized. HAL IRDA Init function already called) 111 * b4-b3 (not used) 112 * xx : Should be set to 00 113 * b2 Intrinsic process state 114 * 0 : Ready 115 * 1 : Busy (IP busy with some configuration or internal operations) 116 * b1 (not used) 117 * x : Should be set to 0 118 * b0 Tx state 119 * 0 : Ready (no Tx operation ongoing) 120 * 1 : Busy (Tx operation ongoing) 121 * - RxState contains information related to Rx operations. 122 * RxState value coding follow below described bitmap : 123 * b7-b6 (not used) 124 * xx : Should be set to 00 125 * b5 IP initilisation status 126 * 0 : Reset (IP not initialized) 127 * 1 : Init done (IP not initialized) 128 * b4-b2 (not used) 129 * xxx : Should be set to 000 130 * b1 Rx state 131 * 0 : Ready (no Rx operation ongoing) 132 * 1 : Busy (Rx operation ongoing) 133 * b0 (not used) 134 * x : Should be set to 0. 135 */ 136 typedef uint32_t HAL_IRDA_StateTypeDef; 137 138 /** 139 * @brief IRDA clock sources definition 140 */ 141 typedef enum 142 { 143 IRDA_CLOCKSOURCE_PCLK1 = 0x00U, /*!< PCLK1 clock source */ 144 IRDA_CLOCKSOURCE_PCLK2 = 0x01U, /*!< PCLK2 clock source */ 145 IRDA_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */ 146 IRDA_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */ 147 IRDA_CLOCKSOURCE_LSE = 0x10U, /*!< LSE clock source */ 148 IRDA_CLOCKSOURCE_UNDEFINED = 0x20U /*!< Undefined clock source */ 149 } IRDA_ClockSourceTypeDef; 150 151 /** 152 * @brief IRDA handle Structure definition 153 */ 154 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) 155 typedef struct __IRDA_HandleTypeDef 156 #else 157 typedef struct 158 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ 159 { 160 USART_TypeDef *Instance; /*!< USART registers base address */ 161 162 IRDA_InitTypeDef Init; /*!< IRDA communication parameters */ 163 164 uint8_t *pTxBuffPtr; /*!< Pointer to IRDA Tx transfer Buffer */ 165 166 uint16_t TxXferSize; /*!< IRDA Tx Transfer size */ 167 168 __IO uint16_t TxXferCount; /*!< IRDA Tx Transfer Counter */ 169 170 uint8_t *pRxBuffPtr; /*!< Pointer to IRDA Rx transfer Buffer */ 171 172 uint16_t RxXferSize; /*!< IRDA Rx Transfer size */ 173 174 __IO uint16_t RxXferCount; /*!< IRDA Rx Transfer Counter */ 175 176 uint16_t Mask; /*!< USART RX RDR register mask */ 177 178 DMA_HandleTypeDef *hdmatx; /*!< IRDA Tx DMA Handle parameters */ 179 180 DMA_HandleTypeDef *hdmarx; /*!< IRDA Rx DMA Handle parameters */ 181 182 HAL_LockTypeDef Lock; /*!< Locking object */ 183 184 __IO HAL_IRDA_StateTypeDef gState; /*!< IRDA state information related to global Handle management 185 and also related to Tx operations. 186 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */ 187 188 __IO HAL_IRDA_StateTypeDef RxState; /*!< IRDA state information related to Rx operations. 189 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */ 190 191 uint32_t ErrorCode; /*!< IRDA Error code */ 192 193 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) 194 void (* TxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Tx Half Complete Callback */ 195 196 void (* TxCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Tx Complete Callback */ 197 198 void (* RxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Rx Half Complete Callback */ 199 200 void (* RxCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Rx Complete Callback */ 201 202 void (* ErrorCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Error Callback */ 203 204 void (* AbortCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Complete Callback */ 205 206 void (* AbortTransmitCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Transmit Complete Callback */ 207 208 void (* AbortReceiveCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Receive Complete Callback */ 209 210 211 void (* MspInitCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Msp Init callback */ 212 213 void (* MspDeInitCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Msp DeInit callback */ 214 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ 215 216 } IRDA_HandleTypeDef; 217 218 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) 219 /** 220 * @brief HAL IRDA Callback ID enumeration definition 221 */ 222 typedef enum 223 { 224 HAL_IRDA_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< IRDA Tx Half Complete Callback ID */ 225 HAL_IRDA_TX_COMPLETE_CB_ID = 0x01U, /*!< IRDA Tx Complete Callback ID */ 226 HAL_IRDA_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< IRDA Rx Half Complete Callback ID */ 227 HAL_IRDA_RX_COMPLETE_CB_ID = 0x03U, /*!< IRDA Rx Complete Callback ID */ 228 HAL_IRDA_ERROR_CB_ID = 0x04U, /*!< IRDA Error Callback ID */ 229 HAL_IRDA_ABORT_COMPLETE_CB_ID = 0x05U, /*!< IRDA Abort Complete Callback ID */ 230 HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, /*!< IRDA Abort Transmit Complete Callback ID */ 231 HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U, /*!< IRDA Abort Receive Complete Callback ID */ 232 233 HAL_IRDA_MSPINIT_CB_ID = 0x08U, /*!< IRDA MspInit callback ID */ 234 HAL_IRDA_MSPDEINIT_CB_ID = 0x09U /*!< IRDA MspDeInit callback ID */ 235 236 } HAL_IRDA_CallbackIDTypeDef; 237 238 /** 239 * @brief HAL IRDA Callback pointer definition 240 */ 241 typedef void (*pIRDA_CallbackTypeDef)(IRDA_HandleTypeDef *hirda); /*!< pointer to an IRDA callback function */ 242 243 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ 244 245 /** 246 * @} 247 */ 248 249 /* Exported constants --------------------------------------------------------*/ 250 /** @defgroup IRDA_Exported_Constants IRDA Exported Constants 251 * @{ 252 */ 253 254 /** @defgroup IRDA_State_Definition IRDA State Code Definition 255 * @{ 256 */ 257 #define HAL_IRDA_STATE_RESET 0x00000000U /*!< Peripheral is not initialized 258 Value is allowed for gState and RxState */ 259 #define HAL_IRDA_STATE_READY 0x00000020U /*!< Peripheral Initialized and ready for use 260 Value is allowed for gState and RxState */ 261 #define HAL_IRDA_STATE_BUSY 0x00000024U /*!< An internal process is ongoing 262 Value is allowed for gState only */ 263 #define HAL_IRDA_STATE_BUSY_TX 0x00000021U /*!< Data Transmission process is ongoing 264 Value is allowed for gState only */ 265 #define HAL_IRDA_STATE_BUSY_RX 0x00000022U /*!< Data Reception process is ongoing 266 Value is allowed for RxState only */ 267 #define HAL_IRDA_STATE_BUSY_TX_RX 0x00000023U /*!< Data Transmission and Reception process is ongoing 268 Not to be used for neither gState nor RxState. 269 Value is result of combination (Or) between gState and RxState values */ 270 #define HAL_IRDA_STATE_TIMEOUT 0x000000A0U /*!< Timeout state 271 Value is allowed for gState only */ 272 #define HAL_IRDA_STATE_ERROR 0x000000E0U /*!< Error 273 Value is allowed for gState only */ 274 /** 275 * @} 276 */ 277 278 /** @defgroup IRDA_Error_Definition IRDA Error Code Definition 279 * @{ 280 */ 281 #define HAL_IRDA_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */ 282 #define HAL_IRDA_ERROR_PE ((uint32_t)0x00000001U) /*!< Parity error */ 283 #define HAL_IRDA_ERROR_NE ((uint32_t)0x00000002U) /*!< Noise error */ 284 #define HAL_IRDA_ERROR_FE ((uint32_t)0x00000004U) /*!< frame error */ 285 #define HAL_IRDA_ERROR_ORE ((uint32_t)0x00000008U) /*!< Overrun error */ 286 #define HAL_IRDA_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */ 287 #define HAL_IRDA_ERROR_BUSY ((uint32_t)0x00000020U) /*!< Busy Error */ 288 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) 289 #define HAL_IRDA_ERROR_INVALID_CALLBACK ((uint32_t)0x00000040U) /*!< Invalid Callback error */ 290 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ 291 /** 292 * @} 293 */ 294 295 /** @defgroup IRDA_Word_Length IRDA Word Length 296 * @{ 297 */ 298 #define IRDA_WORDLENGTH_7B USART_CR1_M1 /*!< 7-bit long frame */ 299 #define IRDA_WORDLENGTH_8B 0x00000000U /*!< 8-bit long frame */ 300 #define IRDA_WORDLENGTH_9B USART_CR1_M0 /*!< 9-bit long frame */ 301 /** 302 * @} 303 */ 304 305 /** @defgroup IRDA_Parity IRDA Parity 306 * @{ 307 */ 308 #define IRDA_PARITY_NONE 0x00000000U /*!< No parity */ 309 #define IRDA_PARITY_EVEN USART_CR1_PCE /*!< Even parity */ 310 #define IRDA_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Odd parity */ 311 /** 312 * @} 313 */ 314 315 /** @defgroup IRDA_Transfer_Mode IRDA Transfer Mode 316 * @{ 317 */ 318 #define IRDA_MODE_RX USART_CR1_RE /*!< RX mode */ 319 #define IRDA_MODE_TX USART_CR1_TE /*!< TX mode */ 320 #define IRDA_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< RX and TX mode */ 321 /** 322 * @} 323 */ 324 325 /** @defgroup IRDA_Low_Power IRDA Low Power 326 * @{ 327 */ 328 #define IRDA_POWERMODE_NORMAL 0x00000000U /*!< IRDA normal power mode */ 329 #define IRDA_POWERMODE_LOWPOWER USART_CR3_IRLP /*!< IRDA low power mode */ 330 /** 331 * @} 332 */ 333 334 #if defined(USART_PRESC_PRESCALER) 335 /** @defgroup IRDA_ClockPrescaler Clock Prescaler 336 * @{ 337 */ 338 #define IRDA_PRESCALER_DIV1 0x00000000U /*!< fclk_pres = fclk */ 339 #define IRDA_PRESCALER_DIV2 0x00000001U /*!< fclk_pres = fclk/2 */ 340 #define IRDA_PRESCALER_DIV4 0x00000002U /*!< fclk_pres = fclk/4 */ 341 #define IRDA_PRESCALER_DIV6 0x00000003U /*!< fclk_pres = fclk/6 */ 342 #define IRDA_PRESCALER_DIV8 0x00000004U /*!< fclk_pres = fclk/8 */ 343 #define IRDA_PRESCALER_DIV10 0x00000005U /*!< fclk_pres = fclk/10 */ 344 #define IRDA_PRESCALER_DIV12 0x00000006U /*!< fclk_pres = fclk/12 */ 345 #define IRDA_PRESCALER_DIV16 0x00000007U /*!< fclk_pres = fclk/16 */ 346 #define IRDA_PRESCALER_DIV32 0x00000008U /*!< fclk_pres = fclk/32 */ 347 #define IRDA_PRESCALER_DIV64 0x00000009U /*!< fclk_pres = fclk/64 */ 348 #define IRDA_PRESCALER_DIV128 0x0000000AU /*!< fclk_pres = fclk/128 */ 349 #define IRDA_PRESCALER_DIV256 0x0000000BU /*!< fclk_pres = fclk/256 */ 350 /** 351 * @} 352 */ 353 #endif 354 355 /** @defgroup IRDA_State IRDA State 356 * @{ 357 */ 358 #define IRDA_STATE_DISABLE 0x00000000U /*!< IRDA disabled */ 359 #define IRDA_STATE_ENABLE USART_CR1_UE /*!< IRDA enabled */ 360 /** 361 * @} 362 */ 363 364 /** @defgroup IRDA_Mode IRDA Mode 365 * @{ 366 */ 367 #define IRDA_MODE_DISABLE 0x00000000U /*!< Associated UART disabled in IRDA mode */ 368 #define IRDA_MODE_ENABLE USART_CR3_IREN /*!< Associated UART enabled in IRDA mode */ 369 /** 370 * @} 371 */ 372 373 /** @defgroup IRDA_One_Bit IRDA One Bit Sampling 374 * @{ 375 */ 376 #define IRDA_ONE_BIT_SAMPLE_DISABLE 0x00000000U /*!< One-bit sampling disabled */ 377 #define IRDA_ONE_BIT_SAMPLE_ENABLE USART_CR3_ONEBIT /*!< One-bit sampling enabled */ 378 /** 379 * @} 380 */ 381 382 /** @defgroup IRDA_DMA_Tx IRDA DMA Tx 383 * @{ 384 */ 385 #define IRDA_DMA_TX_DISABLE 0x00000000U /*!< IRDA DMA TX disabled */ 386 #define IRDA_DMA_TX_ENABLE USART_CR3_DMAT /*!< IRDA DMA TX enabled */ 387 /** 388 * @} 389 */ 390 391 /** @defgroup IRDA_DMA_Rx IRDA DMA Rx 392 * @{ 393 */ 394 #define IRDA_DMA_RX_DISABLE 0x00000000U /*!< IRDA DMA RX disabled */ 395 #define IRDA_DMA_RX_ENABLE USART_CR3_DMAR /*!< IRDA DMA RX enabled */ 396 /** 397 * @} 398 */ 399 400 /** @defgroup IRDA_Request_Parameters IRDA Request Parameters 401 * @{ 402 */ 403 #define IRDA_AUTOBAUD_REQUEST USART_RQR_ABRRQ /*!< Auto-Baud Rate Request */ 404 #define IRDA_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ /*!< Receive Data flush Request */ 405 #define IRDA_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ /*!< Transmit data flush Request */ 406 /** 407 * @} 408 */ 409 410 /** @defgroup IRDA_Flags IRDA Flags 411 * Elements values convention: 0xXXXX 412 * - 0xXXXX : Flag mask in the ISR register 413 * @{ 414 */ 415 #define IRDA_FLAG_REACK USART_ISR_REACK /*!< IRDA receive enable acknowledge flag */ 416 #define IRDA_FLAG_TEACK USART_ISR_TEACK /*!< IRDA transmit enable acknowledge flag */ 417 #define IRDA_FLAG_BUSY USART_ISR_BUSY /*!< IRDA busy flag */ 418 #define IRDA_FLAG_ABRF USART_ISR_ABRF /*!< IRDA auto Baud rate flag */ 419 #define IRDA_FLAG_ABRE USART_ISR_ABRE /*!< IRDA auto Baud rate error */ 420 #if defined(USART_CR1_FIFOEN) 421 #define IRDA_FLAG_TXE USART_ISR_TXE_TXFNF /*!< IRDA transmit data register empty */ 422 #else 423 #define IRDA_FLAG_TXE USART_ISR_TXE /*!< IRDA transmit data register empty */ 424 #endif 425 #define IRDA_FLAG_TC USART_ISR_TC /*!< IRDA transmission complete */ 426 #if defined(USART_CR1_FIFOEN) 427 #define IRDA_FLAG_RXNE USART_ISR_RXNE_RXFNE /*!< IRDA read data register not empty */ 428 #else 429 #define IRDA_FLAG_RXNE USART_ISR_RXNE /*!< IRDA read data register not empty */ 430 #endif 431 #define IRDA_FLAG_ORE USART_ISR_ORE /*!< IRDA overrun error */ 432 #define IRDA_FLAG_NE USART_ISR_NE /*!< IRDA noise error */ 433 #define IRDA_FLAG_FE USART_ISR_FE /*!< IRDA frame error */ 434 #define IRDA_FLAG_PE USART_ISR_PE /*!< IRDA parity error */ 435 /** 436 * @} 437 */ 438 439 /** @defgroup IRDA_Interrupt_definition IRDA Interrupts Definition 440 * Elements values convention: 0000ZZZZ0XXYYYYYb 441 * - YYYYY : Interrupt source position in the XX register (5bits) 442 * - XX : Interrupt source register (2bits) 443 * - 01: CR1 register 444 * - 10: CR2 register 445 * - 11: CR3 register 446 * - ZZZZ : Flag position in the ISR register(4bits) 447 * @{ 448 */ 449 #define IRDA_IT_PE 0x0028U /*!< IRDA Parity error interruption */ 450 #define IRDA_IT_TXE 0x0727U /*!< IRDA Transmit data register empty interruption */ 451 #define IRDA_IT_TC 0x0626U /*!< IRDA Transmission complete interruption */ 452 #define IRDA_IT_RXNE 0x0525U /*!< IRDA Read data register not empty interruption */ 453 #define IRDA_IT_IDLE 0x0424U /*!< IRDA Idle interruption */ 454 455 /* Elements values convention: 000000000XXYYYYYb 456 - YYYYY : Interrupt source position in the XX register (5bits) 457 - XX : Interrupt source register (2bits) 458 - 01: CR1 register 459 - 10: CR2 register 460 - 11: CR3 register */ 461 #define IRDA_IT_ERR 0x0060U /*!< IRDA Error interruption */ 462 463 /* Elements values convention: 0000ZZZZ00000000b 464 - ZZZZ : Flag position in the ISR register(4bits) */ 465 #define IRDA_IT_ORE 0x0300U /*!< IRDA Overrun error interruption */ 466 #define IRDA_IT_NE 0x0200U /*!< IRDA Noise error interruption */ 467 #define IRDA_IT_FE 0x0100U /*!< IRDA Frame error interruption */ 468 /** 469 * @} 470 */ 471 472 /** @defgroup IRDA_IT_CLEAR_Flags IRDA Interruption Clear Flags 473 * @{ 474 */ 475 #define IRDA_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */ 476 #define IRDA_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */ 477 #define IRDA_CLEAR_NEF USART_ICR_NECF /*!< Noise Error detected Clear Flag */ 478 #define IRDA_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */ 479 #define IRDA_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */ 480 #define IRDA_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */ 481 /** 482 * @} 483 */ 484 485 /** @defgroup IRDA_Interruption_Mask IRDA interruptions flags mask 486 * @{ 487 */ 488 #define IRDA_IT_MASK 0x001FU /*!< IRDA Interruptions flags mask */ 489 #define IRDA_CR_MASK 0x00E0U /*!< IRDA control register mask */ 490 #define IRDA_CR_POS 5U /*!< IRDA control register position */ 491 #define IRDA_ISR_MASK 0x1F00U /*!< IRDA ISR register mask */ 492 #define IRDA_ISR_POS 8U /*!< IRDA ISR register position */ 493 /** 494 * @} 495 */ 496 497 /** 498 * @} 499 */ 500 501 502 /* Exported macros -----------------------------------------------------------*/ 503 /** @defgroup IRDA_Exported_Macros IRDA Exported Macros 504 * @{ 505 */ 506 507 /** @brief Reset IRDA handle state. 508 * @param __HANDLE__ IRDA handle. 509 * @retval None 510 */ 511 #if USE_HAL_IRDA_REGISTER_CALLBACKS == 1 512 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \ 513 (__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \ 514 (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \ 515 (__HANDLE__)->MspInitCallback = NULL; \ 516 (__HANDLE__)->MspDeInitCallback = NULL; \ 517 } while(0) 518 #else 519 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \ 520 (__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \ 521 (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \ 522 } while(0) 523 #endif /*USE_HAL_IRDA_REGISTER_CALLBACKS */ 524 525 /** @brief Flush the IRDA DR register. 526 * @param __HANDLE__ specifies the IRDA Handle. 527 * @retval None 528 */ 529 #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) \ 530 do{ \ 531 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_RXDATA_FLUSH_REQUEST); \ 532 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_TXDATA_FLUSH_REQUEST); \ 533 } while(0) 534 535 /** @brief Clear the specified IRDA pending flag. 536 * @param __HANDLE__ specifies the IRDA Handle. 537 * @param __FLAG__ specifies the flag to check. 538 * This parameter can be any combination of the following values: 539 * @arg @ref IRDA_CLEAR_PEF 540 * @arg @ref IRDA_CLEAR_FEF 541 * @arg @ref IRDA_CLEAR_NEF 542 * @arg @ref IRDA_CLEAR_OREF 543 * @arg @ref IRDA_CLEAR_TCF 544 * @arg @ref IRDA_CLEAR_IDLEF 545 * @retval None 546 */ 547 #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) 548 549 /** @brief Clear the IRDA PE pending flag. 550 * @param __HANDLE__ specifies the IRDA Handle. 551 * @retval None 552 */ 553 #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_PEF) 554 555 556 /** @brief Clear the IRDA FE pending flag. 557 * @param __HANDLE__ specifies the IRDA Handle. 558 * @retval None 559 */ 560 #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_FEF) 561 562 /** @brief Clear the IRDA NE pending flag. 563 * @param __HANDLE__ specifies the IRDA Handle. 564 * @retval None 565 */ 566 #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_NEF) 567 568 /** @brief Clear the IRDA ORE pending flag. 569 * @param __HANDLE__ specifies the IRDA Handle. 570 * @retval None 571 */ 572 #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_OREF) 573 574 /** @brief Clear the IRDA IDLE pending flag. 575 * @param __HANDLE__ specifies the IRDA Handle. 576 * @retval None 577 */ 578 #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_IDLEF) 579 580 /** @brief Check whether the specified IRDA flag is set or not. 581 * @param __HANDLE__ specifies the IRDA Handle. 582 * @param __FLAG__ specifies the flag to check. 583 * This parameter can be one of the following values: 584 * @arg @ref IRDA_FLAG_REACK Receive enable acknowledge flag 585 * @arg @ref IRDA_FLAG_TEACK Transmit enable acknowledge flag 586 * @arg @ref IRDA_FLAG_BUSY Busy flag 587 * @arg @ref IRDA_FLAG_ABRF Auto Baud rate detection flag 588 * @arg @ref IRDA_FLAG_ABRE Auto Baud rate detection error flag 589 * @arg @ref IRDA_FLAG_TXE Transmit data register empty flag 590 * @arg @ref IRDA_FLAG_TC Transmission Complete flag 591 * @arg @ref IRDA_FLAG_RXNE Receive data register not empty flag 592 * @arg @ref IRDA_FLAG_ORE OverRun Error flag 593 * @arg @ref IRDA_FLAG_NE Noise Error flag 594 * @arg @ref IRDA_FLAG_FE Framing Error flag 595 * @arg @ref IRDA_FLAG_PE Parity Error flag 596 * @retval The new state of __FLAG__ (TRUE or FALSE). 597 */ 598 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) 599 600 601 /** @brief Enable the specified IRDA interrupt. 602 * @param __HANDLE__ specifies the IRDA Handle. 603 * @param __INTERRUPT__ specifies the IRDA interrupt source to enable. 604 * This parameter can be one of the following values: 605 * @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt 606 * @arg @ref IRDA_IT_TC Transmission complete interrupt 607 * @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt 608 * @arg @ref IRDA_IT_IDLE Idle line detection interrupt 609 * @arg @ref IRDA_IT_PE Parity Error interrupt 610 * @arg @ref IRDA_IT_ERR Error interrupt(Frame error, noise error, overrun error) 611 * @retval None 612 */ 613 #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 1)? ((__HANDLE__)->Instance->CR1 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \ 614 ((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 2)? ((__HANDLE__)->Instance->CR2 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \ 615 ((__HANDLE__)->Instance->CR3 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK)))) 616 617 /** @brief Disable the specified IRDA interrupt. 618 * @param __HANDLE__ specifies the IRDA Handle. 619 * @param __INTERRUPT__ specifies the IRDA interrupt source to disable. 620 * This parameter can be one of the following values: 621 * @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt 622 * @arg @ref IRDA_IT_TC Transmission complete interrupt 623 * @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt 624 * @arg @ref IRDA_IT_IDLE Idle line detection interrupt 625 * @arg @ref IRDA_IT_PE Parity Error interrupt 626 * @arg @ref IRDA_IT_ERR Error interrupt(Frame error, noise error, overrun error) 627 * @retval None 628 */ 629 #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \ 630 ((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \ 631 ((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK)))) 632 633 634 /** @brief Check whether the specified IRDA interrupt has occurred or not. 635 * @param __HANDLE__ specifies the IRDA Handle. 636 * @param __INTERRUPT__ specifies the IRDA interrupt source to check. 637 * This parameter can be one of the following values: 638 * @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt 639 * @arg @ref IRDA_IT_TC Transmission complete interrupt 640 * @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt 641 * @arg @ref IRDA_IT_IDLE Idle line detection interrupt 642 * @arg @ref IRDA_IT_ORE OverRun Error interrupt 643 * @arg @ref IRDA_IT_NE Noise Error interrupt 644 * @arg @ref IRDA_IT_FE Framing Error interrupt 645 * @arg @ref IRDA_IT_PE Parity Error interrupt 646 * @retval The new state of __IT__ (SET or RESET). 647 */ 648 #define __HAL_IRDA_GET_IT(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISR & (0x01U << (((__INTERRUPT__) & IRDA_ISR_MASK)>> IRDA_ISR_POS))) != 0U) ? SET : RESET) 649 650 /** @brief Check whether the specified IRDA interrupt source is enabled or not. 651 * @param __HANDLE__ specifies the IRDA Handle. 652 * @param __INTERRUPT__ specifies the IRDA interrupt source to check. 653 * This parameter can be one of the following values: 654 * @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt 655 * @arg @ref IRDA_IT_TC Transmission complete interrupt 656 * @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt 657 * @arg @ref IRDA_IT_IDLE Idle line detection interrupt 658 * @arg @ref IRDA_IT_ERR Framing, overrun or noise error interrupt 659 * @arg @ref IRDA_IT_PE Parity Error interrupt 660 * @retval The new state of __IT__ (SET or RESET). 661 */ 662 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 0x01U)? (__HANDLE__)->Instance->CR1 : \ 663 (((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 0x02U)? (__HANDLE__)->Instance->CR2 : \ 664 (__HANDLE__)->Instance->CR3)) & ((uint32_t)0x01U << (((uint16_t)(__INTERRUPT__)) & IRDA_IT_MASK))) != 0U) ? SET : RESET) 665 666 /** @brief Clear the specified IRDA ISR flag, in setting the proper ICR register flag. 667 * @param __HANDLE__ specifies the IRDA Handle. 668 * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set 669 * to clear the corresponding interrupt 670 * This parameter can be one of the following values: 671 * @arg @ref IRDA_CLEAR_PEF Parity Error Clear Flag 672 * @arg @ref IRDA_CLEAR_FEF Framing Error Clear Flag 673 * @arg @ref IRDA_CLEAR_NEF Noise detected Clear Flag 674 * @arg @ref IRDA_CLEAR_OREF OverRun Error Clear Flag 675 * @arg @ref IRDA_CLEAR_TCF Transmission Complete Clear Flag 676 * @retval None 677 */ 678 #define __HAL_IRDA_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) 679 680 681 /** @brief Set a specific IRDA request flag. 682 * @param __HANDLE__ specifies the IRDA Handle. 683 * @param __REQ__ specifies the request flag to set 684 * This parameter can be one of the following values: 685 * @arg @ref IRDA_AUTOBAUD_REQUEST Auto-Baud Rate Request 686 * @arg @ref IRDA_RXDATA_FLUSH_REQUEST Receive Data flush Request 687 * @arg @ref IRDA_TXDATA_FLUSH_REQUEST Transmit data flush Request 688 * 689 * @retval None 690 */ 691 #define __HAL_IRDA_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__)) 692 693 /** @brief Enable the IRDA one bit sample method. 694 * @param __HANDLE__ specifies the IRDA Handle. 695 * @retval None 696 */ 697 #define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) 698 699 /** @brief Disable the IRDA one bit sample method. 700 * @param __HANDLE__ specifies the IRDA Handle. 701 * @retval None 702 */ 703 #define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT)) 704 705 /** @brief Enable UART/USART associated to IRDA Handle. 706 * @param __HANDLE__ specifies the IRDA Handle. 707 * @retval None 708 */ 709 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) 710 711 /** @brief Disable UART/USART associated to IRDA Handle. 712 * @param __HANDLE__ specifies the IRDA Handle. 713 * @retval None 714 */ 715 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) 716 717 /** 718 * @} 719 */ 720 721 /* Private macros --------------------------------------------------------*/ 722 /** @addtogroup IRDA_Private_Macros 723 * @{ 724 */ 725 726 /** @brief Compute the mask to apply to retrieve the received data 727 * according to the word length and to the parity bits activation. 728 * @param __HANDLE__ specifies the IRDA Handle. 729 * @retval None, the mask to apply to the associated UART RDR register is stored in (__HANDLE__)->Mask field. 730 */ 731 #define IRDA_MASK_COMPUTATION(__HANDLE__) \ 732 do { \ 733 if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B) \ 734 { \ 735 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ 736 { \ 737 (__HANDLE__)->Mask = 0x01FF ; \ 738 } \ 739 else \ 740 { \ 741 (__HANDLE__)->Mask = 0x00FF ; \ 742 } \ 743 } \ 744 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B) \ 745 { \ 746 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ 747 { \ 748 (__HANDLE__)->Mask = 0x00FF ; \ 749 } \ 750 else \ 751 { \ 752 (__HANDLE__)->Mask = 0x007F ; \ 753 } \ 754 } \ 755 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_7B) \ 756 { \ 757 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ 758 { \ 759 (__HANDLE__)->Mask = 0x007F ; \ 760 } \ 761 else \ 762 { \ 763 (__HANDLE__)->Mask = 0x003F ; \ 764 } \ 765 } \ 766 else \ 767 { \ 768 (__HANDLE__)->Mask = 0x0000U; \ 769 } \ 770 } while(0) 771 772 /** @brief Ensure that IRDA Baud rate is less or equal to maximum value. 773 * @param __BAUDRATE__ specifies the IRDA Baudrate set by the user. 774 * @retval True or False 775 */ 776 #define IS_IRDA_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 115201U) 777 778 /** @brief Ensure that IRDA prescaler value is strictly larger than 0. 779 * @param __PRESCALER__ specifies the IRDA prescaler value set by the user. 780 * @retval True or False 781 */ 782 #define IS_IRDA_PRESCALER(__PRESCALER__) ((__PRESCALER__) > 0U) 783 784 /** 785 * @brief Ensure that IRDA frame length is valid. 786 * @param __LENGTH__ IRDA frame length. 787 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid) 788 */ 789 #define IS_IRDA_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == IRDA_WORDLENGTH_7B) || \ 790 ((__LENGTH__) == IRDA_WORDLENGTH_8B) || \ 791 ((__LENGTH__) == IRDA_WORDLENGTH_9B)) 792 793 /** 794 * @brief Ensure that IRDA frame parity is valid. 795 * @param __PARITY__ IRDA frame parity. 796 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid) 797 */ 798 #define IS_IRDA_PARITY(__PARITY__) (((__PARITY__) == IRDA_PARITY_NONE) || \ 799 ((__PARITY__) == IRDA_PARITY_EVEN) || \ 800 ((__PARITY__) == IRDA_PARITY_ODD)) 801 802 /** 803 * @brief Ensure that IRDA communication mode is valid. 804 * @param __MODE__ IRDA communication mode. 805 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) 806 */ 807 #define IS_IRDA_TX_RX_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(IRDA_MODE_TX_RX)))) == 0x00U) && ((__MODE__) != 0x00U)) 808 809 /** 810 * @brief Ensure that IRDA power mode is valid. 811 * @param __MODE__ IRDA power mode. 812 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) 813 */ 814 #define IS_IRDA_POWERMODE(__MODE__) (((__MODE__) == IRDA_POWERMODE_LOWPOWER) || \ 815 ((__MODE__) == IRDA_POWERMODE_NORMAL)) 816 817 #if defined(USART_PRESC_PRESCALER) 818 /** 819 * @brief Ensure that IRDA clock Prescaler is valid. 820 * @param __CLOCKPRESCALER__ IRDA clock Prescaler value. 821 * @retval SET (__CLOCKPRESCALER__ is valid) or RESET (__CLOCKPRESCALER__ is invalid) 822 */ 823 #define IS_IRDA_CLOCKPRESCALER(__CLOCKPRESCALER__) (((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV1) || \ 824 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV2) || \ 825 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV4) || \ 826 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV6) || \ 827 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV8) || \ 828 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV10) || \ 829 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV12) || \ 830 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV16) || \ 831 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV32) || \ 832 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV64) || \ 833 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV128) || \ 834 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV256)) 835 #endif 836 837 /** 838 * @brief Ensure that IRDA state is valid. 839 * @param __STATE__ IRDA state mode. 840 * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid) 841 */ 842 #define IS_IRDA_STATE(__STATE__) (((__STATE__) == IRDA_STATE_DISABLE) || \ 843 ((__STATE__) == IRDA_STATE_ENABLE)) 844 845 /** 846 * @brief Ensure that IRDA associated UART/USART mode is valid. 847 * @param __MODE__ IRDA associated UART/USART mode. 848 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) 849 */ 850 #define IS_IRDA_MODE(__MODE__) (((__MODE__) == IRDA_MODE_DISABLE) || \ 851 ((__MODE__) == IRDA_MODE_ENABLE)) 852 853 /** 854 * @brief Ensure that IRDA sampling rate is valid. 855 * @param __ONEBIT__ IRDA sampling rate. 856 * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid) 857 */ 858 #define IS_IRDA_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_DISABLE) || \ 859 ((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_ENABLE)) 860 861 /** 862 * @brief Ensure that IRDA DMA TX mode is valid. 863 * @param __DMATX__ IRDA DMA TX mode. 864 * @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid) 865 */ 866 #define IS_IRDA_DMA_TX(__DMATX__) (((__DMATX__) == IRDA_DMA_TX_DISABLE) || \ 867 ((__DMATX__) == IRDA_DMA_TX_ENABLE)) 868 869 /** 870 * @brief Ensure that IRDA DMA RX mode is valid. 871 * @param __DMARX__ IRDA DMA RX mode. 872 * @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid) 873 */ 874 #define IS_IRDA_DMA_RX(__DMARX__) (((__DMARX__) == IRDA_DMA_RX_DISABLE) || \ 875 ((__DMARX__) == IRDA_DMA_RX_ENABLE)) 876 877 /** 878 * @brief Ensure that IRDA request is valid. 879 * @param __PARAM__ IRDA request. 880 * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid) 881 */ 882 #define IS_IRDA_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == IRDA_AUTOBAUD_REQUEST) || \ 883 ((__PARAM__) == IRDA_RXDATA_FLUSH_REQUEST) || \ 884 ((__PARAM__) == IRDA_TXDATA_FLUSH_REQUEST)) 885 /** 886 * @} 887 */ 888 889 /* Include IRDA HAL Extended module */ 890 #include "stm32l4xx_hal_irda_ex.h" 891 892 /* Exported functions --------------------------------------------------------*/ 893 /** @addtogroup IRDA_Exported_Functions IRDA Exported Functions 894 * @{ 895 */ 896 897 /** @addtogroup IRDA_Exported_Functions_Group1 Initialization and de-initialization functions 898 * @{ 899 */ 900 901 /* Initialization and de-initialization functions ****************************/ 902 HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda); 903 HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda); 904 void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda); 905 void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda); 906 907 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) 908 /* Callbacks Register/UnRegister functions ***********************************/ 909 HAL_StatusTypeDef HAL_IRDA_RegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID, pIRDA_CallbackTypeDef pCallback); 910 HAL_StatusTypeDef HAL_IRDA_UnRegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID); 911 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ 912 913 /** 914 * @} 915 */ 916 917 /** @addtogroup IRDA_Exported_Functions_Group2 IO operation functions 918 * @{ 919 */ 920 921 /* IO operation functions *****************************************************/ 922 HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); 923 HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); 924 HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); 925 HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); 926 HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); 927 HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); 928 HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda); 929 HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda); 930 HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda); 931 /* Transfer Abort functions */ 932 HAL_StatusTypeDef HAL_IRDA_Abort(IRDA_HandleTypeDef *hirda); 933 HAL_StatusTypeDef HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef *hirda); 934 HAL_StatusTypeDef HAL_IRDA_AbortReceive(IRDA_HandleTypeDef *hirda); 935 HAL_StatusTypeDef HAL_IRDA_Abort_IT(IRDA_HandleTypeDef *hirda); 936 HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef *hirda); 937 HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef *hirda); 938 939 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda); 940 void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda); 941 void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda); 942 void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda); 943 void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda); 944 void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda); 945 void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda); 946 void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda); 947 void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda); 948 949 /** 950 * @} 951 */ 952 953 /* Peripheral Control functions ************************************************/ 954 955 /** @addtogroup IRDA_Exported_Functions_Group4 Peripheral State and Error functions 956 * @{ 957 */ 958 959 /* Peripheral State and Error functions ***************************************/ 960 HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda); 961 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda); 962 963 /** 964 * @} 965 */ 966 967 /** 968 * @} 969 */ 970 971 /** 972 * @} 973 */ 974 975 /** 976 * @} 977 */ 978 979 #ifdef __cplusplus 980 } 981 #endif 982 983 #endif /* STM32L4xx_HAL_IRDA_H */ 984 985 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 986