Go to the documentation of this file.
52 #ifndef ___HAL_UART_H__
53 #define ___HAL_UART_H__
187 #ifndef HAL_HW_RES_SUSP_UART
236 #define UART_TXFIFO_SIZE 16U
237 #define UART_RXFIFO_SIZE 16U
243 #define HAL_UART_ERROR_NONE (0x00000000U)
244 #define HAL_UART_ERROR_PE LL_UART_LSR_PE
245 #define HAL_UART_ERROR_FE LL_UART_LSR_FE
246 #define HAL_UART_ERROR_OE LL_UART_LSR_OE
247 #define HAL_UART_ERROR_BI LL_UART_LSR_BI
248 #define HAL_UART_ERROR_DMA (0x00000100U)
249 #define HAL_UART_ERROR_BUSY (0x00000200U)
250 #define HAL_UART_ERROR_INVALID_PARAM (0x00000400U)
256 #define UART_DATABITS_5 LL_UART_DATABITS_5B
257 #define UART_DATABITS_6 LL_UART_DATABITS_6B
258 #define UART_DATABITS_7 LL_UART_DATABITS_7B
259 #define UART_DATABITS_8 LL_UART_DATABITS_8B
265 #define UART_STOPBITS_1 LL_UART_STOPBITS_1
266 #define UART_STOPBITS_1_5 LL_UART_STOPBITS_1_5
267 #define UART_STOPBITS_2 LL_UART_STOPBITS_2
273 #define UART_PARITY_NONE LL_UART_PARITY_NONE
274 #define UART_PARITY_ODD LL_UART_PARITY_ODD
275 #define UART_PARITY_EVEN LL_UART_PARITY_EVEN
276 #define UART_PARITY_SP0 LL_UART_PARITY_SP0
277 #define UART_PARITY_SP1 LL_UART_PARITY_SP1
283 #define UART_HWCONTROL_NONE LL_UART_HWCONTROL_NONE
284 #define UART_HWCONTROL_RTS_CTS LL_UART_HWCONTROL_RTS_CTS
290 #define UART_RECEIVER_TIMEOUT_DISABLE (0x00000000U)
291 #define UART_RECEIVER_TIMEOUT_ENABLE (0x00000001U)
297 #define UART_IT_MS LL_UART_IER_MS
298 #define UART_IT_RLS LL_UART_IER_RLS
299 #define UART_IT_THRE LL_UART_IER_THRE
300 #define UART_IT_RDA LL_UART_IER_RDA
306 #define UART_RXDATA_FLUSH_REQUEST UART_SRR_RFR
307 #define UART_TXDATA_FLUSH_REQUEST UART_SRR_XFR
308 #define UART_TXRXDATA_FLUSH_REQUEST (UART_SRR_XFR | UART_SRR_RFR)
314 #define UART_IT_MASK (0x008FU)
320 #define UART_LINE_ERROR_MASK (LL_UART_LSR_PE | LL_UART_LSR_OE | LL_UART_LSR_FE | LL_UART_LSR_BI)
326 #define UART_RETENTION_LENGTH ((uint32_t)8)
332 #define HAL_UART_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
346 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) \
348 (__HANDLE__)->g_state = HAL_UART_STATE_RESET; \
349 (__HANDLE__)->rx_state = HAL_UART_STATE_RESET; \
362 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
364 GLOBAL_EXCEPTION_DISABLE(); \
365 ll_uart_enable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
366 GLOBAL_EXCEPTION_ENABLE(); \
379 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
381 GLOBAL_EXCEPTION_DISABLE(); \
382 ll_uart_disable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
383 GLOBAL_EXCEPTION_ENABLE(); \
395 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->p_instance->SRR = (__REQ__))
408 #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 921600U)
415 #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
416 ((__STOPBITS__) == UART_STOPBITS_1_5) || \
417 ((__STOPBITS__) == UART_STOPBITS_2))
424 #define IS_UART_DATABITS(__DATABITS__) (((__DATABITS__) == UART_DATABITS_5) || \
425 ((__DATABITS__) == UART_DATABITS_6) || \
426 ((__DATABITS__) == UART_DATABITS_7) || \
427 ((__DATABITS__) == UART_DATABITS_8))
434 #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
435 ((__PARITY__) == UART_PARITY_EVEN) || \
436 ((__PARITY__) == UART_PARITY_ODD) || \
437 ((__PARITY__) == UART_PARITY_SP0) || \
438 ((__PARITY__) == UART_PARITY_SP1))
445 #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
446 (((__CONTROL__) == UART_HWCONTROL_NONE) || \
447 ((__CONTROL__) == UART_HWCONTROL_RTS_CTS)
453 #define UART_DEFAULT_CONFIG \
456 .data_bits = UART_DATABITS_8, \
457 .stop_bits = UART_STOPBITS_1, \
458 .parity = UART_PARITY_NONE, \
459 .hw_flow_ctrl = UART_HWCONTROL_NONE, \
460 .rx_timeout_mode = UART_RECEIVER_TIMEOUT_DISABLE, \
1035 #ifdef HAL_PM_ENABLE
void hal_uart_irq_handler(uart_handle_t *p_uart)
Handle UART interrupt request.
void(* uart_abort_rx_cplt_callback)(uart_handle_t *p_uart)
void(* uart_msp_deinit)(uart_handle_t *p_uart)
__IO hal_uart_state_t tx_state
void hal_uart_abort_rx_cplt_callback(uart_handle_t *p_uart)
UART Abort Receive Complete callback.
__IO hal_uart_state_t rx_state
void hal_uart_suspend_reg(uart_handle_t *p_uart)
Suspend some registers related to UART configuration before sleep.
hal_pm_status_t hal_pm_uart_suspend(uart_handle_t *p_uart)
Suspend the specified UART.
uint32_t hal_uart_get_error(uart_handle_t *p_uart)
Return the UART handle error code.
Header file containing functions prototypes of UART LL library.
hal_status_t hal_uart_transmit_dma(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size)
Send an amount of data in DMA mode.
hal_status_t hal_uart_dma_resume(uart_handle_t *p_uart)
Resume the DMA Transfer.
struct _uart_init uart_init_t
UART init structure definition.
hal_status_t hal_uart_transmit(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, uint32_t timeout)
Send an amount of data in blocking mode.
hal_status_t hal_uart_deinit(uart_handle_t *p_uart)
De-initialize the UART peripheral.
hal_uart_state_t
HAL UART State enumerations definition.
functional_state_t dma_rx_mode
hal_status_t hal_uart_abort_receive(uart_handle_t *p_uart)
Abort ongoing Receive transfer (blocking mode).
hal_status_t hal_uart_abort_receive_it(uart_handle_t *p_uart)
Abort ongoing Receive transfer (Interrupt mode).
void hal_pm_uart_resume(uart_handle_t *p_uart)
Resume the specified UART.
hal_status_t hal_uart_abort_it(uart_handle_t *p_uart)
Abort ongoing transfers (Interrupt mode).
void hal_uart_msp_init(uart_handle_t *p_uart)
Initialize the UART MSP.
UART handle Structure definition.
UART init structure definition.
void hal_uart_error_callback(uart_handle_t *p_uart)
UART error callback.
void hal_uart_resume_reg(uart_handle_t *p_uart)
Restore some registers related to UART configuration after sleep. This function must be used in conju...
HAL_UART Callback function definition.
struct _hal_uart_callback hal_uart_callback_t
HAL_UART Callback function definition.
hal_status_t hal_uart_abort_transmit(uart_handle_t *p_uart)
Abort ongoing Transmit transfer (blocking mode).
struct _uart_handle uart_handle_t
UART handle Structure definition.
void(* uart_error_callback)(uart_handle_t *p_uart)
__IO uint16_t tx_xfer_count
hal_status_t hal_uart_init(uart_handle_t *p_uart)
Initialize the UART according to the specified parameters in the uart_init_t and initialize the assoc...
void hal_uart_msp_deinit(uart_handle_t *p_uart)
De-initialize the UART MSP.
hal_status_t hal_uart_dma_stop(uart_handle_t *p_uart)
Stop the DMA Transfer.
void(* uart_abort_cplt_callback)(uart_handle_t *p_uart)
void hal_uart_tx_cplt_callback(uart_handle_t *p_uart)
Tx Transfer completed callback.
void(* uart_rx_cplt_callback)(uart_handle_t *p_uart)
hal_status_t
HAL Status structures definition.
This file contains HAL common definitions, enumeration, macros and structures definitions.
hal_status_t hal_uart_transmit_it(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size)
Send an amount of data in interrupt mode.
hal_status_t hal_uart_abort(uart_handle_t *p_uart)
Abort ongoing transfers (blocking mode).
@ HAL_UART_STATE_BUSY_TXRX
hal_status_t hal_uart_abort_transmit_it(uart_handle_t *p_uart)
Abort ongoing Transmit transfer (Interrupt mode).
void(* uart_abort_tx_cplt_callback)(uart_handle_t *p_uart)
Header file containing functions prototypes of DMA HAL library.
void hal_uart_abort_cplt_callback(uart_handle_t *p_uart)
UART Abort Complete callback.
hal_status_t hal_uart_receive_it(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size)
Receive an amount of data in interrupt mode.
hal_status_t hal_uart_receive(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, uint32_t timeout)
Receive an amount of data in blocking mode.
void(* uart_tx_cplt_callback)(uart_handle_t *p_uart)
__IO uint16_t rx_xfer_count
void(* uart_msp_init)(uart_handle_t *p_uart)
hal_status_t hal_uart_dma_pause(uart_handle_t *p_uart)
Pause the DMA Transfer.
hal_status_t hal_uart_receive_dma(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size)
Receive an amount of data in DMA mode.
DMA handle Structure definition.
functional_state_t dma_tx_mode
void hal_uart_rx_cplt_callback(uart_handle_t *p_uart)
Rx Transfer completed callback.
void hal_uart_abort_tx_cplt_callback(uart_handle_t *p_uart)
UART Abort Tansmit Complete callback.
hal_uart_state_t hal_uart_get_state(uart_handle_t *p_uart)
Return the UART handle state.