2 ******************************************************************************
3 * @file stm32f7xx_hal_irda.h
4 * @author MCD Application Team
7 * @brief Header file of IRDA HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F7xx_HAL_IRDA_H
40 #define __STM32F7xx_HAL_IRDA_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f7xx_hal_def.h"
49 /** @addtogroup STM32F7xx_HAL_Driver
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup IRDA_Exported_Types IRDA Exported Types
62 * @brief IRDA Init Structure definition
66 uint32_t BaudRate
; /*!< This member configures the IRDA communication baud rate.
67 The baud rate register is computed using the following formula:
68 Baud Rate Register = ((PCLKx) / ((hirda->Init.BaudRate))) */
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 IRDAEx_Word_Length */
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). */
80 uint16_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 */
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 */
87 uint16_t PowerMode
; /*!< Specifies the IRDA power mode.
88 This parameter can be a value of @ref IRDA_Low_Power */
92 * @brief HAL IRDA State structures definition
93 * @note HAL IRDA State value is a combination of 2 different substates: gState and RxState.
94 * - gState contains IRDA state information related to global Handle management
95 * and also information related to Tx operations.
96 * gState value coding follow below described bitmap :
97 * b7-b6 Error information
102 * b5 IP initilisation status
103 * 0 : Reset (IP not initialized)
104 * 1 : Init done (IP not initialized. HAL IRDA Init function already called)
106 * xx : Should be set to 00
107 * b2 Intrinsic process state
109 * 1 : Busy (IP busy with some configuration or internal operations)
111 * x : Should be set to 0
113 * 0 : Ready (no Tx operation ongoing)
114 * 1 : Busy (Tx operation ongoing)
115 * - RxState contains information related to Rx operations.
116 * RxState value coding follow below described bitmap :
118 * xx : Should be set to 00
119 * b5 IP initilisation status
120 * 0 : Reset (IP not initialized)
121 * 1 : Init done (IP not initialized)
123 * xxx : Should be set to 000
125 * 0 : Ready (no Rx operation ongoing)
126 * 1 : Busy (Rx operation ongoing)
128 * x : Should be set to 0.
132 HAL_IRDA_STATE_RESET
= 0x00U
, /*!< Peripheral is not yet Initialized
133 Value is allowed for gState and RxState */
134 HAL_IRDA_STATE_READY
= 0x20U
, /*!< Peripheral Initialized and ready for use
135 Value is allowed for gState and RxState */
136 HAL_IRDA_STATE_BUSY
= 0x24U
, /*!< An internal process is ongoing
137 Value is allowed for gState only */
138 HAL_IRDA_STATE_BUSY_TX
= 0x21U
, /*!< Data Transmission process is ongoing
139 Value is allowed for gState only */
140 HAL_IRDA_STATE_BUSY_RX
= 0x22U
, /*!< Data Reception process is ongoing
141 Value is allowed for RxState only */
142 HAL_IRDA_STATE_BUSY_TX_RX
= 0x23U
, /*!< Data Transmission and Reception process is ongoing
143 Not to be used for neither gState nor RxState.
144 Value is result of combination (Or) between gState and RxState values */
145 HAL_IRDA_STATE_TIMEOUT
= 0xA0U
, /*!< Timeout state
146 Value is allowed for gState only */
147 HAL_IRDA_STATE_ERROR
= 0xE0U
/*!< Error
148 Value is allowed for gState only */
149 }HAL_IRDA_StateTypeDef
;
152 * @brief IRDA clock sources definition
156 IRDA_CLOCKSOURCE_PCLK1
= 0x00U
, /*!< PCLK1 clock source */
157 IRDA_CLOCKSOURCE_PCLK2
= 0x01U
, /*!< PCLK2 clock source */
158 IRDA_CLOCKSOURCE_HSI
= 0x02U
, /*!< HSI clock source */
159 IRDA_CLOCKSOURCE_SYSCLK
= 0x04U
, /*!< SYSCLK clock source */
160 IRDA_CLOCKSOURCE_LSE
= 0x08U
, /*!< LSE clock source */
161 IRDA_CLOCKSOURCE_UNDEFINED
= 0x10 /*!< Undefined clock source */
162 }IRDA_ClockSourceTypeDef
;
165 * @brief IRDA handle Structure definition
169 USART_TypeDef
*Instance
; /* IRDA registers base address */
171 IRDA_InitTypeDef Init
; /* IRDA communication parameters */
173 uint8_t *pTxBuffPtr
; /* Pointer to IRDA Tx transfer Buffer */
175 uint16_t TxXferSize
; /* IRDA Tx Transfer size */
177 __IO
uint16_t TxXferCount
; /* IRDA Tx Transfer Counter */
179 uint8_t *pRxBuffPtr
; /* Pointer to IRDA Rx transfer Buffer */
181 uint16_t RxXferSize
; /* IRDA Rx Transfer size */
183 __IO
uint16_t RxXferCount
; /* IRDA Rx Transfer Counter */
185 uint16_t Mask
; /* IRDA RX RDR register mask */
187 DMA_HandleTypeDef
*hdmatx
; /* IRDA Tx DMA Handle parameters */
189 DMA_HandleTypeDef
*hdmarx
; /* IRDA Rx DMA Handle parameters */
191 HAL_LockTypeDef Lock
; /* Locking object */
193 __IO HAL_IRDA_StateTypeDef gState
; /* IRDA state information related to global Handle management
194 and also related to Tx operations.
195 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
197 __IO HAL_IRDA_StateTypeDef RxState
; /* IRDA state information related to Rx operations.
198 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
200 __IO
uint32_t ErrorCode
; /* IRDA Error code */
209 * @brief IRDA Configuration enumeration values definition
212 /* Exported constants --------------------------------------------------------*/
213 /** @defgroup IRDA_Exported_Constants IRDA Exported constants
216 /** @defgroup IRDA_Error_Code IRDA Error Code
217 * @brief IRDA Error Code
221 #define HAL_IRDA_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
222 #define HAL_IRDA_ERROR_PE ((uint32_t)0x00000001U) /*!< Parity error */
223 #define HAL_IRDA_ERROR_NE ((uint32_t)0x00000002U) /*!< Noise error */
224 #define HAL_IRDA_ERROR_FE ((uint32_t)0x00000004U) /*!< frame error */
225 #define HAL_IRDA_ERROR_ORE ((uint32_t)0x00000008U) /*!< Overrun error */
226 #define HAL_IRDA_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */
231 /** @defgroup IRDA_Parity IRDA Parity
234 #define IRDA_PARITY_NONE ((uint32_t)0x0000U)
235 #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
236 #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
242 /** @defgroup IRDA_Transfer_Mode IRDA Transfer Mode
245 #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE)
246 #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE)
247 #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
252 /** @defgroup IRDA_Low_Power IRDA Low Power
255 #define IRDA_POWERMODE_NORMAL ((uint32_t)0x0000U)
256 #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP)
261 /** @defgroup IRDA_State IRDA State
264 #define IRDA_STATE_DISABLE ((uint32_t)0x0000U)
265 #define IRDA_STATE_ENABLE ((uint32_t)USART_CR1_UE)
270 /** @defgroup IRDA_Mode IRDA Mode
273 #define IRDA_MODE_DISABLE ((uint32_t)0x0000U)
274 #define IRDA_MODE_ENABLE ((uint32_t)USART_CR3_IREN)
279 /** @defgroup IRDA_One_Bit IRDA One Bit
282 #define IRDA_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x00000000U)
283 #define IRDA_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT)
288 /** @defgroup IRDA_DMA_Tx IRDA DMA Tx
291 #define IRDA_DMA_TX_DISABLE ((uint32_t)0x00000000U)
292 #define IRDA_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT)
297 /** @defgroup IRDA_DMA_Rx IRDA DMA Rx
300 #define IRDA_DMA_RX_DISABLE ((uint32_t)0x0000U)
301 #define IRDA_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR)
306 /** @defgroup IRDA_Flags IRDA Flags
307 * Elements values convention: 0xXXXX
308 * - 0xXXXX : Flag mask in the ISR register
311 #define IRDA_FLAG_REACK ((uint32_t)0x00400000U)
312 #define IRDA_FLAG_TEACK ((uint32_t)0x00200000U)
313 #define IRDA_FLAG_BUSY ((uint32_t)0x00010000U)
314 #define IRDA_FLAG_ABRF ((uint32_t)0x00008000U)
315 #define IRDA_FLAG_ABRE ((uint32_t)0x00004000U)
316 #define IRDA_FLAG_TXE ((uint32_t)0x00000080U)
317 #define IRDA_FLAG_TC ((uint32_t)0x00000040U)
318 #define IRDA_FLAG_RXNE ((uint32_t)0x00000020U)
319 #define IRDA_FLAG_ORE ((uint32_t)0x00000008U)
320 #define IRDA_FLAG_NE ((uint32_t)0x00000004U)
321 #define IRDA_FLAG_FE ((uint32_t)0x00000002U)
322 #define IRDA_FLAG_PE ((uint32_t)0x00000001U)
327 /** @defgroup IRDA_Interrupt_definition IRDA Interrupt definition
328 * Elements values convention: 0000ZZZZ0XXYYYYYb
329 * - YYYYY : Interrupt source position in the XX register (5bits)
330 * - XX : Interrupt source register (2bits)
334 * - ZZZZ : Flag position in the ISR register(4bits)
337 #define IRDA_IT_PE ((uint16_t)0x0028U)
338 #define IRDA_IT_TXE ((uint16_t)0x0727U)
339 #define IRDA_IT_TC ((uint16_t)0x0626U)
340 #define IRDA_IT_RXNE ((uint16_t)0x0525U)
341 #define IRDA_IT_IDLE ((uint16_t)0x0424U)
345 /** Elements values convention: 000000000XXYYYYYb
346 * - YYYYY : Interrupt source position in the XX register (5bits)
347 * - XX : Interrupt source register (2bits)
352 #define IRDA_IT_ERR ((uint16_t)0x0060U)
354 /** Elements values convention: 0000ZZZZ00000000b
355 * - ZZZZ : Flag position in the ISR register(4bits)
357 #define IRDA_IT_ORE ((uint16_t)0x0300U)
358 #define IRDA_IT_NE ((uint16_t)0x0200U)
359 #define IRDA_IT_FE ((uint16_t)0x0100U)
364 /** @defgroup IRDA_IT_CLEAR_Flags IRDA IT CLEAR Flags
367 #define IRDA_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
368 #define IRDA_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
369 #define IRDA_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
370 #define IRDA_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
371 #define IRDA_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
378 /** @defgroup IRDA_Request_Parameters IRDA Request Parameters
381 #define IRDA_AUTOBAUD_REQUEST ((uint16_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
382 #define IRDA_RXDATA_FLUSH_REQUEST ((uint16_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
383 #define IRDA_TXDATA_FLUSH_REQUEST ((uint16_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
393 /* Exported macro ------------------------------------------------------------*/
394 /** @defgroup IRDA_Exported_Macros IRDA Exported Macros
398 /** @brief Reset IRDA handle state
399 * @param __HANDLE__: specifies the IRDA Handle.
400 * The Handle Instance which can be USART1 or USART2.
403 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IRDA_STATE_RESET)
405 /** @brief Flush the IRDA DR register.
406 * @param __HANDLE__: specifies the IRDA Handle.
409 #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) \
411 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_RXDATA_FLUSH_REQUEST); \
412 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_TXDATA_FLUSH_REQUEST); \
415 /** @brief Clear the specified IRDA pending flag.
416 * @param __HANDLE__: specifies the IRDA Handle.
417 * @param __FLAG__: specifies the flag to check.
418 * This parameter can be any combination of the following values:
419 * @arg @ref IRDA_CLEAR_PEF
420 * @arg @ref IRDA_CLEAR_FEF
421 * @arg @ref IRDA_CLEAR_NEF
422 * @arg @ref IRDA_CLEAR_OREF
423 * @arg @ref IRDA_CLEAR_TCF
426 #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
428 /** @brief Clear the IRDA PE pending flag.
429 * @param __HANDLE__: specifies the IRDA Handle.
432 #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_PEF)
435 /** @brief Clear the IRDA FE pending flag.
436 * @param __HANDLE__: specifies the IRDA Handle.
439 #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_FEF)
441 /** @brief Clear the IRDA NE pending flag.
442 * @param __HANDLE__: specifies the IRDA Handle.
445 #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_NEF)
447 /** @brief Clear the IRDA ORE pending flag.
448 * @param __HANDLE__: specifies the IRDA Handle.
451 #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_OREF)
453 /** @brief Clear the IRDA IDLE pending flag.
454 * @param __HANDLE__: specifies the IRDA Handle.
457 #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_IDLEF)
459 /** @brief Check whether the specified IRDA flag is set or not.
460 * @param __HANDLE__: specifies the IRDA Handle.
461 * The Handle Instance which can be USART1 or USART2.
463 * @param __FLAG__: specifies the flag to check.
464 * This parameter can be one of the following values:
465 * @arg IRDA_FLAG_REACK: Receive enable acknowledge flag
466 * @arg IRDA_FLAG_TEACK: Transmit enable acknowledge flag
467 * @arg IRDA_FLAG_BUSY: Busy flag
468 * @arg IRDA_FLAG_ABRF: Auto Baud rate detection flag
469 * @arg IRDA_FLAG_ABRE: Auto Baud rate detection error flag
470 * @arg IRDA_FLAG_TXE: Transmit data register empty flag
471 * @arg IRDA_FLAG_TC: Transmission Complete flag
472 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag
473 * @arg IRDA_FLAG_IDLE: Idle Line detection flag
474 * @arg IRDA_FLAG_ORE: OverRun Error flag
475 * @arg IRDA_FLAG_NE: Noise Error flag
476 * @arg IRDA_FLAG_FE: Framing Error flag
477 * @arg IRDA_FLAG_PE: Parity Error flag
478 * @retval The new state of __FLAG__ (TRUE or FALSE).
480 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
482 /** @brief Enable the specified IRDA interrupt.
483 * @param __HANDLE__: specifies the IRDA Handle.
484 * The Handle Instance which can be USART1 or USART2.
486 * @param __INTERRUPT__: specifies the IRDA interrupt source to enable.
487 * This parameter can be one of the following values:
488 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
489 * @arg IRDA_IT_TC: Transmission complete interrupt
490 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
491 * @arg IRDA_IT_IDLE: Idle line detection interrupt
492 * @arg IRDA_IT_PE: Parity Error interrupt
493 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
496 #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5) == 1)? ((__HANDLE__)->Instance->CR1 |= (1 << ((__INTERRUPT__) & IRDA_IT_MASK))): \
497 ((((uint8_t)(__INTERRUPT__)) >> 5) == 2)? ((__HANDLE__)->Instance->CR2 |= (1 << ((__INTERRUPT__) & IRDA_IT_MASK))): \
498 ((__HANDLE__)->Instance->CR3 |= (1 << ((__INTERRUPT__) & IRDA_IT_MASK))))
500 /** @brief Disable the specified IRDA interrupt.
501 * @param __HANDLE__: specifies the IRDA Handle.
502 * The Handle Instance which can be USART1 or USART2.
503 * @param __INTERRUPT__: specifies the IRDA interrupt source to disable.
504 * This parameter can be one of the following values:
505 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
506 * @arg IRDA_IT_TC: Transmission complete interrupt
507 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
508 * @arg IRDA_IT_IDLE: Idle line detection interrupt
509 * @arg IRDA_IT_PE: Parity Error interrupt
510 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
513 #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ ((uint32_t)1 << ((__INTERRUPT__) & IRDA_IT_MASK))): \
514 ((((uint8_t)(__INTERRUPT__)) >> 5) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1 << ((__INTERRUPT__) & IRDA_IT_MASK))): \
515 ((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1 << ((__INTERRUPT__) & IRDA_IT_MASK))))
517 /** @brief Check whether the specified IRDA interrupt has occurred or not.
518 * @param __HANDLE__: specifies the IRDA Handle.
519 * The Handle Instance which can be USART1 or USART2.
520 * @param __IT__: specifies the IRDA interrupt source to check.
521 * This parameter can be one of the following values:
522 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
523 * @arg IRDA_IT_TC: Transmission complete interrupt
524 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
525 * @arg IRDA_IT_IDLE: Idle line detection interrupt
526 * @arg IRDA_IT_ORE: OverRun Error interrupt
527 * @arg IRDA_IT_NE: Noise Error interrupt
528 * @arg IRDA_IT_FE: Framing Error interrupt
529 * @arg IRDA_IT_PE: Parity Error interrupt
530 * @retval The new state of __IT__ (TRUE or FALSE).
532 #define __HAL_IRDA_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
534 /** @brief Check whether the specified IRDA interrupt source is enabled.
535 * @param __HANDLE__: specifies the IRDA Handle.
536 * The Handle Instance which can be USART1 or USART2.
537 * @param __IT__: specifies the IRDA interrupt source to check.
538 * This parameter can be one of the following values:
539 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
540 * @arg IRDA_IT_TC: Transmission complete interrupt
541 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
542 * @arg IRDA_IT_IDLE: Idle line detection interrupt
543 * @arg IRDA_IT_ORE: OverRun Error interrupt
544 * @arg IRDA_IT_NE: Noise Error interrupt
545 * @arg IRDA_IT_FE: Framing Error interrupt
546 * @arg IRDA_IT_PE: Parity Error interrupt
547 * @retval The new state of __IT__ (TRUE or FALSE).
549 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \
550 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & IRDA_IT_MASK)))
552 /** @brief Clear the specified IRDA ISR flag, in setting the proper ICR register flag.
553 * @param __HANDLE__: specifies the IRDA Handle.
554 * The Handle Instance which can be USART1 or USART2.
555 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
556 * to clear the corresponding interrupt
557 * This parameter can be one of the following values:
558 * @arg IRDA_CLEAR_PEF: Parity Error Clear Flag
559 * @arg IRDA_CLEAR_FEF: Framing Error Clear Flag
560 * @arg IRDA_CLEAR_NEF: Noise detected Clear Flag
561 * @arg IRDA_CLEAR_OREF: OverRun Error Clear Flag
562 * @arg IRDA_CLEAR_TCF: Transmission Complete Clear Flag
565 #define __HAL_IRDA_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR |= (uint32_t)(__IT_CLEAR__))
567 /** @brief Set a specific IRDA request flag.
568 * @param __HANDLE__: specifies the IRDA Handle.
569 * The Handle Instance which can be USART1 or USART2.
570 * @param __REQ__: specifies the request flag to set
571 * This parameter can be one of the following values:
572 * @arg IRDA_AUTOBAUD_REQUEST: Auto-Baud Rate Request
573 * @arg IRDA_RXDATA_FLUSH_REQUEST: Receive Data flush Request
574 * @arg IRDA_TXDATA_FLUSH_REQUEST: Transmit data flush Request
578 #define __HAL_IRDA_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
580 /** @brief Enable UART/USART associated to IRDA Handle
581 * @param __HANDLE__: specifies the IRDA Handle.
582 * The Handle Instance which can be USART1 or USART2.
585 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
587 /** @brief Disable UART/USART associated to IRDA Handle
588 * @param __HANDLE__: specifies the IRDA Handle.
589 * The Handle Instance which can be USART1 or USART2.
592 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
598 /* Include IRDA HAL Extension module */
599 #include "stm32f7xx_hal_irda_ex.h"
601 /* Exported functions --------------------------------------------------------*/
602 /** @addtogroup IRDA_Exported_Functions IRDA Exported Functions
606 /** @addtogroup IRDA_Exported_Functions_Group1 IrDA Initialization and de-initialization functions
610 /* Initialization and de-initialization functions ****************************/
611 HAL_StatusTypeDef
HAL_IRDA_Init(IRDA_HandleTypeDef
*hirda
);
612 HAL_StatusTypeDef
HAL_IRDA_DeInit(IRDA_HandleTypeDef
*hirda
);
613 void HAL_IRDA_MspInit(IRDA_HandleTypeDef
*hirda
);
614 void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef
*hirda
);
619 /** @addtogroup IRDA_Exported_Functions_Group2 IO operation functions
623 /* IO operation functions *****************************************************/
624 HAL_StatusTypeDef
HAL_IRDA_Transmit(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
, uint32_t Timeout
);
625 HAL_StatusTypeDef
HAL_IRDA_Receive(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
, uint32_t Timeout
);
626 HAL_StatusTypeDef
HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
);
627 HAL_StatusTypeDef
HAL_IRDA_Receive_IT(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
);
628 HAL_StatusTypeDef
HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
);
629 HAL_StatusTypeDef
HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
);
630 HAL_StatusTypeDef
HAL_IRDA_DMAPause(IRDA_HandleTypeDef
*hirda
);
631 HAL_StatusTypeDef
HAL_IRDA_DMAResume(IRDA_HandleTypeDef
*hirda
);
632 HAL_StatusTypeDef
HAL_IRDA_DMAStop(IRDA_HandleTypeDef
*hirda
);
633 /* Transfer Abort functions */
634 HAL_StatusTypeDef
HAL_IRDA_Abort(IRDA_HandleTypeDef
*hirda
);
635 HAL_StatusTypeDef
HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef
*hirda
);
636 HAL_StatusTypeDef
HAL_IRDA_AbortReceive(IRDA_HandleTypeDef
*hirda
);
637 HAL_StatusTypeDef
HAL_IRDA_Abort_IT(IRDA_HandleTypeDef
*hirda
);
638 HAL_StatusTypeDef
HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef
*hirda
);
639 HAL_StatusTypeDef
HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef
*hirda
);
641 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef
*hirda
);
642 void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef
*hirda
);
643 void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef
*hirda
);
644 void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef
*hirda
);
645 void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef
*hirda
);
646 void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef
*hirda
);
647 void HAL_IRDA_AbortCpltCallback (IRDA_HandleTypeDef
*hirda
);
648 void HAL_IRDA_AbortTransmitCpltCallback (IRDA_HandleTypeDef
*hirda
);
649 void HAL_IRDA_AbortReceiveCpltCallback (IRDA_HandleTypeDef
*hirda
);
655 /** @addtogroup IRDA_Exported_Functions_Group3 Peripheral Control functions
658 /* Peripheral State methods **************************************************/
659 HAL_IRDA_StateTypeDef
HAL_IRDA_GetState(IRDA_HandleTypeDef
*hirda
);
660 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef
*hirda
);
669 /* Private types -------------------------------------------------------------*/
670 /* Private variables ---------------------------------------------------------*/
671 /* Private constants ---------------------------------------------------------*/
672 /** @defgroup IRDA_Private_Constants IRDA Private Constants
676 /** @defgroup IRDA_Interruption_Mask IRDA Interruption Mask
679 #define IRDA_IT_MASK ((uint16_t)0x001FU)
687 /* Private macros --------------------------------------------------------*/
688 /** @defgroup IRDA_Private_Macros IRDA Private Macros
692 /** @brief Ensure that IRDA Baud rate is less or equal to maximum value
693 * @param __BAUDRATE__: specifies the IRDA Baudrate set by the user.
694 * @retval True or False
696 #define IS_IRDA_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 115201)
698 /** @brief Ensure that IRDA prescaler value is strictly larger than 0
699 * @param __PRESCALER__: specifies the IRDA prescaler value set by the user.
700 * @retval True or False
702 #define IS_IRDA_PRESCALER(__PRESCALER__) ((__PRESCALER__) > 0)
704 #define IS_IRDA_PARITY(__PARITY__) (((__PARITY__) == IRDA_PARITY_NONE) || \
705 ((__PARITY__) == IRDA_PARITY_EVEN) || \
706 ((__PARITY__) == IRDA_PARITY_ODD))
708 #define IS_IRDA_TX_RX_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(IRDA_MODE_TX_RX)))) == (uint32_t)0x00) && ((__MODE__) != (uint32_t)0x00U))
710 #define IS_IRDA_POWERMODE(__MODE__) (((__MODE__) == IRDA_POWERMODE_LOWPOWER) || \
711 ((__MODE__) == IRDA_POWERMODE_NORMAL))
713 #define IS_IRDA_STATE(__STATE__) (((__STATE__) == IRDA_STATE_DISABLE) || \
714 ((__STATE__) == IRDA_STATE_ENABLE))
716 #define IS_IRDA_MODE(__STATE__) (((__STATE__) == IRDA_MODE_DISABLE) || \
717 ((__STATE__) == IRDA_MODE_ENABLE))
719 #define IS_IRDA_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_DISABLE) || \
720 ((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_ENABLE))
722 #define IS_IRDA_DMA_TX(__DMATX__) (((__DMATX__) == IRDA_DMA_TX_DISABLE) || \
723 ((__DMATX__) == IRDA_DMA_TX_ENABLE))
725 #define IS_IRDA_DMA_RX(__DMARX__) (((__DMARX__) == IRDA_DMA_RX_DISABLE) || \
726 ((__DMARX__) == IRDA_DMA_RX_ENABLE))
728 #define IS_IRDA_REQUEST_PARAMETER(PARAM) (((PARAM) == IRDA_AUTOBAUD_REQUEST) || \
729 ((PARAM) == IRDA_SENDBREAK_REQUEST) || \
730 ((PARAM) == IRDA_MUTE_MODE_REQUEST) || \
731 ((PARAM) == IRDA_RXDATA_FLUSH_REQUEST) || \
732 ((PARAM) == IRDA_TXDATA_FLUSH_REQUEST))
737 /* Private functions ---------------------------------------------------------*/
738 /** @defgroup IRDA_Private_Functions IRDA Private Functions
758 #endif /* __STM32F7xx_HAL_IRDA_H */
760 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/