DEBUG macro in uart.h, enabled by default in makefile
This commit is contained in:
parent
3cb2df2468
commit
78e3ddce19
2 changed files with 16 additions and 0 deletions
3
makefile
3
makefile
|
@ -11,6 +11,9 @@ QEMU_MACHINE_NAME = uno
|
|||
# Compiler flags
|
||||
CFLAGS = -std=c2x -Wall -Wno-array-bounds -mmcu=$(MCU) -DF_CPU=16000000UL -O3
|
||||
|
||||
# Comment the following line to disable UART debugging (see uart.h)
|
||||
CFLAGS += -DDEBUG_UART_ENABLED
|
||||
|
||||
# Source files
|
||||
SRCS = $(wildcard *.c)
|
||||
|
||||
|
|
13
uart.h
13
uart.h
|
@ -1,7 +1,20 @@
|
|||
#pragma once
|
||||
// Simple UART library for ATmega328P
|
||||
|
||||
// Define DEBUG_UART_ENABLED to enable debug messages
|
||||
#ifdef DEBUG_UART_ENABLED
|
||||
#define DEBUG(message) UART_println(message)
|
||||
#else
|
||||
#define DEBUG(message) ((void)0) // Define as no operation (NOP)
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Initialize UART
|
||||
void initUART();
|
||||
|
||||
// Transmit a byte over UART
|
||||
void UART_transmit(uint8_t data);
|
||||
|
||||
// Print a formatted string over UART
|
||||
void UART_println(const char* format, ...);
|
Loading…
Reference in a new issue