summaryrefslogtreecommitdiff
path: root/stmhal
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-08-29 11:37:18 +1000
committerDamien George <damien.p.george@gmail.com>2017-08-29 11:37:18 +1000
commit613510bce83b8318bd21bcd17f247ba30e0d7cea (patch)
treeb1081fce54b9f4e306edeb1159fad0889b5b09a4 /stmhal
parentd5336ba13637bdf07721d02c1095304bf32224ee (diff)
drivers/memory/spiflash: Change from hard-coded soft SPI to generic SPI.
The SPI flash driver now supports using an arbitrary SPI object to communicate with the flash chip, and in particular can use a hardware SPI peripheral.
Diffstat (limited to 'stmhal')
-rw-r--r--stmhal/storage.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/stmhal/storage.c b/stmhal/storage.c
index 6da1ba95c..af75ccda4 100644
--- a/stmhal/storage.c
+++ b/stmhal/storage.c
@@ -176,17 +176,19 @@ static uint8_t *flash_cache_get_addr_for_read(uint32_t flash_addr) {
static bool flash_is_initialised = false;
+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,
+ .polarity = 0,
+ .phase = 0,
+ .sck = &MICROPY_HW_SPIFLASH_SCK,
+ .mosi = &MICROPY_HW_SPIFLASH_MOSI,
+ .miso = &MICROPY_HW_SPIFLASH_MISO,
+};
+
STATIC const mp_spiflash_t spiflash = {
.cs = &MICROPY_HW_SPIFLASH_CS,
- .spi = {
- .base = {&mp_machine_soft_spi_type},
- .delay_half = MICROPY_PY_MACHINE_SPI_MIN_DELAY,
- .polarity = 0,
- .phase = 0,
- .sck = &MICROPY_HW_SPIFLASH_SCK,
- .mosi = &MICROPY_HW_SPIFLASH_MOSI,
- .miso = &MICROPY_HW_SPIFLASH_MISO,
- },
+ .spi = (mp_obj_base_t*)&spiflash_spi_bus.base,
};
#endif