diff options
author | Joey Castillo <joeycastillo@utexas.edu> | 2022-02-17 14:28:25 -0500 |
---|---|---|
committer | Joey Castillo <joeycastillo@utexas.edu> | 2022-02-17 14:28:53 -0500 |
commit | 0337d198ffe20062678a7900a7666f312c229475 (patch) | |
tree | 713f5b84e8c1fb2f2288285cca1a4e3ac9a3e365 | |
parent | 15cbe0941031a8f20d76072d05212d854980a49f (diff) | |
download | Sensor-Watch-0337d198ffe20062678a7900a7666f312c229475.tar.gz Sensor-Watch-0337d198ffe20062678a7900a7666f312c229475.tar.bz2 Sensor-Watch-0337d198ffe20062678a7900a7666f312c229475.zip |
SPI test: just read the chip ID
-rwxr-xr-x | apps/spi-test/Makefile (renamed from apps/spi-test/make/Makefile) | 6 | ||||
-rw-r--r-- | apps/spi-test/app.c | 26 |
2 files changed, 10 insertions, 22 deletions
diff --git a/apps/spi-test/make/Makefile b/apps/spi-test/Makefile index c66ad20c..5534c178 100755 --- a/apps/spi-test/make/Makefile +++ b/apps/spi-test/Makefile @@ -1,10 +1,10 @@ -TOP = ../../.. +TOP = ../.. include $(TOP)/make.mk INCLUDES += \ - -I../ + -I./ SRCS += \ - ../app.c + ./app.c include $(TOP)/rules.mk diff --git a/apps/spi-test/app.c b/apps/spi-test/app.c index 006067a4..428f55d3 100644 --- a/apps/spi-test/app.c +++ b/apps/spi-test/app.c @@ -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); |