atMETEO
An ATmega based weather station
Files | Classes

Wrapper for accessing built-in UART communication interfaces. More...

Collaboration diagram for UART module:

Files

file  uart.h
 Wrapper for accessing built-in UART communication interfaces.
 

Classes

class  Avr::Uart< baud >
 A C++ wrapper for accessing the built-in UART communication interfaces. More...
 

Detailed Description

Wrapper for accessing built-in UART communication interfaces.

Avr::Uart is a template class implementing a C++ wrapper for accessing the built-in UART communication interfaces.


Class Documentation

◆ Avr::Uart

class Avr::Uart

template<uint16_t baud>
class Avr::Uart< baud >

A C++ wrapper for accessing the built-in UART communication interfaces.

Usage:

uart.sendString("Hello UART!");

This template must not be instantiated more than once.

Template Parameters
baudThe baud rate used for the transmission.
Note
Avr::Uart is currently limited to data transmission.
The implementation is based on avr-uart (https://github.com/andygock/avr-uart).
Warning
Sending data has to be used with care in program parts where interrupts are disabled. The data is added to a send buffer and transmitted only when interrupts are enabled. This leads to deadlock when the send buffer becomes full.

Public Member Functions

void sendChar (unsigned char c)
 Transmits the character c. More...
 
void sendString (const char *str)
 Transmits the null-terminated string str. More...
 
void sendLine (const char *str)
 Transmits the null-terminated string str followed by a new line character. More...
 
void sendUInt (uint32_t value, uint8_t radix=10)
 Transmits the string representation of the unsigned integer value. More...
 
void sendValue (const char *description, uint32_t value, uint8_t radix=10)
 Transmits the string representation of the unsigned integer value and its description. More...
 
void sendDouble (double value)
 Transmits the string representation of the double value. More...
 

Static Public Member Functions

static Uartinstance ()
 Returns the Avr::Uart instance. More...
 

Member Function Documentation

◆ instance()

template<uint16_t baud>
static Uart& Avr::Uart< baud >::instance ( )
inlinestatic

Returns the Avr::Uart instance.

Returns
The Avr::Uart instance.

◆ sendChar()

template<uint16_t baud>
void Avr::Uart< baud >::sendChar ( unsigned char  c)
inline

Transmits the character c.

Parameters
cThe character to be sent.

◆ sendString()

template<uint16_t baud>
void Avr::Uart< baud >::sendString ( const char *  str)
inline

Transmits the null-terminated string str.

Parameters
strThe null-terminated string to be sent.

◆ sendLine()

template<uint16_t baud>
void Avr::Uart< baud >::sendLine ( const char *  str)
inline

Transmits the null-terminated string str followed by a new line character.

Parameters
strThe line to be sent.

◆ sendUInt()

template<uint16_t baud>
void Avr::Uart< baud >::sendUInt ( uint32_t  value,
uint8_t  radix = 10 
)
inline

Transmits the string representation of the unsigned integer value.

Parameters
valueThe unsigned integer value to be sent.
radixThe radix for the number conversion.

◆ sendValue()

template<uint16_t baud>
void Avr::Uart< baud >::sendValue ( const char *  description,
uint32_t  value,
uint8_t  radix = 10 
)
inline

Transmits the string representation of the unsigned integer value and its description.

The transmission format is <description>: <value>.

Parameters
descriptionA null-terminated string describing the value.
valueThe unsigned integer value to be sent.
radixThe radix for the number conversion.
See also
sendUInt

◆ sendDouble()

template<uint16_t baud>
void Avr::Uart< baud >::sendDouble ( double  value)
inline

Transmits the string representation of the double value.

The transmission format is [sign]dddd.dd.

Parameters
valueThe double value to be sent.