IOCTL 80percent done

This commit is contained in:
Mario Hüttel 2015-11-25 19:23:14 +01:00
parent 7c937c879e
commit c87d09cc1c

View File

@ -55,7 +55,27 @@ DRESULT SDIO_disk_write(const BYTE *buff, DWORD sector, UINT count){
return RES_OK; return RES_OK;
} }
DRESULT SDIO_disk_ioctl(BYTE cmd, void* buff){ DRESULT SDIO_disk_ioctl(BYTE cmd, void* buff){
return RES_OK; DRESULT res = RES_OK;
switch(cmd) {
case GET_BLOCK_SIZE:
*((DWORD*)buff) = 0x01;
break;
case GET_SECTOR_SIZE:
*((WORD*)buff) = (1<<BLOCKSIZE);
break;
case GET_SECTOR_COUNT:
res = RES_ERROR;
//TODO: Implement
break;
case CTRL_SYNC:
res = RES_ERROR;
//TODO: Implement
break;
default:
res = RES_PARERR;
break;
}
return res;
} }
DWORD __attribute__((weak)) get_fattime(){ DWORD __attribute__((weak)) get_fattime(){
return 0; return 0;
@ -133,7 +153,7 @@ int SDIO_getResp(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *responseBuffe
//Wait for error or success //Wait for error or success
while (1) { while (1) {
if (SDIO->STA & SDIO_STA_CMDREND) break; //Corrct Respone Received if (SDIO->STA & SDIO_STA_CMDREND) break; //Correct Respone Received
//Exclude ACMD41 from valid CRC check //Exclude ACMD41 from valid CRC check
if ((SDIO->STA & SDIO_STA_CCRCFAIL)) { if ((SDIO->STA & SDIO_STA_CCRCFAIL)) {
@ -151,9 +171,9 @@ int SDIO_getResp(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *responseBuffe
//Valid Respone Received //Valid Respone Received
if ((SDIO->RESPCMD & SDIO_RESPCMD_RESPCMD) != expectedCMD) return -1; //Not the expected respose if ((SDIO->RESPCMD & SDIO_RESPCMD_RESPCMD) != expectedCMD) return -1; //Not the expected respose
//Correct Response //If case of a correct Response
*(responseBuffer++) = SDIO->RESP1; *(responseBuffer++) = SDIO->RESP1;
//Long response. Never needed with SD Cards //Long response.
if (typeOfAns == LONG_ANS) { if (typeOfAns == LONG_ANS) {
*(responseBuffer++) = SDIO->RESP2; *(responseBuffer++) = SDIO->RESP2;
*(responseBuffer++) = SDIO->RESP3; *(responseBuffer++) = SDIO->RESP3;