stm32f7xx_hal_uart.c
Go to the documentation of this file.
1 
156 /* Includes ------------------------------------------------------------------*/
157 #include "stm32f7xx_hal.h"
158 
168 #ifdef HAL_UART_MODULE_ENABLED
169 
170 /* Private typedef -----------------------------------------------------------*/
171 /* Private define ------------------------------------------------------------*/
175 #define USART_CR1_FIELDS ((uint32_t)(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | \
176  USART_CR1_TE | USART_CR1_RE | USART_CR1_OVER8 ))
178 #define USART_CR3_FIELDS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE | USART_CR3_ONEBIT))
181 #define UART_BRR_MIN 0x10U /* UART BRR minimum authorized value */
182 #define UART_BRR_MAX 0x0000FFFFU /* UART BRR maximum authorized value */
183 
188 /* Private macros ------------------------------------------------------------*/
189 /* Private variables ---------------------------------------------------------*/
190 /* Private function prototypes -----------------------------------------------*/
194 static void UART_EndTxTransfer(UART_HandleTypeDef *huart);
195 static void UART_EndRxTransfer(UART_HandleTypeDef *huart);
196 static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma);
197 static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma);
198 static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
199 static void UART_DMATxHalfCplt(DMA_HandleTypeDef *hdma);
200 static void UART_DMAError(DMA_HandleTypeDef *hdma);
201 static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma);
202 static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma);
203 static void UART_DMARxAbortCallback(DMA_HandleTypeDef *hdma);
204 static void UART_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma);
205 static void UART_DMARxOnlyAbortCallback(DMA_HandleTypeDef *hdma);
206 static void UART_TxISR_8BIT(UART_HandleTypeDef *huart);
207 static void UART_TxISR_16BIT(UART_HandleTypeDef *huart);
208 static void UART_EndTransmit_IT(UART_HandleTypeDef *huart);
209 static void UART_RxISR_8BIT(UART_HandleTypeDef *huart);
210 static void UART_RxISR_16BIT(UART_HandleTypeDef *huart);
215 /* Exported functions --------------------------------------------------------*/
216 
288 {
289  /* Check the UART handle allocation */
290  if (huart == NULL)
291  {
292  return HAL_ERROR;
293  }
294 
296  {
297  /* Check the parameters */
299  }
300  else
301  {
302  /* Check the parameters */
304  }
305 
307  {
308  /* Allocate lock resource and initialize it */
310 
311 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
312  UART_InitCallbacksToDefault(huart);
313 
314  if (huart->MspInitCallback == NULL)
315  {
316  huart->MspInitCallback = HAL_UART_MspInit;
317  }
318 
319  /* Init the low level hardware */
320  huart->MspInitCallback(huart);
321 #else
322  /* Init the low level hardware : GPIO, CLOCK */
324 #endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
325  }
326 
328 
330 
331  /* Set the UART Communication parameters */
333  {
334  return HAL_ERROR;
335  }
336 
338  {
340  }
341 
342  /* In asynchronous mode, the following bits must be kept cleared:
343  - LINEN and CLKEN bits in the USART_CR2 register,
344  - SCEN, HDSEL and IREN bits in the USART_CR3 register.*/
347 
349 
350  /* TEACK and/or REACK to check before moving huart->gState and huart->RxState to Ready */
351  return (UART_CheckIdleState(huart));
352 }
353 
361 {
362  /* Check the UART handle allocation */
363  if (huart == NULL)
364  {
365  return HAL_ERROR;
366  }
367 
368  /* Check UART instance */
370 
372  {
373  /* Allocate lock resource and initialize it */
375 
376 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
377  UART_InitCallbacksToDefault(huart);
378 
379  if (huart->MspInitCallback == NULL)
380  {
381  huart->MspInitCallback = HAL_UART_MspInit;
382  }
383 
384  /* Init the low level hardware */
385  huart->MspInitCallback(huart);
386 #else
387  /* Init the low level hardware : GPIO, CLOCK */
389 #endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
390  }
391 
393 
395 
396  /* Set the UART Communication parameters */
398  {
399  return HAL_ERROR;
400  }
401 
403  {
405  }
406 
407  /* In half-duplex mode, the following bits must be kept cleared:
408  - LINEN and CLKEN bits in the USART_CR2 register,
409  - SCEN and IREN bits in the USART_CR3 register.*/
412 
413  /* Enable the Half-Duplex mode by setting the HDSEL bit in the CR3 register */
415 
417 
418  /* TEACK and/or REACK to check before moving huart->gState and huart->RxState to Ready */
419  return (UART_CheckIdleState(huart));
420 }
421 
422 
433 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
434 {
435  /* Check the UART handle allocation */
436  if (huart == NULL)
437  {
438  return HAL_ERROR;
439  }
440 
441  /* Check the LIN UART instance */
443  /* Check the Break detection length parameter */
444  assert_param(IS_UART_LIN_BREAK_DETECT_LENGTH(BreakDetectLength));
445 
446  /* LIN mode limited to 16-bit oversampling only */
448  {
449  return HAL_ERROR;
450  }
451  /* LIN mode limited to 8-bit data length */
453  {
454  return HAL_ERROR;
455  }
456 
458  {
459  /* Allocate lock resource and initialize it */
461 
462 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
463  UART_InitCallbacksToDefault(huart);
464 
465  if (huart->MspInitCallback == NULL)
466  {
467  huart->MspInitCallback = HAL_UART_MspInit;
468  }
469 
470  /* Init the low level hardware */
471  huart->MspInitCallback(huart);
472 #else
473  /* Init the low level hardware : GPIO, CLOCK */
475 #endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
476  }
477 
479 
481 
482  /* Set the UART Communication parameters */
484  {
485  return HAL_ERROR;
486  }
487 
489  {
491  }
492 
493  /* In LIN mode, the following bits must be kept cleared:
494  - LINEN and CLKEN bits in the USART_CR2 register,
495  - SCEN and IREN bits in the USART_CR3 register.*/
498 
499  /* Enable the LIN mode by setting the LINEN bit in the CR2 register */
501 
502  /* Set the USART LIN Break detection length. */
503  MODIFY_REG(huart->Instance->CR2, USART_CR2_LBDL, BreakDetectLength);
504 
506 
507  /* TEACK and/or REACK to check before moving huart->gState and huart->RxState to Ready */
508  return (UART_CheckIdleState(huart));
509 }
510 
511 
530 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
531 {
532  /* Check the UART handle allocation */
533  if (huart == NULL)
534  {
535  return HAL_ERROR;
536  }
537 
538  /* Check the wake up method parameter */
539  assert_param(IS_UART_WAKEUPMETHOD(WakeUpMethod));
540 
542  {
543  /* Allocate lock resource and initialize it */
545 
546 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
547  UART_InitCallbacksToDefault(huart);
548 
549  if (huart->MspInitCallback == NULL)
550  {
551  huart->MspInitCallback = HAL_UART_MspInit;
552  }
553 
554  /* Init the low level hardware */
555  huart->MspInitCallback(huart);
556 #else
557  /* Init the low level hardware : GPIO, CLOCK */
559 #endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
560  }
561 
563 
565 
566  /* Set the UART Communication parameters */
568  {
569  return HAL_ERROR;
570  }
571 
573  {
575  }
576 
577  /* In multiprocessor mode, the following bits must be kept cleared:
578  - LINEN and CLKEN bits in the USART_CR2 register,
579  - SCEN, HDSEL and IREN bits in the USART_CR3 register. */
582 
583  if (WakeUpMethod == UART_WAKEUPMETHOD_ADDRESSMARK)
584  {
585  /* If address mark wake up method is chosen, set the USART address node */
587  }
588 
589  /* Set the wake up method by setting the WAKE bit in the CR1 register */
590  MODIFY_REG(huart->Instance->CR1, USART_CR1_WAKE, WakeUpMethod);
591 
593 
594  /* TEACK and/or REACK to check before moving huart->gState and huart->RxState to Ready */
595  return (UART_CheckIdleState(huart));
596 }
597 
598 
605 {
606  /* Check the UART handle allocation */
607  if (huart == NULL)
608  {
609  return HAL_ERROR;
610  }
611 
612  /* Check the parameters */
614 
616 
618 
619  huart->Instance->CR1 = 0x0U;
620  huart->Instance->CR2 = 0x0U;
621  huart->Instance->CR3 = 0x0U;
622 
623 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
624  if (huart->MspDeInitCallback == NULL)
625  {
626  huart->MspDeInitCallback = HAL_UART_MspDeInit;
627  }
628  /* DeInit the low level hardware */
629  huart->MspDeInitCallback(huart);
630 #else
631  /* DeInit the low level hardware */
633 #endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
634 
638 
640 
641  return HAL_OK;
642 }
643 
650 {
651  /* Prevent unused argument(s) compilation warning */
652  UNUSED(huart);
653 
654  /* NOTE : This function should not be modified, when the callback is needed,
655  the HAL_UART_MspInit can be implemented in the user file
656  */
657 }
658 
665 {
666  /* Prevent unused argument(s) compilation warning */
667  UNUSED(huart);
668 
669  /* NOTE : This function should not be modified, when the callback is needed,
670  the HAL_UART_MspDeInit can be implemented in the user file
671  */
672 }
673 
674 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
675 
697 HAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID,
698  pUART_CallbackTypeDef pCallback)
699 {
700  HAL_StatusTypeDef status = HAL_OK;
701 
702  if (pCallback == NULL)
703  {
704  huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
705 
706  return HAL_ERROR;
707  }
708 
709  __HAL_LOCK(huart);
710 
712  {
713  switch (CallbackID)
714  {
715  case HAL_UART_TX_HALFCOMPLETE_CB_ID :
716  huart->TxHalfCpltCallback = pCallback;
717  break;
718 
719  case HAL_UART_TX_COMPLETE_CB_ID :
720  huart->TxCpltCallback = pCallback;
721  break;
722 
723  case HAL_UART_RX_HALFCOMPLETE_CB_ID :
724  huart->RxHalfCpltCallback = pCallback;
725  break;
726 
727  case HAL_UART_RX_COMPLETE_CB_ID :
728  huart->RxCpltCallback = pCallback;
729  break;
730 
731  case HAL_UART_ERROR_CB_ID :
732  huart->ErrorCallback = pCallback;
733  break;
734 
735  case HAL_UART_ABORT_COMPLETE_CB_ID :
736  huart->AbortCpltCallback = pCallback;
737  break;
738 
739  case HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID :
740  huart->AbortTransmitCpltCallback = pCallback;
741  break;
742 
743  case HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID :
744  huart->AbortReceiveCpltCallback = pCallback;
745  break;
746 
747  case HAL_UART_WAKEUP_CB_ID :
748  huart->WakeupCallback = pCallback;
749  break;
750 
751 
752  case HAL_UART_MSPINIT_CB_ID :
753  huart->MspInitCallback = pCallback;
754  break;
755 
756  case HAL_UART_MSPDEINIT_CB_ID :
757  huart->MspDeInitCallback = pCallback;
758  break;
759 
760  default :
761  huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
762 
763  status = HAL_ERROR;
764  break;
765  }
766  }
767  else if (huart->gState == HAL_UART_STATE_RESET)
768  {
769  switch (CallbackID)
770  {
771  case HAL_UART_MSPINIT_CB_ID :
772  huart->MspInitCallback = pCallback;
773  break;
774 
775  case HAL_UART_MSPDEINIT_CB_ID :
776  huart->MspDeInitCallback = pCallback;
777  break;
778 
779  default :
780  huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
781 
782  status = HAL_ERROR;
783  break;
784  }
785  }
786  else
787  {
788  huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
789 
790  status = HAL_ERROR;
791  }
792 
794 
795  return status;
796 }
797 
819 HAL_StatusTypeDef HAL_UART_UnRegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID)
820 {
821  HAL_StatusTypeDef status = HAL_OK;
822 
823  __HAL_LOCK(huart);
824 
826  {
827  switch (CallbackID)
828  {
829  case HAL_UART_TX_HALFCOMPLETE_CB_ID :
830  huart->TxHalfCpltCallback = HAL_UART_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
831  break;
832 
833  case HAL_UART_TX_COMPLETE_CB_ID :
834  huart->TxCpltCallback = HAL_UART_TxCpltCallback; /* Legacy weak TxCpltCallback */
835  break;
836 
837  case HAL_UART_RX_HALFCOMPLETE_CB_ID :
838  huart->RxHalfCpltCallback = HAL_UART_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
839  break;
840 
841  case HAL_UART_RX_COMPLETE_CB_ID :
842  huart->RxCpltCallback = HAL_UART_RxCpltCallback; /* Legacy weak RxCpltCallback */
843  break;
844 
845  case HAL_UART_ERROR_CB_ID :
846  huart->ErrorCallback = HAL_UART_ErrorCallback; /* Legacy weak ErrorCallback */
847  break;
848 
849  case HAL_UART_ABORT_COMPLETE_CB_ID :
850  huart->AbortCpltCallback = HAL_UART_AbortCpltCallback; /* Legacy weak AbortCpltCallback */
851  break;
852 
853  case HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID :
854  huart->AbortTransmitCpltCallback = HAL_UART_AbortTransmitCpltCallback; /* Legacy weak AbortTransmitCpltCallback */
855  break;
856 
857  case HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID :
858  huart->AbortReceiveCpltCallback = HAL_UART_AbortReceiveCpltCallback; /* Legacy weak AbortReceiveCpltCallback */
859  break;
860 
861 #if defined(USART_CR1_UESM)
862  case HAL_UART_WAKEUP_CB_ID :
863  huart->WakeupCallback = HAL_UARTEx_WakeupCallback; /* Legacy weak WakeupCallback */
864  break;
865 
866 #endif /* USART_CR1_UESM */
867  case HAL_UART_MSPINIT_CB_ID :
868  huart->MspInitCallback = HAL_UART_MspInit; /* Legacy weak MspInitCallback */
869  break;
870 
871  case HAL_UART_MSPDEINIT_CB_ID :
872  huart->MspDeInitCallback = HAL_UART_MspDeInit; /* Legacy weak MspDeInitCallback */
873  break;
874 
875  default :
876  huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
877 
878  status = HAL_ERROR;
879  break;
880  }
881  }
882  else if (HAL_UART_STATE_RESET == huart->gState)
883  {
884  switch (CallbackID)
885  {
886  case HAL_UART_MSPINIT_CB_ID :
887  huart->MspInitCallback = HAL_UART_MspInit;
888  break;
889 
890  case HAL_UART_MSPDEINIT_CB_ID :
891  huart->MspDeInitCallback = HAL_UART_MspDeInit;
892  break;
893 
894  default :
895  huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
896 
897  status = HAL_ERROR;
898  break;
899  }
900  }
901  else
902  {
903  huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
904 
905  status = HAL_ERROR;
906  }
907 
909 
910  return status;
911 }
912 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
913 
1011 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
1012 {
1013  uint8_t *pdata8bits;
1014  uint16_t *pdata16bits;
1015  uint32_t tickstart;
1016 
1017  /* Check that a Tx process is not already ongoing */
1019  {
1020  if ((pData == NULL) || (Size == 0U))
1021  {
1022  return HAL_ERROR;
1023  }
1024 
1025  __HAL_LOCK(huart);
1026 
1029 
1030  /* Init tickstart for timeout managment*/
1031  tickstart = HAL_GetTick();
1032 
1033  huart->TxXferSize = Size;
1034  huart->TxXferCount = Size;
1035 
1036  /* In case of 9bits/No Parity transfer, pData needs to be handled as a uint16_t pointer */
1038  {
1039  pdata8bits = NULL;
1040  pdata16bits = (uint16_t *) pData;
1041  }
1042  else
1043  {
1044  pdata8bits = pData;
1045  pdata16bits = NULL;
1046  }
1047 
1049 
1050  while (huart->TxXferCount > 0U)
1051  {
1052  if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)
1053  {
1054  return HAL_TIMEOUT;
1055  }
1056  if (pdata8bits == NULL)
1057  {
1058  huart->Instance->TDR = (uint16_t)(*pdata16bits & 0x01FFU);
1059  pdata16bits++;
1060  }
1061  else
1062  {
1063  huart->Instance->TDR = (uint8_t)(*pdata8bits & 0xFFU);
1064  pdata8bits++;
1065  }
1066  huart->TxXferCount--;
1067  }
1068 
1069  if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TC, RESET, tickstart, Timeout) != HAL_OK)
1070  {
1071  return HAL_TIMEOUT;
1072  }
1073 
1074  /* At end of Tx process, restore huart->gState to Ready */
1076 
1077  return HAL_OK;
1078  }
1079  else
1080  {
1081  return HAL_BUSY;
1082  }
1083 }
1084 
1096 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
1097 {
1098  uint8_t *pdata8bits;
1099  uint16_t *pdata16bits;
1100  uint16_t uhMask;
1101  uint32_t tickstart;
1102 
1103  /* Check that a Rx process is not already ongoing */
1105  {
1106  if ((pData == NULL) || (Size == 0U))
1107  {
1108  return HAL_ERROR;
1109  }
1110 
1111  __HAL_LOCK(huart);
1112 
1115 
1116  /* Init tickstart for timeout managment*/
1117  tickstart = HAL_GetTick();
1118 
1119  huart->RxXferSize = Size;
1120  huart->RxXferCount = Size;
1121 
1122  /* Computation of UART mask to apply to RDR register */
1124  uhMask = huart->Mask;
1125 
1126  /* In case of 9bits/No Parity transfer, pRxData needs to be handled as a uint16_t pointer */
1128  {
1129  pdata8bits = NULL;
1130  pdata16bits = (uint16_t *) pData;
1131  }
1132  else
1133  {
1134  pdata8bits = pData;
1135  pdata16bits = NULL;
1136  }
1137 
1139 
1140  /* as long as data have to be received */
1141  while (huart->RxXferCount > 0U)
1142  {
1143  if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_RXNE, RESET, tickstart, Timeout) != HAL_OK)
1144  {
1145  return HAL_TIMEOUT;
1146  }
1147  if (pdata8bits == NULL)
1148  {
1149  *pdata16bits = (uint16_t)(huart->Instance->RDR & uhMask);
1150  pdata16bits++;
1151  }
1152  else
1153  {
1154  *pdata8bits = (uint8_t)(huart->Instance->RDR & (uint8_t)uhMask);
1155  pdata8bits++;
1156  }
1157  huart->RxXferCount--;
1158  }
1159 
1160  /* At end of Rx process, restore huart->RxState to Ready */
1162 
1163  return HAL_OK;
1164  }
1165  else
1166  {
1167  return HAL_BUSY;
1168  }
1169 }
1170 
1181 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
1182 {
1183  /* Check that a Tx process is not already ongoing */
1185  {
1186  if ((pData == NULL) || (Size == 0U))
1187  {
1188  return HAL_ERROR;
1189  }
1190 
1191  __HAL_LOCK(huart);
1192 
1193  huart->pTxBuffPtr = pData;
1194  huart->TxXferSize = Size;
1195  huart->TxXferCount = Size;
1196  huart->TxISR = NULL;
1197 
1200 
1201  /* Set the Tx ISR function pointer according to the data word length */
1203  {
1204  huart->TxISR = UART_TxISR_16BIT;
1205  }
1206  else
1207  {
1208  huart->TxISR = UART_TxISR_8BIT;
1209  }
1210 
1212 
1213  /* Enable the Transmit Data Register Empty interrupt */
1215 
1216  return HAL_OK;
1217  }
1218  else
1219  {
1220  return HAL_BUSY;
1221  }
1222 }
1223 
1234 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
1235 {
1236  /* Check that a Rx process is not already ongoing */
1238  {
1239  if ((pData == NULL) || (Size == 0U))
1240  {
1241  return HAL_ERROR;
1242  }
1243 
1244  __HAL_LOCK(huart);
1245 
1246  huart->pRxBuffPtr = pData;
1247  huart->RxXferSize = Size;
1248  huart->RxXferCount = Size;
1249  huart->RxISR = NULL;
1250 
1251  /* Computation of UART mask to apply to RDR register */
1253 
1256 
1257  /* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
1259 
1260  /* Set the Rx ISR function pointer according to the data word length */
1262  {
1263  huart->RxISR = UART_RxISR_16BIT;
1264  }
1265  else
1266  {
1267  huart->RxISR = UART_RxISR_8BIT;
1268  }
1269 
1271 
1272  /* Enable the UART Parity Error interrupt and Data Register Not Empty interrupt */
1274 
1275  return HAL_OK;
1276  }
1277  else
1278  {
1279  return HAL_BUSY;
1280  }
1281 }
1282 
1293 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
1294 {
1295  /* Check that a Tx process is not already ongoing */
1297  {
1298  if ((pData == NULL) || (Size == 0U))
1299  {
1300  return HAL_ERROR;
1301  }
1302 
1303  __HAL_LOCK(huart);
1304 
1305  huart->pTxBuffPtr = pData;
1306  huart->TxXferSize = Size;
1307  huart->TxXferCount = Size;
1308 
1311 
1312  if (huart->hdmatx != NULL)
1313  {
1314  /* Set the UART DMA transfer complete callback */
1315  huart->hdmatx->XferCpltCallback = UART_DMATransmitCplt;
1316 
1317  /* Set the UART DMA Half transfer complete callback */
1318  huart->hdmatx->XferHalfCpltCallback = UART_DMATxHalfCplt;
1319 
1320  /* Set the DMA error callback */
1321  huart->hdmatx->XferErrorCallback = UART_DMAError;
1322 
1323  /* Set the DMA abort callback */
1325 
1326  /* Enable the UART transmit DMA channel */
1327  if (HAL_DMA_Start_IT(huart->hdmatx, (uint32_t)huart->pTxBuffPtr, (uint32_t)&huart->Instance->TDR, Size) != HAL_OK)
1328  {
1329  /* Set error code to DMA */
1331 
1333 
1334  /* Restore huart->gState to ready */
1336 
1337  return HAL_ERROR;
1338  }
1339  }
1340  /* Clear the TC flag in the ICR register */
1342 
1344 
1345  /* Enable the DMA transfer for transmit request by setting the DMAT bit
1346  in the UART CR3 register */
1348 
1349  return HAL_OK;
1350  }
1351  else
1352  {
1353  return HAL_BUSY;
1354  }
1355 }
1356 
1369 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
1370 {
1371  /* Check that a Rx process is not already ongoing */
1373  {
1374  if ((pData == NULL) || (Size == 0U))
1375  {
1376  return HAL_ERROR;
1377  }
1378 
1379  __HAL_LOCK(huart);
1380 
1381  huart->pRxBuffPtr = pData;
1382  huart->RxXferSize = Size;
1383 
1386 
1387  if (huart->hdmarx != NULL)
1388  {
1389  /* Set the UART DMA transfer complete callback */
1390  huart->hdmarx->XferCpltCallback = UART_DMAReceiveCplt;
1391 
1392  /* Set the UART DMA Half transfer complete callback */
1393  huart->hdmarx->XferHalfCpltCallback = UART_DMARxHalfCplt;
1394 
1395  /* Set the DMA error callback */
1396  huart->hdmarx->XferErrorCallback = UART_DMAError;
1397 
1398  /* Set the DMA abort callback */
1400 
1401  /* Enable the DMA channel */
1402  if (HAL_DMA_Start_IT(huart->hdmarx, (uint32_t)&huart->Instance->RDR, (uint32_t)huart->pRxBuffPtr, Size) != HAL_OK)
1403  {
1404  /* Set error code to DMA */
1406 
1408 
1409  /* Restore huart->gState to ready */
1411 
1412  return HAL_ERROR;
1413  }
1414  }
1416 
1417  /* Enable the UART Parity Error Interrupt */
1419 
1420  /* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
1422 
1423  /* Enable the DMA transfer for the receiver request by setting the DMAR bit
1424  in the UART CR3 register */
1426 
1427  return HAL_OK;
1428  }
1429  else
1430  {
1431  return HAL_BUSY;
1432  }
1433 }
1434 
1441 {
1442  const HAL_UART_StateTypeDef gstate = huart->gState;
1443  const HAL_UART_StateTypeDef rxstate = huart->RxState;
1444 
1445  __HAL_LOCK(huart);
1446 
1448  (gstate == HAL_UART_STATE_BUSY_TX))
1449  {
1450  /* Disable the UART DMA Tx request */
1452  }
1454  (rxstate == HAL_UART_STATE_BUSY_RX))
1455  {
1456  /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
1459 
1460  /* Disable the UART DMA Rx request */
1462  }
1463 
1465 
1466  return HAL_OK;
1467 }
1468 
1475 {
1476  __HAL_LOCK(huart);
1477 
1479  {
1480  /* Enable the UART DMA Tx request */
1482  }
1484  {
1485  /* Clear the Overrun flag before resuming the Rx transfer */
1487 
1488  /* Reenable PE and ERR (Frame error, noise error, overrun error) interrupts */
1491 
1492  /* Enable the UART DMA Rx request */
1494  }
1495 
1497 
1498  return HAL_OK;
1499 }
1500 
1507 {
1508  /* The Lock is not implemented on this API to allow the user application
1509  to call the HAL UART API under callbacks HAL_UART_TxCpltCallback() / HAL_UART_RxCpltCallback() /
1510  HAL_UART_TxHalfCpltCallback / HAL_UART_RxHalfCpltCallback:
1511  indeed, when HAL_DMA_Abort() API is called, the DMA TX/RX Transfer or Half Transfer complete
1512  interrupt is generated if the DMA transfer interruption occurs at the middle or at the end of
1513  the stream and the corresponding call back is executed. */
1514 
1515  const HAL_UART_StateTypeDef gstate = huart->gState;
1516  const HAL_UART_StateTypeDef rxstate = huart->RxState;
1517 
1518  /* Stop UART DMA Tx request if ongoing */
1520  (gstate == HAL_UART_STATE_BUSY_TX))
1521  {
1523 
1524  /* Abort the UART DMA Tx channel */
1525  if (huart->hdmatx != NULL)
1526  {
1527  if (HAL_DMA_Abort(huart->hdmatx) != HAL_OK)
1528  {
1530  {
1531  /* Set error code to DMA */
1533 
1534  return HAL_TIMEOUT;
1535  }
1536  }
1537  }
1538 
1539  UART_EndTxTransfer(huart);
1540  }
1541 
1542  /* Stop UART DMA Rx request if ongoing */
1544  (rxstate == HAL_UART_STATE_BUSY_RX))
1545  {
1547 
1548  /* Abort the UART DMA Rx channel */
1549  if (huart->hdmarx != NULL)
1550  {
1551  if (HAL_DMA_Abort(huart->hdmarx) != HAL_OK)
1552  {
1554  {
1555  /* Set error code to DMA */
1557 
1558  return HAL_TIMEOUT;
1559  }
1560  }
1561  }
1562 
1563  UART_EndRxTransfer(huart);
1564  }
1565 
1566  return HAL_OK;
1567 }
1568 
1582 {
1583  /* Disable TXEIE, TCIE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1586 
1587  /* Disable the UART DMA Tx request if enabled */
1589  {
1591 
1592  /* Abort the UART DMA Tx channel : use blocking DMA Abort API (no callback) */
1593  if (huart->hdmatx != NULL)
1594  {
1595  /* Set the UART DMA Abort callback to Null.
1596  No call back execution at end of DMA abort procedure */
1598 
1599  if (HAL_DMA_Abort(huart->hdmatx) != HAL_OK)
1600  {
1602  {
1603  /* Set error code to DMA */
1605 
1606  return HAL_TIMEOUT;
1607  }
1608  }
1609  }
1610  }
1611 
1612  /* Disable the UART DMA Rx request if enabled */
1614  {
1616 
1617  /* Abort the UART DMA Rx channel : use blocking DMA Abort API (no callback) */
1618  if (huart->hdmarx != NULL)
1619  {
1620  /* Set the UART DMA Abort callback to Null.
1621  No call back execution at end of DMA abort procedure */
1623 
1624  if (HAL_DMA_Abort(huart->hdmarx) != HAL_OK)
1625  {
1627  {
1628  /* Set error code to DMA */
1630 
1631  return HAL_TIMEOUT;
1632  }
1633  }
1634  }
1635  }
1636 
1637  /* Reset Tx and Rx transfer counters */
1638  huart->TxXferCount = 0U;
1639  huart->RxXferCount = 0U;
1640 
1641  /* Clear the Error flags in the ICR register */
1643 
1644 
1645  /* Discard the received data */
1647 
1648  /* Restore huart->gState and huart->RxState to Ready */
1651 
1653 
1654  return HAL_OK;
1655 }
1656 
1670 {
1671  /* Disable TXEIE and TCIE interrupts */
1673 
1674  /* Disable the UART DMA Tx request if enabled */
1676  {
1678 
1679  /* Abort the UART DMA Tx channel : use blocking DMA Abort API (no callback) */
1680  if (huart->hdmatx != NULL)
1681  {
1682  /* Set the UART DMA Abort callback to Null.
1683  No call back execution at end of DMA abort procedure */
1685 
1686  if (HAL_DMA_Abort(huart->hdmatx) != HAL_OK)
1687  {
1689  {
1690  /* Set error code to DMA */
1692 
1693  return HAL_TIMEOUT;
1694  }
1695  }
1696  }
1697  }
1698 
1699  /* Reset Tx transfer counter */
1700  huart->TxXferCount = 0U;
1701 
1702 
1703  /* Restore huart->gState to Ready */
1705 
1706  return HAL_OK;
1707 }
1708 
1722 {
1723  /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1726 
1727  /* Disable the UART DMA Rx request if enabled */
1729  {
1731 
1732  /* Abort the UART DMA Rx channel : use blocking DMA Abort API (no callback) */
1733  if (huart->hdmarx != NULL)
1734  {
1735  /* Set the UART DMA Abort callback to Null.
1736  No call back execution at end of DMA abort procedure */
1738 
1739  if (HAL_DMA_Abort(huart->hdmarx) != HAL_OK)
1740  {
1742  {
1743  /* Set error code to DMA */
1745 
1746  return HAL_TIMEOUT;
1747  }
1748  }
1749  }
1750  }
1751 
1752  /* Reset Rx transfer counter */
1753  huart->RxXferCount = 0U;
1754 
1755  /* Clear the Error flags in the ICR register */
1757 
1758  /* Discard the received data */
1760 
1761  /* Restore huart->RxState to Ready */
1763 
1764  return HAL_OK;
1765 }
1766 
1782 {
1783  uint32_t abortcplt = 1U;
1784 
1785  /* Disable interrupts */
1788 
1789  /* If DMA Tx and/or DMA Rx Handles are associated to UART Handle, DMA Abort complete callbacks should be initialised
1790  before any call to DMA Abort functions */
1791  /* DMA Tx Handle is valid */
1792  if (huart->hdmatx != NULL)
1793  {
1794  /* Set DMA Abort Complete callback if UART DMA Tx request if enabled.
1795  Otherwise, set it to NULL */
1797  {
1798  huart->hdmatx->XferAbortCallback = UART_DMATxAbortCallback;
1799  }
1800  else
1801  {
1803  }
1804  }
1805  /* DMA Rx Handle is valid */
1806  if (huart->hdmarx != NULL)
1807  {
1808  /* Set DMA Abort Complete callback if UART DMA Rx request if enabled.
1809  Otherwise, set it to NULL */
1811  {
1812  huart->hdmarx->XferAbortCallback = UART_DMARxAbortCallback;
1813  }
1814  else
1815  {
1817  }
1818  }
1819 
1820  /* Disable the UART DMA Tx request if enabled */
1822  {
1823  /* Disable DMA Tx at UART level */
1825 
1826  /* Abort the UART DMA Tx channel : use non blocking DMA Abort API (callback) */
1827  if (huart->hdmatx != NULL)
1828  {
1829  /* UART Tx DMA Abort callback has already been initialised :
1830  will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
1831 
1832  /* Abort DMA TX */
1834  {
1836  }
1837  else
1838  {
1839  abortcplt = 0U;
1840  }
1841  }
1842  }
1843 
1844  /* Disable the UART DMA Rx request if enabled */
1846  {
1848 
1849  /* Abort the UART DMA Rx channel : use non blocking DMA Abort API (callback) */
1850  if (huart->hdmarx != NULL)
1851  {
1852  /* UART Rx DMA Abort callback has already been initialised :
1853  will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
1854 
1855  /* Abort DMA RX */
1857  {
1859  abortcplt = 1U;
1860  }
1861  else
1862  {
1863  abortcplt = 0U;
1864  }
1865  }
1866  }
1867 
1868  /* if no DMA abort complete callback execution is required => call user Abort Complete callback */
1869  if (abortcplt == 1U)
1870  {
1871  /* Reset Tx and Rx transfer counters */
1872  huart->TxXferCount = 0U;
1873  huart->RxXferCount = 0U;
1874 
1875  /* Clear ISR function pointers */
1876  huart->RxISR = NULL;
1877  huart->TxISR = NULL;
1878 
1879  /* Reset errorCode */
1881 
1882  /* Clear the Error flags in the ICR register */
1884 
1885 
1886  /* Discard the received data */
1888 
1889  /* Restore huart->gState and huart->RxState to Ready */
1892 
1893  /* As no DMA to be aborted, call directly user Abort complete callback */
1894 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
1895  /* Call registered Abort complete callback */
1896  huart->AbortCpltCallback(huart);
1897 #else
1898  /* Call legacy weak Abort complete callback */
1900 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
1901  }
1902 
1903  return HAL_OK;
1904 }
1905 
1921 {
1922  /* Disable interrupts */
1924 
1925  /* Disable the UART DMA Tx request if enabled */
1927  {
1929 
1930  /* Abort the UART DMA Tx channel : use non blocking DMA Abort API (callback) */
1931  if (huart->hdmatx != NULL)
1932  {
1933  /* Set the UART DMA Abort callback :
1934  will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
1935  huart->hdmatx->XferAbortCallback = UART_DMATxOnlyAbortCallback;
1936 
1937  /* Abort DMA TX */
1939  {
1940  /* Call Directly huart->hdmatx->XferAbortCallback function in case of error */
1942  }
1943  }
1944  else
1945  {
1946  /* Reset Tx transfer counter */
1947  huart->TxXferCount = 0U;
1948 
1949  /* Clear TxISR function pointers */
1950  huart->TxISR = NULL;
1951 
1952  /* Restore huart->gState to Ready */
1954 
1955  /* As no DMA to be aborted, call directly user Abort complete callback */
1956 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
1957  /* Call registered Abort Transmit Complete Callback */
1958  huart->AbortTransmitCpltCallback(huart);
1959 #else
1960  /* Call legacy weak Abort Transmit Complete Callback */
1962 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
1963  }
1964  }
1965  else
1966  {
1967  /* Reset Tx transfer counter */
1968  huart->TxXferCount = 0U;
1969 
1970  /* Clear TxISR function pointers */
1971  huart->TxISR = NULL;
1972 
1973 
1974  /* Restore huart->gState to Ready */
1976 
1977  /* As no DMA to be aborted, call directly user Abort complete callback */
1978 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
1979  /* Call registered Abort Transmit Complete Callback */
1980  huart->AbortTransmitCpltCallback(huart);
1981 #else
1982  /* Call legacy weak Abort Transmit Complete Callback */
1984 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
1985  }
1986 
1987  return HAL_OK;
1988 }
1989 
2005 {
2006  /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
2009 
2010  /* Disable the UART DMA Rx request if enabled */
2012  {
2014 
2015  /* Abort the UART DMA Rx channel : use non blocking DMA Abort API (callback) */
2016  if (huart->hdmarx != NULL)
2017  {
2018  /* Set the UART DMA Abort callback :
2019  will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
2020  huart->hdmarx->XferAbortCallback = UART_DMARxOnlyAbortCallback;
2021 
2022  /* Abort DMA RX */
2024  {
2025  /* Call Directly huart->hdmarx->XferAbortCallback function in case of error */
2027  }
2028  }
2029  else
2030  {
2031  /* Reset Rx transfer counter */
2032  huart->RxXferCount = 0U;
2033 
2034  /* Clear RxISR function pointer */
2035  huart->pRxBuffPtr = NULL;
2036 
2037  /* Clear the Error flags in the ICR register */
2039 
2040  /* Discard the received data */
2042 
2043  /* Restore huart->RxState to Ready */
2045 
2046  /* As no DMA to be aborted, call directly user Abort complete callback */
2047 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2048  /* Call registered Abort Receive Complete Callback */
2049  huart->AbortReceiveCpltCallback(huart);
2050 #else
2051  /* Call legacy weak Abort Receive Complete Callback */
2053 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
2054  }
2055  }
2056  else
2057  {
2058  /* Reset Rx transfer counter */
2059  huart->RxXferCount = 0U;
2060 
2061  /* Clear RxISR function pointer */
2062  huart->pRxBuffPtr = NULL;
2063 
2064  /* Clear the Error flags in the ICR register */
2066 
2067  /* Restore huart->RxState to Ready */
2069 
2070  /* As no DMA to be aborted, call directly user Abort complete callback */
2071 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2072  /* Call registered Abort Receive Complete Callback */
2073  huart->AbortReceiveCpltCallback(huart);
2074 #else
2075  /* Call legacy weak Abort Receive Complete Callback */
2077 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
2078  }
2079 
2080  return HAL_OK;
2081 }
2082 
2089 {
2090  uint32_t isrflags = READ_REG(huart->Instance->ISR);
2091  uint32_t cr1its = READ_REG(huart->Instance->CR1);
2092  uint32_t cr3its = READ_REG(huart->Instance->CR3);
2093 
2094  uint32_t errorflags;
2095  uint32_t errorcode;
2096 
2097  /* If no error occurs */
2098  errorflags = (isrflags & (uint32_t)(USART_ISR_PE | USART_ISR_FE | USART_ISR_ORE | USART_ISR_NE | USART_ISR_RTOF));
2099  if (errorflags == 0U)
2100  {
2101  /* UART in mode Receiver ---------------------------------------------------*/
2102  if (((isrflags & USART_ISR_RXNE) != 0U)
2103  && ((cr1its & USART_CR1_RXNEIE) != 0U))
2104  {
2105  if (huart->RxISR != NULL)
2106  {
2107  huart->RxISR(huart);
2108  }
2109  return;
2110  }
2111  }
2112 
2113  /* If some errors occur */
2114  if ((errorflags != 0U)
2115  && (((cr3its & USART_CR3_EIE) != 0U)
2116  || ((cr1its & (USART_CR1_RXNEIE | USART_CR1_PEIE)) != 0U)))
2117  {
2118  /* UART parity error interrupt occurred -------------------------------------*/
2119  if (((isrflags & USART_ISR_PE) != 0U) && ((cr1its & USART_CR1_PEIE) != 0U))
2120  {
2122 
2124  }
2125 
2126  /* UART frame error interrupt occurred --------------------------------------*/
2127  if (((isrflags & USART_ISR_FE) != 0U) && ((cr3its & USART_CR3_EIE) != 0U))
2128  {
2130 
2132  }
2133 
2134  /* UART noise error interrupt occurred --------------------------------------*/
2135  if (((isrflags & USART_ISR_NE) != 0U) && ((cr3its & USART_CR3_EIE) != 0U))
2136  {
2138 
2140  }
2141 
2142  /* UART Over-Run interrupt occurred -----------------------------------------*/
2143  if (((isrflags & USART_ISR_ORE) != 0U)
2144  && (((cr1its & USART_CR1_RXNEIE) != 0U) ||
2145  ((cr3its & USART_CR3_EIE) != 0U)))
2146  {
2148 
2150  }
2151 
2152  /* UART Receiver Timeout interrupt occurred ---------------------------------*/
2153  if (((isrflags & USART_ISR_RTOF) != 0U) && ((cr1its & USART_CR1_RTOIE) != 0U))
2154  {
2156 
2158  }
2159 
2160  /* Call UART Error Call back function if need be ----------------------------*/
2162  {
2163  /* UART in mode Receiver --------------------------------------------------*/
2164  if (((isrflags & USART_ISR_RXNE) != 0U)
2165  && ((cr1its & USART_CR1_RXNEIE) != 0U))
2166  {
2167  if (huart->RxISR != NULL)
2168  {
2169  huart->RxISR(huart);
2170  }
2171  }
2172 
2173  /* If Error is to be considered as blocking :
2174  - Receiver Timeout error in Reception
2175  - Overrun error in Reception
2176  - any error occurs in DMA mode reception
2177  */
2178  errorcode = huart->ErrorCode;
2180  ((errorcode & (HAL_UART_ERROR_RTO | HAL_UART_ERROR_ORE)) != 0U))
2181  {
2182  /* Blocking error : transfer is aborted
2183  Set the UART state ready to be able to start again the process,
2184  Disable Rx Interrupts, and disable Rx DMA request, if ongoing */
2185  UART_EndRxTransfer(huart);
2186 
2187  /* Disable the UART DMA Rx request if enabled */
2189  {
2191 
2192  /* Abort the UART DMA Rx channel */
2193  if (huart->hdmarx != NULL)
2194  {
2195  /* Set the UART DMA Abort callback :
2196  will lead to call HAL_UART_ErrorCallback() at end of DMA abort procedure */
2197  huart->hdmarx->XferAbortCallback = UART_DMAAbortOnError;
2198 
2199  /* Abort DMA RX */
2201  {
2202  /* Call Directly huart->hdmarx->XferAbortCallback function in case of error */
2204  }
2205  }
2206  else
2207  {
2208  /* Call user error callback */
2209 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2210  /*Call registered error callback*/
2211  huart->ErrorCallback(huart);
2212 #else
2213  /*Call legacy weak error callback*/
2215 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
2216 
2217  }
2218  }
2219  else
2220  {
2221  /* Call user error callback */
2222 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2223  /*Call registered error callback*/
2224  huart->ErrorCallback(huart);
2225 #else
2226  /*Call legacy weak error callback*/
2228 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
2229  }
2230  }
2231  else
2232  {
2233  /* Non Blocking error : transfer could go on.
2234  Error is notified to user through user error callback */
2235 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2236  /*Call registered error callback*/
2237  huart->ErrorCallback(huart);
2238 #else
2239  /*Call legacy weak error callback*/
2241 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
2243  }
2244  }
2245  return;
2246 
2247  } /* End if some error occurs */
2248 #if defined(USART_CR1_UESM)
2249 
2250  /* UART wakeup from Stop mode interrupt occurred ---------------------------*/
2251  if (((isrflags & USART_ISR_WUF) != 0U) && ((cr3its & USART_CR3_WUFIE) != 0U))
2252  {
2254 
2255  /* UART Rx state is not reset as a reception process might be ongoing.
2256  If UART handle state fields need to be reset to READY, this could be done in Wakeup callback */
2257 
2258 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2259  /* Call registered Wakeup Callback */
2260  huart->WakeupCallback(huart);
2261 #else
2262  /* Call legacy weak Wakeup Callback */
2264 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
2265  return;
2266  }
2267 #endif /* USART_CR1_UESM */
2268 
2269  /* UART in mode Transmitter ------------------------------------------------*/
2270  if (((isrflags & USART_ISR_TXE) != 0U)
2271  && ((cr1its & USART_CR1_TXEIE) != 0U))
2272  {
2273  if (huart->TxISR != NULL)
2274  {
2275  huart->TxISR(huart);
2276  }
2277  return;
2278  }
2279 
2280  /* UART in mode Transmitter (transmission end) -----------------------------*/
2281  if (((isrflags & USART_ISR_TC) != 0U) && ((cr1its & USART_CR1_TCIE) != 0U))
2282  {
2283  UART_EndTransmit_IT(huart);
2284  return;
2285  }
2286 
2287 }
2288 
2295 {
2296  /* Prevent unused argument(s) compilation warning */
2297  UNUSED(huart);
2298 
2299  /* NOTE : This function should not be modified, when the callback is needed,
2300  the HAL_UART_TxCpltCallback can be implemented in the user file.
2301  */
2302 }
2303 
2310 {
2311  /* Prevent unused argument(s) compilation warning */
2312  UNUSED(huart);
2313 
2314  /* NOTE: This function should not be modified, when the callback is needed,
2315  the HAL_UART_TxHalfCpltCallback can be implemented in the user file.
2316  */
2317 }
2318 
2325 {
2326  /* Prevent unused argument(s) compilation warning */
2327  UNUSED(huart);
2328 
2329  /* NOTE : This function should not be modified, when the callback is needed,
2330  the HAL_UART_RxCpltCallback can be implemented in the user file.
2331  */
2332 }
2333 
2340 {
2341  /* Prevent unused argument(s) compilation warning */
2342  UNUSED(huart);
2343 
2344  /* NOTE: This function should not be modified, when the callback is needed,
2345  the HAL_UART_RxHalfCpltCallback can be implemented in the user file.
2346  */
2347 }
2348 
2355 {
2356  /* Prevent unused argument(s) compilation warning */
2357  UNUSED(huart);
2358 
2359  /* NOTE : This function should not be modified, when the callback is needed,
2360  the HAL_UART_ErrorCallback can be implemented in the user file.
2361  */
2362 }
2363 
2370 {
2371  /* Prevent unused argument(s) compilation warning */
2372  UNUSED(huart);
2373 
2374  /* NOTE : This function should not be modified, when the callback is needed,
2375  the HAL_UART_AbortCpltCallback can be implemented in the user file.
2376  */
2377 }
2378 
2385 {
2386  /* Prevent unused argument(s) compilation warning */
2387  UNUSED(huart);
2388 
2389  /* NOTE : This function should not be modified, when the callback is needed,
2390  the HAL_UART_AbortTransmitCpltCallback can be implemented in the user file.
2391  */
2392 }
2393 
2400 {
2401  /* Prevent unused argument(s) compilation warning */
2402  UNUSED(huart);
2403 
2404  /* NOTE : This function should not be modified, when the callback is needed,
2405  the HAL_UART_AbortReceiveCpltCallback can be implemented in the user file.
2406  */
2407 }
2408 
2409 #if defined(USART_CR1_UESM)
2410 
2416 {
2417  /* Prevent unused argument(s) compilation warning */
2418  UNUSED(huart);
2419 
2420  /* NOTE : This function should not be modified, when the callback is needed,
2421  the HAL_UARTEx_WakeupCallback can be implemented in the user file.
2422  */
2423 }
2424 
2425 #endif /* USART_CR1_UESM */
2426 
2463 void HAL_UART_ReceiverTimeout_Config(UART_HandleTypeDef *huart, uint32_t TimeoutValue)
2464 {
2466  MODIFY_REG(huart->Instance->RTOR, USART_RTOR_RTO, TimeoutValue);
2467 }
2468 
2476 {
2478  {
2479  /* Process Locked */
2480  __HAL_LOCK(huart);
2481 
2483 
2484  /* Set the USART RTOEN bit */
2486 
2488 
2489  /* Process Unlocked */
2491 
2492  return HAL_OK;
2493  }
2494  else
2495  {
2496  return HAL_BUSY;
2497  }
2498 }
2499 
2507 {
2509  {
2510  /* Process Locked */
2511  __HAL_LOCK(huart);
2512 
2514 
2515  /* Clear the USART RTOEN bit */
2517 
2519 
2520  /* Process Unlocked */
2522 
2523  return HAL_OK;
2524  }
2525  else
2526  {
2527  return HAL_BUSY;
2528  }
2529 }
2530 
2538 {
2539  __HAL_LOCK(huart);
2540 
2542 
2543  /* Enable USART mute mode by setting the MME bit in the CR1 register */
2545 
2547 
2548  return (UART_CheckIdleState(huart));
2549 }
2550 
2558 {
2559  __HAL_LOCK(huart);
2560 
2562 
2563  /* Disable USART mute mode by clearing the MME bit in the CR1 register */
2565 
2567 
2568  return (UART_CheckIdleState(huart));
2569 }
2570 
2578 {
2580 }
2581 
2588 {
2589  __HAL_LOCK(huart);
2591 
2592  /* Clear TE and RE bits */
2594 
2595  /* Enable the USART's transmit interface by setting the TE bit in the USART CR1 register */
2597 
2599 
2601 
2602  return HAL_OK;
2603 }
2604 
2611 {
2612  __HAL_LOCK(huart);
2614 
2615  /* Clear TE and RE bits */
2617 
2618  /* Enable the USART's receive interface by setting the RE bit in the USART CR1 register */
2620 
2622 
2624 
2625  return HAL_OK;
2626 }
2627 
2628 
2635 {
2636  /* Check the parameters */
2638 
2639  __HAL_LOCK(huart);
2640 
2642 
2643  /* Send break characters */
2645 
2647 
2649 
2650  return HAL_OK;
2651 }
2652 
2680 {
2681  uint32_t temp1;
2682  uint32_t temp2;
2683  temp1 = huart->gState;
2684  temp2 = huart->RxState;
2685 
2686  return (HAL_UART_StateTypeDef)(temp1 | temp2);
2687 }
2688 
2696 {
2697  return huart->ErrorCode;
2698 }
2716 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2717 void UART_InitCallbacksToDefault(UART_HandleTypeDef *huart)
2718 {
2719  /* Init the UART Callback settings */
2720  huart->TxHalfCpltCallback = HAL_UART_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
2721  huart->TxCpltCallback = HAL_UART_TxCpltCallback; /* Legacy weak TxCpltCallback */
2722  huart->RxHalfCpltCallback = HAL_UART_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
2723  huart->RxCpltCallback = HAL_UART_RxCpltCallback; /* Legacy weak RxCpltCallback */
2724  huart->ErrorCallback = HAL_UART_ErrorCallback; /* Legacy weak ErrorCallback */
2725  huart->AbortCpltCallback = HAL_UART_AbortCpltCallback; /* Legacy weak AbortCpltCallback */
2726  huart->AbortTransmitCpltCallback = HAL_UART_AbortTransmitCpltCallback; /* Legacy weak AbortTransmitCpltCallback */
2727  huart->AbortReceiveCpltCallback = HAL_UART_AbortReceiveCpltCallback; /* Legacy weak AbortReceiveCpltCallback */
2728 #if defined(USART_CR1_UESM)
2729  huart->WakeupCallback = HAL_UARTEx_WakeupCallback; /* Legacy weak WakeupCallback */
2730 #endif /* USART_CR1_UESM */
2731 
2732 }
2733 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
2734 
2741 {
2742  uint32_t tmpreg;
2743  uint16_t brrtemp;
2744  UART_ClockSourceTypeDef clocksource;
2745  uint32_t usartdiv = 0x00000000U;
2746  HAL_StatusTypeDef ret = HAL_OK;
2747  uint32_t pclk;
2748 
2749  /* Check the parameters */
2754 
2759 
2760  /*-------------------------- USART CR1 Configuration -----------------------*/
2761  /* Clear M, PCE, PS, TE, RE and OVER8 bits and configure
2762  * the UART Word Length, Parity, Mode and oversampling:
2763  * set the M bits according to huart->Init.WordLength value
2764  * set PCE and PS bits according to huart->Init.Parity value
2765  * set TE and RE bits according to huart->Init.Mode value
2766  * set OVER8 bit according to huart->Init.OverSampling value */
2767  tmpreg = (uint32_t)huart->Init.WordLength | huart->Init.Parity | huart->Init.Mode | huart->Init.OverSampling ;
2768  MODIFY_REG(huart->Instance->CR1, USART_CR1_FIELDS, tmpreg);
2769 
2770  /*-------------------------- USART CR2 Configuration -----------------------*/
2771  /* Configure the UART Stop Bits: Set STOP[13:12] bits according
2772  * to huart->Init.StopBits value */
2774 
2775  /*-------------------------- USART CR3 Configuration -----------------------*/
2776  /* Configure
2777  * - UART HardWare Flow Control: set CTSE and RTSE bits according
2778  * to huart->Init.HwFlowCtl value
2779  * - one-bit sampling method versus three samples' majority rule according
2780  * to huart->Init.OneBitSampling (not applicable to LPUART) */
2781  tmpreg = (uint32_t)huart->Init.HwFlowCtl;
2782 
2783  tmpreg |= huart->Init.OneBitSampling;
2784  MODIFY_REG(huart->Instance->CR3, USART_CR3_FIELDS, tmpreg);
2785 
2786 
2787  /*-------------------------- USART BRR Configuration -----------------------*/
2788  UART_GETCLOCKSOURCE(huart, clocksource);
2789 
2791  {
2792  switch (clocksource)
2793  {
2795  pclk = HAL_RCC_GetPCLK1Freq();
2796  usartdiv = (uint16_t)(UART_DIV_SAMPLING8(pclk, huart->Init.BaudRate));
2797  break;
2799  pclk = HAL_RCC_GetPCLK2Freq();
2800  usartdiv = (uint16_t)(UART_DIV_SAMPLING8(pclk, huart->Init.BaudRate));
2801  break;
2802  case UART_CLOCKSOURCE_HSI:
2803  usartdiv = (uint16_t)(UART_DIV_SAMPLING8(HSI_VALUE, huart->Init.BaudRate));
2804  break;
2806  pclk = HAL_RCC_GetSysClockFreq();
2807  usartdiv = (uint16_t)(UART_DIV_SAMPLING8(pclk, huart->Init.BaudRate));
2808  break;
2809  case UART_CLOCKSOURCE_LSE:
2810  usartdiv = (uint16_t)(UART_DIV_SAMPLING8(LSE_VALUE, huart->Init.BaudRate));
2811  break;
2812  default:
2813  ret = HAL_ERROR;
2814  break;
2815  }
2816 
2817  /* USARTDIV must be greater than or equal to 0d16 */
2818  if ((usartdiv >= UART_BRR_MIN) && (usartdiv <= UART_BRR_MAX))
2819  {
2820  brrtemp = (uint16_t)(usartdiv & 0xFFF0U);
2821  brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U);
2822  huart->Instance->BRR = brrtemp;
2823  }
2824  else
2825  {
2826  ret = HAL_ERROR;
2827  }
2828  }
2829  else
2830  {
2831  switch (clocksource)
2832  {
2834  pclk = HAL_RCC_GetPCLK1Freq();
2835  usartdiv = (uint16_t)(UART_DIV_SAMPLING16(pclk, huart->Init.BaudRate));
2836  break;
2838  pclk = HAL_RCC_GetPCLK2Freq();
2839  usartdiv = (uint16_t)(UART_DIV_SAMPLING16(pclk, huart->Init.BaudRate));
2840  break;
2841  case UART_CLOCKSOURCE_HSI:
2842  usartdiv = (uint16_t)(UART_DIV_SAMPLING16(HSI_VALUE, huart->Init.BaudRate));
2843  break;
2845  pclk = HAL_RCC_GetSysClockFreq();
2846  usartdiv = (uint16_t)(UART_DIV_SAMPLING16(pclk, huart->Init.BaudRate));
2847  break;
2848  case UART_CLOCKSOURCE_LSE:
2849  usartdiv = (uint16_t)(UART_DIV_SAMPLING16(LSE_VALUE, huart->Init.BaudRate));
2850  break;
2851  default:
2852  ret = HAL_ERROR;
2853  break;
2854  }
2855 
2856  /* USARTDIV must be greater than or equal to 0d16 */
2857  if ((usartdiv >= UART_BRR_MIN) && (usartdiv <= UART_BRR_MAX))
2858  {
2859  huart->Instance->BRR = usartdiv;
2860  }
2861  else
2862  {
2863  ret = HAL_ERROR;
2864  }
2865  }
2866 
2867 
2868  /* Clear ISR function pointers */
2869  huart->RxISR = NULL;
2870  huart->TxISR = NULL;
2871 
2872  return ret;
2873 }
2874 
2881 {
2882  /* Check whether the set of advanced features to configure is properly set */
2884 
2885  /* if required, configure TX pin active level inversion */
2887  {
2890  }
2891 
2892  /* if required, configure RX pin active level inversion */
2894  {
2897  }
2898 
2899  /* if required, configure data inversion */
2901  {
2904  }
2905 
2906  /* if required, configure RX/TX pins swap */
2908  {
2911  }
2912 
2913  /* if required, configure RX overrun detection disabling */
2915  {
2918  }
2919 
2920  /* if required, configure DMA disabling on reception error */
2922  {
2925  }
2926 
2927  /* if required, configure auto Baud rate detection scheme */
2929  {
2933  /* set auto Baudrate detection parameters if detection is enabled */
2935  {
2938  }
2939  }
2940 
2941  /* if required, configure MSB first on communication line */
2943  {
2946  }
2947 }
2948 
2955 {
2956  uint32_t tickstart;
2957 
2958  /* Initialize the UART ErrorCode */
2960 
2961  /* Init tickstart for timeout managment*/
2962  tickstart = HAL_GetTick();
2963 
2964  /* Check if the Transmitter is enabled */
2966  {
2967  /* Wait until TEACK flag is set */
2969  {
2970  /* Timeout occurred */
2971  return HAL_TIMEOUT;
2972  }
2973  }
2974 #if defined(USART_ISR_REACK)
2975 
2976  /* Check if the Receiver is enabled */
2978  {
2979  /* Wait until REACK flag is set */
2981  {
2982  /* Timeout occurred */
2983  return HAL_TIMEOUT;
2984  }
2985  }
2986 #endif
2987 
2988  /* Initialize the UART State */
2991 
2993 
2994  return HAL_OK;
2995 }
2996 
3007  uint32_t Tickstart, uint32_t Timeout)
3008 {
3009  /* Wait until flag is set */
3010  while ((__HAL_UART_GET_FLAG(huart, Flag) ? SET : RESET) == Status)
3011  {
3012  /* Check for the Timeout */
3013  if (Timeout != HAL_MAX_DELAY)
3014  {
3015  if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
3016  {
3017  /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */
3020 
3023 
3025 
3026  return HAL_TIMEOUT;
3027  }
3028 
3029  if (READ_BIT(huart->Instance->CR1, USART_CR1_RE) != 0U)
3030  {
3032  {
3033  /* Clear Receiver Timeout flag*/
3035 
3036  /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */
3039 
3043 
3044  /* Process Unlocked */
3046 
3047  return HAL_TIMEOUT;
3048  }
3049  }
3050  }
3051  }
3052  return HAL_OK;
3053 }
3054 
3055 
3061 static void UART_EndTxTransfer(UART_HandleTypeDef *huart)
3062 {
3063  /* Disable TXEIE and TCIE interrupts */
3065 
3066  /* At end of Tx process, restore huart->gState to Ready */
3068 }
3069 
3070 
3076 static void UART_EndRxTransfer(UART_HandleTypeDef *huart)
3077 {
3078  /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
3081 
3082  /* At end of Rx process, restore huart->RxState to Ready */
3084 
3085  /* Reset RxIsr function pointer */
3086  huart->RxISR = NULL;
3087 }
3088 
3089 
3095 static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma)
3096 {
3098 
3099  /* DMA Normal mode */
3100  if (hdma->Init.Mode != DMA_CIRCULAR)
3101  {
3102  huart->TxXferCount = 0U;
3103 
3104  /* Disable the DMA transfer for transmit request by resetting the DMAT bit
3105  in the UART CR3 register */
3107 
3108  /* Enable the UART Transmit Complete Interrupt */
3110  }
3111  /* DMA Circular mode */
3112  else
3113  {
3114 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3115  /*Call registered Tx complete callback*/
3116  huart->TxCpltCallback(huart);
3117 #else
3118  /*Call legacy weak Tx complete callback*/
3120 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3121  }
3122 }
3123 
3129 static void UART_DMATxHalfCplt(DMA_HandleTypeDef *hdma)
3130 {
3132 
3133 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3134  /*Call registered Tx Half complete callback*/
3135  huart->TxHalfCpltCallback(huart);
3136 #else
3137  /*Call legacy weak Tx Half complete callback*/
3139 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3140 }
3141 
3147 static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
3148 {
3150 
3151  /* DMA Normal mode */
3152  if (hdma->Init.Mode != DMA_CIRCULAR)
3153  {
3154  huart->RxXferCount = 0U;
3155 
3156  /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
3159 
3160  /* Disable the DMA transfer for the receiver request by resetting the DMAR bit
3161  in the UART CR3 register */
3163 
3164  /* At end of Rx process, restore huart->RxState to Ready */
3166  }
3167 
3168 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3169  /*Call registered Rx complete callback*/
3170  huart->RxCpltCallback(huart);
3171 #else
3172  /*Call legacy weak Rx complete callback*/
3174 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3175 }
3176 
3182 static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma)
3183 {
3185 
3186 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3187  /*Call registered Rx Half complete callback*/
3188  huart->RxHalfCpltCallback(huart);
3189 #else
3190  /*Call legacy weak Rx Half complete callback*/
3192 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3193 }
3194 
3200 static void UART_DMAError(DMA_HandleTypeDef *hdma)
3201 {
3203 
3204  const HAL_UART_StateTypeDef gstate = huart->gState;
3205  const HAL_UART_StateTypeDef rxstate = huart->RxState;
3206 
3207  /* Stop UART DMA Tx request if ongoing */
3209  (gstate == HAL_UART_STATE_BUSY_TX))
3210  {
3211  huart->TxXferCount = 0U;
3212  UART_EndTxTransfer(huart);
3213  }
3214 
3215  /* Stop UART DMA Rx request if ongoing */
3217  (rxstate == HAL_UART_STATE_BUSY_RX))
3218  {
3219  huart->RxXferCount = 0U;
3220  UART_EndRxTransfer(huart);
3221  }
3222 
3224 
3225 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3226  /*Call registered error callback*/
3227  huart->ErrorCallback(huart);
3228 #else
3229  /*Call legacy weak error callback*/
3231 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3232 }
3233 
3240 static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma)
3241 {
3243  huart->RxXferCount = 0U;
3244  huart->TxXferCount = 0U;
3245 
3246 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3247  /*Call registered error callback*/
3248  huart->ErrorCallback(huart);
3249 #else
3250  /*Call legacy weak error callback*/
3252 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3253 }
3254 
3263 static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma)
3264 {
3266 
3268 
3269  /* Check if an Abort process is still ongoing */
3270  if (huart->hdmarx != NULL)
3271  {
3273  {
3274  return;
3275  }
3276  }
3277 
3278  /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */
3279  huart->TxXferCount = 0U;
3280  huart->RxXferCount = 0U;
3281 
3282  /* Reset errorCode */
3284 
3285  /* Clear the Error flags in the ICR register */
3287 
3288 
3289  /* Restore huart->gState and huart->RxState to Ready */
3292 
3293  /* Call user Abort complete callback */
3294 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3295  /* Call registered Abort complete callback */
3296  huart->AbortCpltCallback(huart);
3297 #else
3298  /* Call legacy weak Abort complete callback */
3300 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3301 }
3302 
3303 
3312 static void UART_DMARxAbortCallback(DMA_HandleTypeDef *hdma)
3313 {
3315 
3317 
3318  /* Check if an Abort process is still ongoing */
3319  if (huart->hdmatx != NULL)
3320  {
3322  {
3323  return;
3324  }
3325  }
3326 
3327  /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */
3328  huart->TxXferCount = 0U;
3329  huart->RxXferCount = 0U;
3330 
3331  /* Reset errorCode */
3333 
3334  /* Clear the Error flags in the ICR register */
3336 
3337  /* Discard the received data */
3339 
3340  /* Restore huart->gState and huart->RxState to Ready */
3343 
3344  /* Call user Abort complete callback */
3345 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3346  /* Call registered Abort complete callback */
3347  huart->AbortCpltCallback(huart);
3348 #else
3349  /* Call legacy weak Abort complete callback */
3351 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3352 }
3353 
3354 
3363 static void UART_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
3364 {
3366 
3367  huart->TxXferCount = 0U;
3368 
3369 
3370  /* Restore huart->gState to Ready */
3372 
3373  /* Call user Abort complete callback */
3374 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3375  /* Call registered Abort Transmit Complete Callback */
3376  huart->AbortTransmitCpltCallback(huart);
3377 #else
3378  /* Call legacy weak Abort Transmit Complete Callback */
3380 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3381 }
3382 
3391 static void UART_DMARxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
3392 {
3394 
3395  huart->RxXferCount = 0U;
3396 
3397  /* Clear the Error flags in the ICR register */
3399 
3400  /* Discard the received data */
3402 
3403  /* Restore huart->RxState to Ready */
3405 
3406  /* Call user Abort complete callback */
3407 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3408  /* Call registered Abort Receive Complete Callback */
3409  huart->AbortReceiveCpltCallback(huart);
3410 #else
3411  /* Call legacy weak Abort Receive Complete Callback */
3413 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3414 }
3415 
3423 static void UART_TxISR_8BIT(UART_HandleTypeDef *huart)
3424 {
3425  /* Check that a Tx process is ongoing */
3427  {
3428  if (huart->TxXferCount == 0U)
3429  {
3430  /* Disable the UART Transmit Data Register Empty Interrupt */
3432 
3433  /* Enable the UART Transmit Complete Interrupt */
3435  }
3436  else
3437  {
3438  huart->Instance->TDR = (uint8_t)(*huart->pTxBuffPtr & (uint8_t)0xFF);
3439  huart->pTxBuffPtr++;
3440  huart->TxXferCount--;
3441  }
3442  }
3443 }
3444 
3452 static void UART_TxISR_16BIT(UART_HandleTypeDef *huart)
3453 {
3454  uint16_t *tmp;
3455 
3456  /* Check that a Tx process is ongoing */
3458  {
3459  if (huart->TxXferCount == 0U)
3460  {
3461  /* Disable the UART Transmit Data Register Empty Interrupt */
3463 
3464  /* Enable the UART Transmit Complete Interrupt */
3466  }
3467  else
3468  {
3469  tmp = (uint16_t *) huart->pTxBuffPtr;
3470  huart->Instance->TDR = (((uint32_t)(*tmp)) & 0x01FFUL);
3471  huart->pTxBuffPtr += 2U;
3472  huart->TxXferCount--;
3473  }
3474  }
3475 }
3476 
3477 
3484 static void UART_EndTransmit_IT(UART_HandleTypeDef *huart)
3485 {
3486  /* Disable the UART Transmit Complete Interrupt */
3488 
3489  /* Tx process is ended, restore huart->gState to Ready */
3491 
3492  /* Cleat TxISR function pointer */
3493  huart->TxISR = NULL;
3494 
3495 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3496  /*Call registered Tx complete callback*/
3497  huart->TxCpltCallback(huart);
3498 #else
3499  /*Call legacy weak Tx complete callback*/
3501 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3502 }
3503 
3509 static void UART_RxISR_8BIT(UART_HandleTypeDef *huart)
3510 {
3511  uint16_t uhMask = huart->Mask;
3512  uint16_t uhdata;
3513 
3514  /* Check that a Rx process is ongoing */
3516  {
3517  uhdata = (uint16_t) READ_REG(huart->Instance->RDR);
3518  *huart->pRxBuffPtr = (uint8_t)(uhdata & (uint8_t)uhMask);
3519  huart->pRxBuffPtr++;
3520  huart->RxXferCount--;
3521 
3522  if (huart->RxXferCount == 0U)
3523  {
3524  /* Disable the UART Parity Error Interrupt and RXNE interrupts */
3526 
3527  /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
3529 
3530  /* Rx process is completed, restore huart->RxState to Ready */
3532 
3533  /* Clear RxISR function pointer */
3534  huart->RxISR = NULL;
3535 
3536 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3537  /*Call registered Rx complete callback*/
3538  huart->RxCpltCallback(huart);
3539 #else
3540  /*Call legacy weak Rx complete callback*/
3542 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3543  }
3544  }
3545  else
3546  {
3547  /* Clear RXNE interrupt flag */
3549  }
3550 }
3551 
3559 static void UART_RxISR_16BIT(UART_HandleTypeDef *huart)
3560 {
3561  uint16_t *tmp;
3562  uint16_t uhMask = huart->Mask;
3563  uint16_t uhdata;
3564 
3565  /* Check that a Rx process is ongoing */
3567  {
3568  uhdata = (uint16_t) READ_REG(huart->Instance->RDR);
3569  tmp = (uint16_t *) huart->pRxBuffPtr ;
3570  *tmp = (uint16_t)(uhdata & uhMask);
3571  huart->pRxBuffPtr += 2U;
3572  huart->RxXferCount--;
3573 
3574  if (huart->RxXferCount == 0U)
3575  {
3576  /* Disable the UART Parity Error Interrupt and RXNE interrupt*/
3578 
3579  /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
3581 
3582  /* Rx process is completed, restore huart->RxState to Ready */
3584 
3585  /* Clear RxISR function pointer */
3586  huart->RxISR = NULL;
3587 
3588 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3589  /*Call registered Rx complete callback*/
3590  huart->RxCpltCallback(huart);
3591 #else
3592  /*Call legacy weak Rx complete callback*/
3594 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
3595  }
3596  }
3597  else
3598  {
3599  /* Clear RXNE interrupt flag */
3601  }
3602 }
3603 
3604 
3609 #endif /* HAL_UART_MODULE_ENABLED */
3610 
3618 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
HAL_UART_ErrorCallback
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
IS_UART_OVERRUN
#define IS_UART_OVERRUN(__OVERRUN__)
Ensure that UART frame overrun setting is valid.
Definition: stm32f7xx_hal_uart.h:1327
USART_ISR_RTOF
#define USART_ISR_RTOF
Definition: stm32f769xx.h:15500
assert_param
#define assert_param(expr)
Include module's header file.
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:353
UART_ADVFEATURE_AUTOBAUDRATE_ENABLE
#define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE
Definition: stm32f7xx_hal_uart.h:542
HAL_UART_Transmit_IT
HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
UART_CLEAR_PEF
#define UART_CLEAR_PEF
Definition: stm32f7xx_hal_uart.h:723
UART_CLOCKSOURCE_PCLK1
@ UART_CLOCKSOURCE_PCLK1
Definition: stm32f7xx_hal_uart.h:174
__UART_HandleTypeDef::TxISR
void(* TxISR)(struct __UART_HandleTypeDef *huart)
Definition: stm32f7xx_hal_uart.h:209
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
USART_CR2_ABREN
#define USART_CR2_ABREN
Definition: stm32f769xx.h:15342
HAL_UART_TxCpltCallback
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
__UART_HandleTypeDef::Init
UART_InitTypeDef Init
Definition: stm32f4xx_hal_uart.h:145
HAL_UART_StateTypeDef
HAL_UART_StateTypeDef
HAL UART State structures definition.
Definition: stm32f4xx_hal_uart.h:117
HAL_UART_AbortReceive
HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart)
USART_CR3_DDRE
#define USART_CR3_DDRE
Definition: stm32f769xx.h:15397
HAL_UART_ERROR_NE
#define HAL_UART_ERROR_NE
Definition: stm32f4xx_hal_uart.h:233
HAL_LIN_SendBreak
HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart)
HAL_UART_Transmit
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
__DMA_HandleTypeDef::XferHalfCpltCallback
void(* XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:153
IS_UART_HWFLOW_INSTANCE
#define IS_UART_HWFLOW_INSTANCE(INSTANCE)
Definition: stm32f407xx.h:15483
HAL_UART_ERROR_FE
#define HAL_UART_ERROR_FE
Definition: stm32f4xx_hal_uart.h:234
USART_CR3_SCEN
#define USART_CR3_SCEN
Definition: stm32f407xx.h:12600
__DMA_HandleTypeDef
DMA handle Structure definition.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:139
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
HAL_UART_Transmit_DMA
HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
USART_CR2_SWAP
#define USART_CR2_SWAP
Definition: stm32f769xx.h:15327
UART_CLOCKSOURCE_PCLK2
@ UART_CLOCKSOURCE_PCLK2
Definition: stm32f7xx_hal_uart.h:175
USART_TypeDef::TDR
__IO uint32_t TDR
Definition: stm32f769xx.h:1018
USART_CR2_ABRMODE
#define USART_CR2_ABRMODE
Definition: stm32f769xx.h:15345
IS_UART_HALFDUPLEX_INSTANCE
#define IS_UART_HALFDUPLEX_INSTANCE(INSTANCE)
Definition: stm32f407xx.h:15472
HAL_DMA_ERROR_TIMEOUT
#define HAL_DMA_ERROR_TIMEOUT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:190
UART_CLOCKSOURCE_SYSCLK
@ UART_CLOCKSOURCE_SYSCLK
Definition: stm32f7xx_hal_uart.h:177
USART_CR2_MSBFIRST
#define USART_CR2_MSBFIRST
Definition: stm32f769xx.h:15339
IS_UART_ADVFEATURE_MSBFIRST
#define IS_UART_ADVFEATURE_MSBFIRST(__MSBFIRST__)
Ensure that UART frame MSB first setting is valid.
Definition: stm32f7xx_hal_uart.h:1351
USART_CR2_ADD
#define USART_CR2_ADD
Definition: stm32f407xx.h:12552
UART_CLEAR_RTOF
#define UART_CLEAR_RTOF
Definition: stm32f7xx_hal_uart.h:735
USART_CR1_MME
#define USART_CR1_MME
Definition: stm32f769xx.h:15260
IS_UART_ADVFEATURE_AUTOBAUDRATE
#define IS_UART_ADVFEATURE_AUTOBAUDRATE(__AUTOBAUDRATE__)
Ensure that UART auto Baud rate state is valid.
Definition: stm32f7xx_hal_uart.h:1335
HAL_UNLOCKED
@ HAL_UNLOCKED
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:53
UART_ADVFEATURE_MSBFIRST_INIT
#define UART_ADVFEATURE_MSBFIRST_INIT
Definition: stm32f7xx_hal_uart.h:488
USART_ISR_WUF
#define USART_ISR_WUF
Definition: stm32f769xx.h:15524
UART_InitTypeDef::OneBitSampling
uint32_t OneBitSampling
Definition: stm32f7xx_hal_uart.h:82
UART_FLAG_TC
#define UART_FLAG_TC
Definition: stm32f4xx_hal_uart.h:337
USART_CR3_HDSEL
#define USART_CR3_HDSEL
Definition: stm32f407xx.h:12594
huart
UART_HandleTypeDef huart
Definition: pv_stm32f469.c:31
HAL_UART_ERROR_RTO
#define HAL_UART_ERROR_RTO
Definition: stm32f7xx_hal_uart.h:313
HAL_DMA_Abort_IT
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
IS_UART_MODE
#define IS_UART_MODE(MODE)
Definition: stm32f4xx_hal_uart.h:788
UART_CLEAR_TCF
#define UART_CLEAR_TCF
Definition: stm32f7xx_hal_uart.h:728
USART_CR1_TXEIE
#define USART_CR1_TXEIE
Definition: stm32f407xx.h:12526
UART_InitTypeDef::OverSampling
uint32_t OverSampling
Definition: stm32f4xx_hal_uart.h:74
UART_ADVFEATURE_NO_INIT
#define UART_ADVFEATURE_NO_INIT
Definition: stm32f7xx_hal_uart.h:480
IS_UART_RECEIVER_TIMEOUT_VALUE
#define IS_UART_RECEIVER_TIMEOUT_VALUE(__TIMEOUTVALUE__)
Check the receiver timeout value.
Definition: stm32f7xx_hal_uart.h:1214
__UART_HandleTypeDef::TxXferCount
__IO uint16_t TxXferCount
Definition: stm32f4xx_hal_uart.h:151
HAL_UART_DMAStop
HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
UART_AdvFeatureConfig
void UART_AdvFeatureConfig(UART_HandleTypeDef *huart)
HAL_UART_Abort_IT
HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
HAL_RCC_GetPCLK2Freq
uint32_t HAL_RCC_GetPCLK2Freq(void)
__DMA_HandleTypeDef::XferAbortCallback
void(* XferAbortCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:161
UART_InitTypeDef::WordLength
uint32_t WordLength
Definition: stm32f4xx_hal_uart.h:55
HAL_MultiProcessor_EnableMuteMode
HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart)
__UART_HandleTypeDef
UART handle Structure definition.
Definition: stm32f4xx_hal_uart.h:141
USART_CR2_TXINV
#define USART_CR2_TXINV
Definition: stm32f769xx.h:15333
__HAL_UART_ENABLE
#define __HAL_UART_ENABLE(__HANDLE__)
Enable UART.
Definition: stm32f4xx_hal_uart.h:652
USART_CR3_OVRDIS
#define USART_CR3_OVRDIS
Definition: stm32f769xx.h:15394
UART_InitTypeDef::BaudRate
uint32_t BaudRate
Definition: stm32f4xx_hal_uart.h:49
USART_CR3_DMAT
#define USART_CR3_DMAT
Definition: stm32f407xx.h:12606
UART_ADVFEATURE_RXINVERT_INIT
#define UART_ADVFEATURE_RXINVERT_INIT
Definition: stm32f7xx_hal_uart.h:482
__DMA_HandleTypeDef::Init
DMA_InitTypeDef Init
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:143
UART_AdvFeatureInitTypeDef::RxPinLevelInvert
uint32_t RxPinLevelInvert
Definition: stm32f7xx_hal_uart.h:101
USART_TypeDef::CR1
__IO uint32_t CR1
Definition: stm32f407xx.h:763
HAL_ERROR
@ HAL_ERROR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:43
UART_WORDLENGTH_9B
#define UART_WORDLENGTH_9B
Definition: stm32f4xx_hal_uart.h:248
__HAL_UART_GET_FLAG
#define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__)
Checks whether the specified UART flag is set or not.
Definition: stm32f4xx_hal_uart.h:426
__HAL_UART_DISABLE
#define __HAL_UART_DISABLE(__HANDLE__)
Disable UART.
Definition: stm32f4xx_hal_uart.h:658
CLEAR_BIT
#define CLEAR_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:214
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:323
HAL_UART_DisableReceiverTimeout
HAL_StatusTypeDef HAL_UART_DisableReceiverTimeout(UART_HandleTypeDef *huart)
USART_ISR_FE
#define USART_ISR_FE
Definition: stm32f769xx.h:15470
IS_UART_WAKEUPMETHOD
#define IS_UART_WAKEUPMETHOD(WAKEUP)
Definition: stm32f4xx_hal_uart.h:796
DMA_CIRCULAR
#define DMA_CIRCULAR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:282
USART_CR1_RTOIE
#define USART_CR1_RTOIE
Definition: stm32f769xx.h:15285
HAL_UART_ERROR_PE
#define HAL_UART_ERROR_PE
Definition: stm32f4xx_hal_uart.h:232
UART_CR2_ADDRESS_LSB_POS
#define UART_CR2_ADDRESS_LSB_POS
Definition: stm32f7xx_hal_uart.h:588
HAL_MultiProcessor_DisableMuteMode
HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart)
HAL_UART_DMAResume
HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart)
UART_CLOCKSOURCE_HSI
@ UART_CLOCKSOURCE_HSI
Definition: stm32f7xx_hal_uart.h:176
USART_ISR_ORE
#define USART_ISR_ORE
Definition: stm32f769xx.h:15476
HAL_UART_STATE_BUSY_TX
@ HAL_UART_STATE_BUSY_TX
Definition: stm32f4xx_hal_uart.h:125
HAL_UART_MspInit
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
UART MSP Initialization This function configures the hardware resources used in this example.
Definition: stm32h7xx_hal_msp.c:320
USART_TypeDef::RTOR
__IO uint32_t RTOR
Definition: stm32f769xx.h:1013
UART_ADVFEATURE_DATAINVERT_INIT
#define UART_ADVFEATURE_DATAINVERT_INIT
Definition: stm32f7xx_hal_uart.h:483
UART_HWCONTROL_NONE
#define UART_HWCONTROL_NONE
Definition: stm32f4xx_hal_uart.h:275
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
UART_InitTypeDef::StopBits
uint32_t StopBits
Definition: stm32f4xx_hal_uart.h:58
UART_OVERSAMPLING_8
#define UART_OVERSAMPLING_8
Definition: stm32f4xx_hal_uart.h:306
HAL_UART_ReceiverTimeout_Config
void HAL_UART_ReceiverTimeout_Config(UART_HandleTypeDef *huart, uint32_t TimeoutValue)
HAL_HalfDuplex_EnableReceiver
HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart)
IS_UART_ADVFEATURE_SWAP
#define IS_UART_ADVFEATURE_SWAP(__SWAP__)
Ensure that UART frame RX/TX pins swap setting is valid.
Definition: stm32f7xx_hal_uart.h:1319
UART_CheckIdleState
HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart)
UART_AdvFeatureInitTypeDef::OverrunDisable
uint32_t OverrunDisable
Definition: stm32f7xx_hal_uart.h:111
HAL_UART_RxCpltCallback
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
IS_UART_ADVFEATURE_RXINV
#define IS_UART_ADVFEATURE_RXINV(__RXINV__)
Ensure that UART frame RX inversion setting is valid.
Definition: stm32f7xx_hal_uart.h:1303
UNUSED
#define UNUSED(x)
Definition: porcupine/demo/c/dr_libs/old/dr.h:92
IS_UART_PARITY
#define IS_UART_PARITY(PARITY)
Definition: stm32f4xx_hal_uart.h:780
HSI_VALUE
#define HSI_VALUE
Internal High Speed oscillator (HSI) value. This value is used by the RCC HAL module to compute the s...
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:82
USART_CR3_WUFIE
#define USART_CR3_WUFIE
Definition: stm32f769xx.h:15417
USART_CR2_STOP
#define USART_CR2_STOP
Definition: stm32f407xx.h:12574
IS_UART_LIN_BREAK_DETECT_LENGTH
#define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH)
Definition: stm32f4xx_hal_uart.h:794
UART_FLAG_RTOF
#define UART_FLAG_RTOF
Definition: stm32f7xx_hal_uart.h:664
HAL_UART_RxHalfCpltCallback
void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
USART_CR2_CLKEN
#define USART_CR2_CLKEN
Definition: stm32f407xx.h:12570
__UART_HandleTypeDef::hdmatx
DMA_HandleTypeDef * hdmatx
Definition: stm32f4xx_hal_uart.h:159
IS_UART_ONE_BIT_SAMPLE
#define IS_UART_ONE_BIT_SAMPLE(__ONEBIT__)
Ensure that UART frame sampling is valid.
Definition: stm32f7xx_hal_uart.h:1188
__HAL_LOCK
#define __HAL_LOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:93
HAL_UART_GetState
HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart)
IS_UART_ADVFEATURE_DMAONRXERROR
#define IS_UART_ADVFEATURE_DMAONRXERROR(__DMA__)
Ensure that UART DMA enabling or disabling on error setting is valid.
Definition: stm32f7xx_hal_uart.h:1343
USART_TypeDef::RDR
__IO uint32_t RDR
Definition: stm32f769xx.h:1017
USART_CR1_RXNEIE
#define USART_CR1_RXNEIE
Definition: stm32f407xx.h:12520
USART_ISR_REACK
#define USART_ISR_REACK
Definition: stm32f769xx.h:15530
USART_RTOR_RTO
#define USART_RTOR_RTO
Definition: stm32f769xx.h:15442
HAL_UART_EnableReceiverTimeout
HAL_StatusTypeDef HAL_UART_EnableReceiverTimeout(UART_HandleTypeDef *huart)
HAL_UART_AbortReceive_IT
HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart)
UART_AdvFeatureInitTypeDef::DataInvert
uint32_t DataInvert
Definition: stm32f7xx_hal_uart.h:104
MODIFY_REG
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:224
HAL_UART_ERROR_DMA
#define HAL_UART_ERROR_DMA
Definition: stm32f4xx_hal_uart.h:236
UART_CLEAR_OREF
#define UART_CLEAR_OREF
Definition: stm32f7xx_hal_uart.h:726
HAL_UART_Init
HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart)
UART_CLEAR_NEF
#define UART_CLEAR_NEF
Definition: stm32f7xx_hal_uart.h:725
HAL_UART_ERROR_ORE
#define HAL_UART_ERROR_ORE
Definition: stm32f4xx_hal_uart.h:235
HAL_UART_AbortTransmit_IT
HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart)
RESET
@ RESET
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:187
UART_MUTE_MODE_REQUEST
#define UART_MUTE_MODE_REQUEST
Definition: stm32f7xx_hal_uart.h:470
__UART_HandleTypeDef::Mask
uint16_t Mask
Definition: stm32f7xx_hal_uart.h:205
__UART_HandleTypeDef::Lock
HAL_LockTypeDef Lock
Definition: stm32f4xx_hal_uart.h:163
HAL_BUSY
@ HAL_BUSY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:44
HAL_DMA_Start_IT
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
HAL_UART_Receive_DMA
HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
UART_FLAG_RXNE
#define UART_FLAG_RXNE
Definition: stm32f4xx_hal_uart.h:338
UART_AdvFeatureInitTypeDef::DMADisableonRxError
uint32_t DMADisableonRxError
Definition: stm32f7xx_hal_uart.h:114
UART_AdvFeatureInitTypeDef::AutoBaudRateMode
uint32_t AutoBaudRateMode
Definition: stm32f7xx_hal_uart.h:120
__UART_HandleTypeDef::RxState
__IO HAL_UART_StateTypeDef RxState
Definition: stm32f4xx_hal_uart.h:169
HAL_UART_TIMEOUT_VALUE
#define HAL_UART_TIMEOUT_VALUE
Definition: stm32f7xx_hal_uart.h:641
HAL_UART_STATE_BUSY_RX
@ HAL_UART_STATE_BUSY_RX
Definition: stm32f4xx_hal_uart.h:127
USART_TypeDef::CR3
__IO uint32_t CR3
Definition: stm32f407xx.h:765
USART_CR1_PEIE
#define USART_CR1_PEIE
Definition: stm32f407xx.h:12529
USART_TypeDef::CR2
__IO uint32_t CR2
Definition: stm32f407xx.h:764
__HAL_UNLOCK
#define __HAL_UNLOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:105
UART_AdvFeatureInitTypeDef::TxPinLevelInvert
uint32_t TxPinLevelInvert
Definition: stm32f7xx_hal_uart.h:98
READ_BIT
#define READ_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:216
UART_CLEAR_FEF
#define UART_CLEAR_FEF
Definition: stm32f7xx_hal_uart.h:724
UART_WORDLENGTH_8B
#define UART_WORDLENGTH_8B
Definition: stm32f4xx_hal_uart.h:247
USART_TypeDef::ISR
__IO uint32_t ISR
Definition: stm32f769xx.h:1015
HAL_MAX_DELAY
#define HAL_MAX_DELAY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:61
__UART_HandleTypeDef::AdvancedInit
UART_AdvFeatureInitTypeDef AdvancedInit
Definition: stm32f7xx_hal_uart.h:191
UART_ClockSourceTypeDef
UART_ClockSourceTypeDef
UART clock sources definition.
Definition: stm32f7xx_hal_uart.h:172
HAL_DMA_Abort
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
__UART_HandleTypeDef::TxXferSize
uint16_t TxXferSize
Definition: stm32f4xx_hal_uart.h:149
__UART_HandleTypeDef::RxISR
void(* RxISR)(struct __UART_HandleTypeDef *huart)
Definition: stm32f7xx_hal_uart.h:207
__HAL_UART_SEND_REQ
#define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__)
Set a specific UART request flag.
Definition: stm32f7xx_hal_uart.h:987
__UART_HandleTypeDef::pTxBuffPtr
uint8_t * pTxBuffPtr
Definition: stm32f4xx_hal_uart.h:147
HAL_UART_Receive
HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
__UART_HandleTypeDef::gState
__IO HAL_UART_StateTypeDef gState
Definition: stm32f4xx_hal_uart.h:165
HAL_UART_ERROR_NONE
#define HAL_UART_ERROR_NONE
Definition: stm32f4xx_hal_uart.h:231
UART_ADVFEATURE_DMADISABLEONERROR_INIT
#define UART_ADVFEATURE_DMADISABLEONERROR_INIT
Definition: stm32f7xx_hal_uart.h:486
IS_UART_INSTANCE
#define IS_UART_INSTANCE
Definition: stm32f407xx.h:15480
__UART_HandleTypeDef::hdmarx
DMA_HandleTypeDef * hdmarx
Definition: stm32f4xx_hal_uart.h:161
__UART_HandleTypeDef::RxXferSize
uint16_t RxXferSize
Definition: stm32f4xx_hal_uart.h:155
UART_SetConfig
HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart)
USART_CR1_TCIE
#define USART_CR1_TCIE
Definition: stm32f407xx.h:12523
USART_TypeDef::BRR
__IO uint32_t BRR
Definition: stm32f407xx.h:762
IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE
#define IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(__INSTANCE__)
Definition: stm32f769xx.h:21979
USART_CR3_EIE
#define USART_CR3_EIE
Definition: stm32f407xx.h:12585
__UART_HandleTypeDef::pRxBuffPtr
uint8_t * pRxBuffPtr
Definition: stm32f4xx_hal_uart.h:153
USART_ISR_TC
#define USART_ISR_TC
Definition: stm32f769xx.h:15485
__UART_HandleTypeDef::ErrorCode
__IO uint32_t ErrorCode
Definition: stm32f4xx_hal_uart.h:172
HAL_TIMEOUT
@ HAL_TIMEOUT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:45
UART_CLEAR_WUF
#define UART_CLEAR_WUF
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_uart.h:806
LSE_VALUE
#define LSE_VALUE
External Low Speed oscillator (LSE) value.
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:97
USART_CR2_LBDL
#define USART_CR2_LBDL
Definition: stm32f407xx.h:12555
UART_WAKEUPMETHOD_ADDRESSMARK
#define UART_WAKEUPMETHOD_ADDRESSMARK
Definition: stm32f4xx_hal_uart.h:324
__DMA_HandleTypeDef::Parent
void * Parent
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:149
IS_UART_LIN_INSTANCE
#define IS_UART_LIN_INSTANCE
Definition: stm32f407xx.h:15488
USART_ISR_TXE
#define USART_ISR_TXE
Definition: stm32f769xx.h:15488
HAL_HalfDuplex_EnableTransmitter
HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart)
UART_ADVFEATURE_TXINVERT_INIT
#define UART_ADVFEATURE_TXINVERT_INIT
Definition: stm32f7xx_hal_uart.h:481
__DMA_HandleTypeDef::XferCpltCallback
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:151
IS_UART_HARDWARE_FLOW_CONTROL
#define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)
Definition: stm32f4xx_hal_uart.h:783
UART_WaitOnFlagUntilTimeout
HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
HAL_RCC_GetPCLK1Freq
uint32_t HAL_RCC_GetPCLK1Freq(void)
USART_CR1_WAKE
#define USART_CR1_WAKE
Definition: stm32f407xx.h:12538
UART_MASK_COMPUTATION
#define UART_MASK_COMPUTATION(__HANDLE__)
Report the UART mask to apply to retrieve the received data according to the word length and to the p...
Definition: stm32f7xx_hal_uart_ex.h:347
USART_ISR_NE
#define USART_ISR_NE
Definition: stm32f769xx.h:15473
SET
@ SET
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:188
UART_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f4xx_hal_uart.h:68
UART_RXDATA_FLUSH_REQUEST
#define UART_RXDATA_FLUSH_REQUEST
Definition: stm32f7xx_hal_uart.h:471
HAL_MultiProcessor_Init
HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
HAL_UART_AbortTransmit
HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart)
HAL_UART_STATE_RESET
@ HAL_UART_STATE_RESET
Definition: stm32f4xx_hal_uart.h:119
HAL_RCC_GetSysClockFreq
uint32_t HAL_RCC_GetSysClockFreq(void)
HAL_LIN_Init
HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
UART_GETCLOCKSOURCE
#define UART_GETCLOCKSOURCE(__HANDLE__, __CLOCKSOURCE__)
Report the UART clock source.
Definition: stm32f7xx_hal_uart_ex.h:162
FlagStatus
FlagStatus
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:185
USART_ISR_RXNE
#define USART_ISR_RXNE
Definition: stm32f769xx.h:15482
HAL_UART_AbortReceiveCpltCallback
void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart)
HAL_UART_IRQHandler
void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
UART_CLOCKSOURCE_LSE
@ UART_CLOCKSOURCE_LSE
Definition: stm32f7xx_hal_uart.h:178
UART_InitTypeDef::HwFlowCtl
uint32_t HwFlowCtl
Definition: stm32f4xx_hal_uart.h:71
USART_CR1_RE
#define USART_CR1_RE
Definition: stm32f407xx.h:12511
HAL_HalfDuplex_Init
HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart)
UART_PARITY_NONE
#define UART_PARITY_NONE
Definition: stm32f4xx_hal_uart.h:265
UART_ADVFEATURE_RXOVERRUNDISABLE_INIT
#define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT
Definition: stm32f7xx_hal_uart.h:485
HAL_IS_BIT_SET
#define HAL_IS_BIT_SET(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:63
IS_UART_STOPBITS
#define IS_UART_STOPBITS(STOPBITS)
Definition: stm32f4xx_hal_uart.h:778
HAL_DMA_GetError
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
HAL_UART_DeInit
HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart)
UART_AdvFeatureInitTypeDef::MSBFirst
uint32_t MSBFirst
Definition: stm32f7xx_hal_uart.h:124
UART_DIV_SAMPLING8
#define UART_DIV_SAMPLING8(_PCLK_, _BAUD_)
Definition: stm32f4xx_hal_uart.h:810
UART_ADVFEATURE_SWAP_INIT
#define UART_ADVFEATURE_SWAP_INIT
Definition: stm32f7xx_hal_uart.h:484
IS_UART_WORD_LENGTH
#define IS_UART_WORD_LENGTH(LENGTH)
Definition: stm32f4xx_hal_uart.h:775
USART_CR2_RTOEN
#define USART_CR2_RTOEN
Definition: stm32f769xx.h:15350
DMA_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:70
READ_REG
#define READ_REG(REG)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:222
USART_ISR_TEACK
#define USART_ISR_TEACK
Definition: stm32f769xx.h:15527
SET_BIT
#define SET_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:212
HAL_UART_AbortTransmitCpltCallback
void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart)
IS_UART_OVERSAMPLING
#define IS_UART_OVERSAMPLING(SAMPLING)
Definition: stm32f4xx_hal_uart.h:791
HAL_UART_TxHalfCpltCallback
void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart)
USART_CR2_LINEN
#define USART_CR2_LINEN
Definition: stm32f407xx.h:12580
USART_CR3_DMAR
#define USART_CR3_DMAR
Definition: stm32f407xx.h:12603
UART_DIV_SAMPLING16
#define UART_DIV_SAMPLING16(_PCLK_, _BAUD_)
Definition: stm32f4xx_hal_uart.h:801
HAL_UART_Receive_IT
HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
HAL_MultiProcessor_EnterMuteMode
HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart)
UART_SENDBREAK_REQUEST
#define UART_SENDBREAK_REQUEST
Definition: stm32f7xx_hal_uart.h:469
IS_UART_ADVFEATURE_DATAINV
#define IS_UART_ADVFEATURE_DATAINV(__DATAINV__)
Ensure that UART frame data inversion setting is valid.
Definition: stm32f7xx_hal_uart.h:1311
IS_UART_ADVFEATURE_TXINV
#define IS_UART_ADVFEATURE_TXINV(__TXINV__)
Ensure that UART frame TX inversion setting is valid.
Definition: stm32f7xx_hal_uart.h:1295
UART_ADVFEATURE_AUTOBAUDRATE_INIT
#define UART_ADVFEATURE_AUTOBAUDRATE_INIT
Definition: stm32f7xx_hal_uart.h:487
USART_CR3_IREN
#define USART_CR3_IREN
Definition: stm32f407xx.h:12588
__UART_HandleTypeDef::Instance
USART_TypeDef * Instance
Definition: stm32f4xx_hal_uart.h:143
UART_AdvFeatureInitTypeDef::AdvFeatureInit
uint32_t AdvFeatureInit
Definition: stm32f7xx_hal_uart.h:94
HAL_UART_AbortCpltCallback
void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart)
IS_UART_ADVFEATURE_INIT
#define IS_UART_ADVFEATURE_INIT(__INIT__)
Ensure that UART advanced features initialization is valid.
Definition: stm32f7xx_hal_uart.h:1280
USART_CR1_TE
#define USART_CR1_TE
Definition: stm32f407xx.h:12514
USART_ISR_PE
#define USART_ISR_PE
Definition: stm32f769xx.h:15467
__HAL_UART_CLEAR_FLAG
#define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clears the specified UART pending flag.
Definition: stm32f4xx_hal_uart.h:450
UART_FLAG_TXE
#define UART_FLAG_TXE
Definition: stm32f4xx_hal_uart.h:336
USART_CR2_DATAINV
#define USART_CR2_DATAINV
Definition: stm32f769xx.h:15336
HAL_UART_STATE_BUSY
@ HAL_UART_STATE_BUSY
Definition: stm32f4xx_hal_uart.h:123
__UART_HandleTypeDef::RxXferCount
__IO uint16_t RxXferCount
Definition: stm32f4xx_hal_uart.h:157
HAL_UART_MspDeInit
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
UART MSP De-Initialization This function freeze the hardware resources used in this example.
Definition: stm32h7xx_hal_msp.c:369
HAL_UARTEx_WakeupCallback
void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart)
stm32f7xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
UART_AdvFeatureInitTypeDef::AutoBaudRateEnable
uint32_t AutoBaudRateEnable
Definition: stm32f7xx_hal_uart.h:117
HAL_UART_DMAPause
HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart)
HAL_UART_Abort
HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart)
__DMA_HandleTypeDef::XferErrorCallback
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:159
UART_InitTypeDef::Parity
uint32_t Parity
Definition: stm32f4xx_hal_uart.h:61
IS_UART_ADVFEATURE_AUTOBAUDRATEMODE
#define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__MODE__)
Ensure that UART auto Baud rate detection mode is valid.
Definition: stm32f7xx_hal_uart.h:1196
USART_CR2_RXINV
#define USART_CR2_RXINV
Definition: stm32f769xx.h:15330
IS_UART_BAUDRATE
#define IS_UART_BAUDRATE(BAUDRATE)
Definition: stm32f4xx_hal_uart.h:798
HAL_UART_STATE_READY
@ HAL_UART_STATE_READY
Definition: stm32f4xx_hal_uart.h:121
UART_AdvFeatureInitTypeDef::Swap
uint32_t Swap
Definition: stm32f7xx_hal_uart.h:108
HAL_UART_GetError
uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart)


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:53