diff --git a/makefile b/makefile index aa20177..41ecf40 100644 --- a/makefile +++ b/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) diff --git a/uart.h b/uart.h index 5dcbf52..dfa0cc4 100644 --- a/uart.h +++ b/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 +// 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, ...); \ No newline at end of file