summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinhard Panhuber <[email protected]>2021-02-24 20:54:35 +0100
committerReinhard Panhuber <[email protected]>2021-02-24 20:54:35 +0100
commit5ebe53f02da9f85e1830b845c92253369c311e37 (patch)
tree921f22e5dcca7423c505299312e36152f633097e
parenta7f07a1a63a07000a35357194dff7d61890c60c6 (diff)
parent280297bdb7aec67adf347ec046943a48a71647df (diff)
Merge remote-tracking branch 'upstream/master' into edpt_ISO_xfer
-rw-r--r--README.md2
-rw-r--r--examples/device/hid_composite/src/main.c6
-rw-r--r--examples/device/hid_composite/src/usb_descriptors.c3
-rw-r--r--examples/device/hid_composite_freertos/src/main.c6
-rw-r--r--examples/device/hid_composite_freertos/src/usb_descriptors.c3
-rw-r--r--examples/device/hid_generic_inout/src/main.c6
-rw-r--r--examples/device/hid_generic_inout/src/usb_descriptors.c3
-rw-r--r--hw/bsp/ea4357/ea4357.c34
-rw-r--r--hw/bsp/ngx4330/ngx4330.c28
-rw-r--r--src/class/hid/hid_device.c41
-rw-r--r--src/class/hid/hid_device.h14
-rw-r--r--src/portable/sony/cxd56/dcd_cxd56.c10
12 files changed, 35 insertions, 121 deletions
diff --git a/README.md b/README.md
index 4b989bfab..d4a0b38ce 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# TinyUSB
-![tinyUSB_240x100](https://user-images.githubusercontent.com/249515/62646655-f9393200-b978-11e9-9c53-484862f15503.png)
+![TinyUSB](https://user-images.githubusercontent.com/2847802/108847382-a0a6a580-75ad-11eb-96d9-280c79389281.png)
[![Build Status](https://github.com/hathach/tinyusb/workflows/Build/badge.svg)](https://github.com/hathach/tinyusb/actions) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
diff --git a/examples/device/hid_composite/src/main.c b/examples/device/hid_composite/src/main.c
index 9fb2de88d..512f6f9d9 100644
--- a/examples/device/hid_composite/src/main.c
+++ b/examples/device/hid_composite/src/main.c
@@ -239,9 +239,10 @@ void tud_hid_report_complete_cb(uint8_t itf, uint8_t const* report, uint8_t len)
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
-uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
+uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
{
// TODO not Implemented
+ (void) itf;
(void) report_id;
(void) report_type;
(void) buffer;
@@ -252,9 +253,10 @@ uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type,
// Invoked when received SET_REPORT control request or
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
-void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
+void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
{
// TODO set LED based on CAPLOCK, NUMLOCK etc...
+ (void) itf;
(void) report_id;
(void) report_type;
(void) buffer;
diff --git a/examples/device/hid_composite/src/usb_descriptors.c b/examples/device/hid_composite/src/usb_descriptors.c
index ec4976188..ccc1306bd 100644
--- a/examples/device/hid_composite/src/usb_descriptors.c
+++ b/examples/device/hid_composite/src/usb_descriptors.c
@@ -82,8 +82,9 @@ uint8_t const desc_hid_report[] =
// Invoked when received GET HID REPORT DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
-uint8_t const * tud_hid_descriptor_report_cb(void)
+uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf)
{
+ (void) itf;
return desc_hid_report;
}
diff --git a/examples/device/hid_composite_freertos/src/main.c b/examples/device/hid_composite_freertos/src/main.c
index aa006fbea..79dc2ec69 100644
--- a/examples/device/hid_composite_freertos/src/main.c
+++ b/examples/device/hid_composite_freertos/src/main.c
@@ -299,9 +299,10 @@ void tud_hid_report_complete_cb(uint8_t itf, uint8_t const* report, uint8_t len)
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
-uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
+uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
{
// TODO not Implemented
+ (void) itf;
(void) report_id;
(void) report_type;
(void) buffer;
@@ -312,9 +313,10 @@ uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type,
// Invoked when received SET_REPORT control request or
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
-void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
+void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
{
// TODO set LED based on CAPLOCK, NUMLOCK etc...
+ (void) itf;
(void) report_id;
(void) report_type;
(void) buffer;
diff --git a/examples/device/hid_composite_freertos/src/usb_descriptors.c b/examples/device/hid_composite_freertos/src/usb_descriptors.c
index ec4976188..ccc1306bd 100644
--- a/examples/device/hid_composite_freertos/src/usb_descriptors.c
+++ b/examples/device/hid_composite_freertos/src/usb_descriptors.c
@@ -82,8 +82,9 @@ uint8_t const desc_hid_report[] =
// Invoked when received GET HID REPORT DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
-uint8_t const * tud_hid_descriptor_report_cb(void)
+uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf)
{
+ (void) itf;
return desc_hid_report;
}
diff --git a/examples/device/hid_generic_inout/src/main.c b/examples/device/hid_generic_inout/src/main.c
index 4573bd7e0..65874f483 100644
--- a/examples/device/hid_generic_inout/src/main.c
+++ b/examples/device/hid_generic_inout/src/main.c
@@ -121,9 +121,10 @@ void tud_resume_cb(void)
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
-uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
+uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
{
// TODO not Implemented
+ (void) itf;
(void) report_id;
(void) report_type;
(void) buffer;
@@ -134,9 +135,10 @@ uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type,
// Invoked when received SET_REPORT control request or
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
-void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
+void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
{
// This example doesn't use multiple report and report ID
+ (void) itf;
(void) report_id;
(void) report_type;
diff --git a/examples/device/hid_generic_inout/src/usb_descriptors.c b/examples/device/hid_generic_inout/src/usb_descriptors.c
index ef7450e8f..db4ddd76e 100644
--- a/examples/device/hid_generic_inout/src/usb_descriptors.c
+++ b/examples/device/hid_generic_inout/src/usb_descriptors.c
@@ -78,8 +78,9 @@ uint8_t const desc_hid_report[] =
// Invoked when received GET HID REPORT DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
-uint8_t const * tud_hid_descriptor_report_cb(void)
+uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf)
{
+ (void) itf;
return desc_hid_report;
}
diff --git a/hw/bsp/ea4357/ea4357.c b/hw/bsp/ea4357/ea4357.c
index 56653bd1b..aa206a28d 100644
--- a/hw/bsp/ea4357/ea4357.c
+++ b/hw/bsp/ea4357/ea4357.c
@@ -172,25 +172,11 @@ void board_init(void)
*/
#if CFG_TUSB_RHPORT0_MODE
Chip_USB0_Init();
-
- // Reset controller
- LPC_USB0->USBCMD_D |= 0x02;
- while( LPC_USB0->USBCMD_D & 0x02 ) {}
-
- // Set mode
- #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
- LPC_USB0->USBMODE_H = USBMODE_HOST | (USBMODE_VBUS_HIGH << 5);
-
- LPC_USB0->PORTSC1_D |= (1<<24); // FIXME force full speed for debugging
- #else // TODO OTG
- LPC_USB0->USBMODE_D = USBMODE_DEVICE;
- LPC_USB0->OTGSC = (1<<3) | (1<<0) /*| (1<<16)| (1<<24)| (1<<25)| (1<<26)| (1<<27)| (1<<28)| (1<<29)| (1<<30)*/;
- #endif
#endif
- /* USB1
+ /* From EA4357 user manual
*
- * For USB Device:
+ * For USB1 Device:
* - a 1.5Kohm pull-up resistor is needed on the USB DP data signal. There are two methods to create this.
* JP15 is inserted and the pull-up resistor is always enabled. Alternatively, the pull-up resistor is activated
* inside the USB OTG chip (U31), and this has to be done via the I2C interface of GPIO52/GPIO53. In the latter case,
@@ -200,7 +186,7 @@ void board_init(void)
* of VBUS can be read via U31.
* - JP16 shall not be inserted.
*
- * For USB Host:
+ * For USB1 Host:
* - 15Kohm pull-down resistors are needed on the USB data signals. These are activated inside the USB OTG chip (U31),
* and this has to be done via the I2C interface of GPIO52/GPIO53.
* - J20 is the connector to use when USB Host is used. In order to provide +5V to the external USB
@@ -211,20 +197,6 @@ void board_init(void)
*/
#if CFG_TUSB_RHPORT1_MODE
Chip_USB1_Init();
-
-// // Reset controller
-// LPC_USB1->USBCMD_D |= 0x02;
-// while( LPC_USB1->USBCMD_D & 0x02 ) {}
-//
-// // Set mode
-// #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST
-// LPC_USB1->USBMODE_H = USBMODE_HOST | (USBMODE_VBUS_HIGH << 5);
-// #else // TODO OTG
-// LPC_USB1->USBMODE_D = USBMODE_DEVICE;
-// #endif
-//
-// // USB1 as fullspeed
-// LPC_USB1->PORTSC1_D |= (1<<24);
#endif
// USB0 Vbus Power: P2_3 on EA4357 channel B U20 GPIO26 active low (base board)
diff --git a/hw/bsp/ngx4330/ngx4330.c b/hw/bsp/ngx4330/ngx4330.c
index 2e4ff9af9..b63f9b894 100644
--- a/hw/bsp/ngx4330/ngx4330.c
+++ b/hw/bsp/ngx4330/ngx4330.c
@@ -169,20 +169,6 @@ void board_init(void)
*/
#if CFG_TUSB_RHPORT0_MODE
Chip_USB0_Init();
-
-// // Reset controller
-// LPC_USB0->USBCMD_D |= 0x02;
-// while( LPC_USB0->USBCMD_D & 0x02 ) {}
-//
-// // Set mode
-// #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
-// LPC_USB0->USBMODE_H = USBMODE_HOST | (USBMODE_VBUS_HIGH << 5);
-//
-// LPC_USB0->PORTSC1_D |= (1<<24); // FIXME force full speed for debugging
-// #else // TODO OTG
-// LPC_USB0->USBMODE_D = USBMODE_DEVICE;
-// LPC_USB0->OTGSC = (1<<3) | (1<<0) /*| (1<<16)| (1<<24)| (1<<25)| (1<<26)| (1<<27)| (1<<28)| (1<<29)| (1<<30)*/;
-// #endif
#endif
/* USB1
@@ -206,20 +192,6 @@ void board_init(void)
#if CFG_TUSB_RHPORT1_MODE
Chip_USB1_Init();
-// // Reset controller
-// LPC_USB1->USBCMD_D |= 0x02;
-// while( LPC_USB1->USBCMD_D & 0x02 ) {}
-//
-// // Set mode
-// #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST
-// LPC_USB1->USBMODE_H = USBMODE_HOST | (USBMODE_VBUS_HIGH << 5);
-// #else // TODO OTG
-// LPC_USB1->USBMODE_D = USBMODE_DEVICE;
-// #endif
-//
-// // USB1 as fullspeed
-// LPC_USB1->PORTSC1_D |= (1<<24);
-
// Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 6); /* GPIO5[6] = USB1_PWR_EN */
// Chip_GPIO_SetPinState(LPC_GPIO_PORT, 5, 6, true); /* GPIO5[6] output high */
#endif
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c
index 4cdcecc9e..18d35bc20 100644
--- a/src/class/hid/hid_device.c
+++ b/src/class/hid/hid_device.c
@@ -251,11 +251,7 @@ bool hidd_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t
}
else if (request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT)
{
- uint8_t const * desc_report = tud_hid_descriptor_report_cb(
- #if CFG_TUD_HID > 1
- hid_itf // TODO for backward compatible callback, remove later when appropriate
- #endif
- );
+ uint8_t const * desc_report = tud_hid_descriptor_report_cb(hid_itf);
tud_control_xfer(rhport, request, (void*) desc_report, p_hid->report_desc_len);
}
else
@@ -275,12 +271,7 @@ bool hidd_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t
uint8_t const report_type = tu_u16_high(request->wValue);
uint8_t const report_id = tu_u16_low(request->wValue);
- uint16_t xferlen = tud_hid_get_report_cb(
- #if CFG_TUD_HID > 1
- hid_itf, // TODO for backward compatible callback, remove later when appropriate
- #endif
- report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength
- );
+ uint16_t xferlen = tud_hid_get_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength);
TU_ASSERT( xferlen > 0 );
tud_control_xfer(rhport, request, p_hid->epin_buf, xferlen);
@@ -298,12 +289,7 @@ bool hidd_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t
uint8_t const report_type = tu_u16_high(request->wValue);
uint8_t const report_id = tu_u16_low(request->wValue);
- tud_hid_set_report_cb(
- #if CFG_TUD_HID > 1
- hid_itf, // TODO for backward compatible callback, remove later when appropriate
- #endif
- report_id, (hid_report_type_t) report_type, p_hid->epout_buf, request->wLength
- );
+ tud_hid_set_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epout_buf, request->wLength);
}
break;
@@ -314,12 +300,7 @@ bool hidd_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t
if ( tud_hid_set_idle_cb )
{
// stall request if callback return false
- TU_VERIFY( tud_hid_set_idle_cb(
- #if CFG_TUD_HID > 1
- hid_itf, // TODO for backward compatible callback, remove later when appropriate
- #endif
- p_hid->idle_rate)
- );
+ TU_VERIFY( tud_hid_set_idle_cb( hid_itf, p_hid->idle_rate) );
}
tud_control_status(rhport, request);
@@ -354,12 +335,7 @@ bool hidd_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t
{
if (tud_hid_boot_mode_cb)
{
- tud_hid_boot_mode_cb(
- #if CFG_TUD_HID > 1
- hid_itf, // TODO for backward compatible callback, remove later when appropriate
- #endif
- p_hid->boot_mode
- );
+ tud_hid_boot_mode_cb(hid_itf, p_hid->boot_mode);
}
}
break;
@@ -400,12 +376,7 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
// Received report
else if (ep_addr == p_hid->ep_out)
{
- tud_hid_set_report_cb(
- #if CFG_TUD_HID > 1
- itf, // TODO for backward compatible callback, remove later when appropriate
- #endif
- 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes
- );
+ tud_hid_set_report_cb(itf, 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
TU_ASSERT(usbd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
}
diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h
index d5de53221..0c59d5d20 100644
--- a/src/class/hid/hid_device.h
+++ b/src/class/hid/hid_device.h
@@ -88,8 +88,6 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
// Callbacks (Weak is optional)
//--------------------------------------------------------------------+
-#if CFG_TUD_HID > 1
-
// Invoked when received GET HID REPORT DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf);
@@ -111,18 +109,6 @@ TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t itf, uint8_t boot_mode);
// - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t itf, uint8_t idle_rate);
-#else
-
-// TODO for backward compatible callback, remove later when appropriate
-uint8_t const * tud_hid_descriptor_report_cb(void);
-uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
-void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
-
-TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
-TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
-
-#endif
-
// Invoked when sent REPORT successfully to host
// Application can use this to send the next report
// Note: For composite reports, report[0] is report ID
diff --git a/src/portable/sony/cxd56/dcd_cxd56.c b/src/portable/sony/cxd56/dcd_cxd56.c
index 904176ba1..54958182b 100644
--- a/src/portable/sony/cxd56/dcd_cxd56.c
+++ b/src/portable/sony/cxd56/dcd_cxd56.c
@@ -329,6 +329,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
{
if (total_bytes == 0)
{
+ usbdcd_driver.setup_processed = true;
dcd_event_xfer_complete(0, ep_addr, 0, XFER_RESULT_SUCCESS, false);
}
else if (ep_addr == 0x00 && total_bytes == usbdcd_driver.outlen)
@@ -350,12 +351,15 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
}
}
- usbdcd_driver.setup_processed = true;
struct usb_ctrlreq_s ctrl;
- if (osal_queue_receive(usbdcd_driver.setup_queue, &ctrl))
+ if (usbdcd_driver.setup_processed)
{
- dcd_event_setup_received(0, (uint8_t *)&ctrl, false);
+ if (osal_queue_receive(usbdcd_driver.setup_queue, &ctrl))
+ {
+ usbdcd_driver.setup_processed = false;
+ dcd_event_setup_received(0, (uint8_t *)&ctrl, false);
+ }
}
}
else