mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Refactored SD card initialisation to contain SD card detection initialisation.
This commit is contained in:
parent
7e6a890e47
commit
da93c07432
4 changed files with 3 additions and 15 deletions
|
@ -67,15 +67,7 @@ sdcard_t sdcard;
|
|||
|
||||
STATIC_ASSERT(sizeof(sdcardCSD_t) == 16, sdcard_csd_bitfields_didnt_pack_properly);
|
||||
|
||||
void sdcardInsertionDetectDeinit(void)
|
||||
{
|
||||
if (sdcard.cardDetectPin) {
|
||||
IOInit(sdcard.cardDetectPin, OWNER_FREE, 0);
|
||||
IOConfigGPIO(sdcard.cardDetectPin, IOCFG_IN_FLOATING);
|
||||
}
|
||||
}
|
||||
|
||||
void sdcardInsertionDetectInit(const sdcardConfig_t *config)
|
||||
static void sdcardInsertionDetectInit(const sdcardConfig_t *config)
|
||||
{
|
||||
if (config->cardDetectTag) {
|
||||
sdcard.cardDetectPin = IOGetByTag(config->cardDetectTag);
|
||||
|
@ -122,6 +114,8 @@ void sdcard_preInit(const sdcardConfig_t *config)
|
|||
|
||||
void sdcard_init(const sdcardConfig_t *config)
|
||||
{
|
||||
sdcardInsertionDetectInit(config);
|
||||
|
||||
switch (config->mode) {
|
||||
#ifdef USE_SDCARD_SPI
|
||||
case SDCARD_MODE_SPI:
|
||||
|
|
|
@ -65,9 +65,6 @@ bool sdcard_readBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationComp
|
|||
sdcardOperationStatus_e sdcard_beginWriteBlocks(uint32_t blockIndex, uint32_t blockCount);
|
||||
sdcardOperationStatus_e sdcard_writeBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData);
|
||||
|
||||
void sdcardInsertionDetectDeinit(void);
|
||||
void sdcardInsertionDetectInit(const sdcardConfig_t *config);
|
||||
|
||||
bool sdcard_isInserted(void);
|
||||
bool sdcard_isInitialized(void);
|
||||
bool sdcard_isFunctional(void);
|
||||
|
|
|
@ -107,8 +107,6 @@ extern sdcard_t sdcard;
|
|||
|
||||
STATIC_ASSERT(sizeof(sdcardCSD_t) == 16, sdcard_csd_bitfields_didnt_pack_properly);
|
||||
|
||||
void sdcardInsertionDetectInit(const sdcardConfig_t *config);
|
||||
void sdcardInsertionDetectDeinit(void);
|
||||
bool sdcard_isInserted(void);
|
||||
|
||||
typedef struct sdcardVTable_s {
|
||||
|
|
|
@ -252,7 +252,6 @@ static void configureSPIAndQuadSPI(void)
|
|||
|
||||
void sdCardAndFSInit()
|
||||
{
|
||||
sdcardInsertionDetectInit(sdcardConfig());
|
||||
sdcard_init(sdcardConfig());
|
||||
afatfs_init();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue