diff options
| -rw-r--r-- | examples/device/cdc_msc_hid/src/tusb_config.h | 6 | ||||
| -rw-r--r-- | src/class/msc/msc_device.h | 4 | ||||
| -rw-r--r-- | src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c | 7 | ||||
| -rw-r--r-- | src/tusb_option.h | 22 |
4 files changed, 28 insertions, 11 deletions
diff --git a/examples/device/cdc_msc_hid/src/tusb_config.h b/examples/device/cdc_msc_hid/src/tusb_config.h index 0aa023352..0634c9576 100644 --- a/examples/device/cdc_msc_hid/src/tusb_config.h +++ b/examples/device/cdc_msc_hid/src/tusb_config.h @@ -55,7 +55,12 @@ #error CFG_TUSB_MCU should be defined using compiler flags #endif +#if CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_LPC18XX +#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED) +#else #define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE +#endif + #define CFG_TUSB_DEBUG 2 #define CFG_TUSB_OS OPT_OS_NONE @@ -121,7 +126,6 @@ //-------------------------------------------------------------------- // MSC //-------------------------------------------------------------------- - // Number of supported Logical Unit Number (At least 1) #define CFG_TUD_MSC_MAXLUN 1 diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h index c4476f56f..b268830ca 100644 --- a/src/class/msc/msc_device.h +++ b/src/class/msc/msc_device.h @@ -73,8 +73,12 @@ TU_VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct"); // TODO highspeed device is 512
#ifndef CFG_TUD_MSC_EPSIZE
+#if TUD_OPT_HIGH_SPEED
+#define CFG_TUD_MSC_EPSIZE 512
+#else
#define CFG_TUD_MSC_EPSIZE 64
#endif
+#endif
#ifdef __cplusplus
diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 2f83f4203..260cc3a45 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -288,7 +288,7 @@ bool dcd_edpt_busy(uint8_t rhport, uint8_t ep_addr) // return !p_qhd->qtd_overlay.halted && p_qhd->qtd_overlay.active;
}
-bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
+bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
{
uint8_t const epnum = edpt_number(ep_addr);
uint8_t const dir = edpt_dir(ep_addr);
@@ -301,9 +301,8 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t while(LPC_USB[rhport]->ENDPTSETUPSTAT & BIT_(0)) {}
}
- dcd_data_t* p_dcd = dcd_data_ptr[rhport];
- dcd_qhd_t * p_qhd = &p_dcd->qhd[ep_idx];
- dcd_qtd_t * p_qtd = &p_dcd->qtd[ep_idx];
+ dcd_qhd_t * p_qhd = &dcd_data_ptr[rhport]->qhd[ep_idx];
+ dcd_qtd_t * p_qtd = &dcd_data_ptr[rhport]->qtd[ep_idx];
//------------- Prepare qtd -------------//
qtd_init(p_qtd, buffer, total_bytes);
diff --git a/src/tusb_option.h b/src/tusb_option.h index 18e1e245e..b64a61e42 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -83,13 +83,16 @@ //--------------------------------------------------------------------
// CONTROLLER
+// Only 1 roothub port can be configured to be device and/or host.
+// tinyusb does not support dual devices or dual host configuration
//--------------------------------------------------------------------
/** \defgroup group_mode Controller Mode Selection
* \brief CFG_TUSB_CONTROLLER_N_MODE must be defined with these
* @{ */
-#define OPT_MODE_HOST 0x02 ///< Host Mode
-#define OPT_MODE_DEVICE 0x01 ///< Device Mode
-#define OPT_MODE_NONE 0x00 ///< Disabled
+#define OPT_MODE_NONE 0x00 ///< Disabled
+#define OPT_MODE_DEVICE 0x01 ///< Device Mode
+#define OPT_MODE_HOST 0x02 ///< Host Mode
+#define OPT_MODE_HIGH_SPEED 0x10 ///< Highspeed
/** @} */
#ifndef CFG_TUSB_RHPORT0_MODE
@@ -100,21 +103,28 @@ #define CFG_TUSB_RHPORT1_MODE OPT_MODE_NONE
#endif
+#if ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) && (CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST)) || \
+ ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) && (CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE))
+ #error "tinyusb does not support same modes on more than 1 roothub port"
+#endif
+
+// TODO remove
#define CONTROLLER_HOST_NUMBER (\
((CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) ? 1 : 0) + \
((CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST) ? 1 : 0))
#define MODE_HOST_SUPPORTED (CONTROLLER_HOST_NUMBER > 0)
+// Which roothub port is configured as host
#define TUH_OPT_RHPORT ( (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) ? 0 : ((CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST) ? 1 : -1) )
#define TUSB_OPT_HOST_ENABLED ( TUH_OPT_RHPORT >= 0 )
+// Which roothub port is configured as device
#define TUD_OPT_RHPORT ( (CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) ? 0 : ((CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE) ? 1 : -1) )
+#define TUD_OPT_HIGH_SPEED ( (CFG_TUSB_RHPORT0_MODE & (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)) || (CFG_TUSB_RHPORT1_MODE & (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)) )
+
#define TUSB_OPT_DEVICE_ENABLED ( TUD_OPT_RHPORT >= 0 )
-#if ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) && (CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST)) || ((CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) && (CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE))
- #error "tinyusb does not support same modes on more than 1 roothub port"
-#endif
//--------------------------------------------------------------------+
// COMMON OPTIONS
|
