STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
stm32f4xx_hal_irda.c
Go to the documentation of this file.
1
202/* Includes ------------------------------------------------------------------*/
203#include "stm32f4xx_hal.h"
204
214#ifdef HAL_IRDA_MODULE_ENABLED
215
216/* Private typedef -----------------------------------------------------------*/
217/* Private define ------------------------------------------------------------*/
218/* Private constants ---------------------------------------------------------*/
219/* Private macro -------------------------------------------------------------*/
220/* Private variables ---------------------------------------------------------*/
221/* Private function prototypes -----------------------------------------------*/
225#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
226void IRDA_InitCallbacksToDefault(IRDA_HandleTypeDef *hirda);
227#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
228static void IRDA_SetConfig(IRDA_HandleTypeDef *hirda);
232static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma);
234static void IRDA_DMAReceiveCplt(DMA_HandleTypeDef *hdma);
236static void IRDA_DMAError(DMA_HandleTypeDef *hdma);
237static void IRDA_DMAAbortOnError(DMA_HandleTypeDef *hdma);
242static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout);
243static void IRDA_EndTxTransfer(IRDA_HandleTypeDef *hirda);
244static void IRDA_EndRxTransfer(IRDA_HandleTypeDef *hirda);
249/* Exported functions --------------------------------------------------------*/
294{
295 /* Check the IRDA handle allocation */
296 if (hirda == NULL)
297 {
298 return HAL_ERROR;
299 }
300
301 /* Check the IRDA instance parameters */
302 assert_param(IS_IRDA_INSTANCE(hirda->Instance));
303 /* Check the IRDA mode parameter in the IRDA handle */
305
306 if (hirda->gState == HAL_IRDA_STATE_RESET)
307 {
308 /* Allocate lock resource and initialize it */
309 hirda->Lock = HAL_UNLOCKED;
310
311#if USE_HAL_IRDA_REGISTER_CALLBACKS == 1
312 IRDA_InitCallbacksToDefault(hirda);
313
314 if (hirda->MspInitCallback == NULL)
315 {
316 hirda->MspInitCallback = HAL_IRDA_MspInit;
317 }
318
319 /* Init the low level hardware */
320 hirda->MspInitCallback(hirda);
321#else
322 /* Init the low level hardware : GPIO, CLOCK */
323 HAL_IRDA_MspInit(hirda);
324#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
325 }
326
328
329 /* Disable the IRDA peripheral */
330 __HAL_IRDA_DISABLE(hirda);
331
332 /* Set the IRDA communication parameters */
333 IRDA_SetConfig(hirda);
334
335 /* In IrDA mode, the following bits must be kept cleared:
336 - LINEN, STOP and CLKEN bits in the USART_CR2 register,
337 - SCEN and HDSEL bits in the USART_CR3 register.*/
338 CLEAR_BIT(hirda->Instance->CR2, (USART_CR2_LINEN | USART_CR2_STOP | USART_CR2_CLKEN));
339 CLEAR_BIT(hirda->Instance->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
340
341 /* Enable the IRDA peripheral */
342 __HAL_IRDA_ENABLE(hirda);
343
344 /* Set the prescaler */
345 MODIFY_REG(hirda->Instance->GTPR, USART_GTPR_PSC, hirda->Init.Prescaler);
346
347 /* Configure the IrDA mode */
348 MODIFY_REG(hirda->Instance->CR3, USART_CR3_IRLP, hirda->Init.IrDAMode);
349
350 /* Enable the IrDA mode by setting the IREN bit in the CR3 register */
351 SET_BIT(hirda->Instance->CR3, USART_CR3_IREN);
352
353 /* Initialize the IRDA state*/
357
358 return HAL_OK;
359}
360
368{
369 /* Check the IRDA handle allocation */
370 if (hirda == NULL)
371 {
372 return HAL_ERROR;
373 }
374
375 /* Check the parameters */
376 assert_param(IS_IRDA_INSTANCE(hirda->Instance));
377
379
380 /* Disable the Peripheral */
381 __HAL_IRDA_DISABLE(hirda);
382
383 /* DeInit the low level hardware */
384#if USE_HAL_IRDA_REGISTER_CALLBACKS == 1
385 if (hirda->MspDeInitCallback == NULL)
386 {
387 hirda->MspDeInitCallback = HAL_IRDA_MspDeInit;
388 }
389 /* DeInit the low level hardware */
390 hirda->MspDeInitCallback(hirda);
391#else
392 HAL_IRDA_MspDeInit(hirda);
393#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
394
396
399
400 /* Release Lock */
401 __HAL_UNLOCK(hirda);
402
403 return HAL_OK;
404}
405
413{
414 /* Prevent unused argument(s) compilation warning */
415 UNUSED(hirda);
416
417 /* NOTE: This function should not be modified, when the callback is needed,
418 the HAL_IRDA_MspInit can be implemented in the user file
419 */
420}
421
429{
430 /* Prevent unused argument(s) compilation warning */
431 UNUSED(hirda);
432
433 /* NOTE: This function should not be modified, when the callback is needed,
434 the HAL_IRDA_MspDeInit can be implemented in the user file
435 */
436}
437
438#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
460HAL_StatusTypeDef HAL_IRDA_RegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID, pIRDA_CallbackTypeDef pCallback)
461{
462 HAL_StatusTypeDef status = HAL_OK;
463
464 if (pCallback == NULL)
465 {
466 /* Update the error code */
467 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
468
469 return HAL_ERROR;
470 }
471
472 if (hirda->gState == HAL_IRDA_STATE_READY)
473 {
474 switch (CallbackID)
475 {
476 case HAL_IRDA_TX_HALFCOMPLETE_CB_ID :
477 hirda->TxHalfCpltCallback = pCallback;
478 break;
479
480 case HAL_IRDA_TX_COMPLETE_CB_ID :
481 hirda->TxCpltCallback = pCallback;
482 break;
483
484 case HAL_IRDA_RX_HALFCOMPLETE_CB_ID :
485 hirda->RxHalfCpltCallback = pCallback;
486 break;
487
488 case HAL_IRDA_RX_COMPLETE_CB_ID :
489 hirda->RxCpltCallback = pCallback;
490 break;
491
492 case HAL_IRDA_ERROR_CB_ID :
493 hirda->ErrorCallback = pCallback;
494 break;
495
496 case HAL_IRDA_ABORT_COMPLETE_CB_ID :
497 hirda->AbortCpltCallback = pCallback;
498 break;
499
500 case HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID :
501 hirda->AbortTransmitCpltCallback = pCallback;
502 break;
503
504 case HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID :
505 hirda->AbortReceiveCpltCallback = pCallback;
506 break;
507
508 case HAL_IRDA_MSPINIT_CB_ID :
509 hirda->MspInitCallback = pCallback;
510 break;
511
512 case HAL_IRDA_MSPDEINIT_CB_ID :
513 hirda->MspDeInitCallback = pCallback;
514 break;
515
516 default :
517 /* Update the error code */
518 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
519
520 /* Return error status */
521 status = HAL_ERROR;
522 break;
523 }
524 }
525 else if (hirda->gState == HAL_IRDA_STATE_RESET)
526 {
527 switch (CallbackID)
528 {
529 case HAL_IRDA_MSPINIT_CB_ID :
530 hirda->MspInitCallback = pCallback;
531 break;
532
533 case HAL_IRDA_MSPDEINIT_CB_ID :
534 hirda->MspDeInitCallback = pCallback;
535 break;
536
537 default :
538 /* Update the error code */
539 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
540
541 /* Return error status */
542 status = HAL_ERROR;
543 break;
544 }
545 }
546 else
547 {
548 /* Update the error code */
549 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
550
551 /* Return error status */
552 status = HAL_ERROR;
553 }
554
555 return status;
556}
557
578HAL_StatusTypeDef HAL_IRDA_UnRegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID)
579{
580 HAL_StatusTypeDef status = HAL_OK;
581
582 if (HAL_IRDA_STATE_READY == hirda->gState)
583 {
584 switch (CallbackID)
585 {
586 case HAL_IRDA_TX_HALFCOMPLETE_CB_ID :
587 hirda->TxHalfCpltCallback = HAL_IRDA_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
588 break;
589
590 case HAL_IRDA_TX_COMPLETE_CB_ID :
591 hirda->TxCpltCallback = HAL_IRDA_TxCpltCallback; /* Legacy weak TxCpltCallback */
592 break;
593
594 case HAL_IRDA_RX_HALFCOMPLETE_CB_ID :
595 hirda->RxHalfCpltCallback = HAL_IRDA_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
596 break;
597
598 case HAL_IRDA_RX_COMPLETE_CB_ID :
599 hirda->RxCpltCallback = HAL_IRDA_RxCpltCallback; /* Legacy weak RxCpltCallback */
600 break;
601
602 case HAL_IRDA_ERROR_CB_ID :
603 hirda->ErrorCallback = HAL_IRDA_ErrorCallback; /* Legacy weak ErrorCallback */
604 break;
605
606 case HAL_IRDA_ABORT_COMPLETE_CB_ID :
607 hirda->AbortCpltCallback = HAL_IRDA_AbortCpltCallback; /* Legacy weak AbortCpltCallback */
608 break;
609
610 case HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID :
611 hirda->AbortTransmitCpltCallback = HAL_IRDA_AbortTransmitCpltCallback; /* Legacy weak AbortTransmitCpltCallback */
612 break;
613
614 case HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID :
615 hirda->AbortReceiveCpltCallback = HAL_IRDA_AbortReceiveCpltCallback; /* Legacy weak AbortReceiveCpltCallback */
616 break;
617
618 case HAL_IRDA_MSPINIT_CB_ID :
619 hirda->MspInitCallback = HAL_IRDA_MspInit; /* Legacy weak MspInitCallback */
620 break;
621
622 case HAL_IRDA_MSPDEINIT_CB_ID :
623 hirda->MspDeInitCallback = HAL_IRDA_MspDeInit; /* Legacy weak MspDeInitCallback */
624 break;
625
626 default :
627 /* Update the error code */
628 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
629
630 /* Return error status */
631 status = HAL_ERROR;
632 break;
633 }
634 }
635 else if (HAL_IRDA_STATE_RESET == hirda->gState)
636 {
637 switch (CallbackID)
638 {
639 case HAL_IRDA_MSPINIT_CB_ID :
640 hirda->MspInitCallback = HAL_IRDA_MspInit;
641 break;
642
643 case HAL_IRDA_MSPDEINIT_CB_ID :
644 hirda->MspDeInitCallback = HAL_IRDA_MspDeInit;
645 break;
646
647 default :
648 /* Update the error code */
649 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
650
651 /* Return error status */
652 status = HAL_ERROR;
653 break;
654 }
655 }
656 else
657 {
658 /* Update the error code */
659 hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK;
660
661 /* Return error status */
662 status = HAL_ERROR;
663 }
664
665 return status;
666}
667#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
668
764HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, const uint8_t *pData, uint16_t Size, uint32_t Timeout)
765{
766 const uint16_t *tmp;
767 uint32_t tickstart = 0U;
768
769 /* Check that a Tx process is not already ongoing */
770 if (hirda->gState == HAL_IRDA_STATE_READY)
771 {
772 if ((pData == NULL) || (Size == 0U))
773 {
774 return HAL_ERROR;
775 }
776
777 /* Process Locked */
778 __HAL_LOCK(hirda);
779
782
783 /* Init tickstart for timeout management*/
784 tickstart = HAL_GetTick();
785
786 hirda->TxXferSize = Size;
787 hirda->TxXferCount = Size;
788 while (hirda->TxXferCount > 0U)
789 {
790 hirda->TxXferCount--;
791 if (hirda->Init.WordLength == IRDA_WORDLENGTH_9B)
792 {
793 if (IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)
794 {
795 return HAL_TIMEOUT;
796 }
797 tmp = (const uint16_t *) pData;
798 hirda->Instance->DR = (*tmp & (uint16_t)0x01FF);
799 if (hirda->Init.Parity == IRDA_PARITY_NONE)
800 {
801 pData += 2U;
802 }
803 else
804 {
805 pData += 1U;
806 }
807 }
808 else
809 {
810 if (IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)
811 {
812 return HAL_TIMEOUT;
813 }
814 hirda->Instance->DR = (*pData++ & (uint8_t)0xFF);
815 }
816 }
817
818 if (IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TC, RESET, tickstart, Timeout) != HAL_OK)
819 {
820 return HAL_TIMEOUT;
821 }
822
823 /* At end of Tx process, restore hirda->gState to Ready */
825
826 /* Process Unlocked */
827 __HAL_UNLOCK(hirda);
828
829 return HAL_OK;
830 }
831 else
832 {
833 return HAL_BUSY;
834 }
835}
836
849HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout)
850{
851 uint16_t *tmp;
852 uint32_t tickstart = 0U;
853
854 /* Check that a Rx process is not already ongoing */
855 if (hirda->RxState == HAL_IRDA_STATE_READY)
856 {
857 if ((pData == NULL) || (Size == 0U))
858 {
859 return HAL_ERROR;
860 }
861
862 /* Process Locked */
863 __HAL_LOCK(hirda);
864
867
868 /* Init tickstart for timeout management*/
869 tickstart = HAL_GetTick();
870
871 hirda->RxXferSize = Size;
872 hirda->RxXferCount = Size;
873
874 /* Check the remain data to be received */
875 while (hirda->RxXferCount > 0U)
876 {
877 hirda->RxXferCount--;
878
879 if (hirda->Init.WordLength == IRDA_WORDLENGTH_9B)
880 {
881 if (IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_RXNE, RESET, tickstart, Timeout) != HAL_OK)
882 {
883 return HAL_TIMEOUT;
884 }
885 tmp = (uint16_t *) pData ;
886 if (hirda->Init.Parity == IRDA_PARITY_NONE)
887 {
888 *tmp = (uint16_t)(hirda->Instance->DR & (uint16_t)0x01FF);
889 pData += 2U;
890 }
891 else
892 {
893 *tmp = (uint16_t)(hirda->Instance->DR & (uint16_t)0x00FF);
894 pData += 1U;
895 }
896 }
897 else
898 {
899 if (IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_RXNE, RESET, tickstart, Timeout) != HAL_OK)
900 {
901 return HAL_TIMEOUT;
902 }
903 if (hirda->Init.Parity == IRDA_PARITY_NONE)
904 {
905 *pData++ = (uint8_t)(hirda->Instance->DR & (uint8_t)0x00FF);
906 }
907 else
908 {
909 *pData++ = (uint8_t)(hirda->Instance->DR & (uint8_t)0x007F);
910 }
911 }
912 }
913
914 /* At end of Rx process, restore hirda->RxState to Ready */
916
917 /* Process Unlocked */
918 __HAL_UNLOCK(hirda);
919
920 return HAL_OK;
921 }
922 else
923 {
924 return HAL_BUSY;
925 }
926}
927
939HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, const uint8_t *pData, uint16_t Size)
940{
941 /* Check that a Tx process is not already ongoing */
942 if (hirda->gState == HAL_IRDA_STATE_READY)
943 {
944 if ((pData == NULL) || (Size == 0U))
945 {
946 return HAL_ERROR;
947 }
948
949 /* Process Locked */
950 __HAL_LOCK(hirda);
951
952 hirda->pTxBuffPtr = pData;
953 hirda->TxXferSize = Size;
954 hirda->TxXferCount = Size;
955
958
959 /* Process Unlocked */
960 __HAL_UNLOCK(hirda);
961
962 /* Enable the IRDA Transmit Data Register Empty Interrupt */
963 SET_BIT(hirda->Instance->CR1, USART_CR1_TXEIE);
964
965 return HAL_OK;
966 }
967 else
968 {
969 return HAL_BUSY;
970 }
971}
972
984HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
985{
986 /* Check that a Rx process is not already ongoing */
987 if (hirda->RxState == HAL_IRDA_STATE_READY)
988 {
989 if ((pData == NULL) || (Size == 0U))
990 {
991 return HAL_ERROR;
992 }
993
994 /* Process Locked */
995 __HAL_LOCK(hirda);
996
997 hirda->pRxBuffPtr = pData;
998 hirda->RxXferSize = Size;
999 hirda->RxXferCount = Size;
1000
1003
1004 /* Process Unlocked */
1005 __HAL_UNLOCK(hirda);
1006
1007 if (hirda->Init.Parity != IRDA_PARITY_NONE)
1008 {
1009 /* Enable the IRDA Parity Error and Data Register Not Empty Interrupts */
1010 SET_BIT(hirda->Instance->CR1, USART_CR1_PEIE | USART_CR1_RXNEIE);
1011 }
1012 else
1013 {
1014 /* Enable the IRDA Data Register Not Empty Interrupts */
1015 SET_BIT(hirda->Instance->CR1, USART_CR1_RXNEIE);
1016 }
1017
1018 /* Enable the IRDA Error Interrupt: (Frame error, Noise error, Overrun error) */
1019 SET_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1020
1021 return HAL_OK;
1022 }
1023 else
1024 {
1025 return HAL_BUSY;
1026 }
1027}
1028
1040HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, const uint8_t *pData, uint16_t Size)
1041{
1042 const uint32_t *tmp;
1043
1044 /* Check that a Tx process is not already ongoing */
1045 if (hirda->gState == HAL_IRDA_STATE_READY)
1046 {
1047 if ((pData == NULL) || (Size == 0U))
1048 {
1049 return HAL_ERROR;
1050 }
1051
1052 /* Process Locked */
1053 __HAL_LOCK(hirda);
1054
1055 hirda->pTxBuffPtr = pData;
1056 hirda->TxXferSize = Size;
1057 hirda->TxXferCount = Size;
1058
1061
1062 /* Set the IRDA DMA transfer complete callback */
1064
1065 /* Set the IRDA DMA half transfer complete callback */
1067
1068 /* Set the DMA error callback */
1070
1071 /* Set the DMA abort callback */
1072 hirda->hdmatx->XferAbortCallback = NULL;
1073
1074 /* Enable the IRDA transmit DMA stream */
1075 tmp = (const uint32_t *)&pData;
1076 HAL_DMA_Start_IT(hirda->hdmatx, *(const uint32_t *)tmp, (uint32_t)&hirda->Instance->DR, Size);
1077
1078 /* Clear the TC flag in the SR register by writing 0 to it */
1080
1081 /* Process Unlocked */
1082 __HAL_UNLOCK(hirda);
1083
1084 /* Enable the DMA transfer for transmit request by setting the DMAT bit
1085 in the USART CR3 register */
1086 SET_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1087
1088 return HAL_OK;
1089 }
1090 else
1091 {
1092 return HAL_BUSY;
1093 }
1094}
1095
1108HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
1109{
1110 uint32_t *tmp;
1111
1112 /* Check that a Rx process is not already ongoing */
1113 if (hirda->RxState == HAL_IRDA_STATE_READY)
1114 {
1115 if ((pData == NULL) || (Size == 0U))
1116 {
1117 return HAL_ERROR;
1118 }
1119
1120 /* Process Locked */
1121 __HAL_LOCK(hirda);
1122
1123 hirda->pRxBuffPtr = pData;
1124 hirda->RxXferSize = Size;
1125
1128
1129 /* Set the IRDA DMA transfer complete callback */
1131
1132 /* Set the IRDA DMA half transfer complete callback */
1134
1135 /* Set the DMA error callback */
1137
1138 /* Set the DMA abort callback */
1139 hirda->hdmarx->XferAbortCallback = NULL;
1140
1141 /* Enable the DMA stream */
1142 tmp = (uint32_t *)&pData;
1143 HAL_DMA_Start_IT(hirda->hdmarx, (uint32_t)&hirda->Instance->DR, *(uint32_t *)tmp, Size);
1144
1145 /* Clear the Overrun flag just before enabling the DMA Rx request: can be mandatory for the second transfer */
1147
1148 /* Process Unlocked */
1149 __HAL_UNLOCK(hirda);
1150
1151 if (hirda->Init.Parity != IRDA_PARITY_NONE)
1152 {
1153 /* Enable the IRDA Parity Error Interrupt */
1154 SET_BIT(hirda->Instance->CR1, USART_CR1_PEIE);
1155 }
1156
1157 /* Enable the IRDA Error Interrupt: (Frame error, Noise error, Overrun error) */
1158 SET_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1159
1160 /* Enable the DMA transfer for the receiver request by setting the DMAR bit
1161 in the USART CR3 register */
1162 SET_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1163
1164 return HAL_OK;
1165 }
1166 else
1167 {
1168 return HAL_BUSY;
1169 }
1170}
1171
1179{
1180 uint32_t dmarequest = 0x00U;
1181
1182 /* Process Locked */
1183 __HAL_LOCK(hirda);
1184
1185 dmarequest = HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT);
1186 if ((hirda->gState == HAL_IRDA_STATE_BUSY_TX) && dmarequest)
1187 {
1188 /* Disable the IRDA DMA Tx request */
1189 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1190 }
1191
1192 dmarequest = HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR);
1193 if ((hirda->RxState == HAL_IRDA_STATE_BUSY_RX) && dmarequest)
1194 {
1195 /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
1196 CLEAR_BIT(hirda->Instance->CR1, USART_CR1_PEIE);
1197 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1198
1199 /* Disable the IRDA DMA Rx request */
1200 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1201 }
1202
1203 /* Process Unlocked */
1204 __HAL_UNLOCK(hirda);
1205
1206 return HAL_OK;
1207}
1208
1216{
1217 /* Process Locked */
1218 __HAL_LOCK(hirda);
1219
1220 if (hirda->gState == HAL_IRDA_STATE_BUSY_TX)
1221 {
1222 /* Enable the IRDA DMA Tx request */
1223 SET_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1224 }
1225
1226 if (hirda->RxState == HAL_IRDA_STATE_BUSY_RX)
1227 {
1228 /* Clear the Overrun flag before resuming the Rx transfer */
1230
1231 /* Re-enable PE and ERR (Frame error, noise error, overrun error) interrupts */
1232 if (hirda->Init.Parity != IRDA_PARITY_NONE)
1233 {
1234 SET_BIT(hirda->Instance->CR1, USART_CR1_PEIE);
1235 }
1236 SET_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1237
1238 /* Enable the IRDA DMA Rx request */
1239 SET_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1240 }
1241
1242 /* Process Unlocked */
1243 __HAL_UNLOCK(hirda);
1244
1245 return HAL_OK;
1246}
1247
1255{
1256 uint32_t dmarequest = 0x00U;
1257 /* The Lock is not implemented on this API to allow the user application
1258 to call the HAL IRDA API under callbacks HAL_IRDA_TxCpltCallback() / HAL_IRDA_RxCpltCallback():
1259 when calling HAL_DMA_Abort() API the DMA TX/RX Transfer complete interrupt is generated
1260 and the correspond call back is executed HAL_IRDA_TxCpltCallback() / HAL_IRDA_RxCpltCallback()
1261 */
1262
1263 /* Stop IRDA DMA Tx request if ongoing */
1264 dmarequest = HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT);
1265 if ((hirda->gState == HAL_IRDA_STATE_BUSY_TX) && dmarequest)
1266 {
1267 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1268
1269 /* Abort the IRDA DMA Tx channel */
1270 if (hirda->hdmatx != NULL)
1271 {
1272 HAL_DMA_Abort(hirda->hdmatx);
1273 }
1274 IRDA_EndTxTransfer(hirda);
1275 }
1276
1277 /* Stop IRDA DMA Rx request if ongoing */
1278 dmarequest = HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR);
1279 if ((hirda->RxState == HAL_IRDA_STATE_BUSY_RX) && dmarequest)
1280 {
1281 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1282
1283 /* Abort the IRDA DMA Rx channel */
1284 if (hirda->hdmarx != NULL)
1285 {
1286 HAL_DMA_Abort(hirda->hdmarx);
1287 }
1288 IRDA_EndRxTransfer(hirda);
1289 }
1290
1291 return HAL_OK;
1292}
1293
1307{
1308 /* Disable TXEIE, TCIE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1309 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
1310 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1311
1312 /* Disable the IRDA DMA Tx request if enabled */
1313 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1314 {
1315 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1316
1317 /* Abort the IRDA DMA Tx channel : use blocking DMA Abort API (no callback) */
1318 if (hirda->hdmatx != NULL)
1319 {
1320 /* Set the IRDA DMA Abort callback to Null.
1321 No call back execution at end of DMA abort procedure */
1322 hirda->hdmatx->XferAbortCallback = NULL;
1323
1324 HAL_DMA_Abort(hirda->hdmatx);
1325 }
1326 }
1327
1328 /* Disable the IRDA DMA Rx request if enabled */
1329 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1330 {
1331 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1332
1333 /* Abort the IRDA DMA Rx channel : use blocking DMA Abort API (no callback) */
1334 if (hirda->hdmarx != NULL)
1335 {
1336 /* Set the IRDA DMA Abort callback to Null.
1337 No call back execution at end of DMA abort procedure */
1338 hirda->hdmarx->XferAbortCallback = NULL;
1339
1340 HAL_DMA_Abort(hirda->hdmarx);
1341 }
1342 }
1343
1344 /* Reset Tx and Rx transfer counters */
1345 hirda->TxXferCount = 0x00U;
1346 hirda->RxXferCount = 0x00U;
1347
1348 /* Reset ErrorCode */
1350
1351 /* Restore hirda->RxState and hirda->gState to Ready */
1354
1355 return HAL_OK;
1356}
1357
1371{
1372 /* Disable TXEIE and TCIE interrupts */
1373 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
1374
1375 /* Disable the IRDA DMA Tx request if enabled */
1376 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1377 {
1378 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1379
1380 /* Abort the IRDA DMA Tx channel : use blocking DMA Abort API (no callback) */
1381 if (hirda->hdmatx != NULL)
1382 {
1383 /* Set the IRDA DMA Abort callback to Null.
1384 No call back execution at end of DMA abort procedure */
1385 hirda->hdmatx->XferAbortCallback = NULL;
1386
1387 HAL_DMA_Abort(hirda->hdmatx);
1388 }
1389 }
1390
1391 /* Reset Tx transfer counter */
1392 hirda->TxXferCount = 0x00U;
1393
1394 /* Restore hirda->gState to Ready */
1396
1397 return HAL_OK;
1398}
1399
1413{
1414 /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1415 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
1416 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1417
1418 /* Disable the IRDA DMA Rx request if enabled */
1419 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1420 {
1421 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1422
1423 /* Abort the IRDA DMA Rx channel : use blocking DMA Abort API (no callback) */
1424 if (hirda->hdmarx != NULL)
1425 {
1426 /* Set the IRDA DMA Abort callback to Null.
1427 No call back execution at end of DMA abort procedure */
1428 hirda->hdmarx->XferAbortCallback = NULL;
1429
1430 HAL_DMA_Abort(hirda->hdmarx);
1431 }
1432 }
1433
1434 /* Reset Rx transfer counter */
1435 hirda->RxXferCount = 0x00U;
1436
1437 /* Restore hirda->RxState to Ready */
1439
1440 return HAL_OK;
1441}
1442
1458{
1459 uint32_t AbortCplt = 0x01U;
1460
1461 /* Disable TXEIE, TCIE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1462 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
1463 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1464
1465 /* If DMA Tx and/or DMA Rx Handles are associated to IRDA Handle, DMA Abort complete callbacks should be initialised
1466 before any call to DMA Abort functions */
1467 /* DMA Tx Handle is valid */
1468 if (hirda->hdmatx != NULL)
1469 {
1470 /* Set DMA Abort Complete callback if IRDA DMA Tx request if enabled.
1471 Otherwise, set it to NULL */
1472 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1473 {
1475 }
1476 else
1477 {
1478 hirda->hdmatx->XferAbortCallback = NULL;
1479 }
1480 }
1481 /* DMA Rx Handle is valid */
1482 if (hirda->hdmarx != NULL)
1483 {
1484 /* Set DMA Abort Complete callback if IRDA DMA Rx request if enabled.
1485 Otherwise, set it to NULL */
1486 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1487 {
1489 }
1490 else
1491 {
1492 hirda->hdmarx->XferAbortCallback = NULL;
1493 }
1494 }
1495
1496 /* Disable the IRDA DMA Tx request if enabled */
1497 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1498 {
1499 /* Disable DMA Tx at IRDA level */
1500 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1501
1502 /* Abort the IRDA DMA Tx channel : use non blocking DMA Abort API (callback) */
1503 if (hirda->hdmatx != NULL)
1504 {
1505 /* IRDA Tx DMA Abort callback has already been initialised :
1506 will lead to call HAL_IRDA_AbortCpltCallback() at end of DMA abort procedure */
1507
1508 /* Abort DMA TX */
1509 if (HAL_DMA_Abort_IT(hirda->hdmatx) != HAL_OK)
1510 {
1511 hirda->hdmatx->XferAbortCallback = NULL;
1512 }
1513 else
1514 {
1515 AbortCplt = 0x00U;
1516 }
1517 }
1518 }
1519
1520 /* Disable the IRDA DMA Rx request if enabled */
1521 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1522 {
1523 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1524
1525 /* Abort the IRDA DMA Rx channel : use non blocking DMA Abort API (callback) */
1526 if (hirda->hdmarx != NULL)
1527 {
1528 /* IRDA Rx DMA Abort callback has already been initialised :
1529 will lead to call HAL_IRDA_AbortCpltCallback() at end of DMA abort procedure */
1530
1531 /* Abort DMA RX */
1532 if (HAL_DMA_Abort_IT(hirda->hdmarx) != HAL_OK)
1533 {
1534 hirda->hdmarx->XferAbortCallback = NULL;
1535 AbortCplt = 0x01U;
1536 }
1537 else
1538 {
1539 AbortCplt = 0x00U;
1540 }
1541 }
1542 }
1543
1544 /* if no DMA abort complete callback execution is required => call user Abort Complete callback */
1545 if (AbortCplt == 0x01U)
1546 {
1547 /* Reset Tx and Rx transfer counters */
1548 hirda->TxXferCount = 0x00U;
1549 hirda->RxXferCount = 0x00U;
1550
1551 /* Reset ErrorCode */
1553
1554 /* Restore hirda->gState and hirda->RxState to Ready */
1557
1558 /* As no DMA to be aborted, call directly user Abort complete callback */
1559#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1560 /* Call registered Abort complete callback */
1561 hirda->AbortCpltCallback(hirda);
1562#else
1563 /* Call legacy weak Abort complete callback */
1565#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1566 }
1567
1568 return HAL_OK;
1569}
1570
1586{
1587 /* Disable TXEIE and TCIE interrupts */
1588 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
1589
1590 /* Disable the IRDA DMA Tx request if enabled */
1591 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1592 {
1593 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1594
1595 /* Abort the IRDA DMA Tx channel : use non blocking DMA Abort API (callback) */
1596 if (hirda->hdmatx != NULL)
1597 {
1598 /* Set the IRDA DMA Abort callback :
1599 will lead to call HAL_IRDA_AbortCpltCallback() at end of DMA abort procedure */
1601
1602 /* Abort DMA TX */
1603 if (HAL_DMA_Abort_IT(hirda->hdmatx) != HAL_OK)
1604 {
1605 /* Call Directly hirda->hdmatx->XferAbortCallback function in case of error */
1606 hirda->hdmatx->XferAbortCallback(hirda->hdmatx);
1607 }
1608 }
1609 else
1610 {
1611 /* Reset Tx transfer counter */
1612 hirda->TxXferCount = 0x00U;
1613
1614 /* Restore hirda->gState to Ready */
1616
1617 /* As no DMA to be aborted, call directly user Abort complete callback */
1618#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1619 /* Call registered Abort Transmit Complete Callback */
1620 hirda->AbortTransmitCpltCallback(hirda);
1621#else
1622 /* Call legacy weak Abort Transmit Complete Callback */
1624#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1625 }
1626 }
1627 else
1628 {
1629 /* Reset Tx transfer counter */
1630 hirda->TxXferCount = 0x00U;
1631
1632 /* Restore hirda->gState to Ready */
1634
1635 /* As no DMA to be aborted, call directly user Abort complete callback */
1636#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1637 /* Call registered Abort Transmit Complete Callback */
1638 hirda->AbortTransmitCpltCallback(hirda);
1639#else
1640 /* Call legacy weak Abort Transmit Complete Callback */
1642#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1643 }
1644
1645 return HAL_OK;
1646}
1647
1663{
1664 /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1665 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
1666 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1667
1668 /* Disable the IRDA DMA Rx request if enabled */
1669 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1670 {
1671 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1672
1673 /* Abort the IRDA DMA Rx channel : use non blocking DMA Abort API (callback) */
1674 if (hirda->hdmarx != NULL)
1675 {
1676 /* Set the IRDA DMA Abort callback :
1677 will lead to call HAL_IRDA_AbortCpltCallback() at end of DMA abort procedure */
1679
1680 /* Abort DMA RX */
1681 if (HAL_DMA_Abort_IT(hirda->hdmarx) != HAL_OK)
1682 {
1683 /* Call Directly hirda->hdmarx->XferAbortCallback function in case of error */
1684 hirda->hdmarx->XferAbortCallback(hirda->hdmarx);
1685 }
1686 }
1687 else
1688 {
1689 /* Reset Rx transfer counter */
1690 hirda->RxXferCount = 0x00U;
1691
1692 /* Restore hirda->RxState to Ready */
1694
1695 /* As no DMA to be aborted, call directly user Abort complete callback */
1696#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1697 /* Call registered Abort Receive Complete Callback */
1698 hirda->AbortReceiveCpltCallback(hirda);
1699#else
1700 /* Call legacy weak Abort Receive Complete Callback */
1702#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1703 }
1704 }
1705 else
1706 {
1707 /* Reset Rx transfer counter */
1708 hirda->RxXferCount = 0x00U;
1709
1710 /* Restore hirda->RxState to Ready */
1712
1713 /* As no DMA to be aborted, call directly user Abort complete callback */
1714#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1715 /* Call registered Abort Receive Complete Callback */
1716 hirda->AbortReceiveCpltCallback(hirda);
1717#else
1718 /* Call legacy weak Abort Receive Complete Callback */
1720#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1721 }
1722
1723 return HAL_OK;
1724}
1725
1733{
1734 uint32_t isrflags = READ_REG(hirda->Instance->SR);
1735 uint32_t cr1its = READ_REG(hirda->Instance->CR1);
1736 uint32_t cr3its = READ_REG(hirda->Instance->CR3);
1737 uint32_t errorflags = 0x00U;
1738 uint32_t dmarequest = 0x00U;
1739
1740 /* If no error occurs */
1741 errorflags = (isrflags & (uint32_t)(USART_SR_PE | USART_SR_FE | USART_SR_ORE | USART_SR_NE));
1742 if (errorflags == RESET)
1743 {
1744 /* IRDA in mode Receiver -----------------------------------------------*/
1745 if (((isrflags & USART_SR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
1746 {
1747 IRDA_Receive_IT(hirda);
1748 return;
1749 }
1750 }
1751
1752 /* If some errors occur */
1753 if ((errorflags != RESET) && (((cr3its & USART_CR3_EIE) != RESET) || ((cr1its & (USART_CR1_RXNEIE | USART_CR1_PEIE)) != RESET)))
1754 {
1755 /* IRDA parity error interrupt occurred -------------------------------*/
1756 if (((isrflags & USART_SR_PE) != RESET) && ((cr1its & USART_CR1_PEIE) != RESET))
1757 {
1758 hirda->ErrorCode |= HAL_IRDA_ERROR_PE;
1759 }
1760
1761 /* IRDA noise error interrupt occurred --------------------------------*/
1762 if (((isrflags & USART_SR_NE) != RESET) && ((cr3its & USART_CR3_EIE) != RESET))
1763 {
1764 hirda->ErrorCode |= HAL_IRDA_ERROR_NE;
1765 }
1766
1767 /* IRDA frame error interrupt occurred --------------------------------*/
1768 if (((isrflags & USART_SR_FE) != RESET) && ((cr3its & USART_CR3_EIE) != RESET))
1769 {
1770 hirda->ErrorCode |= HAL_IRDA_ERROR_FE;
1771 }
1772
1773 /* IRDA Over-Run interrupt occurred -----------------------------------*/
1774 if (((isrflags & USART_SR_ORE) != RESET) && (((cr1its & USART_CR1_RXNEIE) != RESET) || ((cr3its & USART_CR3_EIE) != RESET)))
1775 {
1776 hirda->ErrorCode |= HAL_IRDA_ERROR_ORE;
1777 }
1778 /* Call IRDA Error Call back function if need be -----------------------*/
1779 if (hirda->ErrorCode != HAL_IRDA_ERROR_NONE)
1780 {
1781 /* IRDA in mode Receiver ---------------------------------------------*/
1782 if (((isrflags & USART_SR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
1783 {
1784 IRDA_Receive_IT(hirda);
1785 }
1786
1787 /* If Overrun error occurs, or if any error occurs in DMA mode reception,
1788 consider error as blocking */
1789 dmarequest = HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR);
1790 if (((hirda->ErrorCode & HAL_IRDA_ERROR_ORE) != RESET) || dmarequest)
1791 {
1792 /* Blocking error : transfer is aborted
1793 Set the IRDA state ready to be able to start again the process,
1794 Disable Rx Interrupts, and disable Rx DMA request, if ongoing */
1795 IRDA_EndRxTransfer(hirda);
1796
1797 /* Disable the IRDA DMA Rx request if enabled */
1798 if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1799 {
1800 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1801
1802 /* Abort the IRDA DMA Rx channel */
1803 if (hirda->hdmarx != NULL)
1804 {
1805 /* Set the IRDA DMA Abort callback :
1806 will lead to call HAL_IRDA_ErrorCallback() at end of DMA abort procedure */
1808
1809 /* Abort DMA RX */
1810 if (HAL_DMA_Abort_IT(hirda->hdmarx) != HAL_OK)
1811 {
1812 /* Call Directly XferAbortCallback function in case of error */
1813 hirda->hdmarx->XferAbortCallback(hirda->hdmarx);
1814 }
1815 }
1816 else
1817 {
1818#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1819 /* Call registered user error callback */
1820 hirda->ErrorCallback(hirda);
1821#else
1822 /* Call legacy weak user error callback */
1824#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1825 }
1826 }
1827 else
1828 {
1829#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1830 /* Call registered user error callback */
1831 hirda->ErrorCallback(hirda);
1832#else
1833 /* Call legacy weak user error callback */
1835#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1836 }
1837 }
1838 else
1839 {
1840 /* Non Blocking error : transfer could go on.
1841 Error is notified to user through user error callback */
1842#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1843 /* Call registered user error callback */
1844 hirda->ErrorCallback(hirda);
1845#else
1846 /* Call legacy weak user error callback */
1848#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1849
1851 }
1852 }
1853 return;
1854 } /* End if some error occurs */
1855
1856 /* IRDA in mode Transmitter ------------------------------------------------*/
1857 if (((isrflags & USART_SR_TXE) != RESET) && ((cr1its & USART_CR1_TXEIE) != RESET))
1858 {
1859 IRDA_Transmit_IT(hirda);
1860 return;
1861 }
1862
1863 /* IRDA in mode Transmitter end --------------------------------------------*/
1864 if (((isrflags & USART_SR_TC) != RESET) && ((cr1its & USART_CR1_TCIE) != RESET))
1865 {
1866 IRDA_EndTransmit_IT(hirda);
1867 return;
1868 }
1869}
1870
1878{
1879 /* Prevent unused argument(s) compilation warning */
1880 UNUSED(hirda);
1881
1882 /* NOTE : This function should not be modified, when the callback is needed,
1883 the HAL_IRDA_TxCpltCallback can be implemented in the user file.
1884 */
1885}
1886
1894{
1895 /* Prevent unused argument(s) compilation warning */
1896 UNUSED(hirda);
1897
1898 /* NOTE : This function should not be modified, when the callback is needed,
1899 the HAL_IRDA_TxHalfCpltCallback can be implemented in the user file.
1900 */
1901}
1902
1910{
1911 /* Prevent unused argument(s) compilation warning */
1912 UNUSED(hirda);
1913
1914 /* NOTE : This function should not be modified, when the callback is needed,
1915 the HAL_IRDA_RxCpltCallback can be implemented in the user file.
1916 */
1917}
1918
1926{
1927 /* Prevent unused argument(s) compilation warning */
1928 UNUSED(hirda);
1929
1930 /* NOTE : This function should not be modified, when the callback is needed,
1931 the HAL_IRDA_RxHalfCpltCallback can be implemented in the user file.
1932 */
1933}
1934
1942{
1943 /* Prevent unused argument(s) compilation warning */
1944 UNUSED(hirda);
1945
1946 /* NOTE : This function should not be modified, when the callback is needed,
1947 the HAL_IRDA_ErrorCallback can be implemented in the user file.
1948 */
1949}
1950
1958{
1959 /* Prevent unused argument(s) compilation warning */
1960 UNUSED(hirda);
1961
1962 /* NOTE : This function should not be modified, when the callback is needed,
1963 the HAL_IRDA_AbortCpltCallback can be implemented in the user file.
1964 */
1965}
1966
1974{
1975 /* Prevent unused argument(s) compilation warning */
1976 UNUSED(hirda);
1977
1978 /* NOTE : This function should not be modified, when the callback is needed,
1979 the HAL_IRDA_AbortTransmitCpltCallback can be implemented in the user file.
1980 */
1981}
1982
1990{
1991 /* Prevent unused argument(s) compilation warning */
1992 UNUSED(hirda);
1993
1994 /* NOTE : This function should not be modified, when the callback is needed,
1995 the HAL_IRDA_AbortReceiveCpltCallback can be implemented in the user file.
1996 */
1997}
1998
2027{
2028 uint32_t temp1 = 0x00U, temp2 = 0x00U;
2029 temp1 = hirda->gState;
2030 temp2 = hirda->RxState;
2031
2032 return (HAL_IRDA_StateTypeDef)(temp1 | temp2);
2033}
2034
2042{
2043 return hirda->ErrorCode;
2044}
2045
2058#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2064void IRDA_InitCallbacksToDefault(IRDA_HandleTypeDef *hirda)
2065{
2066 /* Init the IRDA Callback settings */
2067 hirda->TxHalfCpltCallback = HAL_IRDA_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
2068 hirda->TxCpltCallback = HAL_IRDA_TxCpltCallback; /* Legacy weak TxCpltCallback */
2069 hirda->RxHalfCpltCallback = HAL_IRDA_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
2070 hirda->RxCpltCallback = HAL_IRDA_RxCpltCallback; /* Legacy weak RxCpltCallback */
2071 hirda->ErrorCallback = HAL_IRDA_ErrorCallback; /* Legacy weak ErrorCallback */
2072 hirda->AbortCpltCallback = HAL_IRDA_AbortCpltCallback; /* Legacy weak AbortCpltCallback */
2073 hirda->AbortTransmitCpltCallback = HAL_IRDA_AbortTransmitCpltCallback; /* Legacy weak AbortTransmitCpltCallback */
2074 hirda->AbortReceiveCpltCallback = HAL_IRDA_AbortReceiveCpltCallback; /* Legacy weak AbortReceiveCpltCallback */
2075
2076}
2077#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
2078
2086{
2087 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2088 /* DMA Normal mode */
2089 if ((hdma->Instance->CR & DMA_SxCR_CIRC) == 0U)
2090 {
2091 hirda->TxXferCount = 0U;
2092
2093 /* Disable the DMA transfer for transmit request by resetting the DMAT bit
2094 in the IRDA CR3 register */
2095 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
2096
2097 /* Enable the IRDA Transmit Complete Interrupt */
2098 SET_BIT(hirda->Instance->CR1, USART_CR1_TCIE);
2099 }
2100 /* DMA Circular mode */
2101 else
2102 {
2103#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2104 /* Call registered Tx complete callback */
2105 hirda->TxCpltCallback(hirda);
2106#else
2107 /* Call legacy weak Tx complete callback */
2109#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2110 }
2111}
2112
2120{
2121 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2122
2123#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2124 /* Call registered Tx Half complete callback */
2125 hirda->TxHalfCpltCallback(hirda);
2126#else
2127 /* Call legacy weak Tx complete callback */
2129#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2130}
2131
2139{
2140 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2141
2142 /* DMA Normal mode */
2143 if ((hdma->Instance->CR & DMA_SxCR_CIRC) == 0U)
2144 {
2145 hirda->RxXferCount = 0U;
2146
2147 /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
2148 CLEAR_BIT(hirda->Instance->CR1, USART_CR1_PEIE);
2149 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
2150
2151 /* Disable the DMA transfer for the receiver request by resetting the DMAR bit
2152 in the IRDA CR3 register */
2153 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
2154
2155 /* At end of Rx process, restore hirda->RxState to Ready */
2157 }
2158
2159#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2160 /* Call registered Rx complete callback */
2161 hirda->RxCpltCallback(hirda);
2162#else
2163 /* Call legacy weak Rx complete callback */
2165#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
2166}
2167
2175{
2176 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2177
2178#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2179 /*Call registered Rx Half complete callback*/
2180 hirda->RxHalfCpltCallback(hirda);
2181#else
2182 /* Call legacy weak Rx Half complete callback */
2184#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2185}
2186
2194{
2195 uint32_t dmarequest = 0x00U;
2196 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2197
2198 /* Stop IRDA DMA Tx request if ongoing */
2199 dmarequest = HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT);
2200 if ((hirda->gState == HAL_IRDA_STATE_BUSY_TX) && dmarequest)
2201 {
2202 hirda->TxXferCount = 0U;
2203 IRDA_EndTxTransfer(hirda);
2204 }
2205
2206 /* Stop IRDA DMA Rx request if ongoing */
2207 dmarequest = HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR);
2208 if ((hirda->RxState == HAL_IRDA_STATE_BUSY_RX) && dmarequest)
2209 {
2210 hirda->RxXferCount = 0U;
2211 IRDA_EndRxTransfer(hirda);
2212 }
2213
2214 hirda->ErrorCode |= HAL_IRDA_ERROR_DMA;
2215
2216#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2217 /* Call registered user error callback */
2218 hirda->ErrorCallback(hirda);
2219#else
2220 /* Call legacy weak user error callback */
2222#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2223}
2224
2236static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
2237{
2238 /* Wait until flag is set */
2239 while ((__HAL_IRDA_GET_FLAG(hirda, Flag) ? SET : RESET) == Status)
2240 {
2241 /* Check for the Timeout */
2242 if (Timeout != HAL_MAX_DELAY)
2243 {
2244 if ((Timeout == 0U) || ((HAL_GetTick() - Tickstart) > Timeout))
2245 {
2246 /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */
2247 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE));
2248 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
2249
2252
2253 /* Process Unlocked */
2254 __HAL_UNLOCK(hirda);
2255
2256 return HAL_TIMEOUT;
2257 }
2258 }
2259 }
2260 return HAL_OK;
2261}
2262
2269{
2270 /* Disable TXEIE and TCIE interrupts */
2271 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
2272
2273 /* At end of Tx process, restore hirda->gState to Ready */
2275}
2276
2283{
2284 /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
2285 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
2286 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
2287
2288 /* At end of Rx process, restore hirda->RxState to Ready */
2290}
2291
2299{
2300 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2301 hirda->RxXferCount = 0x00U;
2302 hirda->TxXferCount = 0x00U;
2303
2304#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2305 /* Call registered user error callback */
2306 hirda->ErrorCallback(hirda);
2307#else
2308 /* Call legacy weak user error callback */
2310#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2311}
2312
2322{
2323 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2324
2325 hirda->hdmatx->XferAbortCallback = NULL;
2326
2327 /* Check if an Abort process is still ongoing */
2328 if (hirda->hdmarx != NULL)
2329 {
2330 if (hirda->hdmarx->XferAbortCallback != NULL)
2331 {
2332 return;
2333 }
2334 }
2335
2336 /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */
2337 hirda->TxXferCount = 0x00U;
2338 hirda->RxXferCount = 0x00U;
2339
2340 /* Reset ErrorCode */
2342
2343 /* Restore hirda->gState and hirda->RxState to Ready */
2346
2347 /* Call user Abort complete callback */
2348#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2349 /* Call registered Abort complete callback */
2350 hirda->AbortCpltCallback(hirda);
2351#else
2352 /* Call legacy weak Abort complete callback */
2354#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2355}
2356
2366{
2367 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2368
2369 hirda->hdmarx->XferAbortCallback = NULL;
2370
2371 /* Check if an Abort process is still ongoing */
2372 if (hirda->hdmatx != NULL)
2373 {
2374 if (hirda->hdmatx->XferAbortCallback != NULL)
2375 {
2376 return;
2377 }
2378 }
2379
2380 /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */
2381 hirda->TxXferCount = 0x00U;
2382 hirda->RxXferCount = 0x00U;
2383
2384 /* Reset ErrorCode */
2386
2387 /* Restore hirda->gState and hirda->RxState to Ready */
2390
2391 /* Call user Abort complete callback */
2392#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2393 /* Call registered Abort complete callback */
2394 hirda->AbortCpltCallback(hirda);
2395#else
2396 /* Call legacy weak Abort complete callback */
2398#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2399}
2400
2410{
2411 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2412
2413 hirda->TxXferCount = 0x00U;
2414
2415 /* Restore hirda->gState to Ready */
2417
2418 /* Call user Abort complete callback */
2419#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2420 /* Call registered Abort Transmit Complete Callback */
2421 hirda->AbortTransmitCpltCallback(hirda);
2422#else
2423 /* Call legacy weak Abort Transmit Complete Callback */
2425#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2426}
2427
2437{
2438 IRDA_HandleTypeDef *hirda = (IRDA_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
2439
2440 hirda->RxXferCount = 0x00U;
2441
2442 /* Restore hirda->RxState to Ready */
2444
2445 /* Call user Abort complete callback */
2446#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2447 /* Call registered Abort Receive Complete Callback */
2448 hirda->AbortReceiveCpltCallback(hirda);
2449#else
2450 /* Call legacy weak Abort Receive Complete Callback */
2452#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2453}
2454
2462{
2463 const uint16_t *tmp;
2464
2465 /* Check that a Tx process is ongoing */
2466 if (hirda->gState == HAL_IRDA_STATE_BUSY_TX)
2467 {
2468 if (hirda->Init.WordLength == IRDA_WORDLENGTH_9B)
2469 {
2470 tmp = (const uint16_t *) hirda->pTxBuffPtr;
2471 hirda->Instance->DR = (uint16_t)(*tmp & (uint16_t)0x01FF);
2472 if (hirda->Init.Parity == IRDA_PARITY_NONE)
2473 {
2474 hirda->pTxBuffPtr += 2U;
2475 }
2476 else
2477 {
2478 hirda->pTxBuffPtr += 1U;
2479 }
2480 }
2481 else
2482 {
2483 hirda->Instance->DR = (uint8_t)(*hirda->pTxBuffPtr++ & (uint8_t)0x00FF);
2484 }
2485
2486 if (--hirda->TxXferCount == 0U)
2487 {
2488 /* Disable the IRDA Transmit Data Register Empty Interrupt */
2489 CLEAR_BIT(hirda->Instance->CR1, USART_CR1_TXEIE);
2490
2491 /* Enable the IRDA Transmit Complete Interrupt */
2492 SET_BIT(hirda->Instance->CR1, USART_CR1_TCIE);
2493 }
2494
2495 return HAL_OK;
2496 }
2497 else
2498 {
2499 return HAL_BUSY;
2500 }
2501}
2502
2510{
2511 /* Disable the IRDA Transmit Complete Interrupt */
2512 CLEAR_BIT(hirda->Instance->CR1, USART_CR1_TCIE);
2513
2514 /* Disable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */
2515 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
2516
2517 /* Tx process is ended, restore hirda->gState to Ready */
2519
2520#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2521 /* Call registered Tx complete callback */
2522 hirda->TxCpltCallback(hirda);
2523#else
2524 /* Call legacy weak Tx complete callback */
2526#endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2527
2528 return HAL_OK;
2529}
2530
2538{
2539 uint16_t *tmp;
2540 uint16_t uhdata;
2541
2542 /* Check that a Rx process is ongoing */
2543 if (hirda->RxState == HAL_IRDA_STATE_BUSY_RX)
2544 {
2545 uhdata = (uint16_t) READ_REG(hirda->Instance->DR);
2546 if (hirda->Init.WordLength == IRDA_WORDLENGTH_9B)
2547 {
2548 tmp = (uint16_t *) hirda->pRxBuffPtr;
2549 if (hirda->Init.Parity == IRDA_PARITY_NONE)
2550 {
2551 *tmp = (uint16_t)(uhdata & (uint16_t)0x01FF);
2552 hirda->pRxBuffPtr += 2U;
2553 }
2554 else
2555 {
2556 *tmp = (uint16_t)(uhdata & (uint16_t)0x00FF);
2557 hirda->pRxBuffPtr += 1U;
2558 }
2559 }
2560 else
2561 {
2562 if (hirda->Init.Parity == IRDA_PARITY_NONE)
2563 {
2564 *hirda->pRxBuffPtr++ = (uint8_t)(uhdata & (uint8_t)0x00FF);
2565 }
2566 else
2567 {
2568 *hirda->pRxBuffPtr++ = (uint8_t)(uhdata & (uint8_t)0x007F);
2569 }
2570 }
2571
2572 if (--hirda->RxXferCount == 0U)
2573 {
2574 /* Disable the IRDA Data Register not empty Interrupt */
2575 CLEAR_BIT(hirda->Instance->CR1, USART_CR1_RXNEIE);
2576
2577 /* Disable the IRDA Parity Error Interrupt */
2578 CLEAR_BIT(hirda->Instance->CR1, USART_CR1_PEIE);
2579
2580 /* Disable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */
2581 CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
2582
2583 /* Rx process is completed, restore hirda->RxState to Ready */
2585
2586#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2587 /* Call registered Rx complete callback */
2588 hirda->RxCpltCallback(hirda);
2589#else
2590 /* Call legacy weak Rx complete callback */
2592#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
2593
2594 return HAL_OK;
2595 }
2596 return HAL_OK;
2597 }
2598 else
2599 {
2600 return HAL_BUSY;
2601 }
2602}
2603
2611{
2612 uint32_t pclk;
2613
2614 /* Check the parameters */
2615 assert_param(IS_IRDA_INSTANCE(hirda->Instance));
2621
2622 /*-------------------------- USART CR2 Configuration ------------------------*/
2623 /* Clear STOP[13:12] bits */
2624 CLEAR_BIT(hirda->Instance->CR2, USART_CR2_STOP);
2625
2626 /*-------------------------- USART CR1 Configuration -----------------------*/
2627 /* Clear M, PCE, PS, TE and RE bits */
2628 CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | USART_CR1_RE));
2629
2630 /* Configure the USART Word Length, Parity and mode:
2631 Set the M bits according to hirda->Init.WordLength value
2632 Set PCE and PS bits according to hirda->Init.Parity value
2633 Set TE and RE bits according to hirda->Init.Mode value */
2634 /* Write to USART CR1 */
2635 SET_BIT(hirda->Instance->CR1, (hirda->Init.WordLength | hirda->Init.Parity | hirda->Init.Mode));
2636
2637 /*-------------------------- USART CR3 Configuration -----------------------*/
2638 /* Clear CTSE and RTSE bits */
2639 CLEAR_BIT(hirda->Instance->CR3, (USART_CR3_RTSE | USART_CR3_CTSE));
2640
2641 /*-------------------------- USART BRR Configuration -----------------------*/
2642#if defined(USART6) && defined(UART9) && defined(UART10)
2643 if ((hirda->Instance == USART1) || (hirda->Instance == USART6) || (hirda->Instance == UART9) || (hirda->Instance == UART10))
2644 {
2645 pclk = HAL_RCC_GetPCLK2Freq();
2646 SET_BIT(hirda->Instance->BRR, IRDA_BRR(pclk, hirda->Init.BaudRate));
2647 }
2648#elif defined(USART6)
2649 if((hirda->Instance == USART1) || (hirda->Instance == USART6))
2650 {
2651 pclk = HAL_RCC_GetPCLK2Freq();
2652 SET_BIT(hirda->Instance->BRR, IRDA_BRR(pclk, hirda->Init.BaudRate));
2653 }
2654#else
2655 if(hirda->Instance == USART1)
2656 {
2657 pclk = HAL_RCC_GetPCLK2Freq();
2658 SET_BIT(hirda->Instance->BRR, IRDA_BRR(pclk, hirda->Init.BaudRate));
2659 }
2660#endif /* USART6 */
2661 else
2662 {
2663 pclk = HAL_RCC_GetPCLK1Freq();
2664 SET_BIT(hirda->Instance->BRR, IRDA_BRR(pclk, hirda->Init.BaudRate));
2665 }
2666}
2667
2672#endif /* HAL_IRDA_MODULE_ENABLED */
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer.
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
Start the DMA Transfer with interrupt enabled.
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
#define HAL_IRDA_ERROR_DMA
#define HAL_IRDA_ERROR_ORE
#define HAL_IRDA_ERROR_NONE
#define HAL_IRDA_ERROR_PE
#define HAL_IRDA_ERROR_NE
#define HAL_IRDA_ERROR_FE
HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda)
DeInitializes the IRDA peripheral.
void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda)
IRDA MSP Init.
HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda)
Initializes the IRDA mode according to the specified parameters in the IRDA_InitTypeDef and create th...
void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda)
IRDA MSP DeInit.
HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
Receive an amount of data in non blocking mode.
void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda)
IRDA Abort Receive Complete callback.
void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda)
IRDA Abort Transmit Complete callback.
HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, const uint8_t *pData, uint16_t Size, uint32_t Timeout)
Sends an amount of data in blocking mode.
HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda)
Stops the DMA Transfer.
HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout)
Receive an amount of data in blocking mode.
void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda)
Tx Transfer complete callback.
HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda)
Pauses the DMA Transfer.
void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda)
Tx Half Transfer completed callback.
HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef *hirda)
Abort ongoing Transmit transfer (Interrupt mode).
void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda)
Rx Transfer complete callback.
void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda)
Rx Half Transfer complete callback.
void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda)
This function handles IRDA interrupt request.
HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef *hirda)
Abort ongoing Receive transfer (Interrupt mode).
HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, const uint8_t *pData, uint16_t Size)
Send an amount of data in non blocking mode.
HAL_StatusTypeDef HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef *hirda)
Abort ongoing Transmit transfer (blocking mode).
HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
Receives an amount of data in DMA mode.
HAL_StatusTypeDef HAL_IRDA_AbortReceive(IRDA_HandleTypeDef *hirda)
Abort ongoing Receive transfer (blocking mode).
HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, const uint8_t *pData, uint16_t Size)
Send an amount of data in DMA mode.
HAL_StatusTypeDef HAL_IRDA_Abort(IRDA_HandleTypeDef *hirda)
Abort ongoing transfers (blocking mode).
void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda)
IRDA error callback.
HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda)
Resumes the DMA Transfer.
HAL_StatusTypeDef HAL_IRDA_Abort_IT(IRDA_HandleTypeDef *hirda)
Abort ongoing transfers (Interrupt mode).
void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda)
IRDA Abort Complete callback.
uint32_t HAL_IRDA_GetError(const IRDA_HandleTypeDef *hirda)
Return the IRDA error code.
HAL_IRDA_StateTypeDef HAL_IRDA_GetState(const IRDA_HandleTypeDef *hirda)
Return the IRDA state.
#define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__)
Check whether the specified IRDA flag is set or not.
#define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__)
Clear the IRDA ORE pending flag.
#define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clear the specified IRDA pending flag.
#define __HAL_IRDA_ENABLE(__HANDLE__)
Enable UART/USART associated to IRDA Handle.
#define __HAL_IRDA_DISABLE(__HANDLE__)
Disable UART/USART associated to IRDA Handle.
HAL_IRDA_StateTypeDef
HAL IRDA State structures definition.
@ HAL_IRDA_STATE_BUSY_RX
@ HAL_IRDA_STATE_BUSY_TX
@ HAL_IRDA_STATE_BUSY
@ HAL_IRDA_STATE_READY
@ HAL_IRDA_STATE_RESET
#define IRDA_FLAG_RXNE
#define IRDA_FLAG_TXE
#define IRDA_FLAG_TC
#define IRDA_PARITY_NONE
static void IRDA_EndTxTransfer(IRDA_HandleTypeDef *hirda)
End ongoing Tx transfer on IRDA peripheral (following error detection or Transmit completion).
static void IRDA_DMAAbortOnError(DMA_HandleTypeDef *hdma)
DMA IRDA communication abort callback, when initiated by HAL services on Error (To be called at end o...
static void IRDA_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
DMA IRDA receive process complete callback.
static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma)
DMA IRDA transmit process complete callback.
static void IRDA_SetConfig(IRDA_HandleTypeDef *hirda)
Configures the IRDA peripheral.
static void IRDA_DMAError(DMA_HandleTypeDef *hdma)
DMA IRDA communication error callback.
static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
This function handles IRDA Communication Timeout. It waits until a flag is no longer in the specified...
static void IRDA_DMATxAbortCallback(DMA_HandleTypeDef *hdma)
DMA IRDA Tx communication abort callback, when initiated by user (To be called at end of DMA Tx Abort...
static void IRDA_EndRxTransfer(IRDA_HandleTypeDef *hirda)
End ongoing Rx transfer on IRDA peripheral (following error detection or Reception completion).
static void IRDA_DMARxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
DMA IRDA Rx communication abort callback, when initiated by user by a call to HAL_IRDA_AbortReceive_I...
static void IRDA_DMATransmitHalfCplt(DMA_HandleTypeDef *hdma)
DMA IRDA receive process half complete callback.
static HAL_StatusTypeDef IRDA_Receive_IT(IRDA_HandleTypeDef *hirda)
Receives an amount of data in non blocking mode.
static void IRDA_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
DMA IRDA Tx communication abort callback, when initiated by user by a call to HAL_IRDA_AbortTransmit_...
static HAL_StatusTypeDef IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda)
Send an amount of data in non blocking mode.
static void IRDA_DMAReceiveHalfCplt(DMA_HandleTypeDef *hdma)
DMA IRDA receive process half complete callback.
static HAL_StatusTypeDef IRDA_EndTransmit_IT(IRDA_HandleTypeDef *hirda)
Wraps up transmission in non blocking mode.
static void IRDA_DMARxAbortCallback(DMA_HandleTypeDef *hdma)
DMA IRDA Rx communication abort callback, when initiated by user (To be called at end of DMA Rx Abort...
#define IS_IRDA_MODE(MODE)
#define IS_IRDA_PARITY(PARITY)
#define IRDA_BRR(_PCLK_, _BAUD_)
#define IS_IRDA_BAUDRATE(BAUDRATE)
#define IS_IRDA_WORD_LENGTH(LENGTH)
#define IS_IRDA_POWERMODE(MODE)
#define IRDA_WORDLENGTH_9B
uint32_t HAL_RCC_GetPCLK1Freq(void)
Returns the PCLK1 frequency.
uint32_t HAL_RCC_GetPCLK2Freq(void)
Returns the PCLK2 frequency.
#define assert_param(expr)
This file contains all the functions prototypes for the HAL module driver.
#define HAL_IS_BIT_SET(REG, BIT)
HAL_StatusTypeDef
HAL Status structures definition
@ HAL_TIMEOUT
@ HAL_ERROR
@ HAL_OK
@ HAL_BUSY
#define UNUSED(X)
#define __HAL_UNLOCK(__HANDLE__)
#define HAL_MAX_DELAY
@ HAL_UNLOCKED
#define __HAL_LOCK(__HANDLE__)
IRDA handle Structure definition.
DMA_HandleTypeDef * hdmarx
__IO HAL_IRDA_StateTypeDef RxState
__IO HAL_IRDA_StateTypeDef gState
USART_TypeDef * Instance
const uint8_t * pTxBuffPtr
IRDA_InitTypeDef Init
DMA_HandleTypeDef * hdmatx
DMA handle Structure definition.
void(* XferAbortCallback)(struct __DMA_HandleTypeDef *hdma)
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
void(* XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)
DMA_Stream_TypeDef * Instance