From b2c6596657e77d62af92f1e5a92bebcc7ad98644 Mon Sep 17 00:00:00 2001 From: Manfred Steiner Date: Tue, 6 Aug 2024 10:04:24 +0200 Subject: [PATCH] Test-Software Makefile --- software/nano-644/test_2024-07-23/Makefile | 27 ++++++++++++++++--- .../test_2024-07-23/src/units/i2c.cpp | 6 ++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/software/nano-644/test_2024-07-23/Makefile b/software/nano-644/test_2024-07-23/Makefile index 8c5128c..dcb4370 100644 --- a/software/nano-644/test_2024-07-23/Makefile +++ b/software/nano-644/test_2024-07-23/Makefile @@ -2,11 +2,14 @@ $(shell mkdir -p dist >/dev/null) $(shell mkdir -p build >/dev/null) $(shell mkdir -p sim >/dev/null) +$(shell mkdir -p sim/build >/dev/null) NAME="test_2024-07-23_nano-644" SRC= $(wildcard src/*.c src/*.cpp src/*/*.cpp) -OBJ = $(SRC:src/%.c=build/%.o) -OBJ_SIM = $(SRC:src/%.c=sim/%.o) +OBJ_CPP = $(SRC:src/%.cpp=build/%.o) +OBJ = $(OBJ_CPP:src/%.c=build/%.o) +OBJ_SIM_CPP = $(SRC:src/%.cpp=sim/build/%.o) +OBJ_SIM = $(OBJ_SIM_CPP:src/%.c=sim/build/%.o) DEVICE=atmega644p @@ -19,7 +22,13 @@ LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -Wl,-u,vfprintf -lprin all: dist/$(NAME).elf dist/$(NAME).s dist/$(NAME).hex sim/$(NAME).elf sim/$(NAME).s info - + +dbg: + @echo "OBJ_CPP" $(OBJ_CPP) + @echo "OBJ" $(OBJ) + @echo "OBJ_SIM_CPP" $(OBJ_SIM_CPP) + @echo "OBJ_SIM" $(OBJ_SIM) + info: @echo @avr-size --mcu=$(DEVICE) --format=avr dist/$(NAME).elf @@ -43,9 +52,19 @@ sim/$(NAME).elf: .depend $(OBJ_SIM) build/%.o: src/%.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) -o $@ $< + +build/%.o: src/%.cpp + @mkdir -p $(dir $@) $(CC) $(CFLAGS) -o $@ $< -sim/%.o: src/%.c +sim/build/%.o: src/%.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS_SIM) -o $@ $< + +sim/build/%.o: src/%.cpp + @mkdir -p $(dir $@) $(CC) $(CFLAGS_SIM) -o $@ $< sim/%.s: sim/%.elf diff --git a/software/nano-644/test_2024-07-23/src/units/i2c.cpp b/software/nano-644/test_2024-07-23/src/units/i2c.cpp index 0c92e13..60dd22d 100644 --- a/software/nano-644/test_2024-07-23/src/units/i2c.cpp +++ b/software/nano-644/test_2024-07-23/src/units/i2c.cpp @@ -167,11 +167,11 @@ int8_t I2c::run (uint8_t subtest) { ADCSRA |= (1 << ADSC); // start ADC while (ADCSRA & (1 << ADSC)) {} // wait for result buffer[0] = ADCH; - printf_P(PSTR("\n write 0x%02x"), buffer[0]); + printf_P(PSTR("\n I2C-MASTER: to slave: 0x%02x"), buffer[0]); if (!master.write(buffer, 1)) { printf_P(PSTR(" -> ERROR")); } - printf_P(PSTR(", read ")); + printf_P(PSTR(", from slave: ")); if (master.read(buffer, 1)) { printf_P(PSTR("0x%02x"), buffer[0]); } else { @@ -191,7 +191,7 @@ int8_t I2c::run (uint8_t subtest) { ADCSRA |= (1 << ADSC); // start ADC while (ADCSRA & (1 << ADSC)) {} // wait for result slave.write(ADCH); - printf_P(PSTR("\n => from master: 0x%02x -> to master: 0x%02x"), fromMaster, ADCH); + printf_P(PSTR("\n I2C SLAVE: from master: 0x%02x -> to master: 0x%02x"), fromMaster, ADCH); } } while (wait(0) == EOF); slave.end(); -- 2.39.5