From 4c166f98c7ccb9bdc7e17d30786c326031bc9d89 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 23 Sep 2013 19:03:43 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6315 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F4xx/SDC/main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'testhal/STM32F4xx/SDC/main.c') diff --git a/testhal/STM32F4xx/SDC/main.c b/testhal/STM32F4xx/SDC/main.c index 3b804198b..f547f65e8 100644 --- a/testhal/STM32F4xx/SDC/main.c +++ b/testhal/STM32F4xx/SDC/main.c @@ -59,6 +59,9 @@ static uint8_t buf[MMCSD_BLOCK_SIZE * SDC_BURST_SIZE + 1]; void cmd_sdc(BaseSequentialStream *chp, int argc, char *argv[]) { static const char *mode[] = {"SDV11", "SDV20", "MMC", NULL}; + systime_t start, end; + uint32_t n, startblk; + if (argc != 1) { chprintf(chp, "Usage: sdiotest read|write|all\r\n"); return; @@ -84,9 +87,26 @@ void cmd_sdc(BaseSequentialStream *chp, int argc, char *argv[]) { chprintf(chp, "Mode : %s\r\n", mode[SDCD1.cardmode]); chprintf(chp, "Capacity : %DMB\r\n", SDCD1.capacity / 2048); + /* The test is performed in the middle of the flash area.*/ + startblk = (SDCD1.capacity / MMCSD_BLOCK_SIZE) / 2; + if ((strcmp(argv[0], "read") == 0) || (strcmp(argv[0], "all") == 0)) { + /* Single block read performance.*/ + chprintf(chp, "Single block read performance: "); + start = chVTGetSystemTime(); + end = start + MS2ST(1000); + n = 0; + do { + if (blkRead(&SDCD1, startblk, buf, MMCSD_BLOCK_SIZE)) { + chprintf(chp, "failed\r\n"); + break; + } + chThdSleepMilliseconds(1); + n++; + } while (chVTIsSystemTimeWithin(start, end)); + chprintf(chp, "%D blocks per second\r\n", n); } if ((strcmp(argv[0], "write") == 0) || (strcmp(argv[0], "all") == 0)) { -- cgit v1.2.3