Infineon Logo AIROC BTSDK v4.2 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Peripheral UART (PUART)

Defines a driver to facilitate interfacing with the UART hardware to send and receive bytes or a stream of bytes over the UART hardware. More...

Functions

void wiced_hal_puart_init (void)
 Initialize the Peripheral UART interface with the default configuration parameters. More...
 
void wiced_hal_puart_flow_on (void)
 Enable flow control. More...
 
void wiced_hal_puart_flow_off (void)
 Disable flow control. More...
 
uint32_t wiced_hal_puart_select_uart_pads (uint8_t rxdPin, uint8_t txdPin, uint8_t ctsPin, uint8_t rtsPin)
 Select the TX/RX and optional CTS/RTS pins (P<pin>) for the UART hardware to use. More...
 
void wiced_hal_puart_print (char *string)
 Print/send a string of characters via the TX line. More...
 
void wiced_hal_puart_write (uint8_t byte)
 Print/send one byte via the TX line. More...
 
uint32_t wiced_hal_puart_read (uint8_t *rxByte)
 Read one byte via the RX line. More...
 
void wiced_hal_puart_disable_tx (void)
 Disable transmit capability. More...
 
void wiced_hal_puart_enable_tx (void)
 Enable transmit capability. More...
 
void wiced_hal_puart_enable_rx (void)
 Enable receive capability (specifically, by enabling PUART RX interrupts through the MIA driver). More...
 
void wiced_hal_puart_set_baudrate (uint32_t baudrate)
 Set the baud rate (Bd) to a value other than the default 115200 Bd. More...
 
void wiced_hal_puart_synchronous_read (uint8_t *buffer, uint32_t length)
 Read in a set of bytes sequentially. More...
 
void wiced_hal_puart_synchronous_write (uint8_t *buffer, uint32_t length)
 Write a set of bytes sequentially. More...
 
uint32_t wiced_hal_puart_rx_fifo_not_empty (void)
 Check to see if there is any data ready in the RX FIFO. More...
 
void wiced_hal_puart_reset_puart_interrupt (void)
 Clears and enables PUART interrupt. More...
 
void wiced_hal_puart_register_interrupt (void(*puart_rx_cbk)(void *))
 Register Interrupt handler with PUART. More...
 
void wiced_hal_puart_set_watermark_level (uint32_t watermark_level)
 updates the watermark level to the received value More...
 
wiced_result_t wiced_hal_puart_register_sleep_callbacks (void)
 registers puart pre and post sleep callbacks More...
 
wiced_bool_t wiced_hal_puart_configuration (uint32_t baudrate, parity_t parity, stop_bit_t stop_bit)
 updates the parity and stop bits as per received value More...
 

Detailed Description

Defines a driver to facilitate interfacing with the UART hardware to send and receive bytes or a stream of bytes over the UART hardware.

Typical use-cases involve printing messages over UART/RS-232, or to communicate with peripheral devices.

Example Usage:

void testPUARTDriver(void)
{
uint8_t readbyte;
uint8_t loopCtrl = 1;
char printBuffer[50];
//Pins for PUART should be configured from wiced_platform_pin_config.c
wiced_hal_puart_flow_off(); //turn off flow control
while(loopCtrl)
{
while(wiced_hal_puart_read(&readbyte))
{
if(readbyte == 'S')
{
wiced_hal_puart_print("\nYou typed 'S'.");
sprintf(printBuffer, "\nThis message sprintf'ed here.");
wiced_hal_puart_print(printBuffer);
}
if(readbyte == 'E') // End.
{
loopCtrl = 0;
}
}
}
}

Function Documentation

wiced_bool_t wiced_hal_puart_configuration ( uint32_t  baudrate,
parity_t  parity,
stop_bit_t  stop_bit 
)

updates the parity and stop bits as per received value

Parameters
baudrate- Desired rate in symbols/sec ex. 9600
parity- PARITY_ODD for odd parity, PARITY_EVEN for even parity, PARITY_NONE for no parity.
stop_bit- STOP_BIT_1 for 1 stop bit, STOP_BIT_2 for 2 stop bits.
Returns
wiced_bool_t - WICED_TRUE if the configuration was successfully set, otherwise WICED_FALSE. NOTE: For baudrate greater than 2.727272 Mb/sec use of 2 stop bits is mandatory due to hardware limitation.
void wiced_hal_puart_disable_tx ( void  )

Disable transmit capability.

Parameters
none
Returns
none
void wiced_hal_puart_enable_rx ( void  )

Enable receive capability (specifically, by enabling PUART RX interrupts through the MIA driver).

Parameters
none
Returns
none
void wiced_hal_puart_enable_tx ( void  )

Enable transmit capability.

Parameters
none
Returns
none
void wiced_hal_puart_flow_off ( void  )

Disable flow control.

Parameters
none
Returns
none
void wiced_hal_puart_flow_on ( void  )

Enable flow control.

Parameters
none
Returns
none
void wiced_hal_puart_init ( void  )

Initialize the Peripheral UART interface with the default configuration parameters.

This must be invoked once at boot before using any of PUART's services.

Default baud rate is 115200 Bd. This can be changed by calling "wiced_hal_puart_set_baudrate()" as described later, after this initialization function.

Parameters
none
Returns
none

This must be invoked once at boot before using any of PUART's services.

Default baud rate is 115200 Bd. This can be changed by calling "wiced_hal_puart_configuration()" as described later, after this initialization function.

Parameters
none
Returns
none
void wiced_hal_puart_print ( char *  string)

Print/send a string of characters via the TX line.

Parameters
string- A string of characters to send.
Returns
none
wiced_bool_t wiced_hal_puart_read ( uint8_t *  rxByte)

Read one byte via the RX line.

Parameters
rxByte- Destination byte to hold received data byte from RX FIFO.
Returns
TRUE if data was successfully read, FALSE if not (RX FIFO was empty).
void wiced_hal_puart_register_interrupt ( void(*)(void *)  puart_rx_cbk)

Register Interrupt handler with PUART.

Parameters
puart_rx_cbk- Call back function to process rx bytes
Returns
none
wiced_result_t wiced_hal_puart_register_sleep_callbacks ( void  )

registers puart pre and post sleep callbacks

Parameters
none
Returns
none
void wiced_hal_puart_reset_puart_interrupt ( void  )

Clears and enables PUART interrupt.

Parameters
none
Returns
none
wiced_bool_t wiced_hal_puart_rx_fifo_not_empty ( void  )

Check to see if there is any data ready in the RX FIFO.

Parameters
none
Returns
TRUE if bytes are avaliable, FALSE if the FIFO is empty.
wiced_bool_t wiced_hal_puart_select_uart_pads ( uint8_t  rxdPin,
uint8_t  txdPin,
uint8_t  ctsPin,
uint8_t  rtsPin 
)

Select the TX/RX and optional CTS/RTS pins (P<pin>) for the UART hardware to use.

Please follow the guidelines set in the User Documentation when selecting pins, as not all pins are avaliable for the PUART driver; they depend on the specific hardware platform.

Remember that P# is the physical pin number on the board minus 1. Ex: Board Pin 33 = P32.

Parameters
rxdPin- RX Pin
txdPin- TX Pin
ctsPin- CTS Pin
rtsPin- RTS Pin
Returns
TRUE if pads were successfully set, FALSE if pads were not set. If FALSE, make sure input port/pin parameters are correct.
void wiced_hal_puart_set_baudrate ( uint32_t  baudrate)

Set the baud rate (Bd) to a value other than the default 115200 Bd.

Parameters
baudrate- Desired rate in symbols per second, e.g. 9600.
Returns
none
void wiced_hal_puart_set_watermark_level ( uint32_t  watermark_level)

updates the watermark level to the received value

Parameters
watermark_level- watermark level in bytes
Returns
none
void wiced_hal_puart_synchronous_read ( uint8_t *  buffer,
uint32_t  length 
)

Read in a set of bytes sequentially.

Parameters
buffer- Destination buffer to hold incoming bytes.
length- Number of bytes to read from the RX FIFO.
Returns
none
void wiced_hal_puart_synchronous_write ( uint8_t *  buffer,
uint32_t  length 
)

Write a set of bytes sequentially.

Parameters
buffer- Source buffer to hold outgoing bytes.
length- Number of bytes to write to the TX FIFO.
Returns
none
void wiced_hal_puart_write ( uint8_t  byte)

Print/send one byte via the TX line.

Parameters
byte- Byte to send on the TX line.
Returns
none