aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-09-22 08:44:11 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-09-22 08:44:11 +0000
commita9b064908aa85ae5b61b6322f41c97619e73dc6d (patch)
tree30ab878e83f370c56df2c7cf7a26ca1fbeca5ce1
parent5df36352fbd0b637c8f81d0bc04b13f3c404fbb8 (diff)
downloadChibiOS-a9b064908aa85ae5b61b6322f41c97619e73dc6d.tar.gz
ChibiOS-a9b064908aa85ae5b61b6322f41c97619e73dc6d.tar.bz2
ChibiOS-a9b064908aa85ae5b61b6322f41c97619e73dc6d.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6311 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--testhal/STM32F4xx/SDC/Makefile1
-rw-r--r--testhal/STM32F4xx/SDC/main.c84
-rw-r--r--testhal/STM32F4xx/SDC/mcuconf.h4
3 files changed, 86 insertions, 3 deletions
diff --git a/testhal/STM32F4xx/SDC/Makefile b/testhal/STM32F4xx/SDC/Makefile
index abfdea43b..7be4fc2f6 100644
--- a/testhal/STM32F4xx/SDC/Makefile
+++ b/testhal/STM32F4xx/SDC/Makefile
@@ -97,6 +97,7 @@ CSRC = $(PORTSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(CHIBIOS)/os/various/chprintf.c \
+ $(CHIBIOS)/os/various/shell.c \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
diff --git a/testhal/STM32F4xx/SDC/main.c b/testhal/STM32F4xx/SDC/main.c
index f02221398..33975654a 100644
--- a/testhal/STM32F4xx/SDC/main.c
+++ b/testhal/STM32F4xx/SDC/main.c
@@ -14,10 +14,20 @@
limitations under the License.
*/
+#include <string.h>
+
#include "ch.h"
#include "hal.h"
#include "chprintf.h"
+#include "shell.h"
+
+/*
+ * SDIO configuration.
+ */
+static const SDCConfig sdccfg = {
+ 0
+};
/*
* LED blinker thread, times are in milliseconds.
@@ -35,10 +45,61 @@ static msg_t Thread1(void *arg) {
}
}
+/*===========================================================================*/
+/* Command line related. */
+/*===========================================================================*/
+
+#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
+
+void cmd_sdiotest(BaseSequentialStream *chp, int argc, char *argv[]) {
+
+ if (argc != 1) {
+ chprintf(chp, "Usage: sdiotest read|write|all\r\n");
+ return;
+ }
+
+ /* Card presence check.*/
+ if (!blkIsInserted(&SDCD1)) {
+ chprintf(chp, "Card not inserted, aborting.\r\n");
+ return;
+ }
+
+ /* Connection to the card.*/
+ chprintf(chp, "Connecting: ");
+ if (sdcConnect(&SDCD1)) {
+ chprintf(chp, "failed\r\n");
+ return;
+ }
+ chprintf(chp, "OK\r\n");
+ chprintf(chp, "*** Card CSD content is: ");
+ chprintf(chp, "%X %X %X %X \r\n", (&SDCD1)->csd[3], (&SDCD1)->csd[2],
+ (&SDCD1)->csd[1], (&SDCD1)->csd[0]);
+
+ if ((strcmp(argv[0], "read") == 0) ||
+ (strcmp(argv[0], "all") == 0)) {
+
+ }
+ if ((strcmp(argv[0], "write") == 0) ||
+ (strcmp(argv[0], "all") == 0)) {
+
+ }
+}
+
+static const ShellCommand commands[] = {
+ {"sdio", cmd_sdiotest},
+ {NULL, NULL}
+};
+
+static const ShellConfig shell_cfg1 = {
+ (BaseSequentialStream *)&SD6,
+ commands
+};
+
/*
* Application entry point.
*/
int main(void) {
+ thread_t *shelltp = NULL;
/*
* System initializations.
@@ -51,6 +112,21 @@ int main(void) {
chSysInit();
/*
+ * Shell manager initialization.
+ */
+ shellInit();
+
+ /*
+ * Activates the serial driver 6 using the driver default configuration.
+ */
+ sdStart(&SD6, NULL);
+
+ /*
+ * Initializes the SDIO drivers.
+ */
+ sdcStart(&SDCD1, &sdccfg);
+
+ /*
* Creates the blinker thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
@@ -59,6 +135,12 @@ int main(void) {
* Normal main() thread activity, in this demo it does nothing.
*/
while (TRUE) {
- chThdSleepMilliseconds(500);
+ if (!shelltp)
+ shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
+ else if (chThdTerminatedX(shelltp)) {
+ chThdRelease(shelltp); /* Recovers memory of the previous shell. */
+ shelltp = NULL; /* Triggers spawning of a new shell. */
+ }
+ chThdSleepMilliseconds(1000);
}
}
diff --git a/testhal/STM32F4xx/SDC/mcuconf.h b/testhal/STM32F4xx/SDC/mcuconf.h
index 360d60287..6ff49afa9 100644
--- a/testhal/STM32F4xx/SDC/mcuconf.h
+++ b/testhal/STM32F4xx/SDC/mcuconf.h
@@ -206,11 +206,11 @@
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 FALSE
-#define STM32_SERIAL_USE_USART2 TRUE
+#define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USE_UART4 FALSE
#define STM32_SERIAL_USE_UART5 FALSE
-#define STM32_SERIAL_USE_USART6 FALSE
+#define STM32_SERIAL_USE_USART6 TRUE
#define STM32_SERIAL_USART1_PRIORITY 12
#define STM32_SERIAL_USART2_PRIORITY 12
#define STM32_SERIAL_USART3_PRIORITY 12