summaryrefslogtreecommitdiff
path: root/src/class/msc
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-07-17 16:04:55 +0700
committerhathach <[email protected]>2018-07-17 16:04:55 +0700
commit798ce59ebd46118c7d64e9cfa54319787715ef7d (patch)
treebb52af0a951363988a5249fdc0b8bf888ab3268f /src/class/msc
parentabb37e98baa16ae9f99f9d7562e4ee166e8bc4de (diff)
revert usbd_control_xfer_st() implementation
enhance cdc with better multiple interfaces support add default ep size for cdc and msc device CFG_TUD_CDC_EPSIZE, CFG_TUD_MSC_EPSIZE
Diffstat (limited to 'src/class/msc')
-rw-r--r--src/class/msc/msc_device.c39
-rw-r--r--src/class/msc/msc_device.h47
2 files changed, 44 insertions, 42 deletions
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c
index d82958202..b0839ecb0 100644
--- a/src/class/msc/msc_device.c
+++ b/src/class/msc/msc_device.c
@@ -50,41 +50,6 @@
#include "device/usbd_pvt.h"
//--------------------------------------------------------------------+
-// Config Verification
-//--------------------------------------------------------------------+
-VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct");
-
-#ifndef CFG_TUD_MSC_MAXLUN
- #define CFG_TUD_MSC_MAXLUN 1
-#elif CFG_TUD_MSC_MAXLUN == 0 || CFG_TUD_MSC_MAXLUN > 16
- #error MSC Device: Incorrect setting of MAX LUN
-#endif
-
-#ifndef CFG_TUD_MSC_BLOCK_NUM
- #error CFG_TUD_MSC_BLOCK_NUM must be defined
-#endif
-
-#ifndef CFG_TUD_MSC_BLOCK_SZ
- #error CFG_TUD_MSC_BLOCK_SZ must be defined
-#endif
-
-#ifndef CFG_TUD_MSC_BUFSIZE
- #error CFG_TUD_MSC_BUFSIZE must be defined, value of CFG_TUD_MSC_BLOCK_SZ should work well, the more the better
-#endif
-
-#ifndef CFG_TUD_MSC_VENDOR
- #error CFG_TUD_MSC_VENDOR 8-byte name must be defined
-#endif
-
-#ifndef CFG_TUD_MSC_PRODUCT
- #error CFG_TUD_MSC_PRODUCT 16-byte name must be defined
-#endif
-
-#ifndef CFG_TUD_MSC_PRODUCT_REV
- #error CFG_TUD_MSC_PRODUCT_REV 4-byte string must be defined
-#endif
-
-//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
enum
@@ -193,8 +158,8 @@ tusb_error_t mscd_control_request_st(uint8_t rhport, tusb_control_request_t cons
else if (MSC_REQUEST_GET_MAX_LUN == p_request->bRequest)
{
// returned MAX LUN is minus 1 by specs
- uint8_t lun = CFG_TUD_MSC_MAXLUN-1;
- usbd_control_xfer_st(rhport, p_request->bmRequestType_bit.direction, &lun, 1);
+ _usbd_ctrl_buf[0] = CFG_TUD_MSC_MAXLUN-1;
+ usbd_control_xfer_st(rhport, p_request->bmRequestType_bit.direction, _usbd_ctrl_buf, 1);
}else
{
dcd_control_stall(rhport); // stall unsupported request
diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h
index 994e71c36..a32d64a93 100644
--- a/src/class/msc/msc_device.h
+++ b/src/class/msc/msc_device.h
@@ -43,6 +43,48 @@
#include "device/usbd.h"
#include "msc.h"
+
+//--------------------------------------------------------------------+
+// Class Driver Configuration
+//--------------------------------------------------------------------+
+VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct");
+
+#ifndef CFG_TUD_MSC_MAXLUN
+ #define CFG_TUD_MSC_MAXLUN 1
+#elif CFG_TUD_MSC_MAXLUN == 0 || CFG_TUD_MSC_MAXLUN > 16
+ #error MSC Device: Incorrect setting of MAX LUN
+#endif
+
+#ifndef CFG_TUD_MSC_BLOCK_NUM
+ #error CFG_TUD_MSC_BLOCK_NUM must be defined
+#endif
+
+#ifndef CFG_TUD_MSC_BLOCK_SZ
+ #error CFG_TUD_MSC_BLOCK_SZ must be defined
+#endif
+
+#ifndef CFG_TUD_MSC_BUFSIZE
+ #error CFG_TUD_MSC_BUFSIZE must be defined, value of CFG_TUD_MSC_BLOCK_SZ should work well, the more the better
+#endif
+
+#ifndef CFG_TUD_MSC_VENDOR
+ #error CFG_TUD_MSC_VENDOR 8-byte name must be defined
+#endif
+
+#ifndef CFG_TUD_MSC_PRODUCT
+ #error CFG_TUD_MSC_PRODUCT 16-byte name must be defined
+#endif
+
+#ifndef CFG_TUD_MSC_PRODUCT_REV
+ #error CFG_TUD_MSC_PRODUCT_REV 4-byte string must be defined
+#endif
+
+// TODO highspeed device is 512
+#ifndef CFG_TUD_MSC_EPSIZE
+#define CFG_TUD_MSC_EPSIZE 64
+#endif
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -53,11 +95,6 @@
* @{ */
//--------------------------------------------------------------------+
-// APPLICATION API (Multiple Root Hub Ports)
-// Should be used only with MCU that support more than 1 ports
-//--------------------------------------------------------------------+
-
-//--------------------------------------------------------------------+
// APPLICATION CALLBACK API (WEAK is optional)
//--------------------------------------------------------------------+
/** \brief Callback invoked when received \ref SCSI_CMD_READ_10 command