From a91ac72dbdc033fd1cc26651ca2d66d0705b08aa Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Nov 2019 13:29:42 +0700 Subject: [PATCH 1/8] add the most important file of the project: CONTRIBUTORS.md --- CONTRIBUTORS.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 7 ++++++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 CONTRIBUTORS.md diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000..11c947c2 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,50 @@ +# TinyUSB contributors (sorted alphabetically) + +* **[Arturo182](https://github.com/arturo182)** + * Board support for MiMX RT1010 evaluation kit + +* **[Ha Thach](https://github.com/hathach)** + * Author and maintainer + * Most features develpopment + +* **[Jeff Epler](https://github.com/jepler)** + * Improvement to MIDI device driver + +* **[Kamil Tomaszewski](https://github.com/kamtom480)** + * Sony CXD56 device driver port for spresnese board + +* **[Nathan Conrad](https://github.com/pigrew)** + * STM32 fsdev Fullspeed device driver port for STM32 L0, F0, F1, F3 etc ... + * USB device class driver support + * USBTMC class driver support with example + * Improvement to Zero-length packet for control transfer + * Board support for STM32F070RB Nucleo, STM32F303 Discovery + +* **[Scott Shawcroft](https://github.com/tannewt)** + * SAMD21 and SAMD51 device driver port + * MIDI device class driver support + * Improvement to USBD control transfer, MSC, CDC class driver + * Board support for Metro M0 & M4 express + * Write the execellent porting.md documentation + * Introduce inital Makefile + +* **[Sean Cross](https://github.com/xobs)** + * ValentyUSB eptri device driver port + * Board support for fomu + +* **[Sylvain "tnt" Munaut](https://github.com/smunaut)** + * DFU runtime support with example + +* **[Timon Skerutsch](https://github.com/PTS93)** + * hid_test.js script and extensive test for bi-directional raw HID + +* **[Tod E. Kurt](https://github.com/todbot)** + * hid_test.js script and extensive test for bi-directional raw HID + +* **[William D. Jones](https://github.com/cr1901)** + * Synopsys DesignWare device driver port for STM32 L4, F2, F4, F7, H7 etc ... + * MSP430 device driver port (WIP) + * Board support for STM32F407 Discovery, STM32H743 Nucleo, pyboard v1.1 + + +**[Full contributors list](https://github.com/hathach/tinyusb/contributors).** diff --git a/README.md b/README.md index 162b707d..2e503e39 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,11 @@ TinyUSB is an open-source cross-platform USB Host/Device stack for embedded syst └── tools # Files used internally ``` +## Contributors + +Special thanks for all the people who had spent their precious time and effort to helped this project so far. +[CONTRIBUTORS.md](CONTRIBUTORS.md) file contains list of contributors and their awesome work. + ## Supported MCUs The stack supports the following MCUs @@ -32,7 +37,7 @@ The stack supports the following MCUs - iMX RT Series: RT1011, RT1015, RT1021, RT1052, RT1062, RT1064 - **Sony:** CXD56 - **ST:** STM32 series: L0, F0, F1, F2, F3, F4, F7, H7 (device only) -- **[valentyusb](https://github.com/im-tomu/valentyusb)** eptri +- **[ValentyUSB](https://github.com/im-tomu/valentyusb)** eptri [Here is the list of supported Boards](docs/boards.md) that can be used with provided examples. From 168f0cb4711056e452fa335e71ee4a10341a9821 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Nov 2019 13:33:50 +0700 Subject: [PATCH 2/8] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2e503e39..3f7556cf 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ TinyUSB is an open-source cross-platform USB Host/Device stack for embedded syst ## Contributors -Special thanks for all the people who had spent their precious time and effort to helped this project so far. -[CONTRIBUTORS.md](CONTRIBUTORS.md) file contains list of contributors and their awesome work. +Special thanks for all the people who had spent their precious time and effort to helped this project so far. Check out +[CONTRIBUTORS.md](CONTRIBUTORS.md) file for the list of all contributors and their awesome work for the stack. ## Supported MCUs From 0fccfc647fc5538481b8f673e9680ac6a9990e83 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Nov 2019 13:37:55 +0700 Subject: [PATCH 3/8] update --- CONTRIBUTORS.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 11c947c2..0eb6974d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -15,9 +15,8 @@ * **[Nathan Conrad](https://github.com/pigrew)** * STM32 fsdev Fullspeed device driver port for STM32 L0, F0, F1, F3 etc ... - * USB device class driver support * USBTMC class driver support with example - * Improvement to Zero-length packet for control transfer + * Various improvement e.g Zero-length packet, Lint setup * Board support for STM32F070RB Nucleo, STM32F303 Discovery * **[Scott Shawcroft](https://github.com/tannewt)** From 7c606563edfd5207c506566e0c49c25fb5a7e23c Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Nov 2019 20:52:27 +0700 Subject: [PATCH 4/8] lower case for arturo --- CONTRIBUTORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0eb6974d..1c8bbe37 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,6 +1,6 @@ # TinyUSB contributors (sorted alphabetically) -* **[Arturo182](https://github.com/arturo182)** +* **[arturo182](https://github.com/arturo182)** * Board support for MiMX RT1010 evaluation kit * **[Ha Thach](https://github.com/hathach)** From 13f42235176ef6dd49c7798dd83214a0963ee69f Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Nov 2019 21:10:08 +0700 Subject: [PATCH 5/8] add the most important contributor --- CONTRIBUTORS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1c8bbe37..f938c332 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,5 +1,9 @@ # TinyUSB contributors (sorted alphabetically) +* **[Adafruit Team](https://github.com/adafruit)** + * Main supporter and sponsor for hardware boards and kits + * Discussion and suggestion for feature and improvement + * **[arturo182](https://github.com/arturo182)** * Board support for MiMX RT1010 evaluation kit From 3a2d63613bf710e706176f968e2ce1c1337adf26 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Nov 2019 22:56:37 +0700 Subject: [PATCH 6/8] logo design --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f938c332..20f4d9e2 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -3,6 +3,7 @@ * **[Adafruit Team](https://github.com/adafruit)** * Main supporter and sponsor for hardware boards and kits * Discussion and suggestion for feature and improvement + * Design the project logo * **[arturo182](https://github.com/arturo182)** * Board support for MiMX RT1010 evaluation kit From 8a1b6327ba22940e42424e7ff208a81a4eb93e53 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Nov 2019 12:12:52 +0700 Subject: [PATCH 7/8] extract code to invoke_class_control() - also rename usbd_class_drivers to _usbd_driver --- src/device/usbd.c | 75 +++++++++++++++++++-------------------- src/device/usbd_control.c | 4 ++- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/device/usbd.c b/src/device/usbd.c index 7d12e398..1797dfaf 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -84,7 +84,7 @@ typedef struct { void (* sof ) (uint8_t rhport); } usbd_class_driver_t; -static usbd_class_driver_t const usbd_class_drivers[] = +static usbd_class_driver_t const _usbd_driver[] = { #if CFG_TUD_CDC { @@ -183,7 +183,7 @@ static usbd_class_driver_t const usbd_class_drivers[] = #endif }; -enum { USBD_CLASS_DRIVER_COUNT = TU_ARRAY_SIZE(usbd_class_drivers) }; +enum { USBD_CLASS_DRIVER_COUNT = TU_ARRAY_SIZE(_usbd_driver) }; //--------------------------------------------------------------------+ // DCD Event @@ -304,7 +304,7 @@ bool tud_init (void) for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++) { TU_LOG2("%s init\r\n", _usbd_driver_str[i]); - usbd_class_drivers[i].init(); + _usbd_driver[i].init(); } // Init device controller driver @@ -325,7 +325,7 @@ static void usbd_reset(uint8_t rhport) for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++) { - if ( usbd_class_drivers[i].reset ) usbd_class_drivers[i].reset( rhport ); + if ( _usbd_driver[i].reset ) _usbd_driver[i].reset( rhport ); } } @@ -414,7 +414,7 @@ void tud_task (void) TU_ASSERT(drv_id < USBD_CLASS_DRIVER_COUNT,); TU_LOG2(" %s xfer callback\r\n", _usbd_driver_str[drv_id]); - usbd_class_drivers[drv_id].xfer_cb(event.rhport, ep_addr, event.xfer_complete.result, event.xfer_complete.len); + _usbd_driver[drv_id].xfer_cb(event.rhport, ep_addr, event.xfer_complete.result, event.xfer_complete.len); } } break; @@ -430,9 +430,9 @@ void tud_task (void) case DCD_EVENT_SOF: for ( uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++ ) { - if ( usbd_class_drivers[i].sof ) + if ( _usbd_driver[i].sof ) { - usbd_class_drivers[i].sof(event.rhport); + _usbd_driver[i].sof(event.rhport); } } break; @@ -452,6 +452,16 @@ void tud_task (void) // Control Request Parser & Handling //--------------------------------------------------------------------+ +// Helper to invoke class driver control request handler +static bool invoke_class_control(uint8_t rhport, uint8_t drvid, tusb_control_request_t const * request) +{ + TU_ASSERT(_usbd_driver[drvid].control_request); + + usbd_control_set_complete_callback(_usbd_driver[drvid].control_complete); + TU_LOG2(" %s control request\r\n", _usbd_driver_str[drvid]); + return _usbd_driver[drvid].control_request(rhport, request); +} + // This handles the actual request and its response. // return false will cause its caller to stall control endpoint static bool process_control_request(uint8_t rhport, tusb_control_request_t const * p_request) @@ -586,21 +596,13 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const default: // forward to class driver: "STD request to Interface" // GET HID REPORT DESCRIPTOR falls into this case - // stall control endpoint if driver return false - usbd_control_set_complete_callback(usbd_class_drivers[drvid].control_complete); - TU_LOG2(" %s control request\r\n", _usbd_driver_str[drvid]); - TU_VERIFY(usbd_class_drivers[drvid].control_request != NULL && - usbd_class_drivers[drvid].control_request(rhport, p_request)); + TU_VERIFY(invoke_class_control(rhport, drvid, p_request)); break; } }else { // forward to class driver: "non-STD request to Interface" - // stall control endpoint if driver return false - usbd_control_set_complete_callback(usbd_class_drivers[drvid].control_complete); - TU_LOG2(" %s control request\r\n", _usbd_driver_str[drvid]); - TU_VERIFY(usbd_class_drivers[drvid].control_request != NULL && - usbd_class_drivers[drvid].control_request(rhport, p_request)); + TU_VERIFY(invoke_class_control(rhport, drvid, p_request)); } } break; @@ -614,18 +616,12 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const TU_ASSERT(ep_num < TU_ARRAY_SIZE(_usbd_dev.ep2drv) ); - uint8_t const drv_id = _usbd_dev.ep2drv[ep_num][ep_dir]; - TU_ASSERT(drv_id < USBD_CLASS_DRIVER_COUNT); + uint8_t const drvid = _usbd_dev.ep2drv[ep_num][ep_dir]; + TU_ASSERT(drvid < USBD_CLASS_DRIVER_COUNT); bool ret = false; - if ( TUSB_REQ_TYPE_STANDARD != p_request->bmRequestType_bit.type ) - { - // complete callback is also capable of stalling/acking the request - usbd_control_set_complete_callback(usbd_class_drivers[drv_id].control_complete); - } - - // Then handle if it is standard request + // Handle STD request to endpoint if ( TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type ) { // force return true for standard request @@ -660,18 +656,21 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const default: TU_BREAKPOINT(); return false; } } - // Some classes such as TMC needs to clear/re-init its buffer when receiving CLEAR_FEATURE request - // We will forward all request targeted endpoint to its class driver - // For class-type requests: must (call tud_control_status(); return true) or (return false) - // For std-type requests: non-std request codes are already discarded. - // must not call tud_control_status(), and return value will have no effect - // class driver is invoked last, so that EP already has EP stall cleared (in event of clear feature EP halt) - TU_LOG2(" %s control request\r\n", _usbd_driver_str[drv_id]); - if ( usbd_class_drivers[drv_id].control_request && - usbd_class_drivers[drv_id].control_request(rhport, p_request)) + + // Some classes such as USBTMC needs to clear/re-init its buffer when receiving CLEAR_FEATURE request + // We will forward all request targeted endpoint to class drivers after + // - For class-type requests: driver is fully responsible to reply to host + // - For std-type requests : driver init/re-init internal variable/buffer only, and + // must not call tud_control_status(), driver's return value will have no effect. + // EP state has already affected (stalled/cleared) + if ( invoke_class_control(rhport, drvid, p_request) ) ret = true; + + if ( TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type ) { - ret = true; + // Set complete callback = NULL since it can also stall the request. + usbd_control_set_complete_callback(NULL); } + return ret; } break; @@ -714,7 +713,7 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num) uint8_t drv_id; for (drv_id = 0; drv_id < USBD_CLASS_DRIVER_COUNT; drv_id++) { - if ( usbd_class_drivers[drv_id].class_code == desc_itf->bInterfaceClass ) break; + if ( _usbd_driver[drv_id].class_code == desc_itf->bInterfaceClass ) break; } TU_ASSERT( drv_id < USBD_CLASS_DRIVER_COUNT ); @@ -724,7 +723,7 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num) uint16_t itf_len=0; TU_LOG2(" %s open\r\n", _usbd_driver_str[drv_id]); - TU_ASSERT( usbd_class_drivers[drv_id].open(rhport, desc_itf, &itf_len) ); + TU_ASSERT( _usbd_driver[drv_id].open(rhport, desc_itf, &itf_len) ); TU_ASSERT( itf_len >= sizeof(tusb_desc_interface_t) ); mark_interface_endpoint(_usbd_dev.ep2drv, p_desc, itf_len, drv_id); diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index 96786413..7f6cf5a4 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -130,7 +130,9 @@ void usbd_control_set_complete_callback( bool (*fp) (uint8_t, tusb_control_reque _ctrl_xfer.complete_cb = fp; } -// callback when a transaction complete on DATA stage of control endpoint +// callback when a transaction complete on +// - DATA stage of control endpoint or +// - Status stage bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes) { (void) result; From fe1eadf177ec42914ce156704c6d2a6d85371945 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Nov 2019 12:34:30 +0700 Subject: [PATCH 8/8] fix #229 --- src/class/cdc/cdc_device.c | 4 +-- src/class/dfu/dfu_rt_device.c | 14 ++++------ src/class/hid/hid_device.c | 52 +++++++++++++++++------------------ src/class/midi/midi_device.c | 5 ++-- src/class/msc/msc_device.c | 3 +- 5 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 6da9157b..b124b473 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -311,8 +311,8 @@ bool cdcd_control_complete(uint8_t rhport, tusb_control_request_t const * reques // return false to stall control endpoint (e.g unsupported request) bool cdcd_control_request(uint8_t rhport, tusb_control_request_t const * request) { - //------------- Class Specific Request -------------// - TU_ASSERT(request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS); + // Handle class request only + TU_VERIFY(request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS); // TODO Support multiple interfaces uint8_t const itf = 0; diff --git a/src/class/dfu/dfu_rt_device.c b/src/class/dfu/dfu_rt_device.c index 59adae7e..ad1871da 100644 --- a/src/class/dfu/dfu_rt_device.c +++ b/src/class/dfu/dfu_rt_device.c @@ -79,21 +79,17 @@ bool dfu_rtd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16 bool dfu_rtd_control_complete(uint8_t rhport, tusb_control_request_t const * request) { (void) rhport; + (void) request; - //------------- Class Specific Request -------------// - TU_VERIFY(request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS); - TU_VERIFY(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE); - + // nothing to do return true; } bool dfu_rtd_control_request(uint8_t rhport, tusb_control_request_t const * request) { - (void) rhport; - - //------------- Class Specific Request -------------// - TU_ASSERT(request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS); - TU_ASSERT(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE); + // Handle class request only + TU_VERIFY(request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS); + TU_VERIFY(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE); switch ( request->bRequest ) { diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index 1d35e63f..8527fa5d 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -191,89 +191,87 @@ bool hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint16_t // Handle class control request // return false to stall control endpoint (e.g unsupported request) -bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_request) +bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request) { - if (p_request->bmRequestType_bit.recipient != TUSB_REQ_RCPT_INTERFACE) - { - return false; - } - hidd_interface_t* p_hid = get_interface_by_itfnum( (uint8_t) p_request->wIndex ); + TU_VERIFY(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE); + + hidd_interface_t* p_hid = get_interface_by_itfnum( (uint8_t) request->wIndex ); TU_ASSERT(p_hid); - if (p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD) + if (request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD) { //------------- STD Request -------------// - uint8_t const desc_type = tu_u16_high(p_request->wValue); - uint8_t const desc_index = tu_u16_low (p_request->wValue); + uint8_t const desc_type = tu_u16_high(request->wValue); + uint8_t const desc_index = tu_u16_low (request->wValue); (void) desc_index; - if (p_request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_HID) + if (request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_HID) { TU_VERIFY(p_hid->hid_descriptor != NULL); - TU_VERIFY(tud_control_xfer(rhport, p_request, (void*) p_hid->hid_descriptor, p_hid->hid_descriptor->bLength)); + TU_VERIFY(tud_control_xfer(rhport, request, (void*) p_hid->hid_descriptor, p_hid->hid_descriptor->bLength)); } - else if (p_request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT) + else if (request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT) { uint8_t const * desc_report = tud_hid_descriptor_report_cb(); - tud_control_xfer(rhport, p_request, (void*) desc_report, p_hid->report_desc_len); + tud_control_xfer(rhport, request, (void*) desc_report, p_hid->report_desc_len); } else { return false; // stall unsupported request } } - else if (p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS) + else if (request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS) { //------------- Class Specific Request -------------// - switch( p_request->bRequest ) + switch( request->bRequest ) { case HID_REQ_CONTROL_GET_REPORT: { // wValue = Report Type | Report ID - uint8_t const report_type = tu_u16_high(p_request->wValue); - uint8_t const report_id = tu_u16_low(p_request->wValue); + 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(report_id, (hid_report_type_t) report_type, p_hid->epin_buf, p_request->wLength); + uint16_t xferlen = tud_hid_get_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength); TU_ASSERT( xferlen > 0 ); - tud_control_xfer(rhport, p_request, p_hid->epin_buf, xferlen); + tud_control_xfer(rhport, request, p_hid->epin_buf, xferlen); } break; case HID_REQ_CONTROL_SET_REPORT: - TU_VERIFY(p_request->wLength <= sizeof(p_hid->epout_buf)); - tud_control_xfer(rhport, p_request, p_hid->epout_buf, p_request->wLength); + TU_VERIFY(request->wLength <= sizeof(p_hid->epout_buf)); + tud_control_xfer(rhport, request, p_hid->epout_buf, request->wLength); break; case HID_REQ_CONTROL_SET_IDLE: - p_hid->idle_rate = tu_u16_high(p_request->wValue); + p_hid->idle_rate = tu_u16_high(request->wValue); if ( tud_hid_set_idle_cb ) { // stall request if callback return false if ( !tud_hid_set_idle_cb(p_hid->idle_rate) ) return false; } - tud_control_status(rhport, p_request); + tud_control_status(rhport, request); break; case HID_REQ_CONTROL_GET_IDLE: // TODO idle rate of report - tud_control_xfer(rhport, p_request, &p_hid->idle_rate, 1); + tud_control_xfer(rhport, request, &p_hid->idle_rate, 1); break; case HID_REQ_CONTROL_GET_PROTOCOL: { uint8_t protocol = (uint8_t)(1-p_hid->boot_mode); // 0 is Boot, 1 is Report protocol - tud_control_xfer(rhport, p_request, &protocol, 1); + tud_control_xfer(rhport, request, &protocol, 1); } break; case HID_REQ_CONTROL_SET_PROTOCOL: - p_hid->boot_mode = 1 - p_request->wValue; // 0 is Boot, 1 is Report protocol + p_hid->boot_mode = 1 - request->wValue; // 0 is Boot, 1 is Report protocol if (tud_hid_boot_mode_cb) tud_hid_boot_mode_cb(p_hid->boot_mode); - tud_control_status(rhport, p_request); + tud_control_status(rhport, request); break; default: return false; // stall unsupported request diff --git a/src/class/midi/midi_device.c b/src/class/midi/midi_device.c index 11fe06e3..b278039b 100644 --- a/src/class/midi/midi_device.c +++ b/src/class/midi/midi_device.c @@ -322,10 +322,9 @@ bool midid_control_complete(uint8_t rhport, tusb_control_request_t const * p_req bool midid_control_request(uint8_t rhport, tusb_control_request_t const * p_request) { (void) rhport; + (void) p_request; - //------------- Class Specific Request -------------// - if (p_request->bmRequestType_bit.type != TUSB_REQ_TYPE_CLASS) return false; - + // driver doesn't support any request yet return false; } diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index cec76b11..bf2b5bb8 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -149,7 +149,8 @@ bool mscd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t // return false to stall control endpoint (e.g unsupported request) bool mscd_control_request(uint8_t rhport, tusb_control_request_t const * p_request) { - TU_ASSERT(p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS); + // Handle class request only + TU_VERIFY(p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS); switch ( p_request->bRequest ) {