UART Transmit/Receive functions.
More...
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
hal_status_t | hal_uart_dma_pause (uart_handle_t *p_uart) |
| Pause the DMA Transfer. More...
|
|
hal_status_t | hal_uart_dma_resume (uart_handle_t *p_uart) |
| Resume the DMA Transfer. More...
|
|
hal_status_t | hal_uart_dma_stop (uart_handle_t *p_uart) |
| Stop the DMA Transfer. More...
|
|
hal_status_t | hal_uart_abort (uart_handle_t *p_uart) |
| Abort ongoing transfers (blocking mode). More...
|
|
hal_status_t | hal_uart_abort_transmit (uart_handle_t *p_uart) |
| Abort ongoing Transmit transfer (blocking mode). More...
|
|
hal_status_t | hal_uart_abort_receive (uart_handle_t *p_uart) |
| Abort ongoing Receive transfer (blocking mode). More...
|
|
hal_status_t | hal_uart_abort_it (uart_handle_t *p_uart) |
| Abort ongoing transfers (Interrupt mode). More...
|
|
hal_status_t | hal_uart_abort_transmit_it (uart_handle_t *p_uart) |
| Abort ongoing Transmit transfer (Interrupt mode). More...
|
|
hal_status_t | hal_uart_abort_receive_it (uart_handle_t *p_uart) |
| Abort ongoing Receive transfer (Interrupt mode). More...
|
|
UART Transmit/Receive functions.
===============================================================================
##### IO operation functions #####
===============================================================================
This subsection provides a set of functions allowing to manage the UART asynchronous
and Half duplex data transfers.
(#) There are two mode of transfer:
(++) Blocking mode: The communication is performed in polling mode.
The HAL status of all data processing is returned by the same function
after finishing transfer.
(++) Non-Blocking mode: The communication is performed using Interrupts
or DMA, These API's return the HAL status.
The end of the data processing will be indicated through the
dedicated UART IRQ when using Interrupt mode or the DMA IRQ when
using DMA mode.
The hal_uart_tx_cplt_callback(), hal_uart_rx_cplt_callback() user callbacks
will be executed respectively at the end of the transmit or Receive process
The hal_uart_error_callback() user callback will be executed when a
communication error is detected
(#) Blocking mode API's are :
(++) hal_uart_transmit()
(++) hal_uart_receive()
(#) Non-Blocking mode API's with Interrupt are :
(++) hal_uart_transmit_it()
(++) hal_uart_receive_it()
(++) hal_uart_irq_handler()
(#) Non-Blocking mode API's with DMA are :
(++) hal_uart_transmit_dma()
(++) hal_uart_receive_dma()
(++) hal_uart_dma_pause()
(++) hal_uart_dma_resume()
(++) hal_uart_dma_stop()
(#) A set of Transfer Complete Callbacks are provided in Non_Blocking mode:
(++) hal_uart_tx_cplt_callback()
(++) hal_uart_rx_cplt_callback()
(++) hal_uart_error_callback()
(#) Non-Blocking mode transfers could be aborted using Abort API's :
(++) hal_uart_abort()
(++) hal_uart_abort_transmit()
(++) hal_uart_abort_receive()
(++) hal_uart_abort_it()
(++) hal_uart_abort_transmit_it()
(++) hal_uart_abort_receive_it()
(#) For Abort services based on interrupts (hal_uart_abort_xxx_it), a set
of Abort Complete Callbacks are provided:
(++) hal_uart_abort_cplt_callback()
(++) hal_uart_abort_tx_cplt_callback()
(++) hal_uart_abort_rx_cplt_callback()
(#) In Non-Blocking mode transfers, possible errors are split into 2 categories.
Errors are handled as follows :
(++) Error is considered as Recoverable and non blocking. Transfer could go till end, but error severity is
to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error in Interrupt mode reception .
Received character is then retrieved and stored in Rx buffer, Error code is set to allow user to identify error type,
and hal_uart_error_callback() user callback is executed. Transfer is kept ongoing on UART side.
If user wants to abort it, Abort services should be called by user.
(++) Error is considered as Blocking : Transfer could not be completed properly and is aborted.
This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode.
Error code is set to allow user to identify error type, and hal_uart_error_callback() user callback is executed.
-@- In the Half duplex communication, it is forbidden to run the transmit
and receive process in parallel, the UART state hal_uart_state_busy_tx_rx can't be useful.
◆ hal_uart_abort()
Abort ongoing transfers (blocking mode).
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
- Note
- This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode. This procedure performs following operations :
- Disable UART Interrupts (Tx and Rx)
- Disable the DMA transfer in the peripheral register (if enabled)
- Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
- Set handle State to READY
-
This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
- Return values
-
◆ hal_uart_abort_it()
Abort ongoing transfers (Interrupt mode).
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
- Note
- This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode. This procedure performs following operations :
- Disable UART Interrupts (Tx and Rx)
- Disable the DMA transfer in the peripheral register (if enabled)
- Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
- Set handle State to READY
- At abort completion, call user abort complete callback
-
This procedure is executed in Interrupt mode, meaning that abort procedure could be considered as completed only when user abort complete callback is executed (not when exiting function).
- Return values
-
◆ hal_uart_abort_receive()
Abort ongoing Receive transfer (blocking mode).
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
- Note
- This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode. This procedure performs following operations :
- Disable UART Interrupts (Rx)
- Disable the DMA transfer in the peripheral register (if enabled)
- Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
- Set handle State to READY
-
This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
- Return values
-
◆ hal_uart_abort_receive_it()
Abort ongoing Receive transfer (Interrupt mode).
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
- Note
- This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode. This procedure performs following operations :
- Disable UART Interrupts (Rx)
- Disable the DMA transfer in the peripheral register (if enabled)
- Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
- Set handle State to READY
- At abort completion, call user abort complete callback
-
This procedure is executed in Interrupt mode, meaning that abort procedure could be considered as completed only when user abort complete callback is executed (not when exiting function).
- Return values
-
◆ hal_uart_abort_transmit()
Abort ongoing Transmit transfer (blocking mode).
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
- Note
- This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode. This procedure performs following operations :
- Disable UART Interrupts (Tx)
- Disable the DMA transfer in the peripheral register (if enabled)
- Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
- Set handle State to READY
-
This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
- Return values
-
◆ hal_uart_abort_transmit_it()
Abort ongoing Transmit transfer (Interrupt mode).
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
- Note
- This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode. This procedure performs following operations :
- Disable UART Interrupts (Tx)
- Disable the DMA transfer in the peripheral register (if enabled)
- Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
- Set handle State to READY
- At abort completion, call user abort complete callback
-
This procedure is executed in Interrupt mode, meaning that abort procedure could be considered as completed only when user abort complete callback is executed (not when exiting function).
- Return values
-
◆ hal_uart_dma_pause()
Pause the DMA Transfer.
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
- Return values
-
◆ hal_uart_dma_resume()
Resume the DMA Transfer.
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
- Return values
-
◆ hal_uart_dma_stop()
Stop the DMA Transfer.
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
- Return values
-
◆ hal_uart_receive()
Receive an amount of data in blocking mode.
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
[out] | p_data | Pointer to data buffer. |
[in] | size | Amount of data to be received. |
[in] | timeout | Timeout duration. |
- Return values
-
◆ hal_uart_receive_dma()
Receive an amount of data in DMA mode.
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
[out] | p_data | Pointer to data buffer. |
[in] | size | Amount of data to be received, ranging between 0 and 4095. |
- Note
- When the UART parity is enabled (PCE = 1), the received data contain the parity bit (MSB position).
-
This function starts a DMA transfer in interrupt mode meaning that DMA half transfer complete, DMA transfer complete and DMA transfer error interrupts are enabled
- Return values
-
◆ hal_uart_receive_it()
Receive an amount of data in interrupt mode.
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
[out] | p_data | Pointer to data buffer. |
[in] | size | Amount of data to be received. |
- Return values
-
◆ hal_uart_transmit()
Send an amount of data in blocking mode.
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
[in] | p_data | Pointer to data buffer. |
[in] | size | Amount of data to be sent. |
[in] | timeout | Timeout duration. |
- Return values
-
◆ hal_uart_transmit_dma()
Send an amount of data in DMA mode.
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
[in] | p_data | Pointer to data buffer. |
[in] | size | Amount of data to be sent, ranging between 0 ~ 4095. |
- Note
- This function starts a DMA transfer in interrupt mode meaning that DMA half transfer complete, DMA transfer complete and DMA transfer error interrupts are enabled
- Return values
-
◆ hal_uart_transmit_it()
Send an amount of data in interrupt mode.
- Parameters
-
[in] | p_uart | Pointer to a UART handle which contains the configuration information for the specified UART module. |
[in] | p_data | Pointer to data buffer. |
[in] | size | Amount of data to be sent. |
- Return values
-