Debian Codegraph @

ports/stm32/boards/PYBD_SF2/bdev.c

raw
1 /*
2 * This file is part of the MicroPython project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2018-2019 Damien P. George
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
27 #include "storage.h"
28 #include "qspi.h"
29
30 #if MICROPY_HW_SPIFLASH_ENABLE_CACHE
31 // Shared cache for first and second SPI block devices
32 static mp_spiflash_cache_t spi_bdev_cache;
33 #endif
34
35 // First external SPI flash uses software QSPI interface
36
37 static const mp_soft_qspi_obj_t soft_qspi_bus = {
38 .cs = MICROPY_HW_SPIFLASH_CS,
39 .clk = MICROPY_HW_SPIFLASH_SCK,
40 .io0 = MICROPY_HW_SPIFLASH_IO0,
41 .io1 = MICROPY_HW_SPIFLASH_IO1,
42 .io2 = MICROPY_HW_SPIFLASH_IO2,
43 .io3 = MICROPY_HW_SPIFLASH_IO3,
44 };
45
46 const mp_spiflash_config_t spiflash_config = {
47 .bus_kind = MP_SPIFLASH_BUS_QSPI,
48 .bus.u_qspi.data = (void *)&soft_qspi_bus,
49 .bus.u_qspi.proto = &mp_soft_qspi_proto,
50 #if MICROPY_HW_SPIFLASH_ENABLE_CACHE
51 .cache = &spi_bdev_cache,
52 #endif
53 };
54
55 spi_bdev_t spi_bdev;
56
57 // Second external SPI flash uses hardware QSPI interface
58
59 const mp_spiflash_config_t spiflash2_config = {
60 .bus_kind = MP_SPIFLASH_BUS_QSPI,
61 .bus.u_qspi.data = NULL,
62 .bus.u_qspi.proto = &qspi_proto,
63 #if MICROPY_HW_SPIFLASH_ENABLE_CACHE
64 .cache = &spi_bdev_cache,
65 #endif
66 };
67
68 spi_bdev_t spi_bdev2;