Go to the documentation of this file.
52 #ifndef __GR55xx_HAL_UART_H__
53 #define __GR55xx_HAL_UART_H__
235 #define HAL_UART_ERROR_NONE (0x00000000U)
236 #define HAL_UART_ERROR_PE LL_UART_LSR_PE
237 #define HAL_UART_ERROR_FE LL_UART_LSR_FE
238 #define HAL_UART_ERROR_OE LL_UART_LSR_OE
239 #define HAL_UART_ERROR_BI LL_UART_LSR_BI
240 #define HAL_UART_ERROR_DMA (0x00000100U)
241 #define HAL_UART_ERROR_BUSY (0x00000200U)
247 #define UART_DATABITS_5 LL_UART_DATABITS_5B
248 #define UART_DATABITS_6 LL_UART_DATABITS_6B
249 #define UART_DATABITS_7 LL_UART_DATABITS_7B
250 #define UART_DATABITS_8 LL_UART_DATABITS_8B
256 #define UART_STOPBITS_1 LL_UART_STOPBITS_1
257 #define UART_STOPBITS_1_5 LL_UART_STOPBITS_1_5
258 #define UART_STOPBITS_2 LL_UART_STOPBITS_2
264 #define UART_PARITY_NONE LL_UART_PARITY_NONE
265 #define UART_PARITY_ODD LL_UART_PARITY_ODD
266 #define UART_PARITY_EVEN LL_UART_PARITY_EVEN
267 #define UART_PARITY_SP0 LL_UART_PARITY_SP0
268 #define UART_PARITY_SP1 LL_UART_PARITY_SP1
274 #define UART_HWCONTROL_NONE LL_UART_HWCONTROL_NONE
275 #define UART_HWCONTROL_RTS_CTS LL_UART_HWCONTROL_RTS_CTS
281 #define UART_RECEIVER_TIMEOUT_DISABLE (0x00000000U)
282 #define UART_RECEIVER_TIMEOUT_ENABLE (0x00000001U)
288 #define UART_IT_MS LL_UART_IER_MS
289 #define UART_IT_RLS LL_UART_IER_RLS
290 #define UART_IT_THRE LL_UART_IER_THRE
291 #define UART_IT_RDA LL_UART_IER_RDA
297 #define UART_RXDATA_FLUSH_REQUEST UART_SRR_RFR
298 #define UART_TXDATA_FLUSH_REQUEST UART_SRR_XFR
299 #define UART_TXRXDATA_FLUSH_REQUEST (UART_SRR_XFR | UART_SRR_RFR)
305 #define UART_IT_MASK (0x008FU)
311 #define UART_LINE_ERROR_MASK (LL_UART_LSR_PE | LL_UART_LSR_OE | LL_UART_LSR_FE | LL_UART_LSR_BI)
317 #define UART_RETENTION_LENGTH ((uint32_t)8)
323 #define HAL_UART_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
337 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) \
339 (__HANDLE__)->g_state = HAL_UART_STATE_RESET; \
340 (__HANDLE__)->rx_state = HAL_UART_STATE_RESET; \
353 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
355 GLOBAL_EXCEPTION_DISABLE(); \
356 ll_uart_enable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
357 GLOBAL_EXCEPTION_ENABLE(); \
370 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
372 GLOBAL_EXCEPTION_DISABLE(); \
373 ll_uart_disable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
374 GLOBAL_EXCEPTION_ENABLE(); \
386 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->p_instance->SRR = (__REQ__))
399 #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 921600U)
406 #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
407 ((__STOPBITS__) == UART_STOPBITS_1_5) || \
408 ((__STOPBITS__) == UART_STOPBITS_2))
415 #define IS_UART_DATABITS(__DATABITS__) (((__DATABITS__) == UART_DATABITS_5) || \
416 ((__DATABITS__) == UART_DATABITS_6) || \
417 ((__DATABITS__) == UART_DATABITS_7) || \
418 ((__DATABITS__) == UART_DATABITS_8))
425 #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
426 ((__PARITY__) == UART_PARITY_EVEN) || \
427 ((__PARITY__) == UART_PARITY_ODD) || \
428 ((__PARITY__) == UART_PARITY_SP0) || \
429 ((__PARITY__) == UART_PARITY_SP1))
436 #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
437 (((__CONTROL__) == UART_HWCONTROL_NONE) || \
438 ((__CONTROL__) == UART_HWCONTROL_RTS_CTS)
444 #define UART_DEFAULT_CONFIG \
447 .data_bits = UART_DATABITS_8, \
448 .stop_bits = UART_STOPBITS_1, \
449 .parity = UART_PARITY_NONE, \
450 .hw_flow_ctrl = UART_HWCONTROL_NONE, \
451 .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)
UART abort receive complete callback
void(* uart_msp_deinit)(uart_handle_t *p_uart)
UART de-init MSP callback
__IO hal_uart_state_t tx_state
UART state information related to Tx operations.
void hal_uart_abort_rx_cplt_callback(uart_handle_t *p_uart)
UART Abort Receive Complete callback.
__IO hal_uart_state_t rx_state
UART state information related to Rx operations.
dma_handle_t * p_dmatx
UART Tx DMA Handle parameters
hal_lock_t
HAL Lock structures definition.
uint16_t rx_xfer_size
UART Rx Transfer size
uint32_t hal_uart_get_error(uart_handle_t *p_uart)
Return the UART handle error code.
uint32_t baud_rate
This member configures the UART communication baud rate.
uart_init_t init
UART communication parameters
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_BUSY_TX
Data Transmission process is ongoing.
hal_uart_state_t
HAL UART State enumerations definition.
functional_state_t dma_rx_mode
UART Rx DMA mode state
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).
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.
@ HAL_UART_STATE_BUSY_RX
Data Reception process is ongoing.
UART handle Structure definition.
uint32_t stop_bits
Specifies the number of stop bits transmitted.
dma_handle_t * p_dmarx
UART Rx DMA Handle parameters
UART init structure definition.
hal_lock_t lock
Locking object
uint32_t rx_timeout_mode
Specifies whether the receive timeout mode is enabled or disabled.
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.
uint16_t tx_xfer_size
UART Tx Transfer size
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)
UART error callback
@ HAL_UART_STATE_ERROR
Error.
@ HAL_UART_STATE_BUSY
An internal process is ongoing.
uint32_t parity
Specifies the parity mode.
hal_status_t hal_uart_resume_reg(uart_handle_t *p_uart)
Restore some registers related to UART configuration after sleep.
__IO uint16_t tx_xfer_count
UART Tx Transfer Counter
uint8_t * p_rx_buffer
Pointer to UART Rx transfer Buffer.
hal_status_t hal_uart_suspend_reg(uart_handle_t *p_uart)
Suspend some registers related to UART configuration before sleep.
@ HAL_UART_STATE_TIMEOUT
Timeout state.
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...
@ HAL_UART_STATE_READY
Peripheral initialized and ready for use.
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)
UART abort completed callback
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)
UART rx transfer completed callback
uint32_t hw_flow_ctrl
Specifies whether the hardware flow control mode is enabled or disabled.
@ HAL_UART_STATE_RESET
Peripheral is not initialized.
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.
uint32_t retention[8]
UART important register information.
hal_status_t hal_uart_abort(uart_handle_t *p_uart)
Abort ongoing transfers (blocking mode).
@ HAL_UART_STATE_BUSY_TXRX
Data Transmission and Reception process is ongoing.
uint32_t data_bits
Specifies the number of data bits transmitted or received in a frame.
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)
UART abort tansmit complete callback
uint8_t * p_tx_buffer
Pointer to UART Tx transfer Buffer.
void hal_uart_abort_cplt_callback(uart_handle_t *p_uart)
UART Abort Complete callback.
uart_regs_t * p_instance
UART registers base address
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.
__IO uint32_t error_code
UART Error code
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)
UART tx transfer completed callback
__IO uint16_t rx_xfer_count
UART Rx Transfer Counter
void(* uart_msp_init)(uart_handle_t *p_uart)
UART init MSP callback
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
UART Tx DMA mode state
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.