5.11.0.0R3
Software Development Kit
 
Loading...
Searching...
No Matches

Functions

wiced_result_t wiced_uart_deinit (wiced_uart_t uart)
 
wiced_result_t wiced_uart_init (wiced_uart_t uart, const wiced_uart_config_t *config, wiced_ring_buffer_t *optional_rx_buffer)
 
wiced_result_t wiced_uart_receive_bytes (wiced_uart_t uart, void *data, uint32_t *size, uint32_t timeout)
 
wiced_result_t wiced_uart_transmit_bytes (wiced_uart_t uart, const void *data, uint32_t size)
 

Detailed Description

Universal Asynchronous Receiver Transmitter (UART) Functions

Configuration and specifications of the UART depend on underlying platform, please refer to <WICED_SDK>/platforms/<platform_name>/platform.h and <WICED_SDK>/platforms/<platform_name>/platform.c for details.

Example Usage: (Check for return values in actual implementation)

 // Ring buffer (optional) is used to hold data received from UART
 ring_buffer_init(&rx_buffer, rx_data, RX_BUFFER_SIZE);

 // WICED_UART_1 is the UART Port
 // Uart ports are enumerated from WICED_UART_1 to WICED_UART_MAX
 // in <WICED_SDK>/platforms/<platform_name>/platform.h
 // Example uart_config
 wiced_uart_config_t uart_config =
 {
     .baud_rate    = 115200,
     .data_width   = DATA_WIDTH_8BIT,
     .parity       = NO_PARITY,
     .stop_bits    = STOP_BITS_1,
     .flow_control = FLOW_CONTROL_DISABLED,
 };
 // rx_buffer is optional buffer used to hold data received from UART
 wiced_uart_init( WICED_UART_1, &uart_config, &rx_buffer);

 // Done with initialization, now we can send/receive data
 wiced_uart_transmit_bytes( WICED_UART_1, tx_data, tx_data_size );
 wiced_uart_receive_bytes( WICED_UART_1, &rx_data, &rx_data_size, timeout_in_ms )

Refer to <WICD_SDK>/apps/snip/uart/uart.c for example usage.

Function Documentation

◆ wiced_uart_deinit()

wiced_result_t wiced_uart_deinit ( wiced_uart_t uart)

Deinitializes a UART interface

Parameters
[in]uart: The interface which should be deinitialized platform header file enumerates interfaces from WICED_UART_0 to WICED_UART_MAX.
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred with any step

◆ wiced_uart_init()

wiced_result_t wiced_uart_init ( wiced_uart_t uart,
const wiced_uart_config_t * config,
wiced_ring_buffer_t * optional_rx_buffer )

Initializes a UART interface

Prepares an UART hardware interface for communications

Parameters
[in]uart: The interface which should be initialized, platform header file enumerates interfaces from WICED_UART_0 to WICED_UART_MAX.
[in]config: UART configuration structure defined in WICED/platform/include/platform_peripheral.h
[in]optional_rx_buffer: Pointer to an optional RX ring buffer
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred with any step

◆ wiced_uart_receive_bytes()

wiced_result_t wiced_uart_receive_bytes ( wiced_uart_t uart,
void * data,
uint32_t * size,
uint32_t timeout )

Receive data on a UART interface. For interactive reading of bytes, the recommendation is to read one byte at a time, as some platforms will only return data when the amount of data available to read is greater than or equal to the passed in size.

Parameters
[in]uart: The UART interface, platform header file enumerates UART interfaces from WICED_UART_0 to WICED_UART_MAX.
[out]data: Pointer to the buffer which will store incoming data
[in,out]size: Specifies number of bytes to receive; returns number bytes received and placed in the data buffer
[in]timeout: Timeout in milliseconds WICED_WAIT_FOREVER and WICED_NO_WAIT can be specified for infinite and no wait.
Returns
WICED_SUCCESS : on success.
WICED_TIMEOUT : the operation timed out. size is set to the number of valid bytes returned in the buffer (may be 0).
WICED_ERROR : if another error occurred with any step

◆ wiced_uart_transmit_bytes()

wiced_result_t wiced_uart_transmit_bytes ( wiced_uart_t uart,
const void * data,
uint32_t size )

Transmit data on a UART interface

Parameters
[in]uart: The UART interface, platform header file enumerates UART interfaces from WICED_UART_0 to WICED_UART_MAX.
[in]data: Pointer to the start of data
[in]size: Number of bytes to transmit
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred with any step