refactor: SD card SPI HAL (#3957)
* refactor: SD card SPI driver * Removed SPI and DMA StdPeriph drivers * Allow for disabling SPI DMA support * Disable SPI sdcard CRC support * Fix 2MHz timer on NV14 * Shared VS1053b driver * Fix: SPI2 uses PCLK1 * feat: new generic diskio API * More generic SD_CARD_PRESENT() * Fixes * Flush incoming block on token mismatch * Scratch buffer test * Incredible hack to re-sync sd card * fix: SDIO driver
This commit is contained in:
+7
-51
@@ -22,8 +22,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/fatfs_diskio.h"
|
||||
#include "hal/storage.h"
|
||||
|
||||
#include "opentx.h"
|
||||
#include "diskio.h"
|
||||
|
||||
#if defined(LIBOPENUI)
|
||||
#include "libopenui.h"
|
||||
@@ -479,7 +481,8 @@ uint32_t sdGetSize()
|
||||
|
||||
uint32_t sdGetFreeSectors()
|
||||
{
|
||||
return ((SDCARD_MIN_FREE_SPACE_MB*1024*1024)/BLOCK_SIZE)+1; // SIMU SD card is always above threshold
|
||||
// SIMU SD card is always above threshold
|
||||
return ((SDCARD_MIN_FREE_SPACE_MB*1024*1024)/BLOCK_SIZE)+1;
|
||||
}
|
||||
|
||||
uint32_t sdGetFreeKB() { return SDCARD_MIN_FREE_SPACE_MB * 1024 + 1; }
|
||||
@@ -501,41 +504,11 @@ FIL g_bluetoothFile = {};
|
||||
|
||||
#include "audio.h"
|
||||
#include "sdcard.h"
|
||||
#include "disk_cache.h"
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Lock / unlock functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static RTOS_MUTEX_HANDLE ioMutex;
|
||||
uint32_t ioMutexReq = 0, ioMutexRel = 0;
|
||||
int ff_cre_syncobj (BYTE vol, FF_SYNC_t * mutex)
|
||||
{
|
||||
*mutex = ioMutex;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ff_req_grant (FF_SYNC_t mutex)
|
||||
{
|
||||
ioMutexReq += 1;
|
||||
RTOS_LOCK_MUTEX(mutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ff_rel_grant (FF_SYNC_t mutex)
|
||||
{
|
||||
ioMutexRel += 1;
|
||||
RTOS_UNLOCK_MUTEX(mutex);
|
||||
}
|
||||
|
||||
int ff_del_syncobj (FF_SYNC_t mutex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void sdInit()
|
||||
{
|
||||
TRACE("sdInit");
|
||||
RTOS_CREATE_MUTEX(ioMutex);
|
||||
storageInit();
|
||||
sdMount();
|
||||
}
|
||||
|
||||
@@ -543,9 +516,7 @@ void sdMount()
|
||||
{
|
||||
TRACE("sdMount");
|
||||
|
||||
#if defined(DISK_CACHE)
|
||||
diskCache.clear();
|
||||
#endif
|
||||
storagePreMountHook();
|
||||
|
||||
if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) {
|
||||
// call sdGetFreeSectors() now because f_getfree() takes a long time first time it's called
|
||||
@@ -598,18 +569,3 @@ uint32_t sdMounted()
|
||||
return _g_FATFS_init && (g_FATFS_Obj.fs_type != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
uint32_t sdIsHC()
|
||||
{
|
||||
// defined in diskio
|
||||
#define CT_BLOCK 0x08
|
||||
extern uint32_t SD_GetCardType();
|
||||
|
||||
return SD_GetCardType() & CT_BLOCK;
|
||||
}
|
||||
|
||||
uint32_t sdGetSpeed()
|
||||
{
|
||||
return 330000;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user