UART driver support for hardware abstraction layer.
char buff[20];
rt_dev_t uart4;
ssize_t byteRead;
// init
uart4 = uart(4);
uart_open(uart4);
uart_setBaudSpeed(uart4, 115200);
uart_setBitConfig(uart4, 8, UART_BIT_PARITY_NONE, 1);
uart_enable(uart4);
// send and receive data
uart_write(uart4, "test\n", 5);
byteRead = uart_read(uart4, buff, 20); // reads up to 20 chars from uart 4 to buff and returns read byte count.
rt_dev_t uart_getFreeDevice();
Gives a free uart device number and opens it
int uart_open(rt_dev_t device);
Opens an uart
int uart_close(rt_dev_t device);
Closes an uart
int uart_enable(rt_dev_t device);
Enables the specified uart device
int uart_disable(rt_dev_t device);
Disables the specified uart device
int uart_setBaudSpeed(rt_dev_t device, uint32_t baudSpeed);
Sets the speed of receive and transmit
uint32_t uart_baudSpeed(rt_dev_t device);
Gets the true baud speed
uint32_t uart_effectiveBaudSpeed(rt_dev_t device);
Gets the effective baud speed
int uart_setBitConfig(rt_dev_t device, uint8_t bitLength, uint8_t bitParity, uint8_t bitStop);
Sets the configuration bit (bit length, stop bits, parity)
uint8_t uart_bitLength(rt_dev_t device);
Gets the bit length of the device
uint8_t uart_bitParity(rt_dev_t device);
Gets the uart parity mode
uint8_t uart_bitStop(rt_dev_t device);
Gets number of stop bit
ssize_t uart_write(rt_dev_t device, const char *data, size_t size);
Writes data to uart device
ssize_t uart_read(rt_dev_t device, char *data, size_t size_max);
Reads size_max
data received by uart device
size_t uart_datardy(rt_dev_t device);
Gets number of data that could be read (in sw buffer)
Device assignation, configuration, send and read data fully functional
Header file : uart.h