| 1 |
#include "storage.h" |
| 2 |
#include "spi.h" |
| 3 |
#include "py/mpconfig.h" |
| 4 |
|
| 5 |
#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE |
| 6 |
|
| 7 |
#if WEACT_F411_V20 |
| 8 |
// External SPI flash uses SPI interface, but not on all HW spi pins. |
| 9 |
static const mp_soft_spi_obj_t spi_bus = { |
| 10 |
.delay_half = MICROPY_HW_SOFTSPI_MIN_DELAY, |
| 11 |
.polarity = 0, |
| 12 |
.phase = 0, |
| 13 |
.sck = MICROPY_HW_SPIFLASH_SCK, |
| 14 |
.mosi = MICROPY_HW_SPIFLASH_MOSI, |
| 15 |
.miso = MICROPY_HW_SPIFLASH_MISO, |
| 16 |
}; |
| 17 |
|
| 18 |
#else // WEACT_F411_V1.3 or WEACT_F411_V3.1 |
| 19 |
static const spi_proto_cfg_t spi_bus = { |
| 20 |
.spi = &spi_obj[0], // SPI1 |
| 21 |
.baudrate = 25000000, |
| 22 |
.polarity = 0, |
| 23 |
.phase = 0, |
| 24 |
.bits = 8, |
| 25 |
.firstbit = SPI_FIRSTBIT_MSB, |
| 26 |
}; |
| 27 |
#endif |
| 28 |
|
| 29 |
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE |
| 30 |
static mp_spiflash_cache_t spi_bdev_cache; |
| 31 |
#endif |
| 32 |
|
| 33 |
const mp_spiflash_config_t spiflash_config = { |
| 34 |
.bus_kind = MP_SPIFLASH_BUS_SPI, |
| 35 |
.bus.u_spi.cs = MICROPY_HW_SPIFLASH_CS, |
| 36 |
.bus.u_spi.data = (void *)&spi_bus, |
| 37 |
.bus.u_spi.proto = &spi_proto, |
| 38 |
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE |
| 39 |
.cache = &spi_bdev_cache, |
| 40 |
#endif |
| 41 |
}; |
| 42 |
|
| 43 |
spi_bdev_t spi_bdev; |
| 44 |
|
| 45 |
#endif |