9#ifndef INCLUDE_INCLUDE_LOG_H_
10#define INCLUDE_INCLUDE_LOG_H_
15#define LOG_LEVEL_NONE 0
16#define LOG_LEVEL_CRITICAL 1
17#define LOG_LEVEL_ERROR 2
18#define LOG_LEVEL_INFO 3
21#define LOG_LEVEL LOG_LEVEL_INFO
24static const char log_prefix_critical[]
PROGMEM =
"CRITICAL: ";
25static const char log_prefix_info[]
PROGMEM =
"INF: ";
26static const char log_prefix_error[]
PROGMEM =
"ERR: ";
27static const char log_colon_space[]
PROGMEM =
": ";
28static const char log_newline[]
PROGMEM =
"\r\n";
33 while ((c = pgm_read_byte(p++)) != 0) {
38#if LOG_LEVEL > LOG_LEVEL_NONE
39#define LOG_MODULE_DEFINE(name) \
40 static const char _log_module_name[] PROGMEM = name
42#define LOG_MODULE_DEFINE(name)
45#if LOG_LEVEL >= LOG_LEVEL_CRITICAL
46#define LOG_CRITICAL(msg) \
48 _log_print_P(log_prefix_critical); \
49 _log_print_P(_log_module_name); \
50 _log_print_P(log_colon_space); \
51 USART_SendString(msg); \
52 _log_print_P(log_newline); \
55#define LOG_CRITICAL(msg) ((void)0)
58#if LOG_LEVEL >= LOG_LEVEL_INFO
61 _log_print_P(log_prefix_info); \
62 _log_print_P(_log_module_name); \
63 _log_print_P(log_colon_space); \
64 USART_SendString(msg); \
65 _log_print_P(log_newline); \
68#define LOG_INF(msg) ((void)0)
71#if LOG_LEVEL >= LOG_LEVEL_ERROR
72#define LOG_ERR(msg, status) \
74 _log_print_P(log_prefix_error); \
75 _log_print_P(_log_module_name); \
76 _log_print_P(log_colon_space); \
77 USART_SendString(msg); \
78 _log_print_P(log_newline); \
79 STATUS_ASSERT(status); \
82#define LOG_ERR(msg, status) ((void)0)
static const char log_prefix_critical[] PROGMEM
static void _log_print_P(PGM_P p)
int USART_Transmit(unsigned char data)
Transmit a single byte via USART0.
UART communication driver.
Utility and helper functions for joystick, LED debugging, and mapping.