orcus
Enumerations | Functions
uart.h File Reference

UART. More...

#include <stdint.h>

Enumerations

enum  Parity { NONE , ODD , EVEN }
 UART parity settings. More...
 

Functions

void uartConfigure (int baudRate, int bitsPerFrame, Parity parity, int stopBits)
 Configure UART parameters. More...
 
int uartGetc (bool isBlocking)
 Get a character from UART. More...
 
void uartPrintf (const char *format,...)
 printf over UART. More...
 
char uartPutc (char c, bool isBlocking)
 Output character over UART. More...
 
void uartSetEcho (bool isEnabled)
 Set UART echoing. More...
 

Enumeration Type Documentation

◆ Parity

enum Parity
Enumerator
NONE 

No parity bit.

ODD 

Odd parity bit.

EVEN 

Even parity bit.

Function Documentation

◆ uartConfigure()

void uartConfigure ( int  baudRate,
int  bitsPerFrame,
Parity  parity,
int  stopBits 
)

Configures UART parameters.

Example (115200 8N1):

uartConfigure(115200, 8, NONE, 1)
void uartConfigure(int baudRate, int bitsPerFrame, Parity parity, int stopBits)
Configure UART parameters.
@ NONE
No parity bit.
Definition: uart.h:14

◆ uartGetc()

int uartGetc ( bool  isBlocking)

Gets a single character from UART.

Parameters
isBlockingIf true, will wait for a character to become available, otherwise will return immediately if no character is in the input buffer.
Returns
The next character from the input buffer. If non-blocking operation is used and the buffer is empty, EOF.

◆ uartPrintf()

void uartPrintf ( const char *  format,
  ... 
)

As per the standard printf, with output directly to UART.

Note
This has a maximum output buffer of 256 bytes so you may be better off using the newlib printf.

◆ uartPutc()

char uartPutc ( char  c,
bool  isBlocking 
)

Outputs a single character over UART.

Parameters
cCharacter to output
isBlockingIf true will wait until the output buffer has space for this character, will fail fast if false
Returns
The character sent if successful. If non-blocking operation is used and the buffer is full, -1.

◆ uartSetEcho()

void uartSetEcho ( bool  isEnabled)

If enabled, uartGetc will echo any character received back out to the UART. This is handy when implementing a command line interface over UART.

Parameters
isEnabledIf true, UART echoing will be enabled.