stm32/spibdev: Add option to configure SPI block dev to use QSPI flash.
To use QSPI (in software QSPI mode) the configuration needed is: #define MICROPY_HW_SPIFLASH_SIZE_BITS (n * 1024 * 1024) #define MICROPY_HW_SPIFLASH_CS (pin_x1) #define MICROPY_HW_SPIFLASH_SCK (pin_x2) #define MICROPY_HW_SPIFLASH_IO0 (pin_x3) #define MICROPY_HW_SPIFLASH_IO1 (pin_x4) #define MICROPY_HW_SPIFLASH_IO2 (pin_x5) #define MICROPY_HW_SPIFLASH_IO3 (pin_x6)
This commit is contained in:
parent
a0dfc38641
commit
0210383da5
@ -185,6 +185,7 @@ EXTMOD_SRC_C = $(addprefix extmod/,\
|
||||
)
|
||||
|
||||
DRIVERS_SRC_C = $(addprefix drivers/,\
|
||||
bus/softqspi.c \
|
||||
memory/spiflash.c \
|
||||
dht/dht.c \
|
||||
)
|
||||
|
@ -36,6 +36,10 @@
|
||||
|
||||
static uint32_t flash_tick_counter_last_write;
|
||||
|
||||
#if defined(MICROPY_HW_SPIFLASH_MOSI)
|
||||
|
||||
// External SPI flash uses standard SPI interface
|
||||
|
||||
STATIC const mp_machine_soft_spi_obj_t spiflash_spi_bus = {
|
||||
.base = {&mp_machine_soft_spi_type},
|
||||
.delay_half = MICROPY_PY_MACHINE_SPI_MIN_DELAY,
|
||||
@ -53,6 +57,29 @@ STATIC const mp_spiflash_config_t spiflash_config = {
|
||||
.bus.u_spi.proto = &mp_machine_soft_spi_p,
|
||||
};
|
||||
|
||||
#elif defined(MICROPY_HW_SPIFLASH_IO0)
|
||||
|
||||
// External SPI flash uses quad SPI interface
|
||||
|
||||
#include "drivers/bus/qspi.h"
|
||||
|
||||
STATIC const mp_soft_qspi_obj_t soft_qspi_bus = {
|
||||
.cs = &MICROPY_HW_SPIFLASH_CS,
|
||||
.clk = &MICROPY_HW_SPIFLASH_SCK,
|
||||
.io0 = &MICROPY_HW_SPIFLASH_IO0,
|
||||
.io1 = &MICROPY_HW_SPIFLASH_IO1,
|
||||
.io2 = &MICROPY_HW_SPIFLASH_IO2,
|
||||
.io3 = &MICROPY_HW_SPIFLASH_IO3,
|
||||
};
|
||||
|
||||
STATIC const mp_spiflash_config_t spiflash_config = {
|
||||
.bus_kind = MP_SPIFLASH_BUS_QSPI,
|
||||
.bus.u_qspi.data = (void*)&soft_qspi_bus,
|
||||
.bus.u_qspi.proto = &mp_soft_qspi_proto,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
STATIC mp_spiflash_t spiflash;
|
||||
|
||||
void spi_bdev_init(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user