ATmega644 Smart-Card
logger.h
1 
11 #ifndef LOGGER_H
12 #define LOGGER_H
13 
14 #include <string.h>
15 
16 #include "defs.h"
17 
26 class Logger
27 {
28 public:
32  Logger() = default;
33 
42  void init();
43 
48  void operator()(const char* str) const { sendStr(str); }
49 
55  void operator()(const uint8_t* arr, const uint8_t len) const;
56 
57 private:
66  static constexpr uint16_t UBRR0_VALUE = F_CPU/(8*BAUD)-1;
67 
76  void sendChar(const char c) const;
77 
84  void sendStr(const char* str) const;
85 };
86 
87 #endif // LOGGER_H
Logger::Logger
Logger()=default
Construct a new Logger object.
Logger::sendStr
void sendStr(const char *str) const
Transmit a string over USART.
Logger::init
void init()
Initialize USART.
Logger::operator()
void operator()(const char *str) const
Functor to log a string.
Definition: logger.h:48
Logger::UBRR0_VALUE
static constexpr uint16_t UBRR0_VALUE
UBRR0 value for initializing USART.
Definition: logger.h:66
Logger::sendChar
void sendChar(const char c) const
Transmit a single character over USART.
Logger
Logger class that outputs logs over USART.
Definition: logger.h:26