mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
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>
This commit is contained in:
committed by
Damien George
parent
d5d366beef
commit
b5e80fafb2
@@ -44,6 +44,8 @@
|
||||
#define CMD_RD_DEVID (0x9f)
|
||||
#define CMD_CHIP_ERASE (0xc7)
|
||||
#define CMD_C4READ (0xeb)
|
||||
#define CMD_RSTEN (0x66)
|
||||
#define CMD_RESET (0x99)
|
||||
|
||||
// 32 bit addressing commands
|
||||
#define CMD_WRITE_32 (0x12)
|
||||
@@ -180,6 +182,14 @@ void mp_spiflash_init(mp_spiflash_t *self) {
|
||||
// Ensure SPI flash is out of sleep mode
|
||||
mp_spiflash_deepsleep_internal(self, 0);
|
||||
|
||||
// Software reset.
|
||||
#if MICROPY_HW_SPIFLASH_SOFT_RESET
|
||||
mp_spiflash_write_cmd(self, CMD_RSTEN);
|
||||
mp_spiflash_write_cmd(self, CMD_RESET);
|
||||
mp_spiflash_wait_wip0(self);
|
||||
mp_hal_delay_ms(1);
|
||||
#endif
|
||||
|
||||
#if defined(CHECK_DEVID)
|
||||
// Validate device id
|
||||
uint32_t devid;
|
||||
|
||||
Reference in New Issue
Block a user