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:
parent
7471ada0c1
commit
8d78e15a4b
6 changed files with 12 additions and 20 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue