summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2014-03-23 00:00:23 +0700
committerhathach <[email protected]>2014-03-23 00:00:23 +0700
commit3a8dce013d0cf153f4c81f8ba891b5abc1b276fd (patch)
treeed7414d9b5da402143820b0072b7fa6faa2a5fda
parent1cdca167cd41f51ca587a265b41f79446d828e48 (diff)
remove IAD_DESC_REQUIRED
add compiler guard for exceeding number of endpoints for lpc11/13u
-rw-r--r--demos/device/src/tusb_config.h2
-rw-r--r--demos/device/src/tusb_descriptors.c8
-rw-r--r--demos/device/src/tusb_descriptors.h15
-rw-r--r--tinyusb/class/hid_device.c7
-rw-r--r--tinyusb/device/dcd_lpc_11uxx_13uxx.c2
5 files changed, 16 insertions, 18 deletions
diff --git a/demos/device/src/tusb_config.h b/demos/device/src/tusb_config.h
index 803208944..13a81e248 100644
--- a/demos/device/src/tusb_config.h
+++ b/demos/device/src/tusb_config.h
@@ -60,7 +60,7 @@
//------------- CLASS -------------//
#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
-#define TUSB_CFG_DEVICE_HID_MOUSE 1
+#define TUSB_CFG_DEVICE_HID_MOUSE 0
#define TUSB_CFG_DEVICE_HID_GENERIC 0 // not supported yet
#define TUSB_CFG_DEVICE_MSC 1
#define TUSB_CFG_DEVICE_CDC 1
diff --git a/demos/device/src/tusb_descriptors.c b/demos/device/src/tusb_descriptors.c
index 5e8c0ad07..33fc895b4 100644
--- a/demos/device/src/tusb_descriptors.c
+++ b/demos/device/src/tusb_descriptors.c
@@ -143,8 +143,8 @@ tusb_descriptor_device_t desc_device =
.bLength = sizeof(tusb_descriptor_device_t),
.bDescriptorType = TUSB_DESC_TYPE_DEVICE,
.bcdUSB = 0x0200,
- #if IAD_DESC_REQUIRED
- // Multiple Interfaces Using Interface Association Descriptor (IAD)
+ #if TUSB_CFG_DEVICE_CDC
+ // Use Interface Association Descriptor (IAD) for CDC
// As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
.bDeviceClass = TUSB_CLASS_MISC,
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
@@ -188,7 +188,7 @@ app_descriptor_configuration_t desc_configuration =
.bMaxPower = TUSB_DESC_CONFIG_POWER_MA(100)
},
- #if IAD_DESC_REQUIRED
+ #if TUSB_CFG_DEVICE_CDC
// IAD points to CDC Interfaces
.cdc_iad =
{
@@ -203,9 +203,7 @@ app_descriptor_configuration_t desc_configuration =
.bFunctionProtocol = CDC_COMM_PROTOCOL_ATCOMMAND,
.iFunction = 0
},
- #endif
- #if TUSB_CFG_DEVICE_CDC
//------------- CDC Communication Interface -------------//
.cdc_comm_interface =
{
diff --git a/demos/device/src/tusb_descriptors.h b/demos/device/src/tusb_descriptors.h
index ad472ac6c..cae6852e5 100644
--- a/demos/device/src/tusb_descriptors.h
+++ b/demos/device/src/tusb_descriptors.h
@@ -57,16 +57,17 @@
#endif
#define INTERFACE_NO_CDC 0
-#define INTERFACE_NO_HID_KEYBOARD (INTERFACE_NO_CDC + 2*TUSB_CFG_DEVICE_CDC )
-#define INTERFACE_NO_HID_MOUSE (INTERFACE_NO_HID_KEYBOARD + TUSB_CFG_DEVICE_HID_KEYBOARD )
-#define INTERFACE_NO_HID_GENERIC (INTERFACE_NO_HID_MOUSE + TUSB_CFG_DEVICE_HID_MOUSE )
-#define INTERFACE_NO_MSC (INTERFACE_NO_HID_GENERIC + TUSB_CFG_DEVICE_HID_GENERIC )
+#define INTERFACE_NO_HID_KEYBOARD (INTERFACE_NO_CDC + 2*(TUSB_CFG_DEVICE_CDC ? 1 : 0) )
+#define INTERFACE_NO_HID_MOUSE (INTERFACE_NO_HID_KEYBOARD + TUSB_CFG_DEVICE_HID_KEYBOARD )
+#define INTERFACE_NO_HID_GENERIC (INTERFACE_NO_HID_MOUSE + TUSB_CFG_DEVICE_HID_MOUSE )
+#define INTERFACE_NO_MSC (INTERFACE_NO_HID_GENERIC + TUSB_CFG_DEVICE_HID_GENERIC )
#define TOTAL_INTEFACES (2*TUSB_CFG_DEVICE_CDC + TUSB_CFG_DEVICE_HID_KEYBOARD + TUSB_CFG_DEVICE_HID_MOUSE + \
TUSB_CFG_DEVICE_HID_GENERIC + TUSB_CFG_DEVICE_MSC)
-// Interface Assosication Descriptor is required when enable CDC
-#define IAD_DESC_REQUIRED ( TUSB_CFG_DEVICE_CDC )
+#if (TUSB_CFG_MCU == MCU_LPC11UXX || TUSB_CFG_MCU == MCU_LPC13UXX) && (TOTAL_INTEFACES > 4)
+ #error These MCUs do not have enough number of endpoints for the current configuration
+#endif
//--------------------------------------------------------------------+
// Endpoints Address & Max Packet Size
@@ -136,9 +137,7 @@ typedef ATTR_PACKED_STRUCT(struct)
//------------- CDC -------------//
#if TUSB_CFG_DEVICE_CDC
- #if IAD_DESC_REQUIRED
tusb_descriptor_interface_association_t cdc_iad;
- #endif
//CDC Control Interface
tusb_descriptor_interface_t cdc_comm_interface;
diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c
index 91fe0f9d6..e2fb9f62f 100644
--- a/tinyusb/class/hid_device.c
+++ b/tinyusb/class/hid_device.c
@@ -102,7 +102,8 @@ static hidd_class_driver_t const hidd_class_driver[HIDD_NUMBER_OF_SUBCLASS] =
};
// TODO [HID] generic
-TUSB_CFG_ATTR_USBRAM uint8_t m_control_data[ MAX_OF(sizeof(hid_keyboard_report_t), sizeof(hid_mouse_report_t)) ];
+TUSB_CFG_ATTR_USBRAM
+static uint8_t m_control_report[ MAX_OF(sizeof(hid_keyboard_report_t), sizeof(hid_mouse_report_t)) ];
//--------------------------------------------------------------------+
// KEYBOARD APPLICATION API
@@ -228,13 +229,13 @@ tusb_error_t hidd_control_request_subtask(uint8_t coreid, tusb_control_request_t
// wValue = Report Type | Report ID
tusb_error_t error;
- dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, m_control_data, p_request->wLength, true);
+ dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, m_control_report, p_request->wLength, true);
osal_semaphore_wait(usbd_control_xfer_sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // wait for control xfer complete
SUBTASK_ASSERT_STATUS(error);
p_driver->set_report_cb(coreid, (hid_request_report_type_t) u16_high_u8(p_request->wValue),
- m_control_data, p_request->wLength);
+ m_control_report, p_request->wLength);
}
else if (HID_REQUEST_CONTROL_SET_IDLE == p_request->bRequest)
{
diff --git a/tinyusb/device/dcd_lpc_11uxx_13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c
index ae9609088..35c4f47fb 100644
--- a/tinyusb/device/dcd_lpc_11uxx_13uxx.c
+++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c
@@ -470,7 +470,7 @@ endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const
//------------- Prepare Queue Head -------------//
uint8_t ep_id = edpt_addr2phy(p_endpoint_desc->bEndpointAddress);
- ASSERT( dcd_data.qhd[ep_id][0].disable && dcd_data.qhd[ep_id][1].disable, null_handle ); // endpoint must not previously opened
+ ASSERT( dcd_data.qhd[ep_id][0].disable && dcd_data.qhd[ep_id][1].disable, null_handle ); // endpoint must not previously opened, normally this means running out of endpoints
memclr_(dcd_data.qhd[ep_id], 2*sizeof(dcd_11u_13u_qhd_t));
dcd_data.qhd[ep_id][0].is_isochronous = dcd_data.qhd[ep_id][1].is_isochronous = (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS);