diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-10-02 17:13:22 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-10-02 17:13:22 -0400 |
| commit | e7baf2e96f1cec2071cb2e1e6a4735c36611bc26 (patch) | |
| tree | 98cc783b42aed7090680a158b00d5549233d3528 /fw/tests/system/dac_systest.c | |
| parent | 99be520563834d51eb3ddd32b757a3dcd2486632 (diff) | |
| download | can-gauge-interface-e7baf2e96f1cec2071cb2e1e6a4735c36611bc26.zip | |
dac fw module
Diffstat (limited to 'fw/tests/system/dac_systest.c')
| -rw-r--r-- | fw/tests/system/dac_systest.c | 37 |
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; + } +} |