aboutsummaryrefslogtreecommitdiff
path: root/justfile
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-02-04 11:04:04 +0530
committerAkshay Nair <phenax5@gmail.com>2026-02-04 12:55:37 +0530
commitcc9d915435a61d71f11cffa264cf941de58fe444 (patch)
treedc190a76b952e26942c298745f5321c5fb0d95ac /justfile
parentf0423ae9af947512f5200da1ffd3c5adf81d5d7f (diff)
downloaddaft-watch-cc9d915435a61d71f11cffa264cf941de58fe444.tar.gz
daft-watch-cc9d915435a61d71f11cffa264cf941de58fe444.zip
Switch from internal clock to crystal + button
Diffstat (limited to 'justfile')
-rw-r--r--justfile28
1 files changed, 19 insertions, 9 deletions
diff --git a/justfile b/justfile
index a7f3d12..575afa9 100644
--- a/justfile
+++ b/justfile
@@ -5,10 +5,10 @@ default:
just --choose || true
AVR_LIBC := env("AVR_LIBC", "/usr/lib/avr")
-F_CPU := "1000000"
+F_CPU := "32768"
MCU := "attiny84a"
MCU_PART := "attiny84"
-SRC := "./src/main.c"
+SRCS := "./src/main.c ./src/display.c"
OUTDIR := "./out"
PROGRAMMER := "arduino"
UPLOAD_SPEED := "19200"
@@ -18,23 +18,30 @@ CFLAGS := f"-g -Os -std=gnu99 -Isrc -mmcu={{MCU}} -DF_CPU={{F_CPU}}L \
-I{{AVR_LIBC}}/avr/include -L{{AVR_LIBC}}/avr/lib \
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall"
-AVRDUDE := f"avrdude -v -p {{MCU_PART}} -c {{PROGRAMMER}} -P {{SERIAL_PORT}} -b {{UPLOAD_SPEED}}"
+AVRDUDE := f"avrdude -v -p {{MCU_PART}} -c {{PROGRAMMER}} -P {{SERIAL_PORT}} -b {{UPLOAD_SPEED}} -F"
-build: compile_flags
+build: compile-flags
mkdir -p {{OUTDIR}}
- avr-gcc {{CFLAGS}} {{SRC}} -o {{OUTDIR}}/out.elf
+ avr-gcc {{CFLAGS}} {{SRCS}} -o {{OUTDIR}}/out.elf
avr-objcopy -O ihex -R .eeprom {{OUTDIR}}/out.elf {{OUTDIR}}/out.hex
du -bh "{{OUTDIR}}/out.hex"
-write:
- [ -f "{{OUTDIR}}/out.hex" ] || (echo "No out.hex. Run build"; exit 1);
+write: build flash
+
+flash: check-hexfile-exists
{{AVRDUDE}} -U "flash:w:{{OUTDIR}}/out.hex:i"
read:
{{AVRDUDE}} -F -U flash:r:-:h
+write-fuses: check-hexfile-exists
+ {{AVRDUDE}} -U lfuse:w:{{OUTDIR}}/out.elf:e -U hfuse:w:{{OUTDIR}}/out.elf:e -U efuse:w:{{OUTDIR}}/out.elf:e
+
+read-fuse:
+ {{AVRDUDE}} -U lfuse:r:-:h -U hfuse:r:-:h
+
test:
- gcc -g -std=gnu99 -Isrc -DF_CPU={{F_CPU}}L -DSTUBBED=1 -I./test/stubbed/ -Wall {{SRC}} -o {{OUTDIR}}/test
+ gcc -g -std=gnu99 -DSTUBBED=1 -I./src -I./test/stubbed/ -Wall -Wno-unused-variable {{SRCS}} -o {{OUTDIR}}/test
{{OUTDIR}}/test
clean:
@@ -43,5 +50,8 @@ clean:
format:
find src/ -iname '*.h' -o -iname '*.c' | xargs clang-format -i
-@compile_flags:
+@check-hexfile-exists:
+ [ -f "{{OUTDIR}}/out.hex" ] || (echo "No out.hex. Run build first"; exit 1);
+
+@compile-flags:
echo '{{CFLAGS}}' | tr ' ' '\n' > ./compile_flags.txt