Skip to content

Commit b5e80fa

Browse files
iabdalkaderdpgeorge
authored andcommitted
drivers/memory/spiflash: Add a config option to soft-reset SPI flash.
Add a compile-time config option to soft-reset SPI flash on init. This puts the flash in a known state on reset. Note this option is disabled by default. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
1 parent d5d366b commit b5e80fa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/memory/spiflash.c

+10
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#define CMD_RD_DEVID (0x9f)
4545
#define CMD_CHIP_ERASE (0xc7)
4646
#define CMD_C4READ (0xeb)
47+
#define CMD_RSTEN (0x66)
48+
#define CMD_RESET (0x99)
4749

4850
// 32 bit addressing commands
4951
#define CMD_WRITE_32 (0x12)
@@ -180,6 +182,14 @@ void mp_spiflash_init(mp_spiflash_t *self) {
180182
// Ensure SPI flash is out of sleep mode
181183
mp_spiflash_deepsleep_internal(self, 0);
182184

185+
// Software reset.
186+
#if MICROPY_HW_SPIFLASH_SOFT_RESET
187+
mp_spiflash_write_cmd(self, CMD_RSTEN);
188+
mp_spiflash_write_cmd(self, CMD_RESET);
189+
mp_spiflash_wait_wip0(self);
190+
mp_hal_delay_ms(1);
191+
#endif
192+
183193
#if defined(CHECK_DEVID)
184194
// Validate device id
185195
uint32_t devid;

0 commit comments

Comments
 (0)