SDIO. Updated testhal.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4231 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
661cf8e8dc
commit
293eddc33f
|
@ -146,7 +146,7 @@
|
||||||
/ is tied to the partitions listed in VolToPart[]. */
|
/ is tied to the partitions listed in VolToPart[]. */
|
||||||
|
|
||||||
|
|
||||||
#define _USE_ERASE 0 /* 0:Disable or 1:Enable */
|
#define _USE_ERASE 1 /* 0:Disable or 1:Enable */
|
||||||
/* To enable sector erase feature, set _USE_ERASE to 1. CTRL_ERASE_SECTOR command
|
/* To enable sector erase feature, set _USE_ERASE to 1. CTRL_ERASE_SECTOR command
|
||||||
/ should be added to the disk_ioctl functio. */
|
/ should be added to the disk_ioctl functio. */
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
#define SDC_DATA_DESTRUCTIVE_TEST TRUE
|
#define SDC_DATA_DESTRUCTIVE_TEST TRUE
|
||||||
|
|
||||||
#define SDC_BURST_SIZE 8 /* how many sectors reads at once */
|
#define SDC_BURST_SIZE 8 /* how many sectors reads at once */
|
||||||
static uint8_t outbuf[SDC_BLOCK_SIZE * SDC_BURST_SIZE + 1];
|
static uint8_t outbuf[MMCSD_BLOCK_SIZE * SDC_BURST_SIZE + 1];
|
||||||
static uint8_t inbuf[SDC_BLOCK_SIZE * SDC_BURST_SIZE + 1];
|
static uint8_t inbuf[MMCSD_BLOCK_SIZE * SDC_BURST_SIZE + 1];
|
||||||
|
|
||||||
/* FS object.*/
|
/* FS object.*/
|
||||||
static FATFS SDC_FS;
|
static FATFS SDC_FS;
|
||||||
|
@ -59,7 +59,7 @@ bool_t badblocks(uint32_t start, uint32_t end, uint32_t blockatonce, uint8_t pat
|
||||||
chDbgCheck(blockatonce <= SDC_BURST_SIZE, "badblocks");
|
chDbgCheck(blockatonce <= SDC_BURST_SIZE, "badblocks");
|
||||||
|
|
||||||
/* fill control buffer */
|
/* fill control buffer */
|
||||||
for (i=0; i < SDC_BLOCK_SIZE * blockatonce; i++)
|
for (i=0; i < MMCSD_BLOCK_SIZE * blockatonce; i++)
|
||||||
outbuf[i] = pattern;
|
outbuf[i] = pattern;
|
||||||
|
|
||||||
/* fill SD card with pattern. */
|
/* fill SD card with pattern. */
|
||||||
|
@ -75,7 +75,7 @@ bool_t badblocks(uint32_t start, uint32_t end, uint32_t blockatonce, uint8_t pat
|
||||||
while (position < end){
|
while (position < end){
|
||||||
if (sdcRead(&SDCD1, position, inbuf, blockatonce))
|
if (sdcRead(&SDCD1, position, inbuf, blockatonce))
|
||||||
goto ERROR;
|
goto ERROR;
|
||||||
if (memcmp(inbuf, outbuf, blockatonce * SDC_BLOCK_SIZE) != 0)
|
if (memcmp(inbuf, outbuf, blockatonce * MMCSD_BLOCK_SIZE) != 0)
|
||||||
goto ERROR;
|
goto ERROR;
|
||||||
position += blockatonce;
|
position += blockatonce;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ ERROR:
|
||||||
*/
|
*/
|
||||||
void fillbuffer(uint8_t pattern, uint8_t *b){
|
void fillbuffer(uint8_t pattern, uint8_t *b){
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
for (i=0; i < SDC_BLOCK_SIZE * SDC_BURST_SIZE; i++)
|
for (i=0; i < MMCSD_BLOCK_SIZE * SDC_BURST_SIZE; i++)
|
||||||
b[i] = pattern;
|
b[i] = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +110,14 @@ bool_t sdc_lld_is_write_protected(SDCDriver *sdcp) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool_t sdc_lld_is_card_inserted(SDCDriver *sdcp) {
|
||||||
|
(void)sdcp;
|
||||||
|
return !palReadPad(GPIOE, GPIOE_SDIO_DETECT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -152,7 +160,7 @@ void cmd_sdiotest(BaseSequentialStream *chp, int argc, char *argv[]){
|
||||||
for (i=0; i<1000; i++){
|
for (i=0; i<1000; i++){
|
||||||
if (sdcRead(&SDCD1, 0, outbuf, SDC_BURST_SIZE))
|
if (sdcRead(&SDCD1, 0, outbuf, SDC_BURST_SIZE))
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
if (memcmp(inbuf, outbuf, SDC_BURST_SIZE * SDC_BLOCK_SIZE) != 0)
|
if (memcmp(inbuf, outbuf, SDC_BURST_SIZE * MMCSD_BLOCK_SIZE) != 0)
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
}
|
}
|
||||||
chprintf(chp, " OK\r\n");
|
chprintf(chp, " OK\r\n");
|
||||||
|
@ -168,7 +176,7 @@ void cmd_sdiotest(BaseSequentialStream *chp, int argc, char *argv[]){
|
||||||
for (i=0; i<1000; i++){
|
for (i=0; i<1000; i++){
|
||||||
if (sdcRead(&SDCD1, 0, outbuf + 1, SDC_BURST_SIZE))
|
if (sdcRead(&SDCD1, 0, outbuf + 1, SDC_BURST_SIZE))
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
if (memcmp(inbuf, outbuf, SDC_BURST_SIZE * SDC_BLOCK_SIZE) != 0)
|
if (memcmp(inbuf, outbuf, SDC_BURST_SIZE * MMCSD_BLOCK_SIZE) != 0)
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
}
|
}
|
||||||
chprintf(chp, " OK\r\n");
|
chprintf(chp, " OK\r\n");
|
||||||
|
@ -184,7 +192,7 @@ void cmd_sdiotest(BaseSequentialStream *chp, int argc, char *argv[]){
|
||||||
fillbuffer(0, outbuf);
|
fillbuffer(0, outbuf);
|
||||||
if (sdcRead(&SDCD1, 0, outbuf, 1))
|
if (sdcRead(&SDCD1, 0, outbuf, 1))
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
if (memcmp(inbuf, outbuf, SDC_BLOCK_SIZE) != 0)
|
if (memcmp(inbuf, outbuf, MMCSD_BLOCK_SIZE) != 0)
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
chprintf(chp, " OK\r\n");
|
chprintf(chp, " OK\r\n");
|
||||||
|
|
||||||
|
@ -196,7 +204,7 @@ void cmd_sdiotest(BaseSequentialStream *chp, int argc, char *argv[]){
|
||||||
fillbuffer(0, outbuf);
|
fillbuffer(0, outbuf);
|
||||||
if (sdcRead(&SDCD1, 0, outbuf+1, 1))
|
if (sdcRead(&SDCD1, 0, outbuf+1, 1))
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
if (memcmp(inbuf+1, outbuf+1, SDC_BLOCK_SIZE) != 0)
|
if (memcmp(inbuf+1, outbuf+1, MMCSD_BLOCK_SIZE) != 0)
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
chprintf(chp, " OK\r\n");
|
chprintf(chp, " OK\r\n");
|
||||||
|
|
||||||
|
@ -256,7 +264,7 @@ void cmd_sdiotest(BaseSequentialStream *chp, int argc, char *argv[]){
|
||||||
chprintf(chp,
|
chprintf(chp,
|
||||||
"FS: %lu free clusters, %lu sectors per cluster, %lu bytes free\r\n",
|
"FS: %lu free clusters, %lu sectors per cluster, %lu bytes free\r\n",
|
||||||
clusters, (uint32_t)SDC_FS.csize,
|
clusters, (uint32_t)SDC_FS.csize,
|
||||||
clusters * (uint32_t)SDC_FS.csize * (uint32_t)SDC_BLOCK_SIZE);
|
clusters * (uint32_t)SDC_FS.csize * (uint32_t)MMCSD_BLOCK_SIZE);
|
||||||
|
|
||||||
|
|
||||||
chprintf(chp, "Create file \"chtest.txt\"... ");
|
chprintf(chp, "Create file \"chtest.txt\"... ");
|
||||||
|
|
Loading…
Reference in New Issue