aboutsummaryrefslogtreecommitdiffstats
path: root/fw/tests/system
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-10-02 17:13:22 -0400
committerSam Anthony <sam@samanthony.xyz>2025-10-02 17:13:22 -0400
commite7baf2e96f1cec2071cb2e1e6a4735c36611bc26 (patch)
tree98cc783b42aed7090680a158b00d5549233d3528 /fw/tests/system
parent99be520563834d51eb3ddd32b757a3dcd2486632 (diff)
downloadcan-gauge-interface-e7baf2e96f1cec2071cb2e1e6a4735c36611bc26.zip
dac fw module
Diffstat (limited to 'fw/tests/system')
-rw-r--r--fw/tests/system/dac_systest.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/fw/tests/system/dac_systest.c b/fw/tests/system/dac_systest.c
new file mode 100644
index 0000000..8653f96
--- /dev/null
+++ b/fw/tests/system/dac_systest.c
@@ -0,0 +1,37 @@
+#include <xc.h>
+
+#include <stdint.h>
+
+#include "system.h"
+#include "types.h"
+#include "spi.h"
+#include "dac.h"
+
+void
+main(void) {
+ sysInit();
+ spiInit();
+ dacInit();
+
+ dacSet1a((U16){0u, 252u}); // 1.23V
+
+ for (;;) {
+
+ }
+}
+
+void
+__interrupt() isr(void) {
+ static U8 ctr = 0u;
+ static U16 level = {0, 0};
+
+ if (TMR1IF) {
+ ctr++;
+ if (ctr == 23u) { // 1s period
+ ctr = 0u;
+ dacSet1a(level);
+ addU16(&level, 50u);
+ }
+ TMR1IF = 0;
+ }
+}