Functions for using Universal Asynchronous Receive/Transmit (UART) peripheral. More...

Modules

Types
Hardware UART data types.
 

Functions

gos_result_t gos_uart_configure (gos_uart_t uart, const gos_uart_config_t *config, const gos_buffer_t *buffer)
 Configure UART hardware. More...
 
gos_result_t gos_uart_get_configuration (gos_uart_t uart, gos_uart_config_t *config)
 Return a UART's current configuration. More...
 
gos_result_t gos_uart_update_baud (gos_uart_t uart, uint32_t baud)
 Update a UART's BAUD rate to the specified value. More...
 
gos_result_t gos_uart_transmit_bytes (gos_uart_t uart, const void *data, uint32_t size, uint32_t *bytes_written_ptr, uint32_t timeout_ms)
 Transmit data on a UART interface. More...
 
gos_result_t gos_uart_receive_bytes (gos_uart_t uart, void *data, uint32_t size, uint32_t *bytes_read_ptr, uint32_t timeout_ms)
 Receive data on a UART interface. More...
 
gos_result_t gos_uart_peek_bytes (gos_uart_t uart, const uint8_t **data_ptr, uint32_t *byte_pending)
 View pending data and size (without actually reading data)
 
gos_result_t gos_uart_set_tx_processor (gos_uart_t uart, gos_uart_callback_t processor_callback)
 Register callback to periodically trigger will data is pending to be transmitted. More...
 
gos_result_t gos_uart_clear_tx_processor (gos_uart_t uart, gos_uart_callback_t processor_callback)
 Unregister periodic callback to gos_uart_callback_t processor_callback. More...
 
gos_result_t gos_uart_set_rx_callback (gos_uart_t uart, gos_uart_callback_t rx_callback)
 Register rx character callback. More...
 
gos_result_t gos_uart_clear_rx_callback (gos_uart_t uart, gos_uart_callback_t rx_callback)
 Unregister rx character callback. More...
 

Detailed Description

Functions for using Universal Asynchronous Receive/Transmit (UART) peripheral.

Function Documentation

◆ gos_uart_clear_rx_callback()

gos_result_t gos_uart_clear_rx_callback ( gos_uart_t  uart,
gos_uart_callback_t  rx_callback 
)

Unregister rx character callback.

See also
gos_uart_set_rx_callback() for details on setting a callback.
Parameters
uartgos_uart_t to register callback with
rx_callbackCallback to be unregistered
Returns
gos_result_t result of API call

◆ gos_uart_clear_tx_processor()

gos_result_t gos_uart_clear_tx_processor ( gos_uart_t  uart,
gos_uart_callback_t  processor_callback 
)

Unregister periodic callback to gos_uart_callback_t processor_callback.

See also
gos_uart_set_tx_processor() for details on setting a callback.
Parameters
uartgos_uart_t to register tx processor callback
processor_callbackCallback to be unregistered
Returns
gos_result_t result of API call

◆ gos_uart_configure()

gos_result_t gos_uart_configure ( gos_uart_t  uart,
const gos_uart_config_t config,
const gos_buffer_t buffer 
)

Configure UART hardware.

Parameters
[in]uart: the UART interface
[in]config: UART configuration, see gos_uart_config_t
[in]buffer: RX ring buffer. Leave NULL for RX only if UART has not been previously configured. If the UART has already been configured, leave NULL to use previously supplied RX buffer.
Returns
gos_result_t result of API call

◆ gos_uart_get_configuration()

gos_result_t gos_uart_get_configuration ( gos_uart_t  uart,
gos_uart_config_t config 
)

Return a UART's current configuration.

Parameters
[in]uartThe UART for which to retrieve the config
configBuffer to hold configuration, see gos_uart_config_t
Returns
gos_result_t result of API call

◆ gos_uart_receive_bytes()

gos_result_t gos_uart_receive_bytes ( gos_uart_t  uart,
void *  data,
uint32_t  size,
uint32_t *  bytes_read_ptr,
uint32_t  timeout_ms 
)

Receive data on a UART interface.

Parameters
[in]uart: the UART interface
[out]data: pointer to the buffer which will store incoming data
[in]size: number of bytes to receive
[out]bytes_read_ptr: Number of bytes read, optional, leave NULL if unused
[in]timeout_ms: timeout in milisecond
Returns
gos_result_t result of API call

◆ gos_uart_set_rx_callback()

gos_result_t gos_uart_set_rx_callback ( gos_uart_t  uart,
gos_uart_callback_t  rx_callback 
)

Register rx character callback.

Note
The callback executes in the UART IRQ. The callback MUST be very lightweight and do minimal processing.
Call gos_uart_clear_rx_callback() to disable the callback
gos_uart_configure() should be called at least once before setting a callback
Parameters
uartgos_uart_t to register callback with
rx_callbackCallback to be called when uart has RX data
Returns
gos_result_t result of API call

◆ gos_uart_set_tx_processor()

gos_result_t gos_uart_set_tx_processor ( gos_uart_t  uart,
gos_uart_callback_t  processor_callback 
)

Register callback to periodically trigger will data is pending to be transmitted.

If hardware flow control is used and the receiver is unable to immediately receive the data, the gos_uart_transmit_bytes() API will block. Every 100ms this callback will be called while the API blocks.

This is typically used to update system monitors.

Note
The callback executes in the UART IRQ. The callback MUST be very lightweight and do minimal processing.
Call gos_uart_clear_tx_processor() to disable the callback
gos_uart_configure() should be called at least once before setting a callback
Parameters
uartgos_uart_t to register tx processor callback
processor_callbackCallback to be periodically called while UART data is waiting to be sent
Returns
gos_result_t result of API call

◆ gos_uart_transmit_bytes()

gos_result_t gos_uart_transmit_bytes ( gos_uart_t  uart,
const void *  data,
uint32_t  size,
uint32_t *  bytes_written_ptr,
uint32_t  timeout_ms 
)

Transmit data on a UART interface.

This API blocked until all data has been transmitted. If hardware flow control is used, this could potentially block for an extended period of time if the receiver is unable to receive the data.

gos_uart_set_tx_processor() may be used to receive callbacks will the API blocks.

Parameters
[in]uart: the UART interface
[in]data: pointer to the start of data
[in]size: number of bytes to transmit
[out]bytes_written_ptr: Number of bytes written, optional, leave NULL if unused
[in]timeout_ms: Time in milliseconds to wait for write to complete before aborting
Returns
gos_result_t result of API call

◆ gos_uart_update_baud()

gos_result_t gos_uart_update_baud ( gos_uart_t  uart,
uint32_t  baud 
)

Update a UART's BAUD rate to the specified value.

This directly updates the given UART's BAUD rate to the specified value.

Parameters
[in]uart: the UART interface
[in]baud: BAUD rate to update UART
Returns
gos_result_t result of API call