Skip to content

Commit e7edf07

Browse files
committed
drivers/memory/spiflash: Allow a board/port to configure chip params.
This commit allows the user of this driver to dynamically configure the SPI flash chip parameters. For this, enable `MICROPY_HW_SPIFLASH_CHIP_PARAMS` and then set the `mp_spiflash_t::chip_params` element to point to a valid `mp_spiflash_chip_params_t` struct. Signed-off-by: Damien George <[email protected]>
1 parent ef8282c commit e7edf07

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/memory/spiflash.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#include "drivers/bus/spi.h"
3030
#include "drivers/bus/qspi.h"
3131

32+
// Whether to enable dynamic configuration of SPI flash through mp_spiflash_chip_params_t.
33+
#ifndef MICROPY_HW_SPIFLASH_CHIP_PARAMS
34+
#define MICROPY_HW_SPIFLASH_CHIP_PARAMS (0)
35+
#endif
36+
3237
#define MP_SPIFLASH_ERASE_BLOCK_SIZE (4096) // must be a power of 2
3338

3439
enum {
@@ -66,8 +71,20 @@ typedef struct _mp_spiflash_config_t {
6671
#endif
6772
} mp_spiflash_config_t;
6873

74+
#if MICROPY_HW_SPIFLASH_CHIP_PARAMS
75+
typedef struct _mp_spiflash_chip_params_t {
76+
uint32_t jedec_id;
77+
uint8_t memory_size_bytes_log2;
78+
uint8_t qspi_prescaler;
79+
uint8_t qread_num_dummy;
80+
} mp_spiflash_chip_params_t;
81+
#endif
82+
6983
typedef struct _mp_spiflash_t {
7084
const mp_spiflash_config_t *config;
85+
#if MICROPY_HW_SPIFLASH_CHIP_PARAMS
86+
const mp_spiflash_chip_params_t *chip_params;
87+
#endif
7188
volatile uint32_t flags;
7289
} mp_spiflash_t;
7390

0 commit comments

Comments
 (0)