diff options
| author | Anson Bridges <bridges.anson@gmail.com> | 2026-02-17 11:24:06 -0800 |
|---|---|---|
| committer | Anson Bridges <bridges.anson@gmail.com> | 2026-02-17 11:24:06 -0800 |
| commit | 6e952fe110c2a48204c8cb0a836309ab97e5979a (patch) | |
| tree | 64f87be87311dc3d62fb06da4fe23059a55de195 /code_refs/scratchpad.c | |
added files
Diffstat (limited to 'code_refs/scratchpad.c')
| -rw-r--r-- | code_refs/scratchpad.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/code_refs/scratchpad.c b/code_refs/scratchpad.c new file mode 100644 index 0000000..0fc1cfa --- /dev/null +++ b/code_refs/scratchpad.c @@ -0,0 +1,37 @@ + W25Q_STATE s = W25Q_Init(); // init the chip + s = W25Q_EraseSector(0); // erase 4K sector - required before recording + + // make test data + u8_t byte = 0x6D; + u8_t byte_read = 0; + u8_t in_page_shift = 0; + u8_t page_number = 0; + // write data + s= W25Q_ProgramByte(byte, in_page_shift, page_number); + // read data + s = W25Q_ReadByte(&byte_read, in_page_shift, page_number); + s = W25Q_Sleep(); + char str[10]; + sprintf(str, "read: %i", byte_read); + SHARPMEM_write(&lcd, str, 0, 0, 51, true, false); + SHARPMEM_refresh_display(&lcd); + + if(!HAL_I2C_IsDeviceReady(&hi2c1, 0x32, 3, 1000)) { + SHARPMEM_write(&lcd, "I2C works", 0, 0, 17, true, false); + SHARPMEM_refresh_display(&lcd); + uint8_t whoami[1] = {0}; + char whoami_str[10]; + HAL_StatusTypeDef e = HAL_I2C_Mem_Read(&hi2c1, 0x3C, 0x22, 1, whoami, 1, 1000); + if(!e){ + sprintf(whoami_str, "%i", byte_read); + SHARPMEM_write(&lcd, whoami_str, 0, 0, 34, true, false); + SHARPMEM_refresh_display(&lcd); + } else { + sprintf(whoami_str, "err: %x", (uint8_t)e); + SHARPMEM_write(&lcd, whoami_str, 0, 0, 34, true, false); + SHARPMEM_refresh_display(&lcd); + } + } else { + SHARPMEM_write(&lcd, "I2C doesn't work", 0, 0, 17, true, false); + SHARPMEM_refresh_display(&lcd); + } |
