summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--software/mpu/board-F405/board-utils.c16
-rw-r--r--software/mpu/board-F405/board-utils.h5
-rw-r--r--software/mpu/board-F405/board.c2
-rw-r--r--software/mpu/board-F405/board.h44
-rw-r--r--software/mpu/main.c2
-rw-r--r--software/mpu/usb-cdc-shell.c38
6 files changed, 73 insertions, 34 deletions
diff --git a/software/mpu/board-F405/board-utils.c b/software/mpu/board-F405/board-utils.c
index 4928bb6..99d4907 100644
--- a/software/mpu/board-F405/board-utils.c
+++ b/software/mpu/board-F405/board-utils.c
@@ -37,46 +37,46 @@
#if HAL_USE_USB
-int usbConnect(USBDriver* usbp)
+bool_t usbConnect(USBDriver* usbp)
{
// usbConnectBus(usbp); // on F405 this only enables VBUS sensing - not needed
#if STM32_USB_USE_OTG1
if(usbp == &USBD1) {
palClearPad(GPIOA, GPIOA_USB_DISC);
- return 0;
+ return CH_SUCCESS;
}
#endif
#if STM32_USB_USE_OTG2
if(usbp == &USBD2) {
palClearPad(GPIO, GPIO_USB2_DISC);
- return 0;
+ return CH_SUCCESS;
}
#endif
- return 1;
+ return CH_FAILED;
}
-int usbDisconnect(USBDriver* usbp)
+bool_t usbDisconnect(USBDriver* usbp)
{
// usbDisconnectBus(usbp); // on F405 this only disables VBUS sensing - not needed
#if STM32_USB_USE_OTG1
if(usbp == &USBD1) {
palSetPad(GPIOA, GPIOA_USB_DISC);
- return 0;
+ return CH_SUCCESS;
}
#endif
#if STM32_USB_USE_OTG2
if(usbp == &USBD2) {
// palSetPad(GPIO, GPIO_USB2_DISC);
- return 0;
+ return CH_SUCCESS;
}
#endif
- return 1;
+ return CH_FAILED;
}
#endif /* HAL_USE_USB */
diff --git a/software/mpu/board-F405/board-utils.h b/software/mpu/board-F405/board-utils.h
index 1ceb614..1c5f71b 100644
--- a/software/mpu/board-F405/board-utils.h
+++ b/software/mpu/board-F405/board-utils.h
@@ -33,12 +33,13 @@
#ifndef MURSAT_board_utils_h_INCLUDED
#define MURSAT_board_utils_h_INCLUDED
+#include "chtypes.h"
#include "halconf.h"
#if HAL_USE_USB
-int usbConnect(USBDriver* usbp);
-int usbDisconnect(USBDriver* usbp);
+bool_t usbConnect(USBDriver* usbp);
+bool_t usbDisconnect(USBDriver* usbp);
#endif /* HAL_USE_USB */
diff --git a/software/mpu/board-F405/board.c b/software/mpu/board-F405/board.c
index a5d0b55..81b5e95 100644
--- a/software/mpu/board-F405/board.c
+++ b/software/mpu/board-F405/board.c
@@ -88,6 +88,6 @@ bool_t sdc_lld_is_card_inserted(SDCDriver *sdcp) {
bool_t sdc_lld_is_write_protected(SDCDriver *sdcp) {
(void)sdcp;
- return !palReadPad(GPIOA, GPIOA_SDIO_WP);
+ return palReadPad(GPIOA, GPIOA_SDIO_WP);
}
#endif /* HAL_USE_SDC */
diff --git a/software/mpu/board-F405/board.h b/software/mpu/board-F405/board.h
index f056102..02a2841 100644
--- a/software/mpu/board-F405/board.h
+++ b/software/mpu/board-F405/board.h
@@ -67,8 +67,8 @@
#define GPIOA_USB_DM 11
#define GPIOA_USB_DP 12
#define GPIOA_USB_DISC 13
-#define GPIOA_SDIO_WP 14
-#define GPIOA_SDIO_CD 15
+#define GPIOA_SDIO_CD 14
+#define GPIOA_SDIO_WP 15
#define GPIOB_PIN0 0
#define GPIOB_PIN1 1
@@ -95,18 +95,18 @@
#define GPIOC_PIN5 5
#define GPIOC_PIN6 6
#define GPIOC_PIN7 7
-#define GPIOC_SDIO_D0 8
-#define GPIOC_SDIO_D1 9
-#define GPIOC_SDIO_D2 10
-#define GPIOC_SDIO_D3 11
-#define GPIOC_SDIO_CK 12
+#define GPIOC_SDIO_D0 8
+#define GPIOC_SDIO_D1 9
+#define GPIOC_SDIO_D2 10
+#define GPIOC_SDIO_D3 11
+#define GPIOC_SDIO_CK 12
#define GPIOC_PIN13 13
#define GPIOC_PIN14 14
#define GPIOC_PIN15 15
#define GPIOD_PIN0 0
#define GPIOD_PIN1 1
-#define GPIOD_SDIO_CMD 2
+#define GPIOD_SDIO_CMD 2
#define GPIOD_PIN3 3
#define GPIOD_PIN4 4
#define GPIOD_PIN5 5
@@ -245,8 +245,8 @@
* PA11 - USB_DM (alternate 10).
* PA12 - USB_DP (alternate 10).
* PA13 - USB_DISC (output pushpull maximum).
- * PA14 - SDIO_WP (input pullup).
- * PA15 - SDIO_CD (input pullup).
+ * PA14 - SDIO_CD (input pullup).
+ * PA15 - SDIO_WP (input pullup).
*/
#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | \
PIN_MODE_INPUT(GPIOA_PIN1) | \
@@ -262,8 +262,8 @@
PIN_MODE_ALTERNATE(GPIOA_USB_DM) | \
PIN_MODE_ALTERNATE(GPIOA_USB_DP) | \
PIN_MODE_OUTPUT(GPIOA_USB_DISC) | \
- PIN_MODE_INPUT(GPIOA_SDIO_WP) | \
- PIN_MODE_INPUT(GPIOA_SDIO_CD))
+ PIN_MODE_INPUT(GPIOA_SDIO_CD) | \
+ PIN_MODE_INPUT(GPIOA_SDIO_WP))
#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | \
PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | \
PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | \
@@ -278,8 +278,8 @@
PIN_OTYPE_PUSHPULL(GPIOA_USB_DM) | \
PIN_OTYPE_PUSHPULL(GPIOA_USB_DP) | \
PIN_OTYPE_PUSHPULL(GPIOA_USB_DISC) | \
- PIN_OTYPE_PUSHPULL(GPIOA_SDIO_WP) | \
- PIN_OTYPE_PUSHPULL(GPIOA_SDIO_CD))
+ PIN_OTYPE_PUSHPULL(GPIOA_SDIO_CD) | \
+ PIN_OTYPE_PUSHPULL(GPIOA_SDIO_WP))
#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_100M(GPIOA_PIN0) | \
PIN_OSPEED_100M(GPIOA_PIN1) | \
PIN_OSPEED_100M(GPIOA_PIN2) | \
@@ -294,8 +294,8 @@
PIN_OSPEED_100M(GPIOA_USB_DM) | \
PIN_OSPEED_100M(GPIOA_USB_DP) | \
PIN_OSPEED_100M(GPIOA_USB_DISC) | \
- PIN_OSPEED_100M(GPIOA_SDIO_WP) | \
- PIN_OSPEED_100M(GPIOA_SDIO_CD))
+ PIN_OSPEED_100M(GPIOA_SDIO_CD) | \
+ PIN_OSPEED_100M(GPIOA_SDIO_WP))
#define VAL_GPIOA_PUPDR (PIN_PUPDR_PULLUP(GPIOA_PIN0) | \
PIN_PUPDR_PULLUP(GPIOA_PIN1) | \
PIN_PUPDR_PULLUP(GPIOA_PIN2) | \
@@ -309,8 +309,8 @@
PIN_PUPDR_FLOATING(GPIOA_USB_DM) | \
PIN_PUPDR_FLOATING(GPIOA_USB_DP) | \
PIN_PUPDR_FLOATING(GPIOA_USB_DISC) | \
- PIN_PUPDR_PULLUP(GPIOA_SDIO_WP) | \
- PIN_PUPDR_PULLUP(GPIOA_SDIO_CD))
+ PIN_PUPDR_PULLUP(GPIOA_SDIO_CD) | \
+ PIN_PUPDR_PULLUP(GPIOA_SDIO_WP))
#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | \
PIN_ODR_HIGH(GPIOA_PIN1) | \
PIN_ODR_HIGH(GPIOA_PIN2) | \
@@ -325,8 +325,8 @@
PIN_ODR_HIGH(GPIOA_USB_DM) | \
PIN_ODR_HIGH(GPIOA_USB_DP) | \
PIN_ODR_HIGH(GPIOA_USB_DISC) | \
- PIN_ODR_HIGH(GPIOA_SDIO_WP) | \
- PIN_ODR_HIGH(GPIOA_SDIO_CD))
+ PIN_ODR_HIGH(GPIOA_SDIO_CD) | \
+ PIN_ODR_HIGH(GPIOA_SDIO_WP))
#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0) | \
PIN_AFIO_AF(GPIOA_PIN1, 0) | \
PIN_AFIO_AF(GPIOA_PIN2, 7) | \
@@ -341,8 +341,8 @@
PIN_AFIO_AF(GPIOA_USB_DM, 10) | \
PIN_AFIO_AF(GPIOA_USB_DP, 10) | \
PIN_AFIO_AF(GPIOA_USB_DISC, 0) | \
- PIN_AFIO_AF(GPIOA_SDIO_WP, 0) | \
- PIN_AFIO_AF(GPIOA_SDIO_CD, 0))
+ PIN_AFIO_AF(GPIOA_SDIO_CD, 0) | \
+ PIN_AFIO_AF(GPIOA_SDIO_WP, 0))
/*
* GPIOB setup:
diff --git a/software/mpu/main.c b/software/mpu/main.c
index 506d857..9458015 100644
--- a/software/mpu/main.c
+++ b/software/mpu/main.c
@@ -55,7 +55,7 @@ static void sysInit(void)
static void subsystemsInit(void)
{
/* call init functions of all subsystems which should spawn threads for their task */
- blockstoreInit();
+// blockstoreInit();
ihuInit();
heartbeatInit();
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);