55#ifdef HAL_UART_MODULE_ENABLED
63#define RX_FIFO_DEPTH 16U
66#define TX_FIFO_DEPTH 16U
167 uint32_t DeassertionTime)
193#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
194 UART_InitCallbacksToDefault(huart);
196 if (huart->MspInitCallback ==
NULL)
202 huart->MspInitCallback(huart);
448 UARTEx_Wakeup_AddressConfig(huart, WakeUpSelection);
544 UARTEx_SetNbDataToProcess(huart);
628 UARTEx_SetNbDataToProcess(huart);
677 UARTEx_SetNbDataToProcess(huart);
715 uint16_t *pdata16bits;
722 if ((pData ==
NULL) || (Size == 0U))
740 uhMask = huart->
Mask;
746 pdata16bits = (uint16_t *) pData;
780 if (pdata8bits ==
NULL)
782 *pdata16bits = (uint16_t)(huart->
Instance->
RDR & uhMask);
787 *pdata8bits = (uint8_t)(huart->
Instance->
RDR & (uint8_t)uhMask);
798 if (((
HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
841 if ((pData ==
NULL) || (Size == 0U))
898 if ((pData ==
NULL) || (Size == 0U))
1001 uint8_t rx_fifo_depth;
1002 uint8_t tx_fifo_depth;
1003 uint8_t rx_fifo_threshold;
1004 uint8_t tx_fifo_threshold;
1005 static const uint8_t numerator[] = {1U, 1U, 1U, 3U, 7U, 1U, 0U, 0U};
1006 static const uint8_t denominator[] = {8U, 4U, 2U, 4U, 8U, 1U, 1U, 1U};
1015 rx_fifo_depth = RX_FIFO_DEPTH;
1016 tx_fifo_depth = TX_FIFO_DEPTH;
1019 huart->
NbTxDataToProcess = ((uint16_t)tx_fifo_depth * numerator[tx_fifo_threshold]) /
1020 (uint16_t)denominator[tx_fifo_threshold];
1021 huart->
NbRxDataToProcess = ((uint16_t)rx_fifo_depth * numerator[rx_fifo_threshold]) /
1022 (uint16_t)denominator[rx_fifo_threshold];
#define ATOMIC_CLEAR_BIT(REG, BIT)
#define CLEAR_BIT(REG, BIT)
#define SET_BIT(REG, BIT)
#define WRITE_REG(REG, VAL)
#define IS_UART_FIFO_INSTANCE(INSTANCE)
#define ATOMIC_SET_BIT(REG, BIT)
#define IS_UART_WAKEUP_FROMSTOP_INSTANCE(INSTANCE)
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
#define READ_BIT(REG, BIT)
#define IS_UART_DRIVER_ENABLE_INSTANCE(INSTANCE)
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
#define USART_CR1_UESM
USART Enable in STOP Mode.
#define USART_CR3_DEP
Driver Enable Polarity Selection.
#define USART_CR2_ADDM7
7-bit or 4-bit Address Detection
#define USART_CR2_ADD
Address of the USART node.
#define USART_CR3_TXFTCFG
TXFIFO [2:0] threshold configuration.
#define USART_CR1_IDLEIE
IDLE Interrupt Enable.
#define USART_CR3_RXFTCFG_Pos
#define USART_CR1_DEAT
DEAT[4:0] bits (Driver Enable Assertion Time).
#define USART_CR3_WUS
WUS[1:0] bits (Wake UP Interrupt Flag Selection).
#define USART_ISR_REACK
Receive Enable Acknowledge Flag.
#define USART_CR3_TXFTCFG_Pos
#define USART_CR1_DEDT
DEDT[4:0] bits (Driver Enable Deassertion Time).
#define USART_CR3_RXFTCFG
RXFTCFG [2:0]Receive FIFO threshold configuration.
#define USART_CR3_DEM
Driver Enable Mode.
#define USART_CR1_FIFOEN
FIFO mode enable.
HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity, uint32_t AssertionTime, uint32_t DeassertionTime)
void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart)
void HAL_UARTEx_TxFifoEmptyCallback(UART_HandleTypeDef *huart)
void HAL_UARTEx_RxFifoFullCallback(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint16_t *RxLen, uint32_t Timeout)
HAL_UART_RxEventTypeTypeDef HAL_UARTEx_GetRxEventType(const UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UARTEx_DisableFifoMode(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UARTEx_EnableFifoMode(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UARTEx_SetRxFifoThreshold(UART_HandleTypeDef *huart, uint32_t Threshold)
HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection)
HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength)
HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UARTEx_SetTxFifoThreshold(UART_HandleTypeDef *huart, uint32_t Threshold)
HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
#define UART_FIFOMODE_ENABLE
FIFO mode enable.
#define UART_FIFOMODE_DISABLE
FIFO mode disable.
#define IS_UART_TXFIFO_THRESHOLD(__THRESHOLD__)
Ensure that UART TXFIFO threshold level is valid.
#define IS_UART_ADDRESSLENGTH_DETECT(__ADDRESS__)
Ensure that UART wake-up address length is valid.
#define IS_UART_RXFIFO_THRESHOLD(__THRESHOLD__)
Ensure that UART RXFIFO threshold level is valid.
#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_WORDLENGTH_9B
9-bit long UART frame
#define UART_ADVFEATURE_NO_INIT
No advanced feature initialization.
#define UART_CR1_DEAT_ADDRESS_LSB_POS
UART Driver Enable assertion time LSB position in CR1 register.
#define UART_CR1_DEDT_ADDRESS_LSB_POS
UART Driver Enable de-assertion time LSB position in CR1 register.
#define UART_CR2_ADDRESS_LSB_POS
UART address-matching LSB position in CR2 register.
#define HAL_UART_ERROR_NONE
No error.
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
UART MSP Initialization This function configures the hardware resources used in this example.
#define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__)
Check whether the specified UART flag is set or not.
#define __HAL_UART_ENABLE(__HANDLE__)
Enable UART.
#define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clear the specified UART pending flag.
#define __HAL_UART_DISABLE(__HANDLE__)
Disable UART.
struct __UART_HandleTypeDef UART_HandleTypeDef
UART handle Structure definition.
uint32_t HAL_UART_RxEventTypeTypeDef
HAL UART Rx Event type definition.
#define UART_FLAG_IDLE
UART idle flag.
#define UART_FLAG_RXNE
UART read data register not empty.
#define UART_CLEAR_IDLEF
IDLE line detected Clear Flag.
#define UART_PARITY_NONE
No parity.
HAL_StatusTypeDef UART_Start_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart)
HAL_StatusTypeDef UART_Start_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
void UART_AdvFeatureConfig(UART_HandleTypeDef *huart)
HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart)
#define IS_UART_DEASSERTIONTIME(__TIME__)
Check UART deassertion time.
#define IS_UART_ASSERTIONTIME(__TIME__)
Check UART assertion time.
#define IS_UART_WAKEUP_SELECTION(__WAKE__)
Ensure that UART wake-up selection is valid.
#define IS_UART_DE_POLARITY(__POLARITY__)
Ensure that UART driver enable polarity is valid.
#define HAL_UART_RECEPTION_TOIDLE
Reception till completion or IDLE event.
#define HAL_UART_RXEVENT_IDLE
RxEvent linked to IDLE event.
#define HAL_UART_RXEVENT_TC
RxEvent linked to Transfer Complete event.
#define HAL_UART_STATE_READY
Peripheral Initialized and ready for use Value is allowed for gState and RxState.
#define HAL_UART_STATE_BUSY_RX
Data Reception process is ongoing Value is allowed for RxState only.
#define HAL_UART_STATE_BUSY
an internal process is ongoing Value is allowed for gState only
#define HAL_UART_STATE_RESET
Peripheral is not initialized Value is allowed for gState and RxState.
#define HAL_UART_TIMEOUT_VALUE
UART polling-based communications time-out value.
#define UART_WAKEUP_ON_ADDRESS
UART wake-up on address.
This file contains all the functions prototypes for the HAL module driver.
#define assert_param(expr)
Uncomment the line below to expanse the "assert_param" macro in the HAL drivers code.
HAL_StatusTypeDef
HAL Status structures definition.
#define __HAL_UNLOCK(__HANDLE__)
#define __HAL_LOCK(__HANDLE__)
uint32_t AdvFeatureInit
Specifies which advanced UART features is initialized.
uint32_t WordLength
Specifies the number of data bits transmitted or received in a frame.
uint32_t Parity
Specifies the parity mode.
UART wake up from stop mode parameters.
uint8_t Address
UART/USART node address (7-bit long max).
uint32_t WakeUpEvent
Specifies which event will activate the Wakeup from Stop mode flag (WUF).
uint16_t AddressLength
Specifies whether the address is 4 or 7-bit long.
__IO uint32_t CR1
USART Control register 1, Address offset: 0x00.
__IO uint32_t RDR
USART Receive Data register, Address offset: 0x24.
__IO uint32_t CR2
USART Control register 2, Address offset: 0x04.
__IO uint32_t CR3
USART Control register 3, Address offset: 0x08.
__IO HAL_UART_RxEventTypeTypeDef RxEventType
Type of Rx Event.
__IO uint32_t ErrorCode
UART Error code.
__IO uint16_t RxXferCount
UART Rx Transfer Counter.
__IO HAL_UART_StateTypeDef gState
UART state information related to global Handle management and also related to Tx operations.
__IO HAL_UART_StateTypeDef RxState
UART state information related to Rx operations.
HAL_LockTypeDef Lock
Locking object.
uint16_t Mask
UART Rx RDR register mask.
UART_InitTypeDef Init
UART communication parameters.
UART_AdvFeatureInitTypeDef AdvancedInit
UART Advanced Features initialization parameters.
USART_TypeDef * Instance
UART registers base address.
uint32_t FifoMode
Specifies if the FIFO mode is being used.
uint16_t NbRxDataToProcess
Number of data to process during RX ISR execution.
__IO HAL_UART_RxTypeTypeDef ReceptionType
Type of ongoing reception.
uint16_t RxXferSize
UART Rx Transfer size.
uint16_t NbTxDataToProcess
Number of data to process during TX ISR execution.