Merge pull request #11270 from haslinghuis/rename_attr
[betaflight.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Inc / stm32h7xx_hal_irda.h
blob1a82ca01b429211f3d044f60818a8eeeaa48d8d7
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_hal_irda.h
4 * @author MCD Application Team
5 * @brief Header file of IRDA HAL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32H7xx_HAL_IRDA_H
22 #define STM32H7xx_HAL_IRDA_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32h7xx_hal_def.h"
31 /** @addtogroup STM32H7xx_HAL_Driver
32 * @{
35 /** @addtogroup IRDA
36 * @{
39 /* Exported types ------------------------------------------------------------*/
40 /** @defgroup IRDA_Exported_Types IRDA Exported Types
41 * @{
44 /**
45 * @brief IRDA Init Structure definition
47 typedef struct
49 uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate.
50 The baud rate register is computed using the following formula:
51 Baud Rate Register = ((usart_ker_ckpres) / ((hirda->Init.BaudRate)))
52 where usart_ker_ckpres is the IRDA input clock divided by a prescaler */
54 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
55 This parameter can be a value of @ref IRDAEx_Word_Length */
57 uint32_t Parity; /*!< Specifies the parity mode.
58 This parameter can be a value of @ref IRDA_Parity
59 @note When parity is enabled, the computed parity is inserted
60 at the MSB position of the transmitted data (9th bit when
61 the word length is set to 9 data bits; 8th bit when the
62 word length is set to 8 data bits). */
64 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
65 This parameter can be a value of @ref IRDA_Transfer_Mode */
67 uint8_t Prescaler; /*!< Specifies the Prescaler value for dividing the UART/USART source clock
68 to achieve low-power frequency.
69 @note Prescaler value 0 is forbidden */
71 uint16_t PowerMode; /*!< Specifies the IRDA power mode.
72 This parameter can be a value of @ref IRDA_Low_Power */
74 uint32_t ClockPrescaler; /*!< Specifies the prescaler value used to divide the IRDA clock source.
75 This parameter can be a value of @ref IRDA_ClockPrescaler. */
77 } IRDA_InitTypeDef;
79 /**
80 * @brief HAL IRDA State definition
81 * @note HAL IRDA State value is a combination of 2 different substates: gState and RxState (see @ref IRDA_State_Definition).
82 * - gState contains IRDA state information related to global Handle management
83 * and also information related to Tx operations.
84 * gState value coding follow below described bitmap :
85 * b7-b6 Error information
86 * 00 : No Error
87 * 01 : (Not Used)
88 * 10 : Timeout
89 * 11 : Error
90 * b5 Peripheral initialization status
91 * 0 : Reset (Peripheral not initialized)
92 * 1 : Init done (Peripheral not initialized. HAL IRDA Init function already called)
93 * b4-b3 (not used)
94 * xx : Should be set to 00
95 * b2 Intrinsic process state
96 * 0 : Ready
97 * 1 : Busy (Peripheral busy with some configuration or internal operations)
98 * b1 (not used)
99 * x : Should be set to 0
100 * b0 Tx state
101 * 0 : Ready (no Tx operation ongoing)
102 * 1 : Busy (Tx operation ongoing)
103 * - RxState contains information related to Rx operations.
104 * RxState value coding follow below described bitmap :
105 * b7-b6 (not used)
106 * xx : Should be set to 00
107 * b5 Peripheral initialization status
108 * 0 : Reset (Peripheral not initialized)
109 * 1 : Init done (Peripheral not initialized)
110 * b4-b2 (not used)
111 * xxx : Should be set to 000
112 * b1 Rx state
113 * 0 : Ready (no Rx operation ongoing)
114 * 1 : Busy (Rx operation ongoing)
115 * b0 (not used)
116 * x : Should be set to 0.
118 typedef uint32_t HAL_IRDA_StateTypeDef;
121 * @brief IRDA clock sources definition
123 typedef enum
125 IRDA_CLOCKSOURCE_D2PCLK1 = 0x11U, /*!< Domain2 PCLK1 clock source */
126 IRDA_CLOCKSOURCE_D2PCLK2 = 0x12U, /*!< Domain2 PCLK2 clock source */
127 IRDA_CLOCKSOURCE_PLL2Q = 0x14U, /*!< PLL2Q clock source */
128 IRDA_CLOCKSOURCE_PLL3Q = 0x18U, /*!< PCLK2 clock source */
129 IRDA_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */
130 IRDA_CLOCKSOURCE_CSI = 0x08U, /*!< CSI clock source */
131 IRDA_CLOCKSOURCE_LSE = 0x10U, /*!< LSE clock source */
132 IRDA_CLOCKSOURCE_UNDEFINED = 0x20U /*!< Undefined clock source */
133 } IRDA_ClockSourceTypeDef;
136 * @brief IRDA handle Structure definition
138 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
139 typedef struct __IRDA_HandleTypeDef
140 #else
141 typedef struct
142 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
144 USART_TypeDef *Instance; /*!< USART registers base address */
146 IRDA_InitTypeDef Init; /*!< IRDA communication parameters */
148 uint8_t *pTxBuffPtr; /*!< Pointer to IRDA Tx transfer Buffer */
150 uint16_t TxXferSize; /*!< IRDA Tx Transfer size */
152 __IO uint16_t TxXferCount; /*!< IRDA Tx Transfer Counter */
154 uint8_t *pRxBuffPtr; /*!< Pointer to IRDA Rx transfer Buffer */
156 uint16_t RxXferSize; /*!< IRDA Rx Transfer size */
158 __IO uint16_t RxXferCount; /*!< IRDA Rx Transfer Counter */
160 uint16_t Mask; /*!< USART RX RDR register mask */
162 DMA_HandleTypeDef *hdmatx; /*!< IRDA Tx DMA Handle parameters */
164 DMA_HandleTypeDef *hdmarx; /*!< IRDA Rx DMA Handle parameters */
166 HAL_LockTypeDef Lock; /*!< Locking object */
168 __IO HAL_IRDA_StateTypeDef gState; /*!< IRDA state information related to global Handle management
169 and also related to Tx operations.
170 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
172 __IO HAL_IRDA_StateTypeDef RxState; /*!< IRDA state information related to Rx operations.
173 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
175 __IO uint32_t ErrorCode; /*!< IRDA Error code */
177 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
178 void (* TxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Tx Half Complete Callback */
180 void (* TxCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Tx Complete Callback */
182 void (* RxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Rx Half Complete Callback */
184 void (* RxCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Rx Complete Callback */
186 void (* ErrorCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Error Callback */
188 void (* AbortCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Complete Callback */
190 void (* AbortTransmitCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Transmit Complete Callback */
192 void (* AbortReceiveCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Receive Complete Callback */
195 void (* MspInitCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Msp Init callback */
197 void (* MspDeInitCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Msp DeInit callback */
198 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
200 } IRDA_HandleTypeDef;
202 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
204 * @brief HAL IRDA Callback ID enumeration definition
206 typedef enum
208 HAL_IRDA_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< IRDA Tx Half Complete Callback ID */
209 HAL_IRDA_TX_COMPLETE_CB_ID = 0x01U, /*!< IRDA Tx Complete Callback ID */
210 HAL_IRDA_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< IRDA Rx Half Complete Callback ID */
211 HAL_IRDA_RX_COMPLETE_CB_ID = 0x03U, /*!< IRDA Rx Complete Callback ID */
212 HAL_IRDA_ERROR_CB_ID = 0x04U, /*!< IRDA Error Callback ID */
213 HAL_IRDA_ABORT_COMPLETE_CB_ID = 0x05U, /*!< IRDA Abort Complete Callback ID */
214 HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, /*!< IRDA Abort Transmit Complete Callback ID */
215 HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U, /*!< IRDA Abort Receive Complete Callback ID */
217 HAL_IRDA_MSPINIT_CB_ID = 0x08U, /*!< IRDA MspInit callback ID */
218 HAL_IRDA_MSPDEINIT_CB_ID = 0x09U /*!< IRDA MspDeInit callback ID */
220 } HAL_IRDA_CallbackIDTypeDef;
223 * @brief HAL IRDA Callback pointer definition
225 typedef void (*pIRDA_CallbackTypeDef)(IRDA_HandleTypeDef *hirda); /*!< pointer to an IRDA callback function */
227 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
230 * @}
233 /* Exported constants --------------------------------------------------------*/
234 /** @defgroup IRDA_Exported_Constants IRDA Exported Constants
235 * @{
238 /** @defgroup IRDA_State_Definition IRDA State Code Definition
239 * @{
241 #define HAL_IRDA_STATE_RESET 0x00000000U /*!< Peripheral is not initialized
242 Value is allowed for gState and RxState */
243 #define HAL_IRDA_STATE_READY 0x00000020U /*!< Peripheral Initialized and ready for use
244 Value is allowed for gState and RxState */
245 #define HAL_IRDA_STATE_BUSY 0x00000024U /*!< An internal process is ongoing
246 Value is allowed for gState only */
247 #define HAL_IRDA_STATE_BUSY_TX 0x00000021U /*!< Data Transmission process is ongoing
248 Value is allowed for gState only */
249 #define HAL_IRDA_STATE_BUSY_RX 0x00000022U /*!< Data Reception process is ongoing
250 Value is allowed for RxState only */
251 #define HAL_IRDA_STATE_BUSY_TX_RX 0x00000023U /*!< Data Transmission and Reception process is ongoing
252 Not to be used for neither gState nor RxState.
253 Value is result of combination (Or) between gState and RxState values */
254 #define HAL_IRDA_STATE_TIMEOUT 0x000000A0U /*!< Timeout state
255 Value is allowed for gState only */
256 #define HAL_IRDA_STATE_ERROR 0x000000E0U /*!< Error
257 Value is allowed for gState only */
259 * @}
262 /** @defgroup IRDA_Error_Definition IRDA Error Code Definition
263 * @{
265 #define HAL_IRDA_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
266 #define HAL_IRDA_ERROR_PE ((uint32_t)0x00000001U) /*!< Parity error */
267 #define HAL_IRDA_ERROR_NE ((uint32_t)0x00000002U) /*!< Noise error */
268 #define HAL_IRDA_ERROR_FE ((uint32_t)0x00000004U) /*!< frame error */
269 #define HAL_IRDA_ERROR_ORE ((uint32_t)0x00000008U) /*!< Overrun error */
270 #define HAL_IRDA_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */
271 #define HAL_IRDA_ERROR_BUSY ((uint32_t)0x00000020U) /*!< Busy Error */
272 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
273 #define HAL_IRDA_ERROR_INVALID_CALLBACK ((uint32_t)0x00000040U) /*!< Invalid Callback error */
274 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
276 * @}
279 /** @defgroup IRDA_Parity IRDA Parity
280 * @{
282 #define IRDA_PARITY_NONE 0x00000000U /*!< No parity */
283 #define IRDA_PARITY_EVEN USART_CR1_PCE /*!< Even parity */
284 #define IRDA_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Odd parity */
286 * @}
289 /** @defgroup IRDA_Transfer_Mode IRDA Transfer Mode
290 * @{
292 #define IRDA_MODE_RX USART_CR1_RE /*!< RX mode */
293 #define IRDA_MODE_TX USART_CR1_TE /*!< TX mode */
294 #define IRDA_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< RX and TX mode */
296 * @}
299 /** @defgroup IRDA_Low_Power IRDA Low Power
300 * @{
302 #define IRDA_POWERMODE_NORMAL 0x00000000U /*!< IRDA normal power mode */
303 #define IRDA_POWERMODE_LOWPOWER USART_CR3_IRLP /*!< IRDA low power mode */
305 * @}
308 /** @defgroup IRDA_ClockPrescaler IRDA Clock Prescaler
309 * @{
311 #define IRDA_PRESCALER_DIV1 0x00000000U /*!< fclk_pres = fclk */
312 #define IRDA_PRESCALER_DIV2 0x00000001U /*!< fclk_pres = fclk/2 */
313 #define IRDA_PRESCALER_DIV4 0x00000002U /*!< fclk_pres = fclk/4 */
314 #define IRDA_PRESCALER_DIV6 0x00000003U /*!< fclk_pres = fclk/6 */
315 #define IRDA_PRESCALER_DIV8 0x00000004U /*!< fclk_pres = fclk/8 */
316 #define IRDA_PRESCALER_DIV10 0x00000005U /*!< fclk_pres = fclk/10 */
317 #define IRDA_PRESCALER_DIV12 0x00000006U /*!< fclk_pres = fclk/12 */
318 #define IRDA_PRESCALER_DIV16 0x00000007U /*!< fclk_pres = fclk/16 */
319 #define IRDA_PRESCALER_DIV32 0x00000008U /*!< fclk_pres = fclk/32 */
320 #define IRDA_PRESCALER_DIV64 0x00000009U /*!< fclk_pres = fclk/64 */
321 #define IRDA_PRESCALER_DIV128 0x0000000AU /*!< fclk_pres = fclk/128 */
322 #define IRDA_PRESCALER_DIV256 0x0000000BU /*!< fclk_pres = fclk/256 */
324 * @}
327 /** @defgroup IRDA_State IRDA State
328 * @{
330 #define IRDA_STATE_DISABLE 0x00000000U /*!< IRDA disabled */
331 #define IRDA_STATE_ENABLE USART_CR1_UE /*!< IRDA enabled */
333 * @}
336 /** @defgroup IRDA_Mode IRDA Mode
337 * @{
339 #define IRDA_MODE_DISABLE 0x00000000U /*!< Associated UART disabled in IRDA mode */
340 #define IRDA_MODE_ENABLE USART_CR3_IREN /*!< Associated UART enabled in IRDA mode */
342 * @}
345 /** @defgroup IRDA_One_Bit IRDA One Bit Sampling
346 * @{
348 #define IRDA_ONE_BIT_SAMPLE_DISABLE 0x00000000U /*!< One-bit sampling disabled */
349 #define IRDA_ONE_BIT_SAMPLE_ENABLE USART_CR3_ONEBIT /*!< One-bit sampling enabled */
351 * @}
354 /** @defgroup IRDA_DMA_Tx IRDA DMA Tx
355 * @{
357 #define IRDA_DMA_TX_DISABLE 0x00000000U /*!< IRDA DMA TX disabled */
358 #define IRDA_DMA_TX_ENABLE USART_CR3_DMAT /*!< IRDA DMA TX enabled */
360 * @}
363 /** @defgroup IRDA_DMA_Rx IRDA DMA Rx
364 * @{
366 #define IRDA_DMA_RX_DISABLE 0x00000000U /*!< IRDA DMA RX disabled */
367 #define IRDA_DMA_RX_ENABLE USART_CR3_DMAR /*!< IRDA DMA RX enabled */
369 * @}
372 /** @defgroup IRDA_Request_Parameters IRDA Request Parameters
373 * @{
375 #define IRDA_AUTOBAUD_REQUEST USART_RQR_ABRRQ /*!< Auto-Baud Rate Request */
376 #define IRDA_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ /*!< Receive Data flush Request */
377 #define IRDA_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ /*!< Transmit data flush Request */
379 * @}
382 /** @defgroup IRDA_Flags IRDA Flags
383 * Elements values convention: 0xXXXX
384 * - 0xXXXX : Flag mask in the ISR register
385 * @{
387 #define IRDA_FLAG_REACK USART_ISR_REACK /*!< IRDA receive enable acknowledge flag */
388 #define IRDA_FLAG_TEACK USART_ISR_TEACK /*!< IRDA transmit enable acknowledge flag */
389 #define IRDA_FLAG_BUSY USART_ISR_BUSY /*!< IRDA busy flag */
390 #define IRDA_FLAG_ABRF USART_ISR_ABRF /*!< IRDA auto Baud rate flag */
391 #define IRDA_FLAG_ABRE USART_ISR_ABRE /*!< IRDA auto Baud rate error */
392 #define IRDA_FLAG_TXE USART_ISR_TXE_TXFNF /*!< IRDA transmit data register empty */
393 #define IRDA_FLAG_TC USART_ISR_TC /*!< IRDA transmission complete */
394 #define IRDA_FLAG_RXNE USART_ISR_RXNE_RXFNE /*!< IRDA read data register not empty */
395 #define IRDA_FLAG_ORE USART_ISR_ORE /*!< IRDA overrun error */
396 #define IRDA_FLAG_NE USART_ISR_NE /*!< IRDA noise error */
397 #define IRDA_FLAG_FE USART_ISR_FE /*!< IRDA frame error */
398 #define IRDA_FLAG_PE USART_ISR_PE /*!< IRDA parity error */
400 * @}
403 /** @defgroup IRDA_Interrupt_definition IRDA Interrupts Definition
404 * Elements values convention: 0000ZZZZ0XXYYYYYb
405 * - YYYYY : Interrupt source position in the XX register (5bits)
406 * - XX : Interrupt source register (2bits)
407 * - 01: CR1 register
408 * - 10: CR2 register
409 * - 11: CR3 register
410 * - ZZZZ : Flag position in the ISR register(4bits)
411 * @{
413 #define IRDA_IT_PE 0x0028U /*!< IRDA Parity error interruption */
414 #define IRDA_IT_TXE 0x0727U /*!< IRDA Transmit data register empty interruption */
415 #define IRDA_IT_TC 0x0626U /*!< IRDA Transmission complete interruption */
416 #define IRDA_IT_RXNE 0x0525U /*!< IRDA Read data register not empty interruption */
417 #define IRDA_IT_IDLE 0x0424U /*!< IRDA Idle interruption */
419 /* Elements values convention: 000000000XXYYYYYb
420 - YYYYY : Interrupt source position in the XX register (5bits)
421 - XX : Interrupt source register (2bits)
422 - 01: CR1 register
423 - 10: CR2 register
424 - 11: CR3 register */
425 #define IRDA_IT_ERR 0x0060U /*!< IRDA Error interruption */
427 /* Elements values convention: 0000ZZZZ00000000b
428 - ZZZZ : Flag position in the ISR register(4bits) */
429 #define IRDA_IT_ORE 0x0300U /*!< IRDA Overrun error interruption */
430 #define IRDA_IT_NE 0x0200U /*!< IRDA Noise error interruption */
431 #define IRDA_IT_FE 0x0100U /*!< IRDA Frame error interruption */
433 * @}
436 /** @defgroup IRDA_IT_CLEAR_Flags IRDA Interruption Clear Flags
437 * @{
439 #define IRDA_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
440 #define IRDA_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
441 #define IRDA_CLEAR_NEF USART_ICR_NECF /*!< Noise Error detected Clear Flag */
442 #define IRDA_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
443 #define IRDA_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
444 #define IRDA_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
446 * @}
449 /** @defgroup IRDA_Interruption_Mask IRDA interruptions flags mask
450 * @{
452 #define IRDA_IT_MASK 0x001FU /*!< IRDA Interruptions flags mask */
453 #define IRDA_CR_MASK 0x00E0U /*!< IRDA control register mask */
454 #define IRDA_CR_POS 5U /*!< IRDA control register position */
455 #define IRDA_ISR_MASK 0x1F00U /*!< IRDA ISR register mask */
456 #define IRDA_ISR_POS 8U /*!< IRDA ISR register position */
458 * @}
462 * @}
465 /* Exported macros -----------------------------------------------------------*/
466 /** @defgroup IRDA_Exported_Macros IRDA Exported Macros
467 * @{
470 /** @brief Reset IRDA handle state.
471 * @param __HANDLE__ IRDA handle.
472 * @retval None
474 #if USE_HAL_IRDA_REGISTER_CALLBACKS == 1
475 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \
476 (__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \
477 (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \
478 (__HANDLE__)->MspInitCallback = NULL; \
479 (__HANDLE__)->MspDeInitCallback = NULL; \
480 } while(0U)
481 #else
482 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \
483 (__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \
484 (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \
485 } while(0U)
486 #endif /*USE_HAL_IRDA_REGISTER_CALLBACKS */
488 /** @brief Flush the IRDA DR register.
489 * @param __HANDLE__ specifies the IRDA Handle.
490 * @retval None
492 #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) \
493 do{ \
494 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_RXDATA_FLUSH_REQUEST); \
495 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_TXDATA_FLUSH_REQUEST); \
496 } while(0U)
498 /** @brief Clear the specified IRDA pending flag.
499 * @param __HANDLE__ specifies the IRDA Handle.
500 * @param __FLAG__ specifies the flag to check.
501 * This parameter can be any combination of the following values:
502 * @arg @ref IRDA_CLEAR_PEF
503 * @arg @ref IRDA_CLEAR_FEF
504 * @arg @ref IRDA_CLEAR_NEF
505 * @arg @ref IRDA_CLEAR_OREF
506 * @arg @ref IRDA_CLEAR_TCF
507 * @arg @ref IRDA_CLEAR_IDLEF
508 * @retval None
510 #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
512 /** @brief Clear the IRDA PE pending flag.
513 * @param __HANDLE__ specifies the IRDA Handle.
514 * @retval None
516 #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_PEF)
519 /** @brief Clear the IRDA FE pending flag.
520 * @param __HANDLE__ specifies the IRDA Handle.
521 * @retval None
523 #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_FEF)
525 /** @brief Clear the IRDA NE pending flag.
526 * @param __HANDLE__ specifies the IRDA Handle.
527 * @retval None
529 #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_NEF)
531 /** @brief Clear the IRDA ORE pending flag.
532 * @param __HANDLE__ specifies the IRDA Handle.
533 * @retval None
535 #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_OREF)
537 /** @brief Clear the IRDA IDLE pending flag.
538 * @param __HANDLE__ specifies the IRDA Handle.
539 * @retval None
541 #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_IDLEF)
543 /** @brief Check whether the specified IRDA flag is set or not.
544 * @param __HANDLE__ specifies the IRDA Handle.
545 * @param __FLAG__ specifies the flag to check.
546 * This parameter can be one of the following values:
547 * @arg @ref IRDA_FLAG_REACK Receive enable acknowledge flag
548 * @arg @ref IRDA_FLAG_TEACK Transmit enable acknowledge flag
549 * @arg @ref IRDA_FLAG_BUSY Busy flag
550 * @arg @ref IRDA_FLAG_ABRF Auto Baud rate detection flag
551 * @arg @ref IRDA_FLAG_ABRE Auto Baud rate detection error flag
552 * @arg @ref IRDA_FLAG_TXE Transmit data register empty flag
553 * @arg @ref IRDA_FLAG_TC Transmission Complete flag
554 * @arg @ref IRDA_FLAG_RXNE Receive data register not empty flag
555 * @arg @ref IRDA_FLAG_ORE OverRun Error flag
556 * @arg @ref IRDA_FLAG_NE Noise Error flag
557 * @arg @ref IRDA_FLAG_FE Framing Error flag
558 * @arg @ref IRDA_FLAG_PE Parity Error flag
559 * @retval The new state of __FLAG__ (TRUE or FALSE).
561 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
564 /** @brief Enable the specified IRDA interrupt.
565 * @param __HANDLE__ specifies the IRDA Handle.
566 * @param __INTERRUPT__ specifies the IRDA interrupt source to enable.
567 * This parameter can be one of the following values:
568 * @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt
569 * @arg @ref IRDA_IT_TC Transmission complete interrupt
570 * @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt
571 * @arg @ref IRDA_IT_IDLE Idle line detection interrupt
572 * @arg @ref IRDA_IT_PE Parity Error interrupt
573 * @arg @ref IRDA_IT_ERR Error interrupt(Frame error, noise error, overrun error)
574 * @retval None
576 #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 1U)? ((__HANDLE__)->Instance->CR1 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
577 ((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 2U)? ((__HANDLE__)->Instance->CR2 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
578 ((__HANDLE__)->Instance->CR3 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))))
580 /** @brief Disable the specified IRDA interrupt.
581 * @param __HANDLE__ specifies the IRDA Handle.
582 * @param __INTERRUPT__ specifies the IRDA interrupt source to disable.
583 * This parameter can be one of the following values:
584 * @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt
585 * @arg @ref IRDA_IT_TC Transmission complete interrupt
586 * @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt
587 * @arg @ref IRDA_IT_IDLE Idle line detection interrupt
588 * @arg @ref IRDA_IT_PE Parity Error interrupt
589 * @arg @ref IRDA_IT_ERR Error interrupt(Frame error, noise error, overrun error)
590 * @retval None
592 #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
593 ((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
594 ((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))))
597 /** @brief Check whether the specified IRDA interrupt has occurred or not.
598 * @param __HANDLE__ specifies the IRDA Handle.
599 * @param __INTERRUPT__ specifies the IRDA interrupt source to check.
600 * This parameter can be one of the following values:
601 * @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt
602 * @arg @ref IRDA_IT_TC Transmission complete interrupt
603 * @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt
604 * @arg @ref IRDA_IT_IDLE Idle line detection interrupt
605 * @arg @ref IRDA_IT_ORE OverRun Error interrupt
606 * @arg @ref IRDA_IT_NE Noise Error interrupt
607 * @arg @ref IRDA_IT_FE Framing Error interrupt
608 * @arg @ref IRDA_IT_PE Parity Error interrupt
609 * @retval The new state of __IT__ (SET or RESET).
611 #define __HAL_IRDA_GET_IT(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISR\
612 & (0x01U << (((__INTERRUPT__) & IRDA_ISR_MASK)>> IRDA_ISR_POS))) != 0U) ? SET : RESET)
614 /** @brief Check whether the specified IRDA interrupt source is enabled or not.
615 * @param __HANDLE__ specifies the IRDA Handle.
616 * @param __INTERRUPT__ specifies the IRDA interrupt source to check.
617 * This parameter can be one of the following values:
618 * @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt
619 * @arg @ref IRDA_IT_TC Transmission complete interrupt
620 * @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt
621 * @arg @ref IRDA_IT_IDLE Idle line detection interrupt
622 * @arg @ref IRDA_IT_ERR Framing, overrun or noise error interrupt
623 * @arg @ref IRDA_IT_PE Parity Error interrupt
624 * @retval The new state of __IT__ (SET or RESET).
626 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 0x01U)? (__HANDLE__)->Instance->CR1 : \
627 (((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 0x02U)? (__HANDLE__)->Instance->CR2 : \
628 (__HANDLE__)->Instance->CR3)) & ((uint32_t)0x01U << (((uint16_t)(__INTERRUPT__)) & IRDA_IT_MASK))) != 0U) ? SET : RESET)
630 /** @brief Clear the specified IRDA ISR flag, in setting the proper ICR register flag.
631 * @param __HANDLE__ specifies the IRDA Handle.
632 * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set
633 * to clear the corresponding interrupt
634 * This parameter can be one of the following values:
635 * @arg @ref IRDA_CLEAR_PEF Parity Error Clear Flag
636 * @arg @ref IRDA_CLEAR_FEF Framing Error Clear Flag
637 * @arg @ref IRDA_CLEAR_NEF Noise detected Clear Flag
638 * @arg @ref IRDA_CLEAR_OREF OverRun Error Clear Flag
639 * @arg @ref IRDA_CLEAR_TCF Transmission Complete Clear Flag
640 * @retval None
642 #define __HAL_IRDA_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
645 /** @brief Set a specific IRDA request flag.
646 * @param __HANDLE__ specifies the IRDA Handle.
647 * @param __REQ__ specifies the request flag to set
648 * This parameter can be one of the following values:
649 * @arg @ref IRDA_AUTOBAUD_REQUEST Auto-Baud Rate Request
650 * @arg @ref IRDA_RXDATA_FLUSH_REQUEST Receive Data flush Request
651 * @arg @ref IRDA_TXDATA_FLUSH_REQUEST Transmit data flush Request
652 * @retval None
654 #define __HAL_IRDA_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
656 /** @brief Enable the IRDA one bit sample method.
657 * @param __HANDLE__ specifies the IRDA Handle.
658 * @retval None
660 #define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
662 /** @brief Disable the IRDA one bit sample method.
663 * @param __HANDLE__ specifies the IRDA Handle.
664 * @retval None
666 #define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3\
667 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
669 /** @brief Enable UART/USART associated to IRDA Handle.
670 * @param __HANDLE__ specifies the IRDA Handle.
671 * @retval None
673 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
675 /** @brief Disable UART/USART associated to IRDA Handle.
676 * @param __HANDLE__ specifies the IRDA Handle.
677 * @retval None
679 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
682 * @}
685 /* Private macros --------------------------------------------------------*/
686 /** @addtogroup IRDA_Private_Macros
687 * @{
690 /** @brief Ensure that IRDA Baud rate is less or equal to maximum value.
691 * @param __BAUDRATE__ specifies the IRDA Baudrate set by the user.
692 * @retval True or False
694 #define IS_IRDA_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 115201U)
696 /** @brief Ensure that IRDA prescaler value is strictly larger than 0.
697 * @param __PRESCALER__ specifies the IRDA prescaler value set by the user.
698 * @retval True or False
700 #define IS_IRDA_PRESCALER(__PRESCALER__) ((__PRESCALER__) > 0U)
702 /** @brief Ensure that IRDA frame parity is valid.
703 * @param __PARITY__ IRDA frame parity.
704 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
706 #define IS_IRDA_PARITY(__PARITY__) (((__PARITY__) == IRDA_PARITY_NONE) || \
707 ((__PARITY__) == IRDA_PARITY_EVEN) || \
708 ((__PARITY__) == IRDA_PARITY_ODD))
710 /** @brief Ensure that IRDA communication mode is valid.
711 * @param __MODE__ IRDA communication mode.
712 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
714 #define IS_IRDA_TX_RX_MODE(__MODE__) ((((__MODE__)\
715 & (~((uint32_t)(IRDA_MODE_TX_RX)))) == 0x00U) && ((__MODE__) != 0x00U))
717 /** @brief Ensure that IRDA power mode is valid.
718 * @param __MODE__ IRDA power mode.
719 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
721 #define IS_IRDA_POWERMODE(__MODE__) (((__MODE__) == IRDA_POWERMODE_LOWPOWER) || \
722 ((__MODE__) == IRDA_POWERMODE_NORMAL))
724 /** @brief Ensure that IRDA clock Prescaler is valid.
725 * @param __CLOCKPRESCALER__ IRDA clock Prescaler value.
726 * @retval SET (__CLOCKPRESCALER__ is valid) or RESET (__CLOCKPRESCALER__ is invalid)
728 #define IS_IRDA_CLOCKPRESCALER(__CLOCKPRESCALER__) (((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV1) || \
729 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV2) || \
730 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV4) || \
731 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV6) || \
732 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV8) || \
733 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV10) || \
734 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV12) || \
735 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV16) || \
736 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV32) || \
737 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV64) || \
738 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV128) || \
739 ((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV256))
741 /** @brief Ensure that IRDA state is valid.
742 * @param __STATE__ IRDA state mode.
743 * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
745 #define IS_IRDA_STATE(__STATE__) (((__STATE__) == IRDA_STATE_DISABLE) || \
746 ((__STATE__) == IRDA_STATE_ENABLE))
748 /** @brief Ensure that IRDA associated UART/USART mode is valid.
749 * @param __MODE__ IRDA associated UART/USART mode.
750 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
752 #define IS_IRDA_MODE(__MODE__) (((__MODE__) == IRDA_MODE_DISABLE) || \
753 ((__MODE__) == IRDA_MODE_ENABLE))
755 /** @brief Ensure that IRDA sampling rate is valid.
756 * @param __ONEBIT__ IRDA sampling rate.
757 * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid)
759 #define IS_IRDA_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_DISABLE) || \
760 ((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_ENABLE))
762 /** @brief Ensure that IRDA DMA TX mode is valid.
763 * @param __DMATX__ IRDA DMA TX mode.
764 * @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid)
766 #define IS_IRDA_DMA_TX(__DMATX__) (((__DMATX__) == IRDA_DMA_TX_DISABLE) || \
767 ((__DMATX__) == IRDA_DMA_TX_ENABLE))
769 /** @brief Ensure that IRDA DMA RX mode is valid.
770 * @param __DMARX__ IRDA DMA RX mode.
771 * @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid)
773 #define IS_IRDA_DMA_RX(__DMARX__) (((__DMARX__) == IRDA_DMA_RX_DISABLE) || \
774 ((__DMARX__) == IRDA_DMA_RX_ENABLE))
776 /** @brief Ensure that IRDA request is valid.
777 * @param __PARAM__ IRDA request.
778 * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
780 #define IS_IRDA_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == IRDA_AUTOBAUD_REQUEST) || \
781 ((__PARAM__) == IRDA_RXDATA_FLUSH_REQUEST) || \
782 ((__PARAM__) == IRDA_TXDATA_FLUSH_REQUEST))
784 * @}
787 /* Include IRDA HAL Extended module */
788 #include "stm32h7xx_hal_irda_ex.h"
790 /* Exported functions --------------------------------------------------------*/
791 /** @addtogroup IRDA_Exported_Functions IRDA Exported Functions
792 * @{
795 /** @addtogroup IRDA_Exported_Functions_Group1 Initialization and de-initialization functions
796 * @{
799 /* Initialization and de-initialization functions ****************************/
800 HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda);
801 HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda);
802 void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda);
803 void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda);
805 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
806 /* Callbacks Register/UnRegister functions ***********************************/
807 HAL_StatusTypeDef HAL_IRDA_RegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID,
808 pIRDA_CallbackTypeDef pCallback);
809 HAL_StatusTypeDef HAL_IRDA_UnRegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID);
810 #endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
813 * @}
816 /** @addtogroup IRDA_Exported_Functions_Group2 IO operation functions
817 * @{
820 /* IO operation functions *****************************************************/
821 HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
822 HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
823 HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
824 HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
825 HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
826 HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
827 HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda);
828 HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda);
829 HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda);
830 /* Transfer Abort functions */
831 HAL_StatusTypeDef HAL_IRDA_Abort(IRDA_HandleTypeDef *hirda);
832 HAL_StatusTypeDef HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef *hirda);
833 HAL_StatusTypeDef HAL_IRDA_AbortReceive(IRDA_HandleTypeDef *hirda);
834 HAL_StatusTypeDef HAL_IRDA_Abort_IT(IRDA_HandleTypeDef *hirda);
835 HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef *hirda);
836 HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef *hirda);
838 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda);
839 void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda);
840 void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda);
841 void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
842 void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
843 void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda);
844 void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda);
845 void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda);
846 void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda);
849 * @}
852 /* Peripheral Control functions ************************************************/
854 /** @addtogroup IRDA_Exported_Functions_Group4 Peripheral State and Error functions
855 * @{
858 /* Peripheral State and Error functions ***************************************/
859 HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda);
860 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda);
863 * @}
867 * @}
871 * @}
875 * @}
878 #ifdef __cplusplus
880 #endif
882 #endif /* STM32H7xx_HAL_IRDA_H */
884 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/