[4.4.2] Remove 15 m/s limit on estimated vario (#12788)
[betaflight.git] / src / main / pg / sdcard.c
blob292203cb8f8d83172a2c220c735c2413692078d8
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include <stdbool.h>
22 #include <stdint.h>
24 #include "platform.h"
26 #ifdef USE_SDCARD
28 #include "pg/pg.h"
29 #include "pg/pg_ids.h"
31 #include "sdcard.h"
32 #include "drivers/bus_spi.h"
33 #include "drivers/sdio.h"
34 #include "drivers/io.h"
35 #include "drivers/dma.h"
36 #include "drivers/dma_reqmap.h"
38 PG_REGISTER_WITH_RESET_FN(sdcardConfig_t, sdcardConfig, PG_SDCARD_CONFIG, 2);
40 void pgResetFn_sdcardConfig(sdcardConfig_t *config)
42 config->cardDetectTag = IO_TAG(SDCARD_DETECT_PIN);
43 config->cardDetectInverted = SDCARD_DETECT_IS_INVERTED;
45 // We can safely handle SPI and SDIO cases separately on custom targets, as these are exclusive per target.
46 // On generic targets, SPI has precedence over SDIO; SDIO must be post-flash configured.
47 config->device = SPI_DEV_TO_CFG(SPIINVALID);
49 #ifdef CONFIG_IN_SDCARD
50 // CONFIG_ID_SDDCARD requires a default mode.
51 #if defined(USE_SDCARD_SDIO)
52 config->mode = SDCARD_MODE_SDIO;
53 #elif defined(USE_SDCARD_SPI)
54 config->mode = SDCARD_MODE_SPI;
55 #endif
56 #else
57 config->mode = SDCARD_MODE_NONE;
58 #endif
60 #if defined(STM32H7) && defined(USE_SDCARD_SDIO) // H7 only for now, likely should be applied to F4/F7 too
61 config->mode = SDCARD_MODE_SDIO;
62 #endif
64 #ifdef USE_SDCARD_SPI
65 // These settings do not work for Unified Targets
66 // They are only left in place to support legacy targets
67 SPIDevice spidevice = spiDeviceByInstance(SDCARD_SPI_INSTANCE);
68 config->device = SPI_DEV_TO_CFG(spidevice);
69 config->chipSelectTag = IO_TAG(SDCARD_SPI_CS_PIN);
71 if (spidevice != SPIINVALID && config->chipSelectTag) {
72 config->mode = SDCARD_MODE_SPI;
74 #endif
76 #if defined(USE_SDCARD_SDIO)
77 if (SDIO_DEVICE != SDIOINVALID) {
78 config->mode = SDCARD_MODE_SDIO;
80 #endif
82 #endif