Commit b2c6596657e77d62af92f1e5a92bebcc7ad98644
receivedTue, 6. Aug 2024, 10:04:30 (by user sx)
Tue, 6 Aug 2024 08:04:30 +0000 (10:04 +0200)
authorManfred Steiner <sx@htl-kaindorf.at>
Tue, 6 Aug 2024 08:04:24 +0000 (10:04 +0200)
committerManfred Steiner <sx@htl-kaindorf.at>
Tue, 6 Aug 2024 08:04:24 +0000 (10:04 +0200)
2 files changed:
software/nano-644/test_2024-07-23/Makefile
software/nano-644/test_2024-07-23/src/units/i2c.cpp

index 8c5128c01a2738386e99aea3df5048318b5f301b..dcb4370c867876dee2b6e135ec713d1e3ca1924c 100644 (file)
@@ -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
index 0c92e13601464d1484fca18ccaa79d019fef5737..60dd22de2ff7cc3badca1425b64a3e87fcb462c5 100644 (file)
@@ -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();