aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32/STM32F4xx/USB_HOST
diff options
context:
space:
mode:
authorDiego Ismirlian <dismirlian (at) google's mail.com>2017-07-04 19:09:39 -0300
committerDiego Ismirlian <dismirlian (at) google's mail.com>2017-07-04 19:09:39 -0300
commitc900c951a339758d8ec34368b226a900e3f22ac0 (patch)
treeddd92acbec830eb2b437e5ea5e09b8895fffbede /testhal/STM32/STM32F4xx/USB_HOST
parentd2c155b4cf984b85895c5d786b3621cf19f169e6 (diff)
downloadChibiOS-Contrib-c900c951a339758d8ec34368b226a900e3f22ac0.tar.gz
ChibiOS-Contrib-c900c951a339758d8ec34368b226a900e3f22ac0.tar.bz2
ChibiOS-Contrib-c900c951a339758d8ec34368b226a900e3f22ac0.zip
USBH: MSD: Rework to prevent race conditions on unload
Diffstat (limited to 'testhal/STM32/STM32F4xx/USB_HOST')
-rw-r--r--testhal/STM32/STM32F4xx/USB_HOST/main.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/testhal/STM32/STM32F4xx/USB_HOST/main.c b/testhal/STM32/STM32F4xx/USB_HOST/main.c
index ece9fd5..7cf14e1 100644
--- a/testhal/STM32/STM32F4xx/USB_HOST/main.c
+++ b/testhal/STM32/STM32F4xx/USB_HOST/main.c
@@ -19,7 +19,7 @@
#include "ff.h"
#include <string.h>
-#define UVC_TO_MSD_PHOTOS_CAPTURE TRUE
+#define UVC_TO_MSD_PHOTOS_CAPTURE FALSE
#if HAL_USBH_USE_FTDI || HAL_USBH_USE_AOA
@@ -340,7 +340,7 @@ static void ThreadTestMSD(void *p) {
FATFS *fsp;
DWORD clusters;
FRESULT res;
- blkstate_t state;
+
#if !UVC_TO_MSD_PHOTOS_CAPTURE
BaseSequentialStream * const chp = (BaseSequentialStream *)&USBH_DEBUG_SD;
systime_t st, et;
@@ -351,11 +351,15 @@ start:
for(;;) {
chThdSleepMilliseconds(100);
- chSysLock();
- state = blkGetDriverState(&MSBLKD[0]);
- chSysUnlock();
- if (state != BLK_READY)
+ if (blkGetDriverState(&MSBLKD[0]) == BLK_ACTIVE) {
+ usbDbgPuts("BLK: Active, connect....");
+ usbhmsdLUNConnect(&MSBLKD[0]);
+ }
+ if (blkGetDriverState(&MSBLKD[0]) != BLK_READY) {
continue;
+ }
+
+ usbDbgPuts("BLK: Ready.");
#if !UVC_TO_MSD_PHOTOS_CAPTURE
//raw read test