aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/hal/include/hal_usbh.h15
-rw-r--r--os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.c14
-rw-r--r--os/hal/src/hal_usbh.c3
-rw-r--r--os/various/fatfs_bindings/fatfs.mk2
-rw-r--r--os/various/fatfs_bindings/fatfs_devices.h59
-rw-r--r--os/various/fatfs_bindings/fatfs_diskio.c64
-rw-r--r--testhal/STM32/STM32F4xx/USB_HOST/.project4
-rw-r--r--testhal/STM32/STM32F4xx/USB_HOST/halconf.h2
-rw-r--r--testhal/STM32/STM32F4xx/USB_HOST/main.c11
9 files changed, 112 insertions, 62 deletions
diff --git a/os/hal/include/hal_usbh.h b/os/hal/include/hal_usbh.h
index 1ed6416..8d9a85b 100644
--- a/os/hal/include/hal_usbh.h
+++ b/os/hal/include/hal_usbh.h
@@ -52,7 +52,9 @@
#define HAL_USBH_USE_ADDITIONAL_CLASS_DRIVERS FALSE
#endif
+#ifndef HAL_USBH_USE_IAD
#define HAL_USBH_USE_IAD HAL_USBH_USE_UVC
+#endif
#if (HAL_USE_USBH == TRUE) || defined(__DOXYGEN__)
@@ -299,11 +301,22 @@ extern "C" {
}
/* Synchronous API */
- usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep,
+ usbh_urbstatus_t usbhSynchronousTransfer(usbh_ep_t *ep,
void *data,
uint32_t len,
uint32_t *actual_len,
systime_t timeout);
+
+ static inline usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep,
+ void *data,
+ uint32_t len,
+ uint32_t *actual_len,
+ systime_t timeout) {
+ osalDbgAssert(ep->type == USBH_EPTYPE_BULK, "wrong ep");
+
+ return usbhSynchronousTransfer(ep, data, len, actual_len, timeout);
+ }
+
usbh_urbstatus_t usbhControlRequest(usbh_device_t *dev,
uint8_t bmRequestType,
uint8_t bRequest,
diff --git a/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.c b/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.c
index 4723508..0403eae 100644
--- a/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.c
+++ b/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.c
@@ -1172,9 +1172,17 @@ static inline void _nptxfe_int(USBHDriver *host) {
}
static inline void _ptxfe_int(USBHDriver *host) {
- //TODO: implement
- (void)host;
- uinfo("PTXFE");
+ uint32_t rem;
+ stm32_otg_t *const otg = host->otg;
+
+ rem = _write_packet(&host->ep_active_lists[USBH_EPTYPE_ISO],
+ otg->HPTXSTS & HPTXSTS_PTXFSAVL_MASK);
+
+ rem += _write_packet(&host->ep_active_lists[USBH_EPTYPE_INT],
+ otg->HPTXSTS & HPTXSTS_PTXFSAVL_MASK);
+
+ if (!rem)
+ otg->GINTMSK &= ~GINTMSK_PTXFEM;
}
static void _disable(USBHDriver *host) {
diff --git a/os/hal/src/hal_usbh.c b/os/hal/src/hal_usbh.c
index 7dff98a..f9f4687 100644
--- a/os/hal/src/hal_usbh.c
+++ b/os/hal/src/hal_usbh.c
@@ -330,7 +330,7 @@ void _usbh_urb_completeI(usbh_urb_t *urb, usbh_urbstatus_t status) {
/* Synchronous API. */
/*===========================================================================*/
-usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep,
+usbh_urbstatus_t usbhSynchronousTransfer(usbh_ep_t *ep,
void *data,
uint32_t len,
uint32_t *actual_len,
@@ -338,7 +338,6 @@ usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep,
osalDbgCheck(ep != NULL);
osalDbgCheck((data != NULL) || (len == 0));
- osalDbgAssert(ep->type == USBH_EPTYPE_BULK, "wrong ep");
usbh_urb_t urb;
usbhURBObjectInit(&urb, ep, 0, 0, data, len);
diff --git a/os/various/fatfs_bindings/fatfs.mk b/os/various/fatfs_bindings/fatfs.mk
index 238037e..e3ab0c7 100644
--- a/os/various/fatfs_bindings/fatfs.mk
+++ b/os/various/fatfs_bindings/fatfs.mk
@@ -4,4 +4,4 @@ FATFSSRC = ${CHIBIOS_CONTRIB}/os/various/fatfs_bindings/fatfs_diskio.c \
${CHIBIOS}/ext/fatfs/src/ff.c \
${CHIBIOS}/ext/fatfs/src/option/unicode.c
-FATFSINC = ${CHIBIOS}/ext/fatfs/src
+FATFSINC = ${CHIBIOS}/ext/fatfs/src ${CHIBIOS_CONTRIB}/os/various/fatfs_bindings
diff --git a/os/various/fatfs_bindings/fatfs_devices.h b/os/various/fatfs_bindings/fatfs_devices.h
new file mode 100644
index 0000000..5ec05ca
--- /dev/null
+++ b/os/various/fatfs_bindings/fatfs_devices.h
@@ -0,0 +1,59 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+ Copyright (C) 2015..2017 Diego Ismirlian, (dismirlian (at) google's mail)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef FATFS_DEVICES_H_
+#define FATFS_DEVICES_H_
+
+#include "hal.h"
+
+#if HAL_USE_MMC_SPI && HAL_USE_SDC
+#error "cannot specify both MMC_SPI and SDC drivers"
+#endif
+
+#if HAL_USE_MMC_SPI
+extern MMCDriver MMCD1;
+#elif HAL_USE_SDC
+extern SDCDriver SDCD1;
+#elif HAL_USBH_USE_MSD
+
+#else
+#error "MMC_SPI, SDC or USBH_MSD driver must be specified"
+#endif
+
+/*-----------------------------------------------------------------------*/
+/* Correspondence between physical drive number and physical drive. */
+#if HAL_USE_MMC_SPI
+#define FATFSDEV_MMC 0
+#define FATFSDEV_MMC_DRIVE "0:"
+#endif
+
+#if HAL_USE_SDC
+#define FATFSDEV_SDC 0
+#define FATFSDEV_SDC_DRIVE "0:"
+#endif
+
+#if HAL_USBH_USE_MSD
+#if defined(FATFSDEV_MMC) || defined(FATFSDEV_SDC)
+#define FATFSDEV_MSDLUN0 1
+#define FATFSDEV_MSDLUN0_DRIVE "1:"
+#else
+#define FATFSDEV_MSDLUN0 0
+#define FATFSDEV_MSDLUN0_DRIVE "0:"
+#endif
+#endif
+
+#endif /* FATFS_DEVICES_H_ */
diff --git a/os/various/fatfs_bindings/fatfs_diskio.c b/os/various/fatfs_bindings/fatfs_diskio.c
index 9fa41e2..85b07df 100644
--- a/os/various/fatfs_bindings/fatfs_diskio.c
+++ b/os/various/fatfs_bindings/fatfs_diskio.c
@@ -9,38 +9,7 @@
#include "ffconf.h"
#include "diskio.h"
#include "usbh/dev/msd.h"
-
-#if HAL_USE_MMC_SPI && HAL_USE_SDC
-#error "cannot specify both MMC_SPI and SDC drivers"
-#endif
-
-#if HAL_USE_MMC_SPI
-extern MMCDriver MMCD1;
-#elif HAL_USE_SDC
-extern SDCDriver SDCD1;
-#elif HAL_USBH_USE_MSD
-
-#else
-#error "MMC_SPI, SDC or USBH_MSD driver must be specified"
-#endif
-
-/*-----------------------------------------------------------------------*/
-/* Correspondence between physical drive number and physical drive. */
-#if HAL_USE_MMC_SPI
-#define MMC 0
-#endif
-
-#if HAL_USE_SDC
-#define SDC 0
-#endif
-
-#if HAL_USBH_USE_MSD
-#if defined(MMC) || defined(SDC)
-#define MSDLUN0 1
-#else
-#define MSDLUN0 0
-#endif
-#endif
+#include "fatfs_devices.h"
/*-----------------------------------------------------------------------*/
/* Inidialize a Drive */
@@ -53,7 +22,7 @@ DSTATUS disk_initialize (
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MMCD1) != BLK_READY)
@@ -62,7 +31,7 @@ DSTATUS disk_initialize (
stat |= STA_PROTECT;
return stat;
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&SDCD1) != BLK_READY)
@@ -72,7 +41,7 @@ DSTATUS disk_initialize (
return stat;
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MSBLKD[0]) != BLK_READY)
@@ -96,7 +65,7 @@ DSTATUS disk_status (
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MMCD1) != BLK_READY)
@@ -105,7 +74,7 @@ DSTATUS disk_status (
stat |= STA_PROTECT;
return stat;
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&SDCD1) != BLK_READY)
@@ -115,7 +84,7 @@ DSTATUS disk_status (
return stat;
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
stat = 0;
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MSBLKD[0]) != BLK_READY)
@@ -140,7 +109,7 @@ DRESULT disk_read (
{
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
if (blkGetDriverState(&MMCD1) != BLK_READY)
return RES_NOTRDY;
if (mmcStartSequentialRead(&MMCD1, sector))
@@ -155,7 +124,7 @@ DRESULT disk_read (
return RES_ERROR;
return RES_OK;
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
if (blkGetDriverState(&SDCD1) != BLK_READY)
return RES_NOTRDY;
if (sdcRead(&SDCD1, sector, buff, count))
@@ -163,7 +132,7 @@ DRESULT disk_read (
return RES_OK;
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MSBLKD[0]) != BLK_READY)
return RES_NOTRDY;
@@ -189,7 +158,7 @@ DRESULT disk_write (
{
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
if (blkGetDriverState(&MMCD1) != BLK_READY)
return RES_NOTRDY;
if (mmcIsWriteProtected(&MMCD1))
@@ -206,7 +175,7 @@ DRESULT disk_write (
return RES_ERROR;
return RES_OK;
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
if (blkGetDriverState(&SDCD1) != BLK_READY)
return RES_NOTRDY;
if (sdcWrite(&SDCD1, sector, buff, count))
@@ -214,7 +183,7 @@ DRESULT disk_write (
return RES_OK;
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
/* It is initialized externally, just reads the status.*/
if (blkGetDriverState(&MSBLKD[0]) != BLK_READY)
return RES_NOTRDY;
@@ -237,9 +206,10 @@ DRESULT disk_ioctl (
void *buff /* Buffer to send/receive control data */
)
{
+ (void)buff;
switch (pdrv) {
#if HAL_USE_MMC_SPI
- case MMC:
+ case FATFSDEV_MMC:
switch (cmd) {
case CTRL_SYNC:
return RES_OK;
@@ -257,7 +227,7 @@ DRESULT disk_ioctl (
return RES_PARERR;
}
#elif HAL_USE_SDC
- case SDC:
+ case FATFSDEV_SDC:
switch (cmd) {
case CTRL_SYNC:
return RES_OK;
@@ -282,7 +252,7 @@ DRESULT disk_ioctl (
}
#endif
#if HAL_USBH_USE_MSD
- case MSDLUN0:
+ case FATFSDEV_MSDLUN0:
switch (cmd) {
case CTRL_SYNC:
return RES_OK;
diff --git a/testhal/STM32/STM32F4xx/USB_HOST/.project b/testhal/STM32/STM32F4xx/USB_HOST/.project
index 066a4d6..e2dd63e 100644
--- a/testhal/STM32/STM32F4xx/USB_HOST/.project
+++ b/testhal/STM32/STM32F4xx/USB_HOST/.project
@@ -31,9 +31,9 @@
<locationURI>$%7BPARENT-5-PROJECT_LOC%7D/ChibiOS-contrib/os</locationURI>
</link>
<link>
- <name>ChibiOS-RT-os</name>
+ <name>ChibiOS-RT</name>
<type>2</type>
- <locationURI>$%7BPARENT-5-PROJECT_LOC%7D/ChibiOS-RT/os</locationURI>
+ <locationURI>$%7BPARENT-5-PROJECT_LOC%7D/ChibiOS-RT</locationURI>
</link>
</linkedResources>
</projectDescription>
diff --git a/testhal/STM32/STM32F4xx/USB_HOST/halconf.h b/testhal/STM32/STM32F4xx/USB_HOST/halconf.h
index 1511a42..9ddbb1b 100644
--- a/testhal/STM32/STM32F4xx/USB_HOST/halconf.h
+++ b/testhal/STM32/STM32F4xx/USB_HOST/halconf.h
@@ -125,7 +125,7 @@
* @brief Enables the SDC subsystem.
*/
#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
-#define HAL_USE_SDC TRUE
+#define HAL_USE_SDC FALSE
#endif
/**
diff --git a/testhal/STM32/STM32F4xx/USB_HOST/main.c b/testhal/STM32/STM32F4xx/USB_HOST/main.c
index c540233..6bc859e 100644
--- a/testhal/STM32/STM32F4xx/USB_HOST/main.c
+++ b/testhal/STM32/STM32F4xx/USB_HOST/main.c
@@ -297,6 +297,7 @@ start:
#if HAL_USBH_USE_MSD
#include "usbh/dev/msd.h"
#include "ff.h"
+#include "fatfs_devices.h"
static FATFS MSDLUN0FS;
@@ -388,14 +389,14 @@ start:
usbDbgPuts("FS: Block driver ready, try mount...");
- res = f_mount(&MSDLUN0FS, "0:", 1);
+ res = f_mount(&MSDLUN0FS, FATFSDEV_MSDLUN0_DRIVE, 1);
if (res != FR_OK) {
usbDbgPuts("FS: Can't mount. Check file system.");
continue;
}
usbDbgPuts("FS: Mounted.");
- res = f_getfree("0:", &clusters, &fsp);
+ res = f_getfree(FATFSDEV_MSDLUN0_DRIVE, &clusters, &fsp);
if (res != FR_OK) {
usbDbgPuts("FS: f_getfree() failed");
continue;
@@ -419,7 +420,7 @@ start:
//write test
if (1) {
usbDbgPuts("FS: Write test (create file /test.dat, 1MB)");
- f_open(&file, "/test.dat", FA_CREATE_ALWAYS | FA_WRITE);
+ f_open(&file, FATFSDEV_MSDLUN0_DRIVE "/test.dat", FA_CREATE_ALWAYS | FA_WRITE);
src = start;
st = chVTGetSystemTime();
for (j = 0; j < 2048; j++) {
@@ -439,7 +440,7 @@ start:
//read test
if (1) {
usbDbgPuts("FS: Read test (read file /test.dat, 1MB, compare)");
- f_open(&file, "/test.dat", FA_READ);
+ f_open(&file, FATFSDEV_MSDLUN0_DRIVE "/test.dat", FA_READ);
src = start;
st = chVTGetSystemTime();
for (j = 0; j < 2048; j++) {
@@ -463,7 +464,7 @@ start:
//scan files test
if (1) {
usbDbgPuts("FS: Scan files test");
- fbuff[0] = 0;
+ strcpy((char *)fbuff, FATFSDEV_MSDLUN0_DRIVE);
scan_files(chp, (char *)fbuff);
}
}