21 #ifndef STM32F7xx_HAL_IRDA_H
22 #define STM32F7xx_HAL_IRDA_H
133 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
134 typedef struct __IRDA_HandleTypeDef
147 __IO uint16_t TxXferCount;
153 __IO uint16_t RxXferCount;
170 __IO uint32_t ErrorCode;
172 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
173 void (* TxHalfCpltCallback)(
struct __IRDA_HandleTypeDef *hirda);
175 void (* TxCpltCallback)(
struct __IRDA_HandleTypeDef *hirda);
177 void (* RxHalfCpltCallback)(
struct __IRDA_HandleTypeDef *hirda);
179 void (* RxCpltCallback)(
struct __IRDA_HandleTypeDef *hirda);
181 void (* ErrorCallback)(
struct __IRDA_HandleTypeDef *hirda);
183 void (* AbortCpltCallback)(
struct __IRDA_HandleTypeDef *hirda);
185 void (* AbortTransmitCpltCallback)(
struct __IRDA_HandleTypeDef *hirda);
187 void (* AbortReceiveCpltCallback)(
struct __IRDA_HandleTypeDef *hirda);
190 void (* MspInitCallback)(
struct __IRDA_HandleTypeDef *hirda);
192 void (* MspDeInitCallback)(
struct __IRDA_HandleTypeDef *hirda);
197 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
203 HAL_IRDA_TX_HALFCOMPLETE_CB_ID = 0x00U,
204 HAL_IRDA_TX_COMPLETE_CB_ID = 0x01U,
205 HAL_IRDA_RX_HALFCOMPLETE_CB_ID = 0x02U,
206 HAL_IRDA_RX_COMPLETE_CB_ID = 0x03U,
207 HAL_IRDA_ERROR_CB_ID = 0x04U,
208 HAL_IRDA_ABORT_COMPLETE_CB_ID = 0x05U,
209 HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U,
210 HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U,
212 HAL_IRDA_MSPINIT_CB_ID = 0x08U,
213 HAL_IRDA_MSPDEINIT_CB_ID = 0x09U
215 } HAL_IRDA_CallbackIDTypeDef;
236 #define HAL_IRDA_STATE_RESET 0x00000000U
238 #define HAL_IRDA_STATE_READY 0x00000020U
240 #define HAL_IRDA_STATE_BUSY 0x00000024U
242 #define HAL_IRDA_STATE_BUSY_TX 0x00000021U
244 #define HAL_IRDA_STATE_BUSY_RX 0x00000022U
246 #define HAL_IRDA_STATE_BUSY_TX_RX 0x00000023U
249 #define HAL_IRDA_STATE_TIMEOUT 0x000000A0U
251 #define HAL_IRDA_STATE_ERROR 0x000000E0U
260 #define HAL_IRDA_ERROR_NONE ((uint32_t)0x00000000U)
261 #define HAL_IRDA_ERROR_PE ((uint32_t)0x00000001U)
262 #define HAL_IRDA_ERROR_NE ((uint32_t)0x00000002U)
263 #define HAL_IRDA_ERROR_FE ((uint32_t)0x00000004U)
264 #define HAL_IRDA_ERROR_ORE ((uint32_t)0x00000008U)
265 #define HAL_IRDA_ERROR_DMA ((uint32_t)0x00000010U)
266 #define HAL_IRDA_ERROR_BUSY ((uint32_t)0x00000020U)
267 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
268 #define HAL_IRDA_ERROR_INVALID_CALLBACK ((uint32_t)0x00000040U)
277 #define IRDA_PARITY_NONE 0x00000000U
278 #define IRDA_PARITY_EVEN USART_CR1_PCE
279 #define IRDA_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS)
287 #define IRDA_MODE_RX USART_CR1_RE
288 #define IRDA_MODE_TX USART_CR1_TE
289 #define IRDA_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE)
297 #define IRDA_POWERMODE_NORMAL 0x00000000U
298 #define IRDA_POWERMODE_LOWPOWER USART_CR3_IRLP
306 #define IRDA_STATE_DISABLE 0x00000000U
307 #define IRDA_STATE_ENABLE USART_CR1_UE
315 #define IRDA_MODE_DISABLE 0x00000000U
316 #define IRDA_MODE_ENABLE USART_CR3_IREN
324 #define IRDA_ONE_BIT_SAMPLE_DISABLE 0x00000000U
325 #define IRDA_ONE_BIT_SAMPLE_ENABLE USART_CR3_ONEBIT
333 #define IRDA_DMA_TX_DISABLE 0x00000000U
334 #define IRDA_DMA_TX_ENABLE USART_CR3_DMAT
342 #define IRDA_DMA_RX_DISABLE 0x00000000U
343 #define IRDA_DMA_RX_ENABLE USART_CR3_DMAR
351 #define IRDA_AUTOBAUD_REQUEST USART_RQR_ABRRQ
352 #define IRDA_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ
353 #define IRDA_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ
363 #define IRDA_FLAG_TEACK USART_ISR_TEACK
364 #define IRDA_FLAG_BUSY USART_ISR_BUSY
365 #define IRDA_FLAG_ABRF USART_ISR_ABRF
366 #define IRDA_FLAG_ABRE USART_ISR_ABRE
367 #define IRDA_FLAG_TXE USART_ISR_TXE
368 #define IRDA_FLAG_TC USART_ISR_TC
369 #define IRDA_FLAG_RXNE USART_ISR_RXNE
370 #define IRDA_FLAG_ORE USART_ISR_ORE
371 #define IRDA_FLAG_NE USART_ISR_NE
372 #define IRDA_FLAG_FE USART_ISR_FE
373 #define IRDA_FLAG_PE USART_ISR_PE
388 #define IRDA_IT_PE 0x0028U
389 #define IRDA_IT_TXE 0x0727U
390 #define IRDA_IT_TC 0x0626U
391 #define IRDA_IT_RXNE 0x0525U
392 #define IRDA_IT_IDLE 0x0424U
400 #define IRDA_IT_ERR 0x0060U
404 #define IRDA_IT_ORE 0x0300U
405 #define IRDA_IT_NE 0x0200U
406 #define IRDA_IT_FE 0x0100U
414 #define IRDA_CLEAR_PEF USART_ICR_PECF
415 #define IRDA_CLEAR_FEF USART_ICR_FECF
416 #define IRDA_CLEAR_NEF USART_ICR_NCF
417 #define IRDA_CLEAR_OREF USART_ICR_ORECF
418 #define IRDA_CLEAR_IDLEF USART_ICR_IDLECF
419 #define IRDA_CLEAR_TCF USART_ICR_TCCF
427 #define IRDA_IT_MASK 0x001FU
428 #define IRDA_CR_MASK 0x00E0U
429 #define IRDA_CR_POS 5U
430 #define IRDA_ISR_MASK 0x1F00U
431 #define IRDA_ISR_POS 8U
449 #if USE_HAL_IRDA_REGISTER_CALLBACKS == 1
450 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \
451 (__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \
452 (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \
453 (__HANDLE__)->MspInitCallback = NULL; \
454 (__HANDLE__)->MspDeInitCallback = NULL; \
457 #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \
458 (__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \
459 (__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \
467 #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) \
469 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_RXDATA_FLUSH_REQUEST); \
470 SET_BIT((__HANDLE__)->Instance->RQR, IRDA_TXDATA_FLUSH_REQUEST); \
485 #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
491 #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_PEF)
498 #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_FEF)
504 #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_NEF)
510 #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_OREF)
516 #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_IDLEF)
535 #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
550 #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))): \
551 ((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 2U)? ((__HANDLE__)->Instance->CR2 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
552 ((__HANDLE__)->Instance->CR3 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))))
566 #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))): \
567 ((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \
568 ((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))))
585 #define __HAL_IRDA_GET_IT(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISR\
586 & (0x01U << (((__INTERRUPT__) & IRDA_ISR_MASK)>> IRDA_ISR_POS))) != 0U) ? SET : RESET)
600 #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 0x01U)? (__HANDLE__)->Instance->CR1 : \
601 (((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 0x02U)? (__HANDLE__)->Instance->CR2 : \
602 (__HANDLE__)->Instance->CR3)) & ((uint32_t)0x01U << (((uint16_t)(__INTERRUPT__)) & IRDA_IT_MASK))) != 0U) ? SET : RESET)
616 #define __HAL_IRDA_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
628 #define __HAL_IRDA_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
634 #define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
640 #define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3\
641 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
647 #define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
653 #define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
668 #define IS_IRDA_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 115201U)
674 #define IS_IRDA_PRESCALER(__PRESCALER__) ((__PRESCALER__) > 0U)
680 #define IS_IRDA_PARITY(__PARITY__) (((__PARITY__) == IRDA_PARITY_NONE) || \
681 ((__PARITY__) == IRDA_PARITY_EVEN) || \
682 ((__PARITY__) == IRDA_PARITY_ODD))
688 #define IS_IRDA_TX_RX_MODE(__MODE__) ((((__MODE__)\
689 & (~((uint32_t)(IRDA_MODE_TX_RX)))) == 0x00U) && ((__MODE__) != 0x00U))
695 #define IS_IRDA_POWERMODE(__MODE__) (((__MODE__) == IRDA_POWERMODE_LOWPOWER) || \
696 ((__MODE__) == IRDA_POWERMODE_NORMAL))
702 #define IS_IRDA_STATE(__STATE__) (((__STATE__) == IRDA_STATE_DISABLE) || \
703 ((__STATE__) == IRDA_STATE_ENABLE))
709 #define IS_IRDA_MODE(__MODE__) (((__MODE__) == IRDA_MODE_DISABLE) || \
710 ((__MODE__) == IRDA_MODE_ENABLE))
716 #define IS_IRDA_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_DISABLE) || \
717 ((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_ENABLE))
723 #define IS_IRDA_DMA_TX(__DMATX__) (((__DMATX__) == IRDA_DMA_TX_DISABLE) || \
724 ((__DMATX__) == IRDA_DMA_TX_ENABLE))
730 #define IS_IRDA_DMA_RX(__DMARX__) (((__DMARX__) == IRDA_DMA_RX_DISABLE) || \
731 ((__DMARX__) == IRDA_DMA_RX_ENABLE))
737 #define IS_IRDA_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == IRDA_AUTOBAUD_REQUEST) || \
738 ((__PARAM__) == IRDA_RXDATA_FLUSH_REQUEST) || \
739 ((__PARAM__) == IRDA_TXDATA_FLUSH_REQUEST))
762 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
765 pIRDA_CallbackTypeDef pCallback);