mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
Switch between SPI and SDIO based on mode
This commit is contained in:
parent
f34af48dcd
commit
a1589766a2
4 changed files with 140 additions and 18 deletions
|
@ -63,7 +63,7 @@
|
|||
* Returns true if the card has already been, or is currently, initializing and hasn't encountered enough errors to
|
||||
* trip our error threshold and be disabled (i.e. our card is in and working!)
|
||||
*/
|
||||
bool sdcard_isFunctional(void)
|
||||
static bool sdcardSpi_isFunctional(void)
|
||||
{
|
||||
return sdcard.state != SDCARD_STATE_NOT_PRESENT;
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ static bool sdcard_checkInitDone(void)
|
|||
/**
|
||||
* Begin the initialization process for the SD card. This must be called first before any other sdcard_ routine.
|
||||
*/
|
||||
void sdcard_init(const sdcardConfig_t *config)
|
||||
static void sdcardSpi_init(const sdcardConfig_t *config)
|
||||
{
|
||||
sdcard.enabled = config->enabled;
|
||||
if (!sdcard.enabled) {
|
||||
|
@ -587,7 +587,7 @@ static sdcardOperationStatus_e sdcard_endWriteBlocks(void)
|
|||
*
|
||||
* Returns true if the card is ready to accept commands.
|
||||
*/
|
||||
bool sdcard_poll(void)
|
||||
static bool sdcardSpi_poll(void)
|
||||
{
|
||||
if (!sdcard.enabled) {
|
||||
sdcard.state = SDCARD_STATE_NOT_PRESENT;
|
||||
|
@ -897,7 +897,7 @@ bool sdcard_poll(void)
|
|||
* SDCARD_OPERATION_BUSY - The card is already busy and cannot accept your write
|
||||
* SDCARD_OPERATION_FAILURE - Your write was rejected by the card, card will be reset
|
||||
*/
|
||||
sdcardOperationStatus_e sdcard_writeBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData)
|
||||
static sdcardOperationStatus_e sdcardSpi_writeBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData)
|
||||
{
|
||||
uint8_t status;
|
||||
|
||||
|
@ -964,7 +964,7 @@ sdcardOperationStatus_e sdcard_writeBlock(uint32_t blockIndex, uint8_t *buffer,
|
|||
* SDCARD_OPERATION_BUSY - The card is already busy and cannot accept your write
|
||||
* SDCARD_OPERATION_FAILURE - A fatal error occured, card will be reset
|
||||
*/
|
||||
sdcardOperationStatus_e sdcard_beginWriteBlocks(uint32_t blockIndex, uint32_t blockCount)
|
||||
static sdcardOperationStatus_e sdcardSpi_beginWriteBlocks(uint32_t blockIndex, uint32_t blockCount)
|
||||
{
|
||||
if (sdcard.state != SDCARD_STATE_READY) {
|
||||
if (sdcard.state == SDCARD_STATE_WRITING_MULTIPLE_BLOCKS) {
|
||||
|
@ -1012,7 +1012,7 @@ sdcardOperationStatus_e sdcard_beginWriteBlocks(uint32_t blockIndex, uint32_t bl
|
|||
* true - The operation was successfully queued for later completion, your callback will be called later
|
||||
* false - The operation could not be started due to the card being busy (try again later).
|
||||
*/
|
||||
bool sdcard_readBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData)
|
||||
static bool sdcardSpi_readBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData)
|
||||
{
|
||||
if (sdcard.state != SDCARD_STATE_READY) {
|
||||
if (sdcard.state == SDCARD_STATE_WRITING_MULTIPLE_BLOCKS) {
|
||||
|
@ -1056,23 +1056,37 @@ bool sdcard_readBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationComp
|
|||
/**
|
||||
* Returns true if the SD card has successfully completed its startup procedures.
|
||||
*/
|
||||
bool sdcard_isInitialized(void)
|
||||
static bool sdcardSpi_isInitialized(void)
|
||||
{
|
||||
return sdcard.state >= SDCARD_STATE_READY;
|
||||
}
|
||||
|
||||
const sdcardMetadata_t* sdcard_getMetadata(void)
|
||||
static const sdcardMetadata_t* sdcardSpi_getMetadata(void)
|
||||
{
|
||||
return &sdcard.metadata;
|
||||
}
|
||||
|
||||
#ifdef SDCARD_PROFILING
|
||||
|
||||
void sdcard_setProfilerCallback(sdcard_profilerCallback_c callback)
|
||||
static void sdcardSpi_setProfilerCallback(sdcard_profilerCallback_c callback)
|
||||
{
|
||||
sdcard.profiler = callback;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
sdcardVTable_t sdcardSpiVTable = {
|
||||
sdcardSpi_init,
|
||||
sdcardSpi_readBlock,
|
||||
sdcardSpi_beginWriteBlocks,
|
||||
sdcardSpi_writeBlock,
|
||||
sdcardSpi_poll,
|
||||
sdcardSpi_isFunctional,
|
||||
sdcardSpi_isInitialized,
|
||||
sdcardSpi_getMetadata,
|
||||
#ifdef SDCARD_PROFILING
|
||||
sdcardSpi_setProfilerCallback,
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue