2 ******************************************************************************
3 * @file stm32l0xx_hal_irda.h
4 * @author MCD Application Team
6 * @date 06-February-2015
7 * @brief Header file of IRDA HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2015 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 __STM32L0xx_HAL_IRDA_H
40 #define __STM32L0xx_HAL_IRDA_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l0xx_hal_def.h"
49 /** @addtogroup STM32L0xx_HAL_Driver
53 /** @defgroup IRDA IRDA
57 /* Exported types ------------------------------------------------------------*/
60 * @brief IRDA Init Structure definition
64 uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate.
65 The baud rate register is computed using the following formula:
66 Baud Rate Register = ((PCLKx) / ((hirda->Init.BaudRate))) */
68 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
69 This parameter can be a value of @ref IRDAEx_Word_Length */
71 uint32_t Parity; /*!< Specifies the parity mode.
72 This parameter can be a value of @ref IRDA_Parity
73 @note When parity is enabled, the computed parity is inserted
74 at the MSB position of the transmitted data (9th bit when
75 the word length is set to 9 data bits; 8th bit when the
76 word length is set to 8 data bits). */
78 uint16_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
79 This parameter can be a value of @ref IRDA_Mode */
81 uint8_t Prescaler; /*!< Specifies the Prescaler value for dividing the UART/USART source clock
82 to achieve low-power frequency.
83 @note Prescaler value 0 is forbidden */
85 uint16_t PowerMode; /*!< Specifies the IRDA power mode.
86 This parameter can be a value of @ref IRDA_Low_Power */
90 * @brief HAL IRDA State structures definition
94 HAL_IRDA_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */
95 HAL_IRDA_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
96 HAL_IRDA_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
97 HAL_IRDA_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
98 HAL_IRDA_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
99 HAL_IRDA_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
100 HAL_IRDA_STATE_TIMEOUT = 0x03, /*!< Timeout state */
101 HAL_IRDA_STATE_ERROR = 0x04 /*!< Error */
102 }HAL_IRDA_StateTypeDef;
105 * @brief HAL IRDA Error Code definition
108 #define HAL_IRDA_ERROR_NONE ((uint32_t)0x00) /*!< No error */
109 #define HAL_IRDA_ERROR_PE ((uint32_t)0x01) /*!< Parity error */
110 #define HAL_IRDA_ERROR_NE ((uint32_t)0x02) /*!< Noise error */
111 #define HAL_IRDA_ERROR_FE ((uint32_t)0x04) /*!< frame error */
112 #define HAL_IRDA_ERROR_ORE ((uint32_t)0x08) /*!< Overrun error */
113 #define HAL_IRDA_ERROR_DMA ((uint32_t)0x10) /*!< DMA transfer error */
116 * @brief IRDA clock sources definition
120 IRDA_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
121 IRDA_CLOCKSOURCE_PCLK2 = 0x01, /*!< PCLK2 clock source */
122 IRDA_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
123 IRDA_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
124 IRDA_CLOCKSOURCE_LSE = 0x08 /*!< LSE clock source */
125 }IRDA_ClockSourceTypeDef;
128 * @brief IRDA handle Structure definition
132 USART_TypeDef *Instance; /* IRDA registers base address */
134 IRDA_InitTypeDef Init; /* IRDA communication parameters */
136 uint8_t *pTxBuffPtr; /* Pointer to IRDA Tx transfer Buffer */
138 uint16_t TxXferSize; /* IRDA Tx Transfer size */
140 uint16_t TxXferCount; /* IRDA Tx Transfer Counter */
142 uint8_t *pRxBuffPtr; /* Pointer to IRDA Rx transfer Buffer */
144 uint16_t RxXferSize; /* IRDA Rx Transfer size */
146 uint16_t RxXferCount; /* IRDA Rx Transfer Counter */
148 uint16_t Mask; /* IRDA RX RDR register mask */
150 DMA_HandleTypeDef *hdmatx; /* IRDA Tx DMA Handle parameters */
152 DMA_HandleTypeDef *hdmarx; /* IRDA Rx DMA Handle parameters */
154 HAL_LockTypeDef Lock; /* Locking object */
156 __IO HAL_IRDA_StateTypeDef State; /* IRDA communication state */
158 __IO uint32_t ErrorCode; /* IRDA Error code */
163 * @brief IRDA Configuration enumeration values definition
166 /* Exported constants --------------------------------------------------------*/
167 /** @defgroup IRDA_Exported_Constants IRDA Exported Constants
171 /** @defgroup IRDA_Parity IRDA Parity
174 #define IRDA_PARITY_NONE ((uint32_t)0x0000)
175 #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
176 #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
177 #define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \
178 ((PARITY) == IRDA_PARITY_EVEN) || \
179 ((PARITY) == IRDA_PARITY_ODD))
185 /** @defgroup IRDA_Transfer_Mode IRDA transfer mode
188 #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE)
189 #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE)
190 #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
191 #define IS_IRDA_TX_RX_MODE(MODE) ((((MODE) & (~((uint32_t)(IRDA_MODE_TX_RX)))) == (uint32_t)0x00) && ((MODE) != (uint32_t)0x00))
196 /** @defgroup IRDA_Low_Power IRDA low power
199 #define IRDA_POWERMODE_NORMAL ((uint32_t)0x0000)
200 #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP)
201 #define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \
202 ((MODE) == IRDA_POWERMODE_NORMAL))
207 /** @defgroup IRDA_State IRDA State
210 #define IRDA_STATE_DISABLE ((uint32_t)0x0000)
211 #define IRDA_STATE_ENABLE ((uint32_t)USART_CR1_UE)
212 #define IS_IRDA_STATE(STATE) (((STATE) == IRDA_STATE_DISABLE) || \
213 ((STATE) == IRDA_STATE_ENABLE))
218 /** @defgroup IRDA_Mode IRDA Mode
221 #define IRDA_MODE_DISABLE ((uint32_t)0x0000)
222 #define IRDA_MODE_ENABLE ((uint32_t)USART_CR3_IREN)
223 #define IS_IRDA_MODE(STATE) (((STATE) == IRDA_MODE_DISABLE) || \
224 ((STATE) == IRDA_MODE_ENABLE))
229 /** @defgroup IRDA_One_Bit IRDA One bit
232 #define IRDA_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x00000000)
233 #define IRDA_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT)
234 #define IS_IRDA_ONE_BIT_SAMPLE(ONEBIT) (((ONEBIT) == IRDA_ONE_BIT_SAMPLE_DISABLE) || \
235 ((ONEBIT) == IRDA_ONE_BIT_SAMPLE_ENABLE))
240 /** @defgroup IRDA_DMA_Tx IRDA DMA TX
243 #define IRDA_DMA_TX_DISABLE ((uint32_t)0x00000000)
244 #define IRDA_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT)
245 #define IS_IRDA_DMA_TX(DMATX) (((DMATX) == IRDA_DMA_TX_DISABLE) || \
246 ((DMATX) == IRDA_DMA_TX_ENABLE))
251 /** @defgroup IRDA_DMA_Rx IRDA DMA RX
254 #define IRDA_DMA_RX_DISABLE ((uint32_t)0x0000)
255 #define IRDA_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR)
256 #define IS_IRDA_DMA_RX(DMARX) (((DMARX) == IRDA_DMA_RX_DISABLE) || \
257 ((DMARX) == IRDA_DMA_RX_ENABLE))
262 /** @defgroup IRDA_Flags IRDA Flags
263 * Elements values convention: 0xXXXX
264 * - 0xXXXX : Flag mask in the ISR register
267 #define IRDA_FLAG_REACK ((uint32_t)0x00400000)
268 #define IRDA_FLAG_TEACK ((uint32_t)0x00200000)
269 #define IRDA_FLAG_BUSY ((uint32_t)0x00010000)
270 #define IRDA_FLAG_ABRF ((uint32_t)0x00008000)
271 #define IRDA_FLAG_ABRE ((uint32_t)0x00004000)
272 #define IRDA_FLAG_TXE ((uint32_t)0x00000080)
273 #define IRDA_FLAG_TC ((uint32_t)0x00000040)
274 #define IRDA_FLAG_RXNE ((uint32_t)0x00000020)
275 #define IRDA_FLAG_ORE ((uint32_t)0x00000008)
276 #define IRDA_FLAG_NE ((uint32_t)0x00000004)
277 #define IRDA_FLAG_FE ((uint32_t)0x00000002)
278 #define IRDA_FLAG_PE ((uint32_t)0x00000001)
283 /** @defgroup IRDA_Interrupt_definition IRDA Interrupt definition
284 * Elements values convention: 0000ZZZZ0XXYYYYYb
285 * - YYYYY : Interrupt source position in the XX register (5bits)
286 * - XX : Interrupt source register (2bits)
290 * - ZZZZ : Flag position in the ISR register(4bits)
293 #define IRDA_IT_PE ((uint16_t)0x0028)
294 #define IRDA_IT_TXE ((uint16_t)0x0727)
295 #define IRDA_IT_TC ((uint16_t)0x0626)
296 #define IRDA_IT_RXNE ((uint16_t)0x0525)
297 #define IRDA_IT_IDLE ((uint16_t)0x0424)
301 /** Elements values convention: 000000000XXYYYYYb
302 * - YYYYY : Interrupt source position in the XX register (5bits)
303 * - XX : Interrupt source register (2bits)
308 #define IRDA_IT_ERR ((uint16_t)0x0060)
310 /** Elements values convention: 0000ZZZZ00000000b
311 * - ZZZZ : Flag position in the ISR register(4bits)
313 #define IRDA_IT_ORE ((uint16_t)0x0300)
314 #define IRDA_IT_NE ((uint16_t)0x0200)
315 #define IRDA_IT_FE ((uint16_t)0x0100)
320 /** @defgroup IRDA_IT_CLEAR_Flags IRDA Interrupt clear flag
323 #define IRDA_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
324 #define IRDA_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
325 #define IRDA_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
326 #define IRDA_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
327 #define IRDA_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
328 #define IRDA_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
335 /** @defgroup IRDA_Request_Parameters IRDA Request parameters
338 #define IRDA_AUTOBAUD_REQUEST ((uint32_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
339 #define IRDA_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
340 #define IRDA_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
341 #define IS_IRDA_REQUEST_PARAMETER(PARAM) (((PARAM) == IRDA_AUTOBAUD_REQUEST) || \
342 ((PARAM) == IRDA_SENDBREAK_REQUEST) || \
343 ((PARAM) == IRDA_MUTE_MODE_REQUEST) || \
344 ((PARAM) == IRDA_RXDATA_FLUSH_REQUEST) || \
345 ((PARAM) == IRDA_TXDATA_FLUSH_REQUEST))
350 /** @defgroup IRDA_Interruption_Mask IRDA Interruption mask
353 #define IRDA_IT_MASK ((uint16_t)0x001F)
363 /* Exported macro ------------------------------------------------------------*/
364 /** @defgroup IRDA_Exported_Macros IRDA Exported Macros
368 /** @brief Reset IRDA handle state
369 * @param __HANDLE__: specifies the IRDA Handle.
370 * The Handle Instance which can be USART1 or USART2.
373 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IRDA_STATE_RESET)
375 /** @brief Flushs the IRDA DR register
376 * @param __HANDLE__: specifies the IRDA Handle.
377 * The Handle Instance which can be USART1 or USART2.
380 #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) \
382 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_RXDATA_FLUSH_REQUEST); \
383 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_TXDATA_FLUSH_REQUEST); \
387 /** @brief Clears the specified IRDA pending flag.
388 * @param __HANDLE__: specifies the IRDA Handle.
389 * @param __FLAG__: specifies the flag to check.
390 * This parameter can be any combination of the following values:
391 * @arg IRDA_CLEAR_PEF
392 * @arg IRDA_CLEAR_FEF
393 * @arg IRDA_CLEAR_NEF
394 * @arg IRDA_CLEAR_OREF
395 * @arg IRDA_CLEAR_TCF
396 * @arg IRDA_CLEAR_IDLEF
399 #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = ~(__FLAG__))
401 /** @brief Clear the IRDA PE pending flag.
402 * @param __HANDLE__: specifies the IRDA Handle.
405 #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG(__HANDLE__, IRDA_CLEAR_PEF)
408 /** @brief Clear the IRDA FE pending flag.
409 * @param __HANDLE__: specifies the IRDA Handle.
412 #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG(__HANDLE__, IRDA_CLEAR_FEF)
414 /** @brief Clear the IRDA NE pending flag.
415 * @param __HANDLE__: specifies the IRDA Handle.
418 #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG(__HANDLE__, IRDA_CLEAR_NEF)
420 /** @brief Clear the IRDA ORE pending flag.
421 * @param __HANDLE__: specifies the IRDA Handle.
424 #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG(__HANDLE__, IRDA_CLEAR_OREF)
426 /** @brief Clear the IRDA IDLE pending flag.
427 * @param __HANDLE__: specifies the IRDA Handle.
430 #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG(__HANDLE__, IRDA_CLEAR_IDLEF)
432 /** @brief Check whether the specified IRDA flag is set or not.
433 * @param __HANDLE__: specifies the IRDA Handle.
434 * The Handle Instance which can be USART1 or USART2.
436 * @param __FLAG__: specifies the flag to check.
437 * This parameter can be one of the following values:
438 * @arg IRDA_FLAG_REACK: Receive enable ackowledge flag
439 * @arg IRDA_FLAG_TEACK: Transmit enable ackowledge flag
440 * @arg IRDA_FLAG_BUSY: Busy flag
441 * @arg IRDA_FLAG_ABRF: Auto Baud rate detection flag
442 * @arg IRDA_FLAG_ABRE: Auto Baud rate detection error flag
443 * @arg IRDA_FLAG_TXE: Transmit data register empty flag
444 * @arg IRDA_FLAG_TC: Transmission Complete flag
445 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag
446 * @arg IRDA_FLAG_IDLE: Idle Line detection flag
447 * @arg IRDA_FLAG_ORE: OverRun Error flag
448 * @arg IRDA_FLAG_NE: Noise Error flag
449 * @arg IRDA_FLAG_FE: Framing Error flag
450 * @arg IRDA_FLAG_PE: Parity Error flag
451 * @retval The new state of __FLAG__ (TRUE or FALSE).
453 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
455 /** @brief Enable the specified IRDA interrupt.
456 * @param __HANDLE__: specifies the IRDA Handle.
457 * The Handle Instance which can be USART1 or USART2.
459 * @param __INTERRUPT__: specifies the IRDA interrupt source to enable.
460 * This parameter can be one of the following values:
461 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
462 * @arg IRDA_IT_TC: Transmission complete interrupt
463 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
464 * @arg IRDA_IT_IDLE: Idle line detection interrupt
465 * @arg IRDA_IT_PE: Parity Error interrupt
466 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
469 #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5) == 1)? ((__HANDLE__)->Instance->CR1 |= (1 << ((__INTERRUPT__) & IRDA_IT_MASK))): \
470 ((((uint8_t)(__INTERRUPT__)) >> 5) == 2)? ((__HANDLE__)->Instance->CR2 |= (1 << ((__INTERRUPT__) & IRDA_IT_MASK))): \
471 ((__HANDLE__)->Instance->CR3 |= (1 << ((__INTERRUPT__) & IRDA_IT_MASK))))
473 /** @brief Disable the specified IRDA interrupt.
474 * @param __HANDLE__: specifies the IRDA Handle.
475 * The Handle Instance which can be USART1 or USART2.
476 * @param __INTERRUPT__: specifies the IRDA interrupt source to disable.
477 * This parameter can be one of the following values:
478 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
479 * @arg IRDA_IT_TC: Transmission complete interrupt
480 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
481 * @arg IRDA_IT_IDLE: Idle line detection interrupt
482 * @arg IRDA_IT_PE: Parity Error interrupt
483 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
486 #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ ((uint32_t)1 << ((__INTERRUPT__) & IRDA_IT_MASK))): \
487 ((((uint8_t)(__INTERRUPT__)) >> 5) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1 << ((__INTERRUPT__) & IRDA_IT_MASK))): \
488 ((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1 << ((__INTERRUPT__) & IRDA_IT_MASK))))
490 /** @brief Check whether the specified IRDA interrupt has occurred or not.
491 * @param __HANDLE__: specifies the IRDA Handle.
492 * The Handle Instance which can be USART1 or USART2.
493 * @param __IT__: specifies the IRDA interrupt source to check.
494 * This parameter can be one of the following values:
495 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
496 * @arg IRDA_IT_TC: Transmission complete interrupt
497 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
498 * @arg IRDA_IT_IDLE: Idle line detection interrupt
499 * @arg IRDA_IT_ORE: OverRun Error interrupt
500 * @arg IRDA_IT_NE: Noise Error interrupt
501 * @arg IRDA_IT_FE: Framing Error interrupt
502 * @arg IRDA_IT_PE: Parity Error interrupt
503 * @retval The new state of __IT__ (TRUE or FALSE).
505 #define __HAL_IRDA_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
507 /** @brief Check whether the specified IRDA interrupt source is enabled.
508 * @param __HANDLE__: specifies the IRDA Handle.
509 * The Handle Instance which can be USART1 or USART2.
510 * @param __IT__: specifies the IRDA interrupt source to check.
511 * This parameter can be one of the following values:
512 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
513 * @arg IRDA_IT_TC: Transmission complete interrupt
514 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
515 * @arg IRDA_IT_IDLE: Idle line detection interrupt
516 * @arg IRDA_IT_ORE: OverRun Error interrupt
517 * @arg IRDA_IT_NE: Noise Error interrupt
518 * @arg IRDA_IT_FE: Framing Error interrupt
519 * @arg IRDA_IT_PE: Parity Error interrupt
520 * @retval The new state of __IT__ (TRUE or FALSE).
522 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \
523 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & IRDA_IT_MASK)))
525 /** @brief Clear the specified IRDA ISR flag, in setting the proper ICR register flag.
526 * @param __HANDLE__: specifies the IRDA Handle.
527 * The Handle Instance which can be USART1 or USART2.
528 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
529 * to clear the corresponding interrupt
530 * This parameter can be one of the following values:
531 * @arg IRDA_CLEAR_PEF: Parity Error Clear Flag
532 * @arg IRDA_CLEAR_FEF: Framing Error Clear Flag
533 * @arg IRDA_CLEAR_NEF: Noise detected Clear Flag
534 * @arg IRDA_CLEAR_OREF: OverRun Error Clear Flag
535 * @arg IRDA_CLEAR_TCF: Transmission Complete Clear Flag
538 #define __HAL_IRDA_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR |= (uint32_t)(__IT_CLEAR__))
540 /** @brief Set a specific IRDA request flag.
541 * @param __HANDLE__: specifies the IRDA Handle.
542 * The Handle Instance which can be USART1 or USART2.
543 * @param __REQ__: specifies the request flag to set
544 * This parameter can be one of the following values:
545 * @arg IRDA_AUTOBAUD_REQUEST: Auto-Baud Rate Request
546 * @arg IRDA_RXDATA_FLUSH_REQUEST: Receive Data flush Request
547 * @arg IRDA_TXDATA_FLUSH_REQUEST: Transmit data flush Request
551 #define __HAL_IRDA_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint32_t)(__REQ__))
553 /** @brief Enables the IRDA one bit sample method
554 * @param __HANDLE__: specifies the IRDA Handle.
557 #define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
559 /** @brief Disables the IRDA one bit sample method
560 * @param __HANDLE__: specifies the IRDA Handle.
563 #define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
565 /** @brief Enable UART/USART associated to IRDA Handle
566 * @param __HANDLE__: specifies the IRDA Handle.
567 * The Handle Instance which can be USART1 or USART2.
570 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
572 /** @brief Disable UART/USART associated to IRDA Handle
573 * @param __HANDLE__: specifies the IRDA Handle.
574 * The Handle Instance which can be USART1 or USART2.
577 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
579 /** @brief Ensure that IRDA Baud rate is less or equal to maximum value
580 * @param __BAUDRATE__: specifies the IRDA Baudrate set by the user.
581 * @retval True or False
583 #define IS_IRDA_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 115201)
585 /** @brief Ensure that IRDA prescaler value is strictly larger than 0
586 * @param __PRESCALER__: specifies the IRDA prescaler value set by the user.
587 * @retval True or False
589 #define IS_IRDA_PRESCALER(__PRESCALER__) ((__PRESCALER__) > 0)
595 /* Include IRDA HAL Extension module */
596 #include "stm32l0xx_hal_irda_ex.h"
598 /* Exported functions --------------------------------------------------------*/
599 /** @defgroup IRDA_Exported_Functions IRDA Exported Functions
603 /** @defgroup IRDA_Exported_Functions_Group1 Initialization and de-initialization functions
606 /* Exported functions --------------------------------------------------------*/
607 /* Initialization/de-initialization methods **********************************/
608 HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda);
609 HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda);
610 void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda);
611 void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda);
616 /** @defgroup IRDA_Exported_Functions_Group2 IRDA IO operationfunctions
620 /* IO operation methods *******************************************************/
621 HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
622 HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
623 HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
624 HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
625 HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
626 HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
627 HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda);
628 HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda);
629 HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda);
630 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda);
631 void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda);
632 void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda);
633 void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
634 void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
635 void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda);
640 /** @defgroup IRDA_Exported_Functions_Group3 Peripheral Control functions
643 /* Peripheral State methods **************************************************/
644 HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda);
645 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda);
666 #endif /* __STM32L0xx_HAL_IRDA_H */
668 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/