Go to the documentation of this file.
168 #ifdef HAL_UART_MODULE_ENABLED
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
182 #define UART_BRR_MAX 0x0000FFFFU
311 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
312 UART_InitCallbacksToDefault(
huart);
376 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
377 UART_InitCallbacksToDefault(
huart);
462 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
463 UART_InitCallbacksToDefault(
huart);
546 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
547 UART_InitCallbacksToDefault(
huart);
623 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
674 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
698 pUART_CallbackTypeDef pCallback)
702 if (pCallback ==
NULL)
715 case HAL_UART_TX_HALFCOMPLETE_CB_ID :
716 huart->TxHalfCpltCallback = pCallback;
719 case HAL_UART_TX_COMPLETE_CB_ID :
720 huart->TxCpltCallback = pCallback;
723 case HAL_UART_RX_HALFCOMPLETE_CB_ID :
724 huart->RxHalfCpltCallback = pCallback;
727 case HAL_UART_RX_COMPLETE_CB_ID :
728 huart->RxCpltCallback = pCallback;
731 case HAL_UART_ERROR_CB_ID :
732 huart->ErrorCallback = pCallback;
735 case HAL_UART_ABORT_COMPLETE_CB_ID :
736 huart->AbortCpltCallback = pCallback;
739 case HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID :
740 huart->AbortTransmitCpltCallback = pCallback;
743 case HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID :
744 huart->AbortReceiveCpltCallback = pCallback;
747 case HAL_UART_WAKEUP_CB_ID :
748 huart->WakeupCallback = pCallback;
752 case HAL_UART_MSPINIT_CB_ID :
753 huart->MspInitCallback = pCallback;
756 case HAL_UART_MSPDEINIT_CB_ID :
757 huart->MspDeInitCallback = pCallback;
771 case HAL_UART_MSPINIT_CB_ID :
772 huart->MspInitCallback = pCallback;
775 case HAL_UART_MSPDEINIT_CB_ID :
776 huart->MspDeInitCallback = pCallback;
829 case HAL_UART_TX_HALFCOMPLETE_CB_ID :
833 case HAL_UART_TX_COMPLETE_CB_ID :
837 case HAL_UART_RX_HALFCOMPLETE_CB_ID :
841 case HAL_UART_RX_COMPLETE_CB_ID :
845 case HAL_UART_ERROR_CB_ID :
849 case HAL_UART_ABORT_COMPLETE_CB_ID :
853 case HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID :
857 case HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID :
861 #if defined(USART_CR1_UESM)
862 case HAL_UART_WAKEUP_CB_ID :
867 case HAL_UART_MSPINIT_CB_ID :
871 case HAL_UART_MSPDEINIT_CB_ID :
886 case HAL_UART_MSPINIT_CB_ID :
890 case HAL_UART_MSPDEINIT_CB_ID :
1013 uint8_t *pdata8bits;
1014 uint16_t *pdata16bits;
1020 if ((pData ==
NULL) || (Size == 0U))
1040 pdata16bits = (uint16_t *) pData;
1056 if (pdata8bits ==
NULL)
1098 uint8_t *pdata8bits;
1099 uint16_t *pdata16bits;
1106 if ((pData ==
NULL) || (Size == 0U))
1130 pdata16bits = (uint16_t *) pData;
1147 if (pdata8bits ==
NULL)
1186 if ((pData ==
NULL) || (Size == 0U))
1239 if ((pData ==
NULL) || (Size == 0U))
1298 if ((pData ==
NULL) || (Size == 0U))
1374 if ((pData ==
NULL) || (Size == 0U))
1539 UART_EndTxTransfer(
huart);
1563 UART_EndRxTransfer(
huart);
1783 uint32_t abortcplt = 1U;
1869 if (abortcplt == 1U)
1894 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
1956 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
1978 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2047 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2071 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2094 uint32_t errorflags;
2099 if (errorflags == 0U)
2114 if ((errorflags != 0U)
2185 UART_EndRxTransfer(
huart);
2209 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2222 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2235 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2248 #if defined(USART_CR1_UESM)
2258 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2283 UART_EndTransmit_IT(
huart);
2409 #if defined(USART_CR1_UESM)
2716 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
2728 #if defined(USART_CR1_UESM)
2745 uint32_t usartdiv = 0x00000000U;
2792 switch (clocksource)
2818 if ((usartdiv >= UART_BRR_MIN) && (usartdiv <= UART_BRR_MAX))
2820 brrtemp = (uint16_t)(usartdiv & 0xFFF0U);
2821 brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U);
2831 switch (clocksource)
2857 if ((usartdiv >= UART_BRR_MIN) && (usartdiv <= UART_BRR_MAX))
2974 #if defined(USART_ISR_REACK)
3007 uint32_t Tickstart, uint32_t Timeout)
3015 if (((
HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
3114 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3133 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3168 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3186 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3212 UART_EndTxTransfer(
huart);
3220 UART_EndRxTransfer(
huart);
3225 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3246 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3294 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3345 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3374 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3407 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3495 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3536 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
3570 *tmp = (uint16_t)(uhdata & uhMask);
3588 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
#define IS_UART_OVERRUN(__OVERRUN__)
Ensure that UART frame overrun setting is valid.
#define assert_param(expr)
Include module's header file.
#define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE
HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
void(* TxISR)(struct __UART_HandleTypeDef *huart)
HAL_StatusTypeDef
HAL Status structures definition
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
HAL_UART_StateTypeDef
HAL UART State structures definition.
HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart)
#define HAL_UART_ERROR_NE
HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
void(* XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)
#define IS_UART_HWFLOW_INSTANCE(INSTANCE)
#define HAL_UART_ERROR_FE
DMA handle Structure definition.
HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
#define USART_CR2_ABRMODE
#define IS_UART_HALFDUPLEX_INSTANCE(INSTANCE)
#define HAL_DMA_ERROR_TIMEOUT
@ UART_CLOCKSOURCE_SYSCLK
#define USART_CR2_MSBFIRST
#define IS_UART_ADVFEATURE_MSBFIRST(__MSBFIRST__)
Ensure that UART frame MSB first setting is valid.
#define IS_UART_ADVFEATURE_AUTOBAUDRATE(__AUTOBAUDRATE__)
Ensure that UART auto Baud rate state is valid.
#define UART_ADVFEATURE_MSBFIRST_INIT
#define HAL_UART_ERROR_RTO
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
#define IS_UART_MODE(MODE)
#define UART_ADVFEATURE_NO_INIT
#define IS_UART_RECEIVER_TIMEOUT_VALUE(__TIMEOUTVALUE__)
Check the receiver timeout value.
__IO uint16_t TxXferCount
HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
void UART_AdvFeatureConfig(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
uint32_t HAL_RCC_GetPCLK2Freq(void)
void(* XferAbortCallback)(struct __DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart)
UART handle Structure definition.
#define __HAL_UART_ENABLE(__HANDLE__)
Enable UART.
#define UART_ADVFEATURE_RXINVERT_INIT
uint32_t RxPinLevelInvert
#define UART_WORDLENGTH_9B
#define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__)
Checks whether the specified UART flag is set or not.
#define __HAL_UART_DISABLE(__HANDLE__)
Disable UART.
#define CLEAR_BIT(REG, BIT)
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
HAL_StatusTypeDef HAL_UART_DisableReceiverTimeout(UART_HandleTypeDef *huart)
#define IS_UART_WAKEUPMETHOD(WAKEUP)
#define HAL_UART_ERROR_PE
#define UART_CR2_ADDRESS_LSB_POS
HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart)
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
UART MSP Initialization This function configures the hardware resources used in this example.
#define UART_ADVFEATURE_DATAINVERT_INIT
#define UART_HWCONTROL_NONE
#define UART_OVERSAMPLING_8
void HAL_UART_ReceiverTimeout_Config(UART_HandleTypeDef *huart, uint32_t TimeoutValue)
HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart)
#define IS_UART_ADVFEATURE_SWAP(__SWAP__)
Ensure that UART frame RX/TX pins swap setting is valid.
HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart)
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
#define IS_UART_ADVFEATURE_RXINV(__RXINV__)
Ensure that UART frame RX inversion setting is valid.
#define IS_UART_PARITY(PARITY)
#define HSI_VALUE
Internal High Speed oscillator (HSI) value. This value is used by the RCC HAL module to compute the s...
#define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH)
void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
DMA_HandleTypeDef * hdmatx
#define IS_UART_ONE_BIT_SAMPLE(__ONEBIT__)
Ensure that UART frame sampling is valid.
#define __HAL_LOCK(__HANDLE__)
HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart)
#define IS_UART_ADVFEATURE_DMAONRXERROR(__DMA__)
Ensure that UART DMA enabling or disabling on error setting is valid.
HAL_StatusTypeDef HAL_UART_EnableReceiverTimeout(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart)
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
#define HAL_UART_ERROR_DMA
HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart)
#define HAL_UART_ERROR_ORE
HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart)
#define UART_MUTE_MODE_REQUEST
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
uint32_t DMADisableonRxError
uint32_t AutoBaudRateMode
__IO HAL_UART_StateTypeDef RxState
#define HAL_UART_TIMEOUT_VALUE
#define __HAL_UNLOCK(__HANDLE__)
uint32_t TxPinLevelInvert
#define READ_BIT(REG, BIT)
#define UART_WORDLENGTH_8B
UART_AdvFeatureInitTypeDef AdvancedInit
UART_ClockSourceTypeDef
UART clock sources definition.
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
void(* RxISR)(struct __UART_HandleTypeDef *huart)
#define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__)
Set a specific UART request flag.
HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
__IO HAL_UART_StateTypeDef gState
#define HAL_UART_ERROR_NONE
#define UART_ADVFEATURE_DMADISABLEONERROR_INIT
DMA_HandleTypeDef * hdmarx
HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart)
#define IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(__INSTANCE__)
#define LSE_VALUE
External Low Speed oscillator (LSE) value.
#define UART_WAKEUPMETHOD_ADDRESSMARK
#define IS_UART_LIN_INSTANCE
HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart)
#define UART_ADVFEATURE_TXINVERT_INIT
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
#define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)
HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
uint32_t HAL_RCC_GetPCLK1Freq(void)
#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...
#define UART_RXDATA_FLUSH_REQUEST
HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart)
uint32_t HAL_RCC_GetSysClockFreq(void)
HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
#define UART_GETCLOCKSOURCE(__HANDLE__, __CLOCKSOURCE__)
Report the UART clock source.
void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart)
#define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT
#define HAL_IS_BIT_SET(REG, BIT)
#define IS_UART_STOPBITS(STOPBITS)
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart)
#define UART_DIV_SAMPLING8(_PCLK_, _BAUD_)
#define UART_ADVFEATURE_SWAP_INIT
#define IS_UART_WORD_LENGTH(LENGTH)
#define SET_BIT(REG, BIT)
void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart)
#define IS_UART_OVERSAMPLING(SAMPLING)
void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart)
#define UART_DIV_SAMPLING16(_PCLK_, _BAUD_)
HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart)
#define UART_SENDBREAK_REQUEST
#define IS_UART_ADVFEATURE_DATAINV(__DATAINV__)
Ensure that UART frame data inversion setting is valid.
#define IS_UART_ADVFEATURE_TXINV(__TXINV__)
Ensure that UART frame TX inversion setting is valid.
#define UART_ADVFEATURE_AUTOBAUDRATE_INIT
void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart)
#define IS_UART_ADVFEATURE_INIT(__INIT__)
Ensure that UART advanced features initialization is valid.
#define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clears the specified UART pending flag.
#define USART_CR2_DATAINV
__IO uint16_t RxXferCount
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
UART MSP De-Initialization This function freeze the hardware resources used in this example.
void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart)
This file contains all the functions prototypes for the HAL module driver.
uint32_t AutoBaudRateEnable
HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart)
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
#define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__MODE__)
Ensure that UART auto Baud rate detection mode is valid.
#define IS_UART_BAUDRATE(BAUDRATE)
uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart)