Go to the documentation of this file.
52 #ifndef __GR55xx_HAL_UART_H__
53 #define __GR55xx_HAL_UART_H__
235 #define UART_TXFIFO_SIZE 128
236 #define UART_RXFIFO_SIZE 128
242 #define HAL_UART_ERROR_NONE (0x00000000U)
243 #define HAL_UART_ERROR_PE LL_UART_LSR_PE
244 #define HAL_UART_ERROR_FE LL_UART_LSR_FE
245 #define HAL_UART_ERROR_OE LL_UART_LSR_OE
246 #define HAL_UART_ERROR_BI LL_UART_LSR_BI
247 #define HAL_UART_ERROR_DMA (0x00000100U)
248 #define HAL_UART_ERROR_BUSY (0x00000200U)
249 #define HAL_UART_ERROR_INVALID_PARAM (0x00000400U)
255 #define UART_DATABITS_5 LL_UART_DATABITS_5B
256 #define UART_DATABITS_6 LL_UART_DATABITS_6B
257 #define UART_DATABITS_7 LL_UART_DATABITS_7B
258 #define UART_DATABITS_8 LL_UART_DATABITS_8B
264 #define UART_STOPBITS_1 LL_UART_STOPBITS_1
265 #define UART_STOPBITS_1_5 LL_UART_STOPBITS_1_5
266 #define UART_STOPBITS_2 LL_UART_STOPBITS_2
272 #define UART_PARITY_NONE LL_UART_PARITY_NONE
273 #define UART_PARITY_ODD LL_UART_PARITY_ODD
274 #define UART_PARITY_EVEN LL_UART_PARITY_EVEN
275 #define UART_PARITY_SP0 LL_UART_PARITY_SP0
276 #define UART_PARITY_SP1 LL_UART_PARITY_SP1
282 #define UART_HWCONTROL_NONE LL_UART_HWCONTROL_NONE
283 #define UART_HWCONTROL_RTS_CTS LL_UART_HWCONTROL_RTS_CTS
289 #define UART_RECEIVER_TIMEOUT_DISABLE (0x00000000U)
290 #define UART_RECEIVER_TIMEOUT_ENABLE (0x00000001U)
296 #define UART_IT_MS LL_UART_IER_MS
297 #define UART_IT_RLS LL_UART_IER_RLS
298 #define UART_IT_THRE LL_UART_IER_THRE
299 #define UART_IT_RDA LL_UART_IER_RDA
305 #define UART_RXDATA_FLUSH_REQUEST UART_SRR_RFR
306 #define UART_TXDATA_FLUSH_REQUEST UART_SRR_XFR
307 #define UART_TXRXDATA_FLUSH_REQUEST (UART_SRR_XFR | UART_SRR_RFR)
313 #define UART_IT_MASK (0x008FU)
319 #define UART_LINE_ERROR_MASK (LL_UART_LSR_PE | LL_UART_LSR_OE | LL_UART_LSR_FE | LL_UART_LSR_BI)
325 #define UART_RETENTION_LENGTH ((uint32_t)8)
331 #define HAL_UART_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
345 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) \
347 (__HANDLE__)->g_state = HAL_UART_STATE_RESET; \
348 (__HANDLE__)->rx_state = HAL_UART_STATE_RESET; \
361 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
363 GLOBAL_EXCEPTION_DISABLE(); \
364 ll_uart_enable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
365 GLOBAL_EXCEPTION_ENABLE(); \
378 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
380 GLOBAL_EXCEPTION_DISABLE(); \
381 ll_uart_disable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
382 GLOBAL_EXCEPTION_ENABLE(); \
394 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->p_instance->SRR = (__REQ__))
407 #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 921600U)
414 #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
415 ((__STOPBITS__) == UART_STOPBITS_1_5) || \
416 ((__STOPBITS__) == UART_STOPBITS_2))
423 #define IS_UART_DATABITS(__DATABITS__) (((__DATABITS__) == UART_DATABITS_5) || \
424 ((__DATABITS__) == UART_DATABITS_6) || \
425 ((__DATABITS__) == UART_DATABITS_7) || \
426 ((__DATABITS__) == UART_DATABITS_8))
433 #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
434 ((__PARITY__) == UART_PARITY_EVEN) || \
435 ((__PARITY__) == UART_PARITY_ODD) || \
436 ((__PARITY__) == UART_PARITY_SP0) || \
437 ((__PARITY__) == UART_PARITY_SP1))
444 #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
445 (((__CONTROL__) == UART_HWCONTROL_NONE) || \
446 ((__CONTROL__) == UART_HWCONTROL_RTS_CTS)
452 #define UART_DEFAULT_CONFIG \
455 .data_bits = UART_DATABITS_8, \
456 .stop_bits = UART_STOPBITS_1, \
457 .parity = UART_PARITY_NONE, \
458 .hw_flow_ctrl = UART_HWCONTROL_NONE, \
459 .rx_timeout_mode = UART_RECEIVER_TIMEOUT_DISABLE, \
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
hal_status_t hal_uart_transmit_dma_sg_llp(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, dma_sg_llp_config_t *sg_llp_config)
Send an amount of data in DMA mode.
hal_lock_t
HAL Lock structures definition.
uint32_t hal_uart_get_error(uart_handle_t *p_uart)
Return the UART handle error code.
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).
LL DMA sg and llp config definition.
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.
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)
hal_status_t 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...
__IO uint16_t tx_xfer_count
hal_status_t hal_uart_suspend_reg(uart_handle_t *p_uart)
Suspend some registers related to UART configuration before sleep.
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)
Header file containing functions prototypes of UART LL library.
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.
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).
hal_status_t hal_uart_receive_dma_sg_llp(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, dma_sg_llp_config_t *sg_llp_config)
Receive an amount of data in DMA mode.
void(* uart_abort_tx_cplt_callback)(uart_handle_t *p_uart)
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.
This file contains HAL common definitions, enumeration, macros and structures definitions.
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.