Посмотрел Ваши исходники и то что использую (исходники Martin THOMAS для инициализации), команды отсылаются в одинаковом порядке. Начал снова дебажить, в функции MCI_disk_initialize()
инициализация самой флешки проходит нормально (в выше написанной функции дергаются MCI_CardInit() и MCI_Check_CID, и они возвращают true), а вот дальше при вызове MCI_Set_Address() уже начинаются косяки. Вот как выглядит сама функция:
Код
DWORD MCI_Set_Address(void) {
volatile DWORD i; // mthomas - volatile
DWORD retryCount;
DWORD respStatus;
DWORD respValue[4];
DWORD CmdArgument;
/* If it's a SD card, SET_RELATIVE_ADDR is to get the address
from the card and use this value in RCA, if it's a MMC, set default
RCA addr. 0x00010000. */
#if 1
// mthomas:
if (MCI_CardType & MMC_CARD) {
/* If it's unknown or MMC_CARD, fix the RCA address */
CmdArgument = 0x00010000;
} else {
CmdArgument = 0;
}
#else
// NXP original:
if ( MCI_CardType == SD_CARD )
{
CmdArgument = 0;
}
else /* If it's unknown or MMC_CARD, fix the RCA address */
{
CmdArgument = 0x00010000;
}
#endif
retryCount = 0x20; /* reset retry counter */
while (retryCount > 0) {
/* Send CMD3 command repeatedly until the response is back correctly */
MCI_SendCmd( SET_RELATIVE_ADDR, CmdArgument, EXPECT_SHORT_RESP, 0);
respStatus = MCI_GetCmdResp( SET_RELATIVE_ADDR, EXPECT_SHORT_RESP, (DWORD *)&respValue[0]);
/* bit 0 and bit 2 must be zero, or it's timeout or CRC error */
/* It should go to IDEN state and bit 8 should be 1 */
if ( !(respStatus & MCI_CMD_TIMEOUT) && ((respValue[0] & (0x0F << 8))
== 0x0500)) {
CardRCA = respValue[0] & 0xFFFF0000; /* Save the RCA value from SD card */
return ( TRUE ); /* response is back and correct. */
}
for (i = 0; i < 0x20; i++) {
;
}
retryCount--;
}
return ( FALSE );
}
когда пытаемся прочитать ответ
Код
respStatus = MCI_GetCmdResp( SET_RELATIVE_ADDR, EXPECT_SHORT_RESP, (DWORD *)&respValue[0]);
MCI_GetCmdResp возвращает -1