2 ******************************************************************************
3 * @file stm32f4xx_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 __STM32F4xx_HAL_IRDA_H
40 #define __STM32F4xx_HAL_IRDA_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f4xx_hal_def.h"
49 /** @addtogroup STM32F4xx_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 is computed using the following formula:
68 - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate)))
69 - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */
71 uint32_t WordLength
; /*!< Specifies the number of data bits transmitted or received in a frame.
72 This parameter can be a value of @ref IRDA_Word_Length */
74 uint32_t Parity
; /*!< Specifies the parity mode.
75 This parameter can be a value of @ref IRDA_Parity
76 @note When parity is enabled, the computed parity is inserted
77 at the MSB position of the transmitted data (9th bit when
78 the word length is set to 9 data bits; 8th bit when the
79 word length is set to 8 data bits). */
81 uint32_t Mode
; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
82 This parameter can be a value of @ref IRDA_Mode */
84 uint8_t Prescaler
; /*!< Specifies the Prescaler */
86 uint32_t IrDAMode
; /*!< Specifies the IrDA mode
87 This parameter can be a value of @ref IRDA_Low_Power */
91 * @brief HAL IRDA State structures definition
92 * @note HAL IRDA State value is a combination of 2 different substates: gState and RxState.
93 * - gState contains IRDA state information related to global Handle management
94 * and also information related to Tx operations.
95 * gState value coding follow below described bitmap :
96 * b7-b6 Error information
101 * b5 IP initilisation status
102 * 0 : Reset (IP not initialized)
103 * 1 : Init done (IP not initialized. HAL IRDA Init function already called)
105 * xx : Should be set to 00
106 * b2 Intrinsic process state
108 * 1 : Busy (IP busy with some configuration or internal operations)
110 * x : Should be set to 0
112 * 0 : Ready (no Tx operation ongoing)
113 * 1 : Busy (Tx operation ongoing)
114 * - RxState contains information related to Rx operations.
115 * RxState value coding follow below described bitmap :
117 * xx : Should be set to 00
118 * b5 IP initilisation status
119 * 0 : Reset (IP not initialized)
120 * 1 : Init done (IP not initialized)
122 * xxx : Should be set to 000
124 * 0 : Ready (no Rx operation ongoing)
125 * 1 : Busy (Rx operation ongoing)
127 * x : Should be set to 0.
131 HAL_IRDA_STATE_RESET
= 0x00U
, /*!< Peripheral is not yet Initialized
132 Value is allowed for gState and RxState */
133 HAL_IRDA_STATE_READY
= 0x20U
, /*!< Peripheral Initialized and ready for use
134 Value is allowed for gState and RxState */
135 HAL_IRDA_STATE_BUSY
= 0x24U
, /*!< An internal process is ongoing
136 Value is allowed for gState only */
137 HAL_IRDA_STATE_BUSY_TX
= 0x21U
, /*!< Data Transmission process is ongoing
138 Value is allowed for gState only */
139 HAL_IRDA_STATE_BUSY_RX
= 0x22U
, /*!< Data Reception process is ongoing
140 Value is allowed for RxState only */
141 HAL_IRDA_STATE_BUSY_TX_RX
= 0x23U
, /*!< Data Transmission and Reception process is ongoing
142 Not to be used for neither gState nor RxState.
143 Value is result of combination (Or) between gState and RxState values */
144 HAL_IRDA_STATE_TIMEOUT
= 0xA0U
, /*!< Timeout state
145 Value is allowed for gState only */
146 HAL_IRDA_STATE_ERROR
= 0xE0U
/*!< Error
147 Value is allowed for gState only */
148 }HAL_IRDA_StateTypeDef
;
151 * @brief IRDA handle Structure definition
155 USART_TypeDef
*Instance
; /* USART registers base address */
157 IRDA_InitTypeDef Init
; /* IRDA communication parameters */
159 uint8_t *pTxBuffPtr
; /* Pointer to IRDA Tx transfer Buffer */
161 uint16_t TxXferSize
; /* IRDA Tx Transfer size */
163 __IO
uint16_t TxXferCount
; /* IRDA Tx Transfer Counter */
165 uint8_t *pRxBuffPtr
; /* Pointer to IRDA Rx transfer Buffer */
167 uint16_t RxXferSize
; /* IRDA Rx Transfer size */
169 __IO
uint16_t RxXferCount
; /* IRDA Rx Transfer Counter */
171 DMA_HandleTypeDef
*hdmatx
; /* IRDA Tx DMA Handle parameters */
173 DMA_HandleTypeDef
*hdmarx
; /* IRDA Rx DMA Handle parameters */
175 HAL_LockTypeDef Lock
; /* Locking object */
177 __IO HAL_IRDA_StateTypeDef gState
; /* IRDA state information related to global Handle management
178 and also related to Tx operations.
179 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
181 __IO HAL_IRDA_StateTypeDef RxState
; /* IRDA state information related to Rx operations.
182 This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
184 __IO
uint32_t ErrorCode
; /* IRDA Error code */
191 /* Exported constants --------------------------------------------------------*/
192 /** @defgroup IRDA_Exported_Constants IRDA Exported constants
195 /** @defgroup IRDA_Error_Code IRDA Error Code
196 * @brief IRDA Error Code
199 #define HAL_IRDA_ERROR_NONE 0x00000000U /*!< No error */
200 #define HAL_IRDA_ERROR_PE 0x00000001U /*!< Parity error */
201 #define HAL_IRDA_ERROR_NE 0x00000002U /*!< Noise error */
202 #define HAL_IRDA_ERROR_FE 0x00000004U /*!< Frame error */
203 #define HAL_IRDA_ERROR_ORE 0x00000008U /*!< Overrun error */
204 #define HAL_IRDA_ERROR_DMA 0x00000010U /*!< DMA transfer error */
209 /** @defgroup IRDA_Word_Length IRDA Word Length
212 #define IRDA_WORDLENGTH_8B 0x00000000U
213 #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
218 /** @defgroup IRDA_Parity IRDA Parity
221 #define IRDA_PARITY_NONE 0x00000000U
222 #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
223 #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
228 /** @defgroup IRDA_Mode IRDA Transfer Mode
231 #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE)
232 #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE)
233 #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
238 /** @defgroup IRDA_Low_Power IRDA Low Power
241 #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP)
242 #define IRDA_POWERMODE_NORMAL 0x00000000U
247 /** @defgroup IRDA_Flags IRDA Flags
248 * Elements values convention: 0xXXXX
249 * - 0xXXXX : Flag mask in the SR register
252 #define IRDA_FLAG_TXE 0x00000080U
253 #define IRDA_FLAG_TC 0x00000040U
254 #define IRDA_FLAG_RXNE 0x00000020U
255 #define IRDA_FLAG_IDLE 0x00000010U
256 #define IRDA_FLAG_ORE 0x00000008U
257 #define IRDA_FLAG_NE 0x00000004U
258 #define IRDA_FLAG_FE 0x00000002U
259 #define IRDA_FLAG_PE 0x00000001U
264 /** @defgroup IRDA_Interrupt_definition IRDA Interrupt Definitions
265 * Elements values convention: 0xY000XXXX
266 * - XXXX : Interrupt mask in the XX register
267 * - Y : Interrupt source register (2bits)
273 #define IRDA_IT_PE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
274 #define IRDA_IT_TXE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
275 #define IRDA_IT_TC ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
276 #define IRDA_IT_RXNE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
277 #define IRDA_IT_IDLE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
279 #define IRDA_IT_LBD ((uint32_t)(IRDA_CR2_REG_INDEX << 28U | USART_CR2_LBDIE))
281 #define IRDA_IT_CTS ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_CTSIE))
282 #define IRDA_IT_ERR ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_EIE))
291 /* Exported macro ------------------------------------------------------------*/
292 /** @defgroup IRDA_Exported_Macros IRDA Exported Macros
296 /** @brief Reset IRDA handle gstate & RxState
297 * @param __HANDLE__: specifies the USART Handle.
298 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
302 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \
303 (__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \
304 (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \
307 /** @brief Flushs the IRDA DR register
308 * @param __HANDLE__: specifies the USART Handle.
309 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
312 #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
314 /** @brief Checks whether the specified IRDA flag is set or not.
315 * @param __HANDLE__: specifies the USART Handle.
316 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
318 * @param __FLAG__: specifies the flag to check.
319 * This parameter can be one of the following values:
320 * @arg IRDA_FLAG_TXE: Transmit data register empty flag
321 * @arg IRDA_FLAG_TC: Transmission Complete flag
322 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag
323 * @arg IRDA_FLAG_IDLE: Idle Line detection flag
324 * @arg IRDA_FLAG_ORE: OverRun Error flag
325 * @arg IRDA_FLAG_NE: Noise Error flag
326 * @arg IRDA_FLAG_FE: Framing Error flag
327 * @arg IRDA_FLAG_PE: Parity Error flag
328 * @retval The new state of __FLAG__ (TRUE or FALSE).
330 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
332 /** @brief Clears the specified IRDA pending flag.
333 * @param __HANDLE__: specifies the USART Handle.
334 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
336 * @param __FLAG__: specifies the flag to check.
337 * This parameter can be any combination of the following values:
338 * @arg IRDA_FLAG_TC: Transmission Complete flag.
339 * @arg IRDA_FLAG_RXNE: Receive data register not empty flag.
341 * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun
342 * error) and IDLE (Idle line detected) flags are cleared by software
343 * sequence: a read operation to USART_SR register followed by a read
344 * operation to USART_DR register.
345 * @note RXNE flag can be also cleared by a read to the USART_DR register.
346 * @note TC flag can be also cleared by software sequence: a read operation to
347 * USART_SR register followed by a write operation to USART_DR register.
348 * @note TXE flag is cleared only by a write to the USART_DR register.
352 #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
354 /** @brief Clear the IRDA PE pending flag.
355 * @param __HANDLE__: specifies the USART Handle.
356 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
360 #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) \
362 __IO uint32_t tmpreg = 0x00U; \
363 tmpreg = (__HANDLE__)->Instance->SR; \
367 /** @brief Clear the IRDA FE pending flag.
368 * @param __HANDLE__: specifies the USART Handle.
369 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
373 #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
375 /** @brief Clear the IRDA NE pending flag.
376 * @param __HANDLE__: specifies the USART Handle.
377 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
381 #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
383 /** @brief Clear the IRDA ORE pending flag.
384 * @param __HANDLE__: specifies the USART Handle.
385 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
389 #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
391 /** @brief Clear the IRDA IDLE pending flag.
392 * @param __HANDLE__: specifies the USART Handle.
393 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
397 #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
399 /** @brief Enables or disables the specified IRDA interrupt.
400 * @param __HANDLE__: specifies the USART Handle.
401 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
403 * @param __INTERRUPT__: specifies the IRDA interrupt source to check.
404 * This parameter can be one of the following values:
405 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
406 * @arg IRDA_IT_TC: Transmission complete interrupt
407 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
408 * @arg IRDA_IT_IDLE: Idle line detection interrupt
409 * @arg IRDA_IT_PE: Parity Error interrupt
410 * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
413 #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \
414 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \
415 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK)))
416 #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
417 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
418 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK)))
420 /** @brief Checks whether the specified IRDA interrupt has occurred or not.
421 * @param __HANDLE__: specifies the USART Handle.
422 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
424 * @param __IT__: specifies the IRDA interrupt source to check.
425 * This parameter can be one of the following values:
426 * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
427 * @arg IRDA_IT_TC: Transmission complete interrupt
428 * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
429 * @arg IRDA_IT_IDLE: Idle line detection interrupt
430 * @arg USART_IT_ERR: Error interrupt
431 * @arg IRDA_IT_PE: Parity Error interrupt
432 * @retval The new state of __IT__ (TRUE or FALSE).
434 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == 2U)? \
435 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK))
437 /** @brief Macro to enable the IRDA's one bit sample method
438 * @param __HANDLE__: specifies the IRDA Handle.
441 #define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
443 /** @brief Macro to disable the IRDA's one bit sample method
444 * @param __HANDLE__: specifies the IRDA Handle.
447 #define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
449 /** @brief Enable UART/USART associated to IRDA Handle
450 * @param __HANDLE__: specifies the IRDA Handle.
451 * IRDA Handle selects the USARTx or UARTy peripheral
452 * (USART,UART availability and x,y values depending on device).
455 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
457 /** @brief Disable UART/USART associated to IRDA Handle
458 * @param __HANDLE__: specifies the IRDA Handle.
459 * IRDA Handle selects the USARTx or UARTy peripheral
460 * (USART,UART availability and x,y values depending on device).
463 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
469 /* Exported functions --------------------------------------------------------*/
470 /** @addtogroup IRDA_Exported_Functions
474 /** @addtogroup IRDA_Exported_Functions_Group1
477 /* Initialization/de-initialization functions **********************************/
478 HAL_StatusTypeDef
HAL_IRDA_Init(IRDA_HandleTypeDef
*hirda
);
479 HAL_StatusTypeDef
HAL_IRDA_DeInit(IRDA_HandleTypeDef
*hirda
);
480 void HAL_IRDA_MspInit(IRDA_HandleTypeDef
*hirda
);
481 void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef
*hirda
);
486 /** @addtogroup IRDA_Exported_Functions_Group2
489 /* IO operation functions *******************************************************/
490 HAL_StatusTypeDef
HAL_IRDA_Transmit(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
, uint32_t Timeout
);
491 HAL_StatusTypeDef
HAL_IRDA_Receive(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
, uint32_t Timeout
);
492 HAL_StatusTypeDef
HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
);
493 HAL_StatusTypeDef
HAL_IRDA_Receive_IT(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
);
494 HAL_StatusTypeDef
HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
);
495 HAL_StatusTypeDef
HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef
*hirda
, uint8_t *pData
, uint16_t Size
);
496 HAL_StatusTypeDef
HAL_IRDA_DMAPause(IRDA_HandleTypeDef
*hirda
);
497 HAL_StatusTypeDef
HAL_IRDA_DMAResume(IRDA_HandleTypeDef
*hirda
);
498 HAL_StatusTypeDef
HAL_IRDA_DMAStop(IRDA_HandleTypeDef
*hirda
);
499 /* Transfer Abort functions */
500 HAL_StatusTypeDef
HAL_IRDA_Abort(IRDA_HandleTypeDef
*hirda
);
501 HAL_StatusTypeDef
HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef
*hirda
);
502 HAL_StatusTypeDef
HAL_IRDA_AbortReceive(IRDA_HandleTypeDef
*hirda
);
503 HAL_StatusTypeDef
HAL_IRDA_Abort_IT(IRDA_HandleTypeDef
*hirda
);
504 HAL_StatusTypeDef
HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef
*hirda
);
505 HAL_StatusTypeDef
HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef
*hirda
);
507 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef
*hirda
);
508 void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef
*hirda
);
509 void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef
*hirda
);
510 void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef
*hirda
);
511 void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef
*hirda
);
512 void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef
*hirda
);
513 void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef
*hirda
);
514 void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef
*hirda
);
515 void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef
*hirda
);
520 /** @addtogroup IRDA_Exported_Functions_Group3
523 /* Peripheral State functions **************************************************/
524 HAL_IRDA_StateTypeDef
HAL_IRDA_GetState(IRDA_HandleTypeDef
*hirda
);
525 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef
*hirda
);
534 /* Private types -------------------------------------------------------------*/
535 /* Private variables ---------------------------------------------------------*/
536 /* Private constants ---------------------------------------------------------*/
537 /** @defgroup IRDA_Private_Constants IRDA Private Constants
541 /** @brief IRDA interruptions flag mask
544 #define IRDA_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
545 USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE )
547 #define IRDA_CR1_REG_INDEX 1U
548 #define IRDA_CR2_REG_INDEX 2U
549 #define IRDA_CR3_REG_INDEX 3U
554 /* Private macros --------------------------------------------------------*/
555 /** @defgroup IRDA_Private_Macros IRDA Private Macros
558 #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \
559 ((LENGTH) == IRDA_WORDLENGTH_9B))
560 #define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \
561 ((PARITY) == IRDA_PARITY_EVEN) || \
562 ((PARITY) == IRDA_PARITY_ODD))
563 #define IS_IRDA_MODE(MODE) ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x00000000U))
564 #define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \
565 ((MODE) == IRDA_POWERMODE_NORMAL))
566 #define IS_IRDA_BAUDRATE(BAUDRATE) ((BAUDRATE) < 115201U)
568 #define IRDA_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_)))
569 #define IRDA_DIVMANT(_PCLK_, _BAUD_) (IRDA_DIV((_PCLK_), (_BAUD_))/100U)
570 #define IRDA_DIVFRAQ(_PCLK_, _BAUD_) (((IRDA_DIV((_PCLK_), (_BAUD_)) - (IRDA_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
571 /* UART BRR = mantissa + overflow + fraction
572 = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */
573 #define IRDA_BRR(_PCLK_, _BAUD_) (((IRDA_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \
574 (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U)) + \
575 (IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
581 /* Private functions ---------------------------------------------------------*/
582 /** @defgroup IRDA_Private_Functions IRDA Private Functions
602 #endif /* __STM32F4xx_HAL_IRDA_H */
604 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/