1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 01:35:35 +03:00

[SDCARD/FLASH] Make sure we only init what's needed for blackbox. This allows SPI bus sharing between SPI and FLASH

This commit is contained in:
Konstantin Sharlaimov (DigitalEntity) 2019-04-10 23:24:08 +02:00
parent 1873c20e74
commit 1084d7de49
2 changed files with 33 additions and 11 deletions

View file

@ -83,7 +83,7 @@ bool sdcard_isInserted(void)
/** /**
* Dispatch * Dispatch
*/ */
sdcardVTable_t *sdcardVTable; sdcardVTable_t *sdcardVTable = NULL;
void sdcard_init(void) void sdcard_init(void)
{ {
@ -100,17 +100,29 @@ void sdcard_init(void)
bool sdcard_readBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData) bool sdcard_readBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData)
{ {
return sdcardVTable->readBlock(blockIndex, buffer, callback, callbackData); if (sdcardVTable) {
return sdcardVTable->readBlock(blockIndex, buffer, callback, callbackData);
} else {
return false;
}
} }
sdcardOperationStatus_e sdcard_beginWriteBlocks(uint32_t blockIndex, uint32_t blockCount) sdcardOperationStatus_e sdcard_beginWriteBlocks(uint32_t blockIndex, uint32_t blockCount)
{ {
return sdcardVTable->beginWriteBlocks(blockIndex, blockCount); if (sdcardVTable) {
return sdcardVTable->beginWriteBlocks(blockIndex, blockCount);
} else {
return false;
}
} }
sdcardOperationStatus_e sdcard_writeBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData) sdcardOperationStatus_e sdcard_writeBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData)
{ {
return sdcardVTable->writeBlock(blockIndex, buffer, callback, callbackData); if (sdcardVTable) {
return sdcardVTable->writeBlock(blockIndex, buffer, callback, callbackData);
} else {
return false;
}
} }
bool sdcard_poll(void) bool sdcard_poll(void)

View file

@ -22,6 +22,7 @@
#include "platform.h" #include "platform.h"
#include "blackbox/blackbox.h" #include "blackbox/blackbox.h"
#include "blackbox/blackbox_io.h"
#include "build/assert.h" #include "build/assert.h"
#include "build/atomic.h" #include "build/atomic.h"
@ -597,21 +598,30 @@ void init(void)
} }
#endif #endif
#ifdef USE_BLACKBOX
// SDCARD and FLASHFS are used only for blackbox
// Make sure we only init what's necessary for blackbox
switch (blackboxConfig()->device) {
#ifdef USE_FLASHFS #ifdef USE_FLASHFS
case BLACKBOX_DEVICE_FLASH:
#ifdef USE_FLASH_M25P16 #ifdef USE_FLASH_M25P16
m25p16_init(0); m25p16_init(0);
#endif #endif
flashfsInit();
flashfsInit(); break;
#endif #endif
#ifdef USE_SDCARD #ifdef USE_SDCARD
sdcardInsertionDetectInit(); case BLACKBOX_DEVICE_SDCARD:
sdcard_init(); sdcardInsertionDetectInit();
afatfs_init(); sdcard_init();
afatfs_init();
break;
#endif #endif
default:
break;
}
#ifdef USE_BLACKBOX
blackboxInit(); blackboxInit();
#endif #endif