1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Fix use of sdcard.cardDetectPin before it is initialised.

* de-duplicate some SDIO/SPI sd-card detection code.
* ensure detectionInverted is set to false for SDIO case where
`cardDetectTag` is not configured.
This commit is contained in:
Dominic Clifton 2019-07-10 17:06:19 +02:00
parent 7471ada0c1
commit 8d78e15a4b
6 changed files with 12 additions and 20 deletions

View file

@ -75,8 +75,16 @@ void sdcardInsertionDetectDeinit(void)
}
}
void sdcardInsertionDetectInit(void)
void sdcardInsertionDetectInit(const sdcardConfig_t *config)
{
if (config->cardDetectTag) {
sdcard.cardDetectPin = IOGetByTag(config->cardDetectTag);
sdcard.detectionInverted = config->cardDetectInverted;
} else {
sdcard.cardDetectPin = IO_NONE;
sdcard.detectionInverted = false;
}
if (sdcard.cardDetectPin) {
IOInit(sdcard.cardDetectPin, OWNER_SDCARD_DETECT, 0);
IOConfigGPIO(sdcard.cardDetectPin, IOCFG_IPU);