Loading...
Searching...
No Matches
Interface

UART interface from which external peripherals inherit. More...

Data Structures

struct  UART_Config
 
struct  UART_t
 Struct definition for UART interface. More...
 

Enumerations

enum  UART_OversampleMode
 UART oversampling mode enum. More...
 
enum  UART_WordLength
 UART word length enum. More...
 
enum  UART_Wake
 UART wake up method enum. More...
 
enum  UART_ParitySelect
 UART parity selection enum. More...
 
enum  UART_ReceiverWake
 UART receiver wake up enum. More...
 

Functions

UART_t UART_init (USART_TypeDef *interface, uint32_t baud, UART_Config *config)
 Initialiser for a UART device interface.
 
void UART_updateConfig (UART_t *, UART_Config *)
 Update UART peripheral configuration.
 
void UART_send (UART_t *, uint8_t data)
 Sends a single byte of data over the UART interface.
 
void UART_sendBytes (UART_t *, uint8_t *data, int length)
 Sends an array of bytes over the UART interface.
 
void UART_print (UART_t *, char *data)
 Sends a null terminated string over the UART interface.
 
void UART_println (UART_t *, char *data)
 Sends a null terminated string over the UART interface. Terminates with a line feed control character \n.
 
uint8_t UART_receive (UART_t *)
 Receives a single byte of data from the UART interface.
 

Detailed Description

UART interface from which external peripherals inherit.


Data Structure Documentation

◆ UART_Config

struct UART_Config

Definition at line 110 of file uart.h.

Data Fields
bool SBK: 1 | (default )
UART_ReceiverWake RWU: 1 | (default )
bool RE: 1 | (default )
bool TE: 1 | (default )
bool IDLEIE: 1 | (default )
bool RXNEIE: 1 | (default )
bool TCIE: 1 | (default )
bool TXEIE: 1 | (default )
bool PEIE: 1 | (default )
UART_ParitySelect PS: 1 | (default )
bool PCE: 1 | (default )
UART_Wake WAKE: 1 | (default )
UART_WordLength M: 1 | (default )
bool UE: 1 | (default )
unsigned int: 1 RESERVED.
UART_OversampleMode OVER8: 1 | (default )

◆ UART_t

struct UART_t

Struct definition for UART interface.

Definition at line 132 of file uart.h.

Data Fields
USART_TypeDef * interface
UART_Config config
uint32_t baud
UART_OversampleMode over8
void(*)(struct UART *, uint32_t) setBaud
void(*)(struct UART *, uint8_t) send UART send method.
See also
UART_send
void(*)(struct UART *, uint8_t *, int) sendBytes UART send multiple bytes method.
See also
UART_sendBytes
void(*)(struct UART *, char *) print UART print string method.
See also
UART_print
void(*)(struct UART *, char *) println UART print line method.
See also
UART_print
uint8_t(*)(struct UART *) receive UART receive method.
See also
UART_receive

Enumeration Type Documentation

◆ UART_OversampleMode

UART oversampling mode enum.

Describes the number of bits to use in oversampling

Definition at line 69 of file uart.h.

◆ UART_WordLength

UART word length enum.

Describes the number of bits to use in data word

Definition at line 78 of file uart.h.

◆ UART_Wake

enum UART_Wake

UART wake up method enum.

Describes

Definition at line 87 of file uart.h.

◆ UART_ParitySelect

UART parity selection enum.

Describes odd/even parity type when parity is enabled

Definition at line 96 of file uart.h.

◆ UART_ReceiverWake

UART receiver wake up enum.

Describes if the UART is in mute mode or not

Definition at line 105 of file uart.h.

Function Documentation

◆ UART_init()

UART_t UART_init ( USART_TypeDef * interface,
uint32_t baud,
UART_Config * config )

Initialiser for a UART device interface.

Parameters
*interfacePointer to UART interface struct.
baudUART baud rate.
*configPointer to UART configuration struct.
Returns
Initialised UART_t driver struct.

Definition at line 27 of file uart.c.

◆ UART_updateConfig()

void UART_updateConfig ( UART_t * uart,
UART_Config * config )

Update UART peripheral configuration.

Uses the provided configuration to update the UART registers and resets the associated peripheral. As with initialisation, passing NULL will set the default config.

Parameters
uartPointer to UART_t struct.
Returns
NULL.

Definition at line 207 of file uart.c.

◆ UART_send()

void UART_send ( UART_t * uart,
uint8_t data )

Sends a single byte of data over the UART interface.

Parameters
*uartPointer to UART struct.
dataByte of data to be sent.
Returns
NULL.

Definition at line 127 of file uart.c.

◆ UART_sendBytes()

void UART_sendBytes ( UART_t * uart,
uint8_t * data,
int length )

Sends an array of bytes over the UART interface.

Parameters
*uartPointer to UART struct.
*dataPointer to the array of bytes to be sent.
lengthNumber of bytes to send.
Returns
NULL.

Definition at line 144 of file uart.c.

◆ UART_print()

void UART_print ( UART_t * uart,
char * data )

Sends a null terminated string over the UART interface.

Parameters
*uartPointer to UART struct.
*dataPointer to the string of characters to be sent.
Returns
NULL.

Definition at line 159 of file uart.c.

◆ UART_println()

void UART_println ( UART_t * uart,
char * data )

Sends a null terminated string over the UART interface. Terminates with a line feed control character \n.

Parameters
*uartPointer to UART struct.
*dataPointer to the string of characters to be sent.
Returns
NULL.

Definition at line 176 of file uart.c.

◆ UART_receive()

uint8_t UART_receive ( UART_t * uart)

Receives a single byte of data from the UART interface.

Parameters
*uartPointer to UART struct.
Returns
The received byte of data.

Definition at line 189 of file uart.c.