|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2025 Mike Tolkachev <contact@miketolkachev.dev> |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + * of this software and associated documentation files (the "Software"), to deal |
| 10 | + * in the Software without restriction, including without limitation the rights |
| 11 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + * copies of the Software, and to permit persons to whom the Software is |
| 13 | + * furnished to do so, subject to the following conditions: |
| 14 | + * |
| 15 | + * The above copyright notice and this permission notice shall be included in |
| 16 | + * all copies or substantial portions of the Software. |
| 17 | + * |
| 18 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + * THE SOFTWARE. |
| 25 | + */ |
| 26 | + |
1 | 27 | #include "storage.h" |
2 | 28 | #include "qspi.h" |
3 | 29 |
|
4 | | -// External SPI flash uses standard SPI interface |
5 | | - |
6 | | -STATIC mp_spiflash_cache_t spi_bdev_cache; |
7 | | - |
8 | | -#ifdef MICROPY_F469DISC_USE_SOFTSPI |
9 | | - |
10 | | -STATIC const mp_soft_spi_obj_t soft_spi_bus = { |
11 | | - .delay_half = MICROPY_HW_SOFTSPI_MIN_DELAY, |
12 | | - .polarity = 0, |
13 | | - .phase = 0, |
14 | | - .sck = MICROPY_HW_SPIFLASH_SCK, |
15 | | - .mosi = MICROPY_HW_SPIFLASH_MOSI, |
16 | | - .miso = MICROPY_HW_SPIFLASH_MISO, |
17 | | -}; |
18 | | - |
19 | | -const mp_spiflash_config_t spiflash_config = { |
20 | | - .bus_kind = MP_SPIFLASH_BUS_SPI, |
21 | | - .bus.u_spi.cs = MICROPY_HW_SPIFLASH_CS, |
22 | | - .bus.u_spi.data = (void *)&soft_spi_bus, |
23 | | - .bus.u_spi.proto = &mp_soft_spi_proto, |
24 | | - .cache = &spi_bdev_cache, |
25 | | -}; |
26 | | - |
27 | | -#else // MICROPY_F469DISC_USE_SOFTSPI |
| 30 | +#if MICROPY_HW_SPIFLASH_ENABLE_CACHE |
| 31 | +static mp_spiflash_cache_t spi_bdev_cache; |
| 32 | +#endif |
28 | 33 |
|
| 34 | +// External SPI flash uses QSPI interface |
29 | 35 | const mp_spiflash_config_t spiflash_config = { |
30 | 36 | .bus_kind = MP_SPIFLASH_BUS_QSPI, |
31 | 37 | .bus.u_qspi.data = NULL, |
32 | 38 | .bus.u_qspi.proto = &qspi_proto, |
| 39 | + #if MICROPY_HW_SPIFLASH_ENABLE_CACHE |
33 | 40 | .cache = &spi_bdev_cache, |
| 41 | + #endif |
34 | 42 | }; |
35 | 43 |
|
36 | | -#endif // MICROPY_F469DISC_USE_SOFTSPI |
37 | | - |
| 44 | +// SPI flash device instance |
38 | 45 | spi_bdev_t spi_bdev; |
0 commit comments