]> git.earman.xyz Git - sensor-watch.git/commitdiff
SPI test: just read the chip ID
authorJoey Castillo <joeycastillo@utexas.edu>
Thu, 17 Feb 2022 19:28:25 +0000 (14:28 -0500)
committerJoey Castillo <joeycastillo@utexas.edu>
Thu, 17 Feb 2022 19:28:53 +0000 (14:28 -0500)
apps/spi-test/Makefile [new file with mode: 0755]
apps/spi-test/app.c
apps/spi-test/make/Makefile [deleted file]

diff --git a/apps/spi-test/Makefile b/apps/spi-test/Makefile
new file mode 100755 (executable)
index 0000000..5534c17
--- /dev/null
@@ -0,0 +1,10 @@
+TOP = ../..
+include $(TOP)/make.mk
+
+INCLUDES += \
+  -I./
+
+SRCS += \
+  ./app.c
+
+include $(TOP)/rules.mk
index 006067a48abc6e9ba4a5505c95a1532e960bb829..428f55d33484b91ed7db27fa292ed1878edca3a4 100644 (file)
@@ -20,16 +20,6 @@ static bool wait_for_flash_ready(void) {
 void app_init(void) {
     spi_flash_init();
     delay_ms(5000);
-
-    uint8_t buf[256] = {0};
-    for(int i = 1; i < 16; i++) {
-        wait_for_flash_ready();
-        watch_set_pin_level(A3, false);
-        spi_flash_command(CMD_ENABLE_WRITE);
-        watch_set_pin_level(A3, true);
-        wait_for_flash_ready();
-        spi_flash_write_data(i * 256, buf, 256);
-    }
 }
 
 void app_wake_from_backup(void) {
@@ -46,18 +36,16 @@ void app_wake_from_standby(void) {
 
 
 bool app_loop(void) {
-    uint8_t buf[4100] = {0};
+    uint8_t buf[3] = {0};
     printf("loop\n");
 
     wait_for_flash_ready();
-    spi_flash_read_data(0, buf, 4100);
-    for(int i = 0; i < 4100; i++) {
-        if (buf[i] > 0) {
-            // should break at "byte 4096 is 255"
-            printf("    byte %d is %d!\n", i, buf[i]);
-            break;
-        }
-    }
+    watch_set_pin_level(A3, false);
+    spi_flash_read_command(CMD_READ_JEDEC_ID, buf, 3);
+    printf("ident: %x, %x, %x\n", buf[0], buf[1], buf[2]);
+
+    watch_set_pin_level(A3, true);
+    wait_for_flash_ready();
 
     delay_ms(10000);
 
diff --git a/apps/spi-test/make/Makefile b/apps/spi-test/make/Makefile
deleted file mode 100755 (executable)
index c66ad20..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-TOP = ../../..
-include $(TOP)/make.mk
-
-INCLUDES += \
-  -I../
-
-SRCS += \
-  ../app.c
-
-include $(TOP)/rules.mk