Wrapper for accessing built-in UART communication interfaces.
More...
|
file | uart.h |
| Wrapper for accessing built-in UART communication interfaces.
|
|
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.
◆ 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
-
baud | The 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 Uart & | instance () |
| Returns the Avr::Uart instance. More...
|
|
◆ instance()
◆ sendChar()
template<uint16_t baud>
void Avr::Uart< baud >::sendChar |
( |
unsigned char |
c | ) |
|
|
inline |
Transmits the character c
.
- Parameters
-
c | The 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
-
str | The 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
-
◆ 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
-
value | The unsigned integer value to be sent. |
radix | The 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
-
description | A null-terminated string describing the value . |
value | The unsigned integer value to be sent. |
radix | The 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
-
value | The double value to be sent. |