diff options
Diffstat (limited to 'software/mpu/usb-cdc-shell.c')
-rw-r--r-- | software/mpu/usb-cdc-shell.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/software/mpu/usb-cdc-shell.c b/software/mpu/usb-cdc-shell.c index cd7ea15..145c941 100644 --- a/software/mpu/usb-cdc-shell.c +++ b/software/mpu/usb-cdc-shell.c @@ -178,6 +178,36 @@ static int8_t shell_return_code; #define SHELL_WA_SIZE THD_WA_SIZE(2048) #define TEST_WA_SIZE THD_WA_SIZE(256) + + +static const SDCConfig sdccfg = { + 0 +}; + +static void cmd_sdc(BaseSequentialStream *chp, int argc, char *argv[]) +{ + (void)argv; + if (argc > 0) { + chprintf(chp, "Usage: sdc\r\n"); + return; + } + chprintf(chp, "Running SDCard Test\r\n"); + + unsigned int n; + chprintf(chp, "waiting for card ."); + for(n = 0; n < 20; n++) { + if(blkIsInserted(&SDCD1)) { + chprintf(chp, " found\r\n"); + chprintf(chp, " write proteciton: %s\r\n", blkIsWriteProtected(&SDCD1) ? "ON" : "OFF"); + return; + } + chprintf(chp, "."); + chThdSleepMilliseconds(1000); + } + + chprintf(chp, " timeout\r\n"); +} + static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) { size_t n, size; @@ -299,6 +329,7 @@ static void cmd_reboot(BaseSequentialStream *chp, int argc, char *argv[]) /* } */ static const ShellCommand commands[] = { + {"sdc", cmd_sdc}, {"mem", cmd_mem}, {"threads", cmd_threads}, {"test", cmd_test}, @@ -327,6 +358,10 @@ int8_t usbCDCShellRun(void) shellInit(); + + sdcStart(&SDCD1, &sdccfg); + + shell_return_code = MPU_CONTINUE; Thread *shelltp = NULL; while (TRUE) { @@ -340,6 +375,9 @@ int8_t usbCDCShellRun(void) chThdSleepMilliseconds(1000); } + sdcStop(&SDCD1); + + usbDisconnect(serusbcfg.usbp); usbStop(serusbcfg.usbp); sduStop(&SDU1); |