Skip to content

Commit 3b92139

Browse files
committed
alif/ospi_flash: Add ospi_flash_sleep helper function.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 6d9d880 commit 3b92139

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

ports/alif/ospi_flash.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ int ospi_flash_xip_restore(ospi_flash_t *self) {
391391
/******************************************************************************/
392392
// Top-level read/erase/write functions.
393393

394+
void ospi_flash_sleep(void) {
395+
ospi_flash_t *self = &global_flash;
396+
ospi_flash_write_cmd(self, self->set->power_down_command);
397+
}
398+
394399
int ospi_flash_erase_sector(uint32_t addr) {
395400
ospi_flash_t *self = &global_flash;
396401

ports/alif/ospi_flash.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ typedef struct _ospi_flash_settings_t {
7373
uint8_t read_dummy_cycles;
7474
uint16_t write_command;
7575
uint16_t erase_command;
76+
uint16_t power_down_command;
7677
} ospi_flash_settings_t;
7778

7879
// Provided by the board when it enables OSPI.
@@ -97,6 +98,7 @@ int ospi_flash_xip_exit(struct _ospi_flash_t *self);
9798
// SPI flash interface.
9899
int ospi_flash_init(void);
99100
uintptr_t ospi_flash_get_xip_base(void);
101+
void ospi_flash_sleep(void);
100102
int ospi_flash_erase_sector(uint32_t addr);
101103
int ospi_flash_read(uint32_t addr, uint32_t len, uint8_t *dest);
102104
int ospi_flash_write(uint32_t addr, uint32_t len, const uint8_t *src);

ports/alif/ospi_flash_settings.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
.read_id_dummy_cycles = 4, \
4545
.read_command = 0xee11, \
4646
.write_command = 0x12ed, \
47-
.erase_command = 0x21de
47+
.erase_command = 0x21de, \
48+
.power_down_command = 0xb946
4849

4950
// Everspin EM.
5051
#define OSPI_FLASH_SETTINGS_EM \
@@ -61,7 +62,8 @@
6162
.read_id_dummy_cycles = 8, \
6263
.read_command = 0xfd, \
6364
.write_command = 0xc2, \
64-
.erase_command = 0x21
65+
.erase_command = 0x21, \
66+
.power_down_command = 0xb9
6567

6668
// ISSI IS25.
6769
#define OSPI_FLASH_SETTINGS_IS25 \
@@ -78,5 +80,7 @@
7880
.read_id_dummy_cycles = 8, \
7981
.read_command = 0xfd, \
8082
.write_command = 0xc2, \
81-
.erase_command = 0x21
83+
.erase_command = 0x21, \
84+
.power_down_command = 0xb9
85+
8286
#endif // __OSPI_FLASH_SETTINGS_H__

0 commit comments

Comments
 (0)