diff options
author | Brett Weiland <brett_weiland@bpcsapce.com> | 2023-01-24 14:58:52 -0600 |
---|---|---|
committer | Brett Weiland <brett_weiland@bpcsapce.com> | 2023-01-24 14:58:52 -0600 |
commit | a5984050eb556741ef40792d6335b7f65fa1eb4f (patch) | |
tree | aaf870b1558d6b40369f481443c4ce768f9b76be | |
parent | b666668d0e6b67e4632e65486cae814ab5abbc39 (diff) |
started fixing makefile, created test function
-rw-r--r-- | src/build/br24t_eeprom_driver.o | bin | 0 -> 756 bytes | |||
-rw-r--r-- | src/build/debug.o | bin | 0 -> 3572 bytes | |||
-rw-r--r-- | src/build/i2c.o | bin | 0 -> 2604 bytes | |||
-rw-r--r-- | src/build/main.o | bin | 0 -> 1624 bytes | |||
-rw-r--r-- | src/build/paint.o | bin | 0 -> 1536 bytes | |||
-rw-r--r-- | src/build/pcf_clock_driver.o | bin | 0 -> 752 bytes | |||
-rw-r--r-- | src/build/ssd1306_display_driver.o | bin | 0 -> 2188 bytes | |||
-rw-r--r-- | src/build/uart.o | bin | 0 -> 984 bytes | |||
-rw-r--r-- | src/compile_commands.json | 120 | ||||
-rw-r--r-- | src/i2c.c | 2 | ||||
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/makefile | 24 | ||||
-rw-r--r-- | src/paint.c | 2 | ||||
-rw-r--r-- | src/ssd1306_display_driver.c | 8 |
14 files changed, 90 insertions, 71 deletions
diff --git a/src/build/br24t_eeprom_driver.o b/src/build/br24t_eeprom_driver.o Binary files differnew file mode 100644 index 0000000..8565140 --- /dev/null +++ b/src/build/br24t_eeprom_driver.o diff --git a/src/build/debug.o b/src/build/debug.o Binary files differnew file mode 100644 index 0000000..68832b3 --- /dev/null +++ b/src/build/debug.o diff --git a/src/build/i2c.o b/src/build/i2c.o Binary files differnew file mode 100644 index 0000000..ffcd173 --- /dev/null +++ b/src/build/i2c.o diff --git a/src/build/main.o b/src/build/main.o Binary files differnew file mode 100644 index 0000000..8b7594f --- /dev/null +++ b/src/build/main.o diff --git a/src/build/paint.o b/src/build/paint.o Binary files differnew file mode 100644 index 0000000..0861827 --- /dev/null +++ b/src/build/paint.o diff --git a/src/build/pcf_clock_driver.o b/src/build/pcf_clock_driver.o Binary files differnew file mode 100644 index 0000000..4b61851 --- /dev/null +++ b/src/build/pcf_clock_driver.o diff --git a/src/build/ssd1306_display_driver.o b/src/build/ssd1306_display_driver.o Binary files differnew file mode 100644 index 0000000..868b006 --- /dev/null +++ b/src/build/ssd1306_display_driver.o diff --git a/src/build/uart.o b/src/build/uart.o Binary files differnew file mode 100644 index 0000000..d68e15a --- /dev/null +++ b/src/build/uart.o 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" } ] @@ -4,9 +4,7 @@ #include <util/delay.h> #include <stdbool.h> #include <string.h> -#ifdef DEBUG_BUILD #include "debug.h" -#endif #include "i2c.h" @@ -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 <stdio.h> #include <string.h> #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(); +} |