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:
parent
5df36352fb
commit
a9b064908a
|
@ -97,6 +97,7 @@ CSRC = $(PORTSRC) \
|
||||||
$(PLATFORMSRC) \
|
$(PLATFORMSRC) \
|
||||||
$(BOARDSRC) \
|
$(BOARDSRC) \
|
||||||
$(CHIBIOS)/os/various/chprintf.c \
|
$(CHIBIOS)/os/various/chprintf.c \
|
||||||
|
$(CHIBIOS)/os/various/shell.c \
|
||||||
main.c
|
main.c
|
||||||
|
|
||||||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
|
|
@ -14,10 +14,20 @@
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
#include "chprintf.h"
|
#include "chprintf.h"
|
||||||
|
#include "shell.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SDIO configuration.
|
||||||
|
*/
|
||||||
|
static const SDCConfig sdccfg = {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LED blinker thread, times are in milliseconds.
|
* 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.
|
* Application entry point.
|
||||||
*/
|
*/
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
thread_t *shelltp = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System initializations.
|
* System initializations.
|
||||||
|
@ -50,6 +111,21 @@ int main(void) {
|
||||||
halInit();
|
halInit();
|
||||||
chSysInit();
|
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.
|
* Creates the blinker thread.
|
||||||
*/
|
*/
|
||||||
|
@ -59,6 +135,12 @@ int main(void) {
|
||||||
* Normal main() thread activity, in this demo it does nothing.
|
* Normal main() thread activity, in this demo it does nothing.
|
||||||
*/
|
*/
|
||||||
while (TRUE) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,11 +206,11 @@
|
||||||
* SERIAL driver system settings.
|
* SERIAL driver system settings.
|
||||||
*/
|
*/
|
||||||
#define STM32_SERIAL_USE_USART1 FALSE
|
#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_USART3 FALSE
|
||||||
#define STM32_SERIAL_USE_UART4 FALSE
|
#define STM32_SERIAL_USE_UART4 FALSE
|
||||||
#define STM32_SERIAL_USE_UART5 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_USART1_PRIORITY 12
|
||||||
#define STM32_SERIAL_USART2_PRIORITY 12
|
#define STM32_SERIAL_USART2_PRIORITY 12
|
||||||
#define STM32_SERIAL_USART3_PRIORITY 12
|
#define STM32_SERIAL_USART3_PRIORITY 12
|
||||||
|
|
Loading…
Reference in New Issue