aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-02-05 13:05:33 +0530
committerAkshay Nair <phenax5@gmail.com>2026-02-05 13:05:33 +0530
commita40d8f331ba5b7ea239b35714eaa1cff504a086b (patch)
treefb7e59823959b7ca71f4b4c0a211571b56b56ac2
parentcc9d915435a61d71f11cffa264cf941de58fe444 (diff)
downloaddaft-watch-a40d8f331ba5b7ea239b35714eaa1cff504a086b.tar.gz
daft-watch-a40d8f331ba5b7ea239b35714eaa1cff504a086b.zip
Updates stub
-rw-r--r--.clangd3
-rw-r--r--justfile6
-rw-r--r--test/stubbed/avr/interrupt.h20
-rw-r--r--test/stubbed/avr/io.h44
-rw-r--r--test/stubbed/util/delay.h4
5 files changed, 68 insertions, 9 deletions
diff --git a/.clangd b/.clangd
index 2ac690e..f162070 100644
--- a/.clangd
+++ b/.clangd
@@ -1,2 +1,5 @@
CompileFlags:
Compiler: avr-gcc
+Diagnostics:
+ Suppress: unknown-attributes
+ Add: bugprone-*, readability-*
diff --git a/justfile b/justfile
index 575afa9..eec984d 100644
--- a/justfile
+++ b/justfile
@@ -37,8 +37,8 @@ read:
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
+read-fuses:
+ {{AVRDUDE}} -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h
test:
gcc -g -std=gnu99 -DSTUBBED=1 -I./src -I./test/stubbed/ -Wall -Wno-unused-variable {{SRCS}} -o {{OUTDIR}}/test
@@ -48,7 +48,7 @@ clean:
rm -rf {{OUTDIR}}
format:
- find src/ -iname '*.h' -o -iname '*.c' | xargs clang-format -i
+ find src/ test/ -iname '*.h' -o -iname '*.c' | xargs clang-format -i
@check-hexfile-exists:
[ -f "{{OUTDIR}}/out.hex" ] || (echo "No out.hex. Run build first"; exit 1);
diff --git a/test/stubbed/avr/interrupt.h b/test/stubbed/avr/interrupt.h
new file mode 100644
index 0000000..bcab79c
--- /dev/null
+++ b/test/stubbed/avr/interrupt.h
@@ -0,0 +1,20 @@
+#define ISR(INTER) void generated_interrupt_##INTER()
+
+static void cli() {}
+static void sei() {}
+
+#define stub_run_timers() \
+ { \
+ if (TCNT0 == OCR0A) { \
+ generated_interrupt_TIM0_OVF_vect(); \
+ TCNT0 = 0; \
+ } else { \
+ TCNT0++; \
+ } \
+ if (TCNT1L == OCR1AH) { \
+ generated_interrupt_TIM1_OVF_vect(); \
+ TCNT1L = 0; \
+ } else { \
+ TCNT1L++; \
+ } \
+ }
diff --git a/test/stubbed/avr/io.h b/test/stubbed/avr/io.h
index cfbdef3..8c1ee92 100644
--- a/test/stubbed/avr/io.h
+++ b/test/stubbed/avr/io.h
@@ -10,6 +10,7 @@ static int PORTB = 0;
static int PINA = 0;
static int PINB = 0;
+#define PA0 0
#define PA1 1
#define PA2 2
#define PA3 3
@@ -22,7 +23,44 @@ static int PINB = 0;
#define PB2 2
#define PB3 3
#define PB4 4
-#define PB5 5
-#define PB6 6
-#define PB7 7
+
+static int PRR = 0;
+static int TCCR0B = 0;
+static int TCCR0A = 0;
+static int TIMSK0 = 0;
+static int TIFR0 = 0;
+static int OCR0A = 0;
+static int OCR0B = 0;
+static int TCNT0 = 0;
+static int TCCR1B = 0;
+static int TCCR1A = 0;
+static int TIMSK1 = 0;
+static int TIFR1 = 0;
+static int OCR1AH = 0;
+static int OCR1BH = 0;
+static int OCR1AL = 0;
+static int OCR1BL = 0;
+static int TCNT1 = 0;
+static int TCNT1H = 0;
+static int TCNT1L = 0;
+
+#define CS00 1
+#define CS01 1
+#define CS02 2
+#define CS10 1
+#define CS11 1
+#define CS12 2
+#define WGM00 0
+#define WGM01 1
+#define WGM02 2
+#define WGM10 0
+#define WGM11 1
+#define WGM12 2
+#define WGM13 3
+#define TOIE0 0
+#define TOIE1 0
+#define TOV0 0
+#define TOV1 0
+#define OCF1A 0
+#define OCF1B 0
#endif
diff --git a/test/stubbed/util/delay.h b/test/stubbed/util/delay.h
index db61690..3954609 100644
--- a/test/stubbed/util/delay.h
+++ b/test/stubbed/util/delay.h
@@ -3,7 +3,5 @@
#include <unistd.h>
-static void _delay_ms(int ms) {
- usleep(ms * 1000);
-}
+static void _delay_ms(int ms) { usleep(ms * 1000); }
#endif