1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 08:15:17 +03:00

[sky9x] SD initialization reworked!

This commit is contained in:
bsongis 2012-08-29 21:56:28 +00:00
parent 3223b890ad
commit 665830cf82
4 changed files with 9 additions and 11 deletions

View file

@ -481,7 +481,7 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
printf("playFile(\"%s\")\n", filename); fflush(stdout);
#endif
if (!CardIsConnected() || (Card_state != SD_ST_MOUNTED && Card_state != SD_ST_STARTUP))
if (Card_initialized && !sd_card_mounted())
return;
CoEnterMutexSection(audioMutex);

View file

@ -512,6 +512,7 @@
#define SD_ST_MOUNTED 10
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, \

View file

@ -70,6 +70,7 @@ uint32_t Card_ID[4] ;
uint32_t Card_SCR[2] ;
uint32_t Card_CSD[4] ;
int32_t Card_state = SD_ST_STARTUP ;
uint32_t Card_initialized = 0;
uint32_t Sd_128_resp[4] ;
uint32_t Sd_rca ;
uint32_t Cmd_8_resp ;
@ -801,7 +802,7 @@ void retrieveAvailableAudioFiles();
void sdPoll10mS()
{
if (Card_state == SD_ST_STARTUP)
if (!Card_initialized)
return;
if (!CardIsConnected()) {
@ -903,21 +904,17 @@ void sdInit()
sdCmd9();
sdCmd7(); // Select Card
CoTickDelay(1); // 2ms
sdAcmd51();
sdAcmd6(); // Set bus width to 4 bits, and speed to 9 MHz
CoTickDelay(1); // 2ms
// Should check the card can do this ****
if (f_mount(0, &g_FATFS_Obj) != FR_OK) {
Card_state = SD_ST_DATA;
return;
}
Card_state = SD_ST_DATA;
f_mount(0, &g_FATFS_Obj);
retrieveAvailableAudioFiles();
Card_state = SD_ST_MOUNTED;
Card_initialized = 1;
}
// Checks for card ready for read/write

View file

@ -3128,7 +3128,7 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
doSplash();
#if defined(PCBARM)
while (Card_state == SD_ST_STARTUP) {
while (!Card_initialized) {
CoTickDelay(1); // 2ms
}
#endif