git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6311 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2013-09-22 08:44:11 +00:00
parent 5df36352fb
commit a9b064908a
3 changed files with 86 additions and 3 deletions

View File

@ -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

View File

@ -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.
@ -50,6 +111,21 @@ int main(void) {
halInit();
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.
*/
@ -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);
}
}

View File

@ -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