mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
[sky9x] SD initialization reworked!
This commit is contained in:
parent
3223b890ad
commit
665830cf82
4 changed files with 9 additions and 11 deletions
|
@ -481,7 +481,7 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
|
||||||
printf("playFile(\"%s\")\n", filename); fflush(stdout);
|
printf("playFile(\"%s\")\n", filename); fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!CardIsConnected() || (Card_state != SD_ST_MOUNTED && Card_state != SD_ST_STARTUP))
|
if (Card_initialized && !sd_card_mounted())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CoEnterMutexSection(audioMutex);
|
CoEnterMutexSection(audioMutex);
|
||||||
|
|
|
@ -512,6 +512,7 @@
|
||||||
#define SD_ST_MOUNTED 10
|
#define SD_ST_MOUNTED 10
|
||||||
|
|
||||||
extern int32_t Card_state;
|
extern int32_t Card_state;
|
||||||
|
extern uint32_t Card_initialized;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define BOARD_PSRAM_PINS PIN_EBI_DATA_BUS, PIN_EBI_NCS0, PIN_EBI_NRD, PIN_EBI_NWE, \
|
#define BOARD_PSRAM_PINS PIN_EBI_DATA_BUS, PIN_EBI_NCS0, PIN_EBI_NRD, PIN_EBI_NWE, \
|
||||||
|
|
|
@ -70,6 +70,7 @@ uint32_t Card_ID[4] ;
|
||||||
uint32_t Card_SCR[2] ;
|
uint32_t Card_SCR[2] ;
|
||||||
uint32_t Card_CSD[4] ;
|
uint32_t Card_CSD[4] ;
|
||||||
int32_t Card_state = SD_ST_STARTUP ;
|
int32_t Card_state = SD_ST_STARTUP ;
|
||||||
|
uint32_t Card_initialized = 0;
|
||||||
uint32_t Sd_128_resp[4] ;
|
uint32_t Sd_128_resp[4] ;
|
||||||
uint32_t Sd_rca ;
|
uint32_t Sd_rca ;
|
||||||
uint32_t Cmd_8_resp ;
|
uint32_t Cmd_8_resp ;
|
||||||
|
@ -801,7 +802,7 @@ void retrieveAvailableAudioFiles();
|
||||||
|
|
||||||
void sdPoll10mS()
|
void sdPoll10mS()
|
||||||
{
|
{
|
||||||
if (Card_state == SD_ST_STARTUP)
|
if (!Card_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!CardIsConnected()) {
|
if (!CardIsConnected()) {
|
||||||
|
@ -903,21 +904,17 @@ void sdInit()
|
||||||
sdCmd9();
|
sdCmd9();
|
||||||
sdCmd7(); // Select Card
|
sdCmd7(); // Select Card
|
||||||
|
|
||||||
CoTickDelay(1); // 2ms
|
|
||||||
|
|
||||||
sdAcmd51();
|
sdAcmd51();
|
||||||
sdAcmd6(); // Set bus width to 4 bits, and speed to 9 MHz
|
sdAcmd6(); // Set bus width to 4 bits, and speed to 9 MHz
|
||||||
|
|
||||||
CoTickDelay(1); // 2ms
|
|
||||||
|
|
||||||
// Should check the card can do this ****
|
// Should check the card can do this ****
|
||||||
if (f_mount(0, &g_FATFS_Obj) != FR_OK) {
|
Card_state = SD_ST_DATA;
|
||||||
Card_state = SD_ST_DATA;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
f_mount(0, &g_FATFS_Obj);
|
||||||
retrieveAvailableAudioFiles();
|
retrieveAvailableAudioFiles();
|
||||||
Card_state = SD_ST_MOUNTED;
|
Card_state = SD_ST_MOUNTED;
|
||||||
|
|
||||||
|
Card_initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks for card ready for read/write
|
// Checks for card ready for read/write
|
||||||
|
|
|
@ -3128,7 +3128,7 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
||||||
doSplash();
|
doSplash();
|
||||||
|
|
||||||
#if defined(PCBARM)
|
#if defined(PCBARM)
|
||||||
while (Card_state == SD_ST_STARTUP) {
|
while (!Card_initialized) {
|
||||||
CoTickDelay(1); // 2ms
|
CoTickDelay(1); // 2ms
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue