started fixing makefile, created test function

This commit is contained in:
Brett Weiland 2023-01-24 14:58:52 -06:00
parent b666668d0e
commit a5984050eb
14 changed files with 91 additions and 72 deletions

Binary file not shown.

BIN
src/build/debug.o Normal file

Binary file not shown.

BIN
src/build/i2c.o Normal file

Binary file not shown.

BIN
src/build/main.o Normal file

Binary file not shown.

BIN
src/build/paint.o Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
src/build/uart.o Normal file

Binary file not shown.

View File

@ -3,16 +3,17 @@
"directory": "/home/indigo/projects/watch/src", "directory": "/home/indigo/projects/watch/src",
"arguments": [ "arguments": [
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc",
"-v", "-c",
"-mmcu=atmega2560",
"-I", "-I",
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include",
"-o", "-mmcu=atmega2560",
"compiled_payload", "-DDEBUG_BUILD=1",
"-DBAUD=9600", "-DBAUD=9600",
"-DF_CPU=16000000", "-DF_CPU=16000000",
"-Wall", "-Wall",
"-O1", "-O1",
"-o",
"build/main.o",
"main.c" "main.c"
], ],
"file": "main.c" "file": "main.c"
@ -21,21 +22,18 @@
"directory": "/home/indigo/projects/watch/src", "directory": "/home/indigo/projects/watch/src",
"arguments": [ "arguments": [
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc",
"-lc", "-c",
"-mmcu=atmega2560",
"-I", "-I",
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include",
"-o", "-mmcu=atmega2560",
"compiled_payload.elf",
"-DDEBUG_BUILD=1", "-DDEBUG_BUILD=1",
"-DBAUD=9600", "-DBAUD=9600",
"-DF_CPU=16000000", "-DF_CPU=16000000",
"-Wall", "-Wall",
"-O1", "-O1",
"main.c", "-o",
"debug_serial.c", "build/i2c.o",
"i2c.c", "i2c.c"
"ssd1306_driver.h"
], ],
"file": "i2c.c" "file": "i2c.c"
}, },
@ -43,22 +41,18 @@
"directory": "/home/indigo/projects/watch/src", "directory": "/home/indigo/projects/watch/src",
"arguments": [ "arguments": [
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc",
"-mmcu=atmega2560", "-c",
"-I", "-I",
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include",
"-o", "-mmcu=atmega2560",
"compiled_payload.elf",
"-DDEBUG_BUILD=1", "-DDEBUG_BUILD=1",
"-DBAUD=9600", "-DBAUD=9600",
"-DF_CPU=16000000", "-DF_CPU=16000000",
"-Wall", "-Wall",
"-O1", "-O1",
"main.c", "-o",
"debug.c", "build/uart.o",
"i2c.c", "uart.c"
"ssd1306_driver.c",
"uart.c",
"-Wall"
], ],
"file": "uart.c" "file": "uart.c"
}, },
@ -66,23 +60,18 @@
"directory": "/home/indigo/projects/watch/src", "directory": "/home/indigo/projects/watch/src",
"arguments": [ "arguments": [
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc",
"-mmcu=atmega2560", "-c",
"-I", "-I",
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include",
"-o", "-mmcu=atmega2560",
"compiled_payload.elf",
"-DDEBUG_BUILD=1", "-DDEBUG_BUILD=1",
"-DBAUD=9600", "-DBAUD=9600",
"-DF_CPU=16000000", "-DF_CPU=16000000",
"-Wall", "-Wall",
"-O1", "-O1",
"main.c", "-o",
"debug.c", "build/br24t_eeprom_driver.o",
"i2c.c", "br24t_eeprom_driver.c"
"ssd1306_display_driver.c",
"uart.c",
"br24t_eeprom_driver.c",
"-Wall"
], ],
"file": "br24t_eeprom_driver.c" "file": "br24t_eeprom_driver.c"
}, },
@ -90,24 +79,18 @@
"directory": "/home/indigo/projects/watch/src", "directory": "/home/indigo/projects/watch/src",
"arguments": [ "arguments": [
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc",
"-mmcu=atmega2560", "-c",
"-I", "-I",
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include",
"-o", "-mmcu=atmega2560",
"compiled_payload.elf",
"-DDEBUG_BUILD=1", "-DDEBUG_BUILD=1",
"-DBAUD=9600", "-DBAUD=9600",
"-DF_CPU=16000000", "-DF_CPU=16000000",
"-Wall", "-Wall",
"-O1", "-O1",
"main.c", "-o",
"debug.c", "build/paint.o",
"i2c.c", "paint.c"
"ssd1306_display_driver.c",
"uart.c",
"br24t_eeprom_driver.c",
"paint.c",
"-Wall"
], ],
"file": "paint.c" "file": "paint.c"
}, },
@ -115,26 +98,57 @@
"directory": "/home/indigo/projects/watch/src", "directory": "/home/indigo/projects/watch/src",
"arguments": [ "arguments": [
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc",
"-mmcu=atmega2560", "-c",
"-I", "-I",
"/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include", "/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64/avr/include",
"-o", "-mmcu=atmega2560",
"compiled_payload.elf",
"-DDEBUG_BUILD=1", "-DDEBUG_BUILD=1",
"-DBAUD=9600", "-DBAUD=9600",
"-DF_CPU=16000000", "-DF_CPU=16000000",
"-Wall", "-Wall",
"-O1", "-O1",
"main.c", "-o",
"debug.c", "build/pcf_clock_driver.o",
"i2c.c", "pcf_clock_driver.c"
"ssd1306_display_driver.c",
"uart.c",
"br24t_eeprom_driver.c",
"paint.c",
"pcf_clock_driver.c",
"-Wall"
], ],
"file": "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",
"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",
"-o",
"build/ssd1306_display_driver.o",
"ssd1306_display_driver.c"
],
"file": "ssd1306_display_driver.c"
} }
] ]

View File

@ -4,9 +4,7 @@
#include <util/delay.h> #include <util/delay.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#ifdef DEBUG_BUILD
#include "debug.h" #include "debug.h"
#endif
#include "i2c.h" #include "i2c.h"

View File

@ -21,11 +21,6 @@
* organize i2c eeprom/timer code * organize i2c eeprom/timer code
*/ */
#ifndef FLASH_EEPROM #ifndef FLASH_EEPROM
int main() { int main() {
LED_DEBUG_DDR |= _BV(LED_DEBUG); //TODO move to debug file or somethin LED_DEBUG_DDR |= _BV(LED_DEBUG); //TODO move to debug file or somethin

View File

@ -1,7 +1,6 @@
#compile options #compile options
TOOLCHAIN_DIR=/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64 TOOLCHAIN_DIR=/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64
CC=$(TOOLCHAIN_DIR)/bin/avr-gcc CC=$(TOOLCHAIN_DIR)/bin/avr-gcc
LD=$(TOOLCHAIN_DIR)/bin/avr-ld
INC=$(TOOLCHAIN_DIR)/avr/include INC=$(TOOLCHAIN_DIR)/avr/include
OUT=compiled_payload.elf OUT=compiled_payload.elf
DEVICE=atmega2560 DEVICE=atmega2560
@ -21,16 +20,19 @@ BAUD=115200
#baudrate #baudrate
RUNTIME_BAUDRATE=9600 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 make: $(OBJFILES)
#$(CC) -mmcu=$(DEVICE) -I $(INC) -c main.o -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c echo $(SRCFILES)
#$(CC) -mmcu=$(DEVICE) -I $(INC) -c debug_serial.o -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 i2c.c $(CC) -DDEBUG_BUILD=$(DEBUG) -mmcu=$(DEVICE) -o $(OUT) $(OBJFILES)
#$(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
compiledb make --dry-run > /dev/null 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: reset:
doas avrdude -c usbtiny -p $(PARTNO) doas avrdude -c usbtiny -p $(PARTNO)
@ -41,8 +43,8 @@ eeprom_write:
eeprom: eeprom:
./compile_eeprom.py ./compile_eeprom.py
eeprom_install: #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 #$(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 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) doas screen $(DEBUG_PORT) $(RUNTIME_BAUDRATE)
clean: clean:
rm -f *.o *.elf compiled_eeprom rm -f *.o *.elf compiled_eeprom build/*

View File

@ -1,3 +1,4 @@
#include <stdio.h>
#include <string.h> #include <string.h>
#include "ssd1306_display_driver.h" #include "ssd1306_display_driver.h"
#include "paint.h" #include "paint.h"
@ -19,6 +20,7 @@
void screen_clear() { memset(&screen_buffer, 0, sizeof(screen_buffer)); } void screen_clear() { memset(&screen_buffer, 0, sizeof(screen_buffer)); }
//images are optimized to follow page formatting //images are optimized to follow page formatting
void draw_image(EEPROM_ADDR image) { void draw_image(EEPROM_ADDR image) {
for(int on_pix = 0; on_pix < (SCREEN_RES_X * SCREEN_RES_Y) / 8; on_pix++) for(int on_pix = 0; on_pix < (SCREEN_RES_X * SCREEN_RES_Y) / 8; on_pix++)

View File

@ -73,6 +73,7 @@ void screen_init() {
} }
void screen_off() { i2c_write_reg(SSD1306_ADDR, SSD1306_CMD_REG, 0xaf); } void screen_off() { i2c_write_reg(SSD1306_ADDR, SSD1306_CMD_REG, 0xaf); }
void screen_on() { i2c_write_reg(SSD1306_ADDR, SSD1306_CMD_REG, 0xae); } 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();
}