aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compile_flags.txt1
-rw-r--r--justfile9
-rw-r--r--test/stubbed/avr/io.h24
-rw-r--r--test/stubbed/util/delay.h5
4 files changed, 36 insertions, 3 deletions
diff --git a/compile_flags.txt b/compile_flags.txt
index 7e86e45..8720d77 100644
--- a/compile_flags.txt
+++ b/compile_flags.txt
@@ -11,4 +11,3 @@
-fpack-struct
-fshort-enums
-Wall
--Wstrict-prototypes
diff --git a/justfile b/justfile
index 4978f92..a7f3d12 100644
--- a/justfile
+++ b/justfile
@@ -16,7 +16,7 @@ SERIAL_PORT := "/dev/ttyUSB0"
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 -Wstrict-prototypes"
+-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall"
AVRDUDE := f"avrdude -v -p {{MCU_PART}} -c {{PROGRAMMER}} -P {{SERIAL_PORT}} -b {{UPLOAD_SPEED}}"
@@ -24,6 +24,7 @@ build: compile_flags
mkdir -p {{OUTDIR}}
avr-gcc {{CFLAGS}} {{SRC}} -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);
@@ -32,11 +33,15 @@ write:
read:
{{AVRDUDE}} -F -U flash:r:-:h
+test:
+ gcc -g -std=gnu99 -Isrc -DF_CPU={{F_CPU}}L -DSTUBBED=1 -I./test/stubbed/ -Wall {{SRC}} -o {{OUTDIR}}/test
+ {{OUTDIR}}/test
+
clean:
rm -rf {{OUTDIR}}
format:
find src/ -iname '*.h' -o -iname '*.c' | xargs clang-format -i
-compile_flags:
+@compile_flags:
echo '{{CFLAGS}}' | tr ' ' '\n' > ./compile_flags.txt
diff --git a/test/stubbed/avr/io.h b/test/stubbed/avr/io.h
new file mode 100644
index 0000000..cd4a7bc
--- /dev/null
+++ b/test/stubbed/avr/io.h
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+int DDRA = 0;
+int DDRB = 0;
+
+int PORTA = 0;
+int PORTB = 0;
+
+int PA1 = 1;
+int PA2 = 2;
+int PA3 = 3;
+int PA4 = 4;
+int PA5 = 5;
+int PA6 = 6;
+int PA7 = 7;
+
+int PB1 = 1;
+int PB2 = 2;
+int PB3 = 3;
+int PB4 = 4;
+int PB5 = 5;
+int PB6 = 6;
+int PB7 = 7;
+
diff --git a/test/stubbed/util/delay.h b/test/stubbed/util/delay.h
new file mode 100644
index 0000000..ce4323e
--- /dev/null
+++ b/test/stubbed/util/delay.h
@@ -0,0 +1,5 @@
+#include <unistd.h>
+
+void _delay_ms(int ms) {
+ usleep(ms * 1000);
+}