[X9E] Massstorage OK?
This commit is contained in:
@@ -157,6 +157,7 @@ void delay_ms(uint32_t ms);
|
||||
void getCPUUniqueID(char * s);
|
||||
|
||||
// SD driver
|
||||
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
||||
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
||||
uint32_t sdIsHC(void);
|
||||
uint32_t sdGetSpeed(void);
|
||||
@@ -164,8 +165,8 @@ void getCPUUniqueID(char * s);
|
||||
#define SD_GET_SPEED() (sdGetSpeed())
|
||||
#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors())
|
||||
#else
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
|
||||
@@ -628,12 +628,35 @@ DSTATUS disk_status (
|
||||
}
|
||||
|
||||
|
||||
#if defined(STM32F4) && !defined(BOOT)
|
||||
DWORD scratch[BLOCK_SIZE / 4] __DMA;
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
int8_t SD_ReadSectors(uint8_t *buff, uint32_t sector, uint32_t count)
|
||||
int8_t SD_ReadSectors(uint8_t * buff, uint32_t sector, uint32_t count)
|
||||
{
|
||||
#if defined(STM32F4) && !defined(BOOT)
|
||||
if ((DWORD)buff < 0x20000000 || ((DWORD)buff & 3)) {
|
||||
TRACE("disk_read bad alignment (%p)", buff);
|
||||
while (count--) {
|
||||
int8_t res = SD_ReadSectors((BYTE *)scratch, sector++, 1);
|
||||
|
||||
if (res != 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
memcpy(buff, scratch, BLOCK_SIZE);
|
||||
|
||||
buff += BLOCK_SIZE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */
|
||||
|
||||
if (count == 1) { /* Single block read */
|
||||
@@ -686,8 +709,27 @@ DRESULT disk_read (
|
||||
/* Write Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
int8_t SD_WriteSectors(const uint8_t *buff, uint32_t sector, uint32_t count)
|
||||
int8_t SD_WriteSectors(const uint8_t * buff, uint32_t sector, uint32_t count)
|
||||
{
|
||||
#if defined(STM32F4) && !defined(BOOT)
|
||||
if ((DWORD)buff < 0x20000000 || ((DWORD)buff & 3)) {
|
||||
TRACE("disk_write bad alignment (%p)", buff);
|
||||
while (count--) {
|
||||
memcpy(scratch, buff, BLOCK_SIZE);
|
||||
|
||||
int8_t res = SD_WriteSectors((const uint8_t *)scratch, sector++, 1);
|
||||
|
||||
if (res != 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
buff += BLOCK_SIZE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */
|
||||
|
||||
if (count == 1) { /* Single block write */
|
||||
|
||||
Reference in New Issue
Block a user