From a5984050eb556741ef40792d6335b7f65fa1eb4f Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Tue, 24 Jan 2023 14:58:52 -0600 Subject: started fixing makefile, created test function --- src/build/br24t_eeprom_driver.o | Bin 0 -> 756 bytes src/build/debug.o | Bin 0 -> 3572 bytes src/build/i2c.o | Bin 0 -> 2604 bytes src/build/main.o | Bin 0 -> 1624 bytes src/build/paint.o | Bin 0 -> 1536 bytes src/build/pcf_clock_driver.o | Bin 0 -> 752 bytes src/build/ssd1306_display_driver.o | Bin 0 -> 2188 bytes src/build/uart.o | Bin 0 -> 984 bytes src/compile_commands.json | 120 +++++++++++++++++++++---------------- src/i2c.c | 2 - src/main.c | 5 -- src/makefile | 24 ++++---- src/paint.c | 2 + src/ssd1306_display_driver.c | 8 +++ 14 files changed, 90 insertions(+), 71 deletions(-) create mode 100644 src/build/br24t_eeprom_driver.o create mode 100644 src/build/debug.o create mode 100644 src/build/i2c.o create mode 100644 src/build/main.o create mode 100644 src/build/paint.o create mode 100644 src/build/pcf_clock_driver.o create mode 100644 src/build/ssd1306_display_driver.o create mode 100644 src/build/uart.o diff --git a/src/build/br24t_eeprom_driver.o b/src/build/br24t_eeprom_driver.o new file mode 100644 index 0000000..8565140 Binary files /dev/null and b/src/build/br24t_eeprom_driver.o differ diff --git a/src/build/debug.o b/src/build/debug.o new file mode 100644 index 0000000..68832b3 Binary files /dev/null and b/src/build/debug.o differ diff --git a/src/build/i2c.o b/src/build/i2c.o new file mode 100644 index 0000000..ffcd173 Binary files /dev/null and b/src/build/i2c.o differ diff --git a/src/build/main.o b/src/build/main.o new file mode 100644 index 0000000..8b7594f Binary files /dev/null and b/src/build/main.o differ diff --git a/src/build/paint.o b/src/build/paint.o new file mode 100644 index 0000000..0861827 Binary files /dev/null and b/src/build/paint.o differ diff --git a/src/build/pcf_clock_driver.o b/src/build/pcf_clock_driver.o new file mode 100644 index 0000000..4b61851 Binary files /dev/null and b/src/build/pcf_clock_driver.o differ diff --git a/src/build/ssd1306_display_driver.o b/src/build/ssd1306_display_driver.o new file mode 100644 index 0000000..868b006 Binary files /dev/null and b/src/build/ssd1306_display_driver.o differ diff --git a/src/build/uart.o b/src/build/uart.o new file mode 100644 index 0000000..d68e15a Binary files /dev/null and b/src/build/uart.o differ diff --git a/src/compile_commands.json b/src/compile_commands.json index 7646b7a..67f3d54 100644 --- a/src/compile_commands.json +++ b/src/compile_commands.json @@ -3,16 +3,17 @@ "directory": "/home/indigo/projects/watch/src", "arguments": [ "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", - "-v", - "-mmcu=atmega2560", + "-c", "-I", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", - "-o", - "compiled_payload", + "-mmcu=atmega2560", + "-DDEBUG_BUILD=1", "-DBAUD=9600", "-DF_CPU=16000000", "-Wall", "-O1", + "-o", + "build/main.o", "main.c" ], "file": "main.c" @@ -21,21 +22,18 @@ "directory": "/home/indigo/projects/watch/src", "arguments": [ "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", - "-lc", - "-mmcu=atmega2560", + "-c", "-I", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", - "-o", - "compiled_payload.elf", + "-mmcu=atmega2560", "-DDEBUG_BUILD=1", "-DBAUD=9600", "-DF_CPU=16000000", "-Wall", "-O1", - "main.c", - "debug_serial.c", - "i2c.c", - "ssd1306_driver.h" + "-o", + "build/i2c.o", + "i2c.c" ], "file": "i2c.c" }, @@ -43,22 +41,18 @@ "directory": "/home/indigo/projects/watch/src", "arguments": [ "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", - "-mmcu=atmega2560", + "-c", "-I", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", - "-o", - "compiled_payload.elf", + "-mmcu=atmega2560", "-DDEBUG_BUILD=1", "-DBAUD=9600", "-DF_CPU=16000000", "-Wall", "-O1", - "main.c", - "debug.c", - "i2c.c", - "ssd1306_driver.c", - "uart.c", - "-Wall" + "-o", + "build/uart.o", + "uart.c" ], "file": "uart.c" }, @@ -66,23 +60,18 @@ "directory": "/home/indigo/projects/watch/src", "arguments": [ "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", - "-mmcu=atmega2560", + "-c", "-I", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", - "-o", - "compiled_payload.elf", + "-mmcu=atmega2560", "-DDEBUG_BUILD=1", "-DBAUD=9600", "-DF_CPU=16000000", "-Wall", "-O1", - "main.c", - "debug.c", - "i2c.c", - "ssd1306_display_driver.c", - "uart.c", - "br24t_eeprom_driver.c", - "-Wall" + "-o", + "build/br24t_eeprom_driver.o", + "br24t_eeprom_driver.c" ], "file": "br24t_eeprom_driver.c" }, @@ -90,24 +79,18 @@ "directory": "/home/indigo/projects/watch/src", "arguments": [ "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", - "-mmcu=atmega2560", + "-c", "-I", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", - "-o", - "compiled_payload.elf", + "-mmcu=atmega2560", "-DDEBUG_BUILD=1", "-DBAUD=9600", "-DF_CPU=16000000", "-Wall", "-O1", - "main.c", - "debug.c", - "i2c.c", - "ssd1306_display_driver.c", - "uart.c", - "br24t_eeprom_driver.c", - "paint.c", - "-Wall" + "-o", + "build/paint.o", + "paint.c" ], "file": "paint.c" }, @@ -115,26 +98,57 @@ "directory": "/home/indigo/projects/watch/src", "arguments": [ "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", + "-c", + "-I", + "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", "-mmcu=atmega2560", + "-DDEBUG_BUILD=1", + "-DBAUD=9600", + "-DF_CPU=16000000", + "-Wall", + "-O1", + "-o", + "build/pcf_clock_driver.o", + "pcf_clock_driver.c" + ], + "file": "pcf_clock_driver.c" + }, + { + "directory": "/home/indigo/projects/watch/src", + "arguments": [ + "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", + "-c", "-I", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", + "-mmcu=atmega2560", + "-DDEBUG_BUILD=1", + "-DBAUD=9600", + "-DF_CPU=16000000", + "-Wall", + "-O1", "-o", - "compiled_payload.elf", + "build/debug.o", + "debug.c" + ], + "file": "debug.c" + }, + { + "directory": "/home/indigo/projects/watch/src", + "arguments": [ + "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", + "-c", + "-I", + "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", + "-mmcu=atmega2560", "-DDEBUG_BUILD=1", "-DBAUD=9600", "-DF_CPU=16000000", "-Wall", "-O1", - "main.c", - "debug.c", - "i2c.c", - "ssd1306_display_driver.c", - "uart.c", - "br24t_eeprom_driver.c", - "paint.c", - "pcf_clock_driver.c", - "-Wall" + "-o", + "build/ssd1306_display_driver.o", + "ssd1306_display_driver.c" ], - "file": "pcf_clock_driver.c" + "file": "ssd1306_display_driver.c" } ] diff --git a/src/i2c.c b/src/i2c.c index 6259095..6591149 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -4,9 +4,7 @@ #include #include #include -#ifdef DEBUG_BUILD #include "debug.h" -#endif #include "i2c.h" diff --git a/src/main.c b/src/main.c index 96fb34e..a159657 100644 --- a/src/main.c +++ b/src/main.c @@ -21,11 +21,6 @@ * organize i2c eeprom/timer code */ - - - - - #ifndef FLASH_EEPROM int main() { LED_DEBUG_DDR |= _BV(LED_DEBUG); //TODO move to debug file or somethin diff --git a/src/makefile b/src/makefile index 7191432..51a9541 100644 --- a/src/makefile +++ b/src/makefile @@ -1,7 +1,6 @@ #compile options TOOLCHAIN_DIR=/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64 CC=$(TOOLCHAIN_DIR)/bin/avr-gcc -LD=$(TOOLCHAIN_DIR)/bin/avr-ld INC=$(TOOLCHAIN_DIR)/avr/include OUT=compiled_payload.elf DEVICE=atmega2560 @@ -21,16 +20,19 @@ BAUD=115200 #baudrate RUNTIME_BAUDRATE=9600 +SRCFILES := $(wildcard *.c) +OBJFILES := $(patsubst %.c,build/%.o,$(SRCFILES)) -make: - #$(CC) -mmcu=$(DEVICE) -I $(INC) -c debug_serial.o -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 debug_serial.c - #$(CC) -mmcu=$(DEVICE) -I $(INC) -c main.o -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c - #$(CC) -mmcu=$(DEVICE) -I $(INC) -c debug_serial.o -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 i2c.c - #$(LD) -mavr6 -o $(OUT) -s main.o debug_serial.o #TODO wish I knew how to make -mavr6 dependent on DEVICE - #TODO no debug.c if debug disabled - $(CC) -mmcu=$(DEVICE) -I $(INC) -o $(OUT) -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c debug.c i2c.c ssd1306_display_driver.c uart.c br24t_eeprom_driver.c paint.c pcf_clock_driver.c -Wall + +make: $(OBJFILES) + echo $(SRCFILES) + $(CC) -DDEBUG_BUILD=$(DEBUG) -mmcu=$(DEVICE) -o $(OUT) $(OBJFILES) compiledb make --dry-run > /dev/null +build/%.o: %.c + if [ ! -d "build" ]; then mkdir -p build; fi + $(CC) $(CCOPTS) -c -I $(INC) -mmcu=$(DEVICE) -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 -o $@ $< + reset: doas avrdude -c usbtiny -p $(PARTNO) @@ -41,8 +43,8 @@ eeprom_write: eeprom: ./compile_eeprom.py -eeprom_install: - $(CC) -mmcu=atmega2560 -I $(INC) -o $(OUT) -DFLASH_EEPROM -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c debug.c i2c.c ssd1306_display_driver.c uart.c br24t_eeprom_driver.c paint.c -Wall +#eeprom_install: + #$(CC) -mmcu=atmega2560 -I $(INC) -o $(OUT) -DFLASH_EEPROM -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c debug.c i-DDEBUG_BUILD=$(DEBUG)2c.c ssd1306_display_driver.c uart.c br24t_eeprom_driver.c paint.c -Wall doas avrdude -B 1 -v -p ATmega2560 -c usbtiny -U flash:w:$(OUT):e @@ -56,5 +58,5 @@ screen: doas screen $(DEBUG_PORT) $(RUNTIME_BAUDRATE) clean: - rm -f *.o *.elf compiled_eeprom + rm -f *.o *.elf compiled_eeprom build/* diff --git a/src/paint.c b/src/paint.c index 6a2b741..71d93cd 100644 --- a/src/paint.c +++ b/src/paint.c @@ -1,3 +1,4 @@ +#include #include #include "ssd1306_display_driver.h" #include "paint.h" @@ -19,6 +20,7 @@ void screen_clear() { memset(&screen_buffer, 0, sizeof(screen_buffer)); } + //images are optimized to follow page formatting void draw_image(EEPROM_ADDR image) { for(int on_pix = 0; on_pix < (SCREEN_RES_X * SCREEN_RES_Y) / 8; on_pix++) diff --git a/src/ssd1306_display_driver.c b/src/ssd1306_display_driver.c index 0bff3b0..9155e1e 100644 --- a/src/ssd1306_display_driver.c +++ b/src/ssd1306_display_driver.c @@ -73,6 +73,7 @@ void screen_init() { } + void screen_off() { i2c_write_reg(SSD1306_ADDR, SSD1306_CMD_REG, 0xaf); } void screen_on() { i2c_write_reg(SSD1306_ADDR, SSD1306_CMD_REG, 0xae); } @@ -86,3 +87,10 @@ void screen_update() { } } +void screen_test() { + printf("testing screen\n"); + for(int on_pix = 0; on_pix < (SCREEN_RES_X * SCREEN_RES_Y) / 8; on_pix++) + screen_buffer[on_pix] = 0b10101010; + printf("done testing screen\n"); + screen_update(); +} -- cgit v1.2.3