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

Modules

Types
Hardware UART data types.
 

Functions

zos_result_t zn_uart_configure (zos_uart_t uart, const zos_uart_config_t *config, const zos_uart_buffer_t *buffer)
 Configure UART hardware. More...
 
zos_result_t zn_uart_get_configuration (zos_uart_t uart, zos_uart_config_t *config)
 Return a UART's current configuration. More...
 
zos_result_t zn_uart_update_baud (zos_uart_t uart, uint32_t baud)
 Update a UART's BAUD rate to the specified value. More...
 
zos_result_t zn_uart_transmit_bytes (zos_uart_t uart, const void *data, uint32_t size)
 Transmit data on a UART interface. More...
 
zos_result_t zn_uart_receive_bytes (zos_uart_t uart, void *data, uint32_t size, uint32_t timeout)
 Receive data on a UART interface. More...
 
uint32_t zn_uart_get_bytes_received (zos_uart_t uart)
 Get number of bytes read from previous zn_uart_receive_bytes() call.
 
zos_result_t zn_uart_peek_bytes (zos_uart_t uart, const uint8_t **data, uint16_t *byte_pending)
 View pending data and size (without actually reading data) More...
 
zos_result_t zn_uart_set_packet_mode (zos_uart_t uart, const zos_uart_mode_config_t *config)
 Change the data reception Mode. More...
 
zos_bool_t zn_uart_is_processing_packet (zos_uart_t uart)
 A rx data packet is being populated. More...
 
zos_result_t zn_uart_set_packet (zos_uart_t uart, void *data, uint16_t length)
 Add packet to hold rx data. More...
 
zos_result_t zn_uart_set_packet_timed_out (zos_uart_t uart)
 Signal that rx packet has timedout. More...
 
zos_uart_callback_t zn_uart_set_tx_processor (zos_uart_t uart, zos_uart_callback_t processor_callback)
 Register callback to periodically trigger will data is pending to be transmitted. More...
 
zos_uart_callback_t zn_uart_register_rx_callback (zos_uart_t uart, zos_uart_callback_t rx_callback)
 Register rx character callback. More...
 

Detailed Description

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

Function Documentation

zos_result_t zn_uart_configure ( zos_uart_t  uart,
const zos_uart_config_t config,
const zos_uart_buffer_t buffer 
)

Configure UART hardware.

Parameters
[in]uart: the UART interface
[in]config: UART configuration, see zos_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
zos_result_t result of API call
Examples:
basic/ftp_upload/ftp_upload.c, basic/uart/uart.c, demo/gps/main.c, demo/uart_blaster/uart_blaster.c, and sensors/range_finder/main.c.
zos_result_t zn_uart_get_configuration ( zos_uart_t  uart,
zos_uart_config_t config 
)

Return a UART's current configuration.

Parameters
zos_bool_t zn_uart_is_processing_packet ( zos_uart_t  uart)

A rx data packet is being populated.

zos_result_t zn_uart_peek_bytes ( zos_uart_t  uart,
const uint8_t **  data,
uint16_t *  byte_pending 
)

View pending data and size (without actually reading data)

Examples:
basic/ftp_upload/ftp_upload.c, basic/uart/uart.c, demo/gps/main.c, and sensors/range_finder/main.c.
zos_result_t zn_uart_receive_bytes ( zos_uart_t  uart,
void *  data,
uint32_t  size,
uint32_t  timeout 
)

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
[in]timeout: timeout in milisecond
Returns
zos_result_t result of API call
Examples:
basic/ftp_upload/ftp_upload.c, basic/http_methods/main.c, basic/uart/uart.c, demo/gps/main.c, demo/uart_blaster/uart_blaster.c, and sensors/range_finder/main.c.
zos_uart_callback_t zn_uart_register_rx_callback ( zos_uart_t  uart,
zos_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.
Parameters
uartzos_uart_t to register callback with
rx_callbackCallback to be called when uart has RX data
Returns
Previously registered callback
Examples:
basic/uart/uart.c, demo/uart_blaster/uart_blaster.c, and sensors/range_finder/main.c.
zos_result_t zn_uart_set_packet ( zos_uart_t  uart,
void *  data,
uint16_t  length 
)

Add packet to hold rx data.

zos_result_t zn_uart_set_packet_mode ( zos_uart_t  uart,
const zos_uart_mode_config_t config 
)

Change the data reception Mode.

zos_result_t zn_uart_set_packet_timed_out ( zos_uart_t  uart)

Signal that rx packet has timedout.

zos_uart_callback_t zn_uart_set_tx_processor ( zos_uart_t  uart,
zos_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 zn_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.

Parameters
uartzos_uart_t to register tx processor callback
processor_callbackCallback to be periodically called while UART data is waiting to be sent
Returns
Previously registered callback
zos_result_t zn_uart_transmit_bytes ( zos_uart_t  uart,
const void *  data,
uint32_t  size 
)

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.

zn_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
Returns
zos_result_t result of API call
Examples:
basic/http_methods/main.c, basic/uart/uart.c, and demo/uart_blaster/uart_blaster.c.
zos_result_t zn_uart_update_baud ( zos_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 specificied value.

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