aboutsummaryrefslogtreecommitdiffstats
path: root/fw/tests/system
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-10-02 14:45:56 -0400
committerSam Anthony <sam@samanthony.xyz>2025-10-02 14:45:56 -0400
commit99be520563834d51eb3ddd32b757a3dcd2486632 (patch)
tree7c31bcc262950d431a1676b62624b6ac82f30df3 /fw/tests/system
parentc91e3d96c90cd1c9b3b6155bc5e37954011cf0af (diff)
downloadcan-gauge-interface-99be520563834d51eb3ddd32b757a3dcd2486632.zip
spi systest
Diffstat (limited to 'fw/tests/system')
-rw-r--r--fw/tests/system/eeprom_systest.c31
-rw-r--r--fw/tests/system/spi_systest.c22
2 files changed, 49 insertions, 4 deletions
diff --git a/fw/tests/system/eeprom_systest.c b/fw/tests/system/eeprom_systest.c
index 9099345..81fa189 100644
--- a/fw/tests/system/eeprom_systest.c
+++ b/fw/tests/system/eeprom_systest.c
@@ -2,20 +2,43 @@
#include <stdint.h>
+#include "system.h"
#include "types.h"
-#include "init.h"
#include "spi.h"
#include "eeprom.h"
-#include "config.h"
+#include "usb.h"
void
main(void) {
- clockInit();
- pinsInit();
+ sysInit();
spiInit();
eepromInit();
+ usbInit();
+
+ T1CON = 0;
+ T1CONbits.TMR1CS = 0x0; // FOSC/4
+ T1CONbits.T1CKPS = 0x3; // 1:8 prescaler
+ T1CONbits.TMR1ON = 1;
+
+ TMR1IE = 1;
+ TMR1IF = 0;
+ PEIE = 1;
+ GIE = 1;
for (;;) {
}
}
+
+void
+__interrupt() isr(void) {
+ static U8 ctr = 0u;
+
+ if (TMR1IF) {
+ if (ctr == 23u) { // 1s period
+
+ }
+ ctr = (ctr+1u) % 23u;
+ TMR1IF = 0;
+ }
+}
diff --git a/fw/tests/system/spi_systest.c b/fw/tests/system/spi_systest.c
new file mode 100644
index 0000000..1adc624
--- /dev/null
+++ b/fw/tests/system/spi_systest.c
@@ -0,0 +1,22 @@
+#include <xc.h>
+
+#include <stdint.h>
+
+#include "system.h"
+#include "types.h"
+#include "spi.h"
+
+void
+main(void) {
+ sysInit();
+ spiInit();
+
+ for (;;) {
+ (void)spiTx(0x05); // 0b0000101
+ }
+}
+
+void
+__interrupt() isr(void) {
+
+}