Logger class that outputs logs over USART.
More...
#include <logger.h>
|
void | sendChar (const char c) const |
| Transmit a single character over USART. More...
|
|
void | sendStr (const char *str) const |
| Transmit a string over USART. More...
|
|
|
static constexpr uint16_t | UBRR0_VALUE = F_CPU/(8*BAUD)-1 |
| UBRR0 value for initializing USART. More...
|
|
Logger class that outputs logs over USART.
- Authors
- Philipp Karg (phili.nosp@m.pp.k.nosp@m.arg@t.nosp@m.um.d.nosp@m.e)
- Date
- 02.06.2022
- Copyright
- Philipp Karg 2022
◆ init()
Initialize USART.
- Enable double speed.
- Set baud-rate in both UBRR registers with UBRR0_VALUE.
- Enable the transmitter.
- Set the data frame (8 data-bits, 1 stop-bit).
◆ operator()() [1/2]
void Logger::operator() |
( |
const char * |
str | ) |
const |
|
inline |
Functor to log a string.
- Parameters
-
[in] | str | (const char*): String to log. |
◆ operator()() [2/2]
void Logger::operator() |
( |
const uint8_t * |
arr, |
|
|
const uint8_t |
len |
|
) |
| const |
Functor to log an array of hex-values.
- Parameters
-
[in] | arr | (const uint8_t*): Array of hex values to log. |
[in] | len | (const uint8_t): Length of the array. |
◆ sendChar()
void Logger::sendChar |
( |
const char |
c | ) |
const |
|
private |
Transmit a single character over USART.
- Wait for an empty transmit buffer.
- Write
c
into the buffer.
- Parameters
-
[in] | c | (const char): Character to send. |
◆ sendStr()
void Logger::sendStr |
( |
const char * |
str | ) |
const |
|
private |
Transmit a string over USART.
Continuously call sendChar() and send each character of str
.
- Parameters
-
[in] | str | (const char*): String to send. |
◆ UBRR0_VALUE
constexpr uint16_t Logger::UBRR0_VALUE = F_CPU/(8*BAUD)-1 |
|
staticconstexprprivate |
UBRR0 value for initializing USART.
This value was found through trial and error. According to the data-sheet, this value should be calculated as the following: UBRR0 = f_clk/(16*BAUD) - 1 However this did not work with the provided clock-frequency of 3276800 in the manual.
The documentation for this class was generated from the following file: