From 54150a8f62d57bd3af5efce1439ba3c29e20f07f Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 26 Mar 2011 01:04:10 +0000 Subject: Incorporate changes from Uros Platise git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3419 42af7a65-404d-4744-a932-0658087f49c3 --- apps/vsn/sdcard/sdcard.c | 51 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'apps/vsn/sdcard') diff --git a/apps/vsn/sdcard/sdcard.c b/apps/vsn/sdcard/sdcard.c index bf3e82a07..2f6c44f89 100644 --- a/apps/vsn/sdcard/sdcard.c +++ b/apps/vsn/sdcard/sdcard.c @@ -48,13 +48,13 @@ # include #endif - +// TODO get the structure out from the slot number +static FAR struct sdio_dev_s *sdio = NULL; /* Create device device for the SDIO-based MMC/SD block driver */ int sdcard_start(int slotno) { - FAR struct sdio_dev_s *sdio; int ret; /* First, get an instance of the SDIO interface */ @@ -89,22 +89,41 @@ int sdcard_start(int slotno) int sdcard_main(int argc, char *argv[]) { - int slotno; + int slotno = 0; - if (argc == 3) { - slotno = atoi(argv[2]); + if (argc >= 2) { - if (!strcmp(argv[1], "start")) { - return sdcard_start(slotno); - } - else if (!strcmp(argv[1], "stop")) { - } - else if (!strcmp(argv[1], "insert")) { - } - else if (!strcmp(argv[1], "eject")) { + /* The 3rd argument is expected to be a slot number, if given */ + if (argc==3) + slotno = atoi(argv[2]); + + /* Commands */ + + if (!strcmp(argv[1], "start")) { + return sdcard_start(slotno); + } + else if (!strcmp(argv[1], "stop")) { + fprintf(stderr, "Not implemented yet\n"); + } + else if (!strcmp(argv[1], "insert")) { + if (sdio) { + return sdio_mediachange(sdio, true); + } + } + else if (!strcmp(argv[1], "eject")) { + if (sdio) { + return sdio_mediachange(sdio, false); + } + } + else if (!strcmp(argv[1], "status")) { + printf("SDcard #%d Status:\n", slotno); +#ifndef CONFIG_MMCSD_HAVECARDDETECT + printf("\t - Without SDcard detect capability\n"); +#endif + return 0; + } } - } - printf("%s: \n", argv[0]); - return -1; + printf("%s: {slotno}\n", argv[0]); + return -1; } -- cgit v1.2.3