mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 16:55:29 +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:
parent
1873c20e74
commit
1084d7de49
2 changed files with 33 additions and 11 deletions
|
@ -83,7 +83,7 @@ bool sdcard_isInserted(void)
|
|||
/**
|
||||
* Dispatch
|
||||
*/
|
||||
sdcardVTable_t *sdcardVTable;
|
||||
sdcardVTable_t *sdcardVTable = NULL;
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return sdcardVTable->writeBlock(blockIndex, buffer, callback, callbackData);
|
||||
if (sdcardVTable) {
|
||||
return sdcardVTable->writeBlock(blockIndex, buffer, callback, callbackData);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool sdcard_poll(void)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "platform.h"
|
||||
|
||||
#include "blackbox/blackbox.h"
|
||||
#include "blackbox/blackbox_io.h"
|
||||
|
||||
#include "build/assert.h"
|
||||
#include "build/atomic.h"
|
||||
|
@ -597,21 +598,30 @@ void init(void)
|
|||
}
|
||||
#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
|
||||
case BLACKBOX_DEVICE_FLASH:
|
||||
#ifdef USE_FLASH_M25P16
|
||||
m25p16_init(0);
|
||||
m25p16_init(0);
|
||||
#endif
|
||||
|
||||
flashfsInit();
|
||||
flashfsInit();
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDCARD
|
||||
sdcardInsertionDetectInit();
|
||||
sdcard_init();
|
||||
afatfs_init();
|
||||
case BLACKBOX_DEVICE_SDCARD:
|
||||
sdcardInsertionDetectInit();
|
||||
sdcard_init();
|
||||
afatfs_init();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef USE_BLACKBOX
|
||||
blackboxInit();
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue