[sky9x] SD Format working?
This commit is contained in:
@@ -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
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user