From c900c951a339758d8ec34368b226a900e3f22ac0 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Tue, 4 Jul 2017 19:09:39 -0300 Subject: USBH: MSD: Rework to prevent race conditions on unload --- testhal/STM32/STM32F4xx/USB_HOST/main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'testhal/STM32/STM32F4xx/USB_HOST/main.c') 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 -#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 -- cgit v1.2.3 From 6b7161b90a3572bbb7717d0317306741043528e5 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Sun, 9 Jul 2017 19:42:36 -0300 Subject: USBH: moved usbh/desciter.h and usbh/debug.h to usbh/internal.h --- testhal/STM32/STM32F4xx/USB_HOST/main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'testhal/STM32/STM32F4xx/USB_HOST/main.c') diff --git a/testhal/STM32/STM32F4xx/USB_HOST/main.c b/testhal/STM32/STM32F4xx/USB_HOST/main.c index 7cf14e1..a450019 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/main.c +++ b/testhal/STM32/STM32F4xx/USB_HOST/main.c @@ -18,6 +18,8 @@ #include "hal.h" #include "ff.h" #include +#include "usbh/debug.h" /* for usbDbgPuts/usbDbgPrintf */ + #define UVC_TO_MSD_PHOTOS_CAPTURE FALSE -- cgit v1.2.3 From 2e2e10417e4e2a6e2aec3493fd65859ad80e8c30 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Thu, 13 Jul 2017 16:46:26 -0300 Subject: USBH: testhal example: add delay for VBUS stabilization --- testhal/STM32/STM32F4xx/USB_HOST/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'testhal/STM32/STM32F4xx/USB_HOST/main.c') diff --git a/testhal/STM32/STM32F4xx/USB_HOST/main.c b/testhal/STM32/STM32F4xx/USB_HOST/main.c index a450019..215b9ec 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/main.c +++ b/testhal/STM32/STM32F4xx/USB_HOST/main.c @@ -917,6 +917,7 @@ int main(void) { //turn on USB power palClearPad(GPIOC, GPIOC_OTG_FS_POWER_ON); + chThdSleepMilliseconds(100); //start #if STM32_USBH_USE_OTG1 -- cgit v1.2.3 From 06dc7fbb1e85f63e5aa092cb5656ea7627a3ad01 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Mon, 31 Jul 2017 10:27:30 -0300 Subject: USBH: testhal MSD: abort read on error --- testhal/STM32/STM32F4xx/USB_HOST/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'testhal/STM32/STM32F4xx/USB_HOST/main.c') diff --git a/testhal/STM32/STM32F4xx/USB_HOST/main.c b/testhal/STM32/STM32F4xx/USB_HOST/main.c index 215b9ec..44210a3 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/main.c +++ b/testhal/STM32/STM32F4xx/USB_HOST/main.c @@ -374,7 +374,8 @@ start: usbDbgPrintf("BLK: Raw read test (%dMB, %dB blocks)", RAW_READ_SZ_MB, sizeof(fbuff)); st = chVTGetSystemTime(); for (j = 0; j < NITERATIONS; j++) { - blkRead(&MSBLKD[0], start, fbuff, NBLOCKS); + if (blkRead(&MSBLKD[0], start, fbuff, NBLOCKS) != HAL_SUCCESS) + goto start; start += NBLOCKS; } et = chVTGetSystemTime(); -- cgit v1.2.3