[sky9x] SD Format working?

This commit is contained in:
bsongis
2012-09-25 14:03:00 +00:00
parent b19386d8a7
commit fa10615077
5 changed files with 11 additions and 18 deletions
+7
View File
@@ -513,6 +513,13 @@
extern int32_t Card_state;
extern volatile uint32_t Card_initialized;
extern uint32_t Card_CSD[4];
#define SD_CSD(csd, bitfield, bits) ((csd[3-(bitfield)/32] >> ((bitfield)%32)) & ((1 << (bits)) - 1))
#define SD_CSD_C_SIZE_HC(csd) ((SD_CSD(csd, 64, 6) << 16) + \
(SD_CSD(csd, 56, 8) << 8) + \
SD_CSD(csd, 48, 8)) ///< Device size v2.0 High Capacity
/*
#define BOARD_PSRAM_PINS PIN_EBI_DATA_BUS, PIN_EBI_NCS0, PIN_EBI_NRD, PIN_EBI_NWE, \
+2 -14
View File
@@ -1290,9 +1290,6 @@ DRESULT disk_ioctl (
)
{
DRESULT res;
BYTE *csd = (BYTE*)&Card_CSD[0];
BYTE n; // csd[16], *ptr = buff;
WORD csize;
if (drv) return RES_PARERR;
@@ -1324,17 +1321,8 @@ DRESULT disk_ioctl (
break;
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
// if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */
csize = csd[9] + ((WORD)csd[8] << 8) + 1;
*(DWORD*)buff = (DWORD)csize << 10;
} else { /* SDC ver 1.XX or MMC*/
n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1;
*(DWORD*)buff = (DWORD)csize << (n - 9);
}
res = RES_OK;
// }
*(DWORD*)buff = ((SD_CSD_C_SIZE_HC(Card_CSD) + 1) * 1024);
res = RES_OK;
break;
case GET_SECTOR_SIZE : /* Get R/W sector size (WORD) */
@@ -214,8 +214,6 @@ static unsigned char MEDSdcard_Write(Media *media,
/// \return 1 if success.
//------------------------------------------------------------------------------
extern uint32_t Card_CSD[4];
unsigned char MEDSdcard_Initialize(Media *media, unsigned char mciID)
{
TRACE_INFO("MEDSdcard init\n\r");
+1 -1
View File
@@ -49,7 +49,7 @@
// Headers
//------------------------------------------------------------------------------
#include <board.h>
// #include <board.h>
#include <usb/common/core/USBEndpointDescriptor.h>
#include <usb/common/core/USBGenericRequest.h>
@@ -52,7 +52,7 @@
#include "MSD.h"
#include "MSDLun.h"
#include <utility/trace.h>
// #include <utility/trace.h>
//------------------------------------------------------------------------------
// Global functions