UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
Files | Functions

UART Peripheral Driver. More...

Files

file  uart.c
 UART Driver - uos3-proto board.
 

Functions

void UART_init (uint8_t uart_num, uint32_t baudrate)
 
char UART_getc (uint8_t uart_num)
 
void UART_putc (uint8_t uart_num, char c)
 
void UART_puts (uint8_t uart_num, char *str)
 
void UART_putb (uint8_t uart_num, char *str, uint32_t len)
 
bool UART_getc_nonblocking (uint8_t uart_num, char *c)
 
bool UART_putc_nonblocking (uint8_t uart_num, char c)
 
bool UART_puts_nonblocking (uint8_t uart_num, char *str)
 
bool UART_putb_nonblocking (uint8_t uart_num, char *str, uint32_t len)
 
bool UART_busy (uint8_t uart_num)
 
bool UART_charsAvail (uint8_t uart_num)
 

Detailed Description

UART Peripheral Driver.

Hardware UART Peripheral Driver.

UART ports for each board are defined in ${board}/board.h

Function Documentation

void UART_init ( uint8_t  uart_num,
uint32_t  baudrate 
)

Initialises the specified UART peripheral at the given baudrate.

Parameters
uart_numID of the UART peripheral
baudratebuadrate to be used on the UART peripheral

Public Functions

Definition at line 78 of file uart.c.

char UART_getc ( uint8_t  uart_num)

Retrieves a byte from the RX FIFO of the specified UART peripheral, waits for a byte if RX FIFO is empty.

Parameters
uart_numID of the UART peripheral
Returns
byte received from UART peripheral

Definition at line 113 of file uart.c.

void UART_putc ( uint8_t  uart_num,
char  c 
)

Sends a byte from the specified UART peripheral, waits to send if TX FIFO is full.

Parameters
uart_numID of the UART peripheral
cbyte to send

Definition at line 121 of file uart.c.

void UART_puts ( uint8_t  uart_num,
char *  str 
)

Sends a null-terminated string from the specified UART peripheral, waits to send if TX FIFO is full.

Parameters
uart_numID of the UART peripheral
strpointer to the string to send

Definition at line 129 of file uart.c.

void UART_putb ( uint8_t  uart_num,
char *  str,
uint32_t  len 
)

Sends a buffer from the specified UART peripheral, waits to send if TX FIFO is full.

Parameters
uart_numID of the UART peripheral
strpointer to the string to send
lennumber of bytes in the buffer to send

Definition at line 137 of file uart.c.

bool UART_getc_nonblocking ( uint8_t  uart_num,
char *  c 
)

Retrieves a byte from the RX FIFO of the specified UART peripheral, returns if RX FIFO is empty.

Parameters
uart_numID of the UART peripheral
cpointer to a variable for the received byte
Returns
true if a byte was retrieved, false otherwise

Definition at line 145 of file uart.c.

bool UART_putc_nonblocking ( uint8_t  uart_num,
char  c 
)

Sends a byte from the specified UART peripheral,, returns if TX FIFO is full.

Parameters
uart_numID of the UART peripheral
cbyte to send
Returns
true if the byte was sent, false otherwise

Definition at line 163 of file uart.c.

bool UART_puts_nonblocking ( uint8_t  uart_num,
char *  str 
)

Sends a null-terminated string from the specified UART peripheral, returns if TX FIFO is full.

Parameters
uart_numID of the UART peripheral
strpointer to the string to send
Returns
true if the string was sent, false otherwise

Definition at line 171 of file uart.c.

bool UART_putb_nonblocking ( uint8_t  uart_num,
char *  str,
uint32_t  len 
)

Sends a buffer from the specified UART peripheral, returns if TX FIFO is full.

Parameters
uart_numID of the UART peripheral
strpointer to the string to send
lennumber of bytes in the buffer to send
Returns
true if the string was sent, false otherwise

Definition at line 183 of file uart.c.

bool UART_busy ( uint8_t  uart_num)

Retrieves the TX FIFO status of the specified UART peripheral.

Parameters
uart_numID of the UART peripheral
Returns
true if there are bytes waiting in the TX FIFO, false otherwise

Definition at line 195 of file uart.c.

bool UART_charsAvail ( uint8_t  uart_num)

Retrieves the RX FIFO status of the specified UART peripheral.

Parameters
uart_numID of the UART peripheral
Returns
true if there are bytes waiting in the RX FIFO, false otherwise

Definition at line 203 of file uart.c.