Skip to content

Commit 421d053

Browse files
authored
Merge pull request #267 from adafruit/more-tinyusb-update
More tinyusb update to commit 07976ad26d4fbcad0694aa3a08294af7fd5f759f
2 parents ee35022 + 12b6f5c commit 421d053

File tree

18 files changed

+362
-240
lines changed

18 files changed

+362
-240
lines changed

.github/workflows/githubci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030
- name: pre-install
3131
run: bash ci/actions_install.sh
3232

33-
- name: clang
34-
run: python3 ci/run-clang-format.py -r src/arduino
33+
# - name: clang
34+
# run: python3 ci/run-clang-format.py -r src/arduino
3535

3636
- name: doxygen
3737
env:

.pre-commit-config.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,27 @@
33
# SPDX-License-Identifier: Unlicense
44

55
repos:
6+
- repo: https://github.com/pre-commit/mirrors-clang-format
7+
rev: v15.0.7
8+
hooks:
9+
- id: clang-format
10+
exclude: |
11+
(?x)^(
12+
examples/|
13+
src/class|
14+
src/common|
15+
src/device|
16+
src/host|
17+
src/osal|
18+
src/portable|
19+
src/tusb_option.h|
20+
src/tusb.c|
21+
src/tusb.h
22+
)
23+
types_or: [c++, c, header]
24+
625
- repo: https://github.com/codespell-project/codespell
726
rev: v2.2.4
827
hooks:
928
- id: codespell
10-
#args: [-w]
29+
args: [-w]

examples/DualRole/CDC/serial_host_bridge/serial_host_bridge.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ void setup1() {
9191
while ( !Serial ) {
9292
delay(10); // wait for native usb
9393
}
94-
Serial.printf("Error: CPU Clock = %u, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
95-
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n", cpu_hz);
94+
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
95+
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
9696
while(1) {
9797
delay(1);
9898
}

examples/DualRole/HID/hid_device_report/hid_device_report.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ void setup1() {
6868
uint32_t cpu_hz = clock_get_hz(clk_sys);
6969
if ( cpu_hz != 120000000UL && cpu_hz != 240000000UL ) {
7070
while ( !Serial ) delay(10); // wait for native usb
71-
Serial.printf("Error: CPU Clock = %u, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
72-
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n", cpu_hz);
71+
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
72+
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
7373
while(1) delay(1);
7474
}
7575

examples/DualRole/HID/hid_remapper/hid_remapper.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ void setup1() {
8686
uint32_t cpu_hz = clock_get_hz(clk_sys);
8787
if ( cpu_hz != 120000000UL && cpu_hz != 240000000UL ) {
8888
while ( !Serial ) delay(10); // wait for native usb
89-
Serial.printf("Error: CPU Clock = %u, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
90-
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n", cpu_hz);
89+
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
90+
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
9191
while(1) delay(1);
9292
}
9393

examples/DualRole/MassStorage/msc_data_logger/msc_data_logger.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ void setup1() {
112112
while ( !Serial ) {
113113
delay(10); // wait for native usb
114114
}
115-
Serial.printf("Error: CPU Clock = %u, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
116-
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n", cpu_hz);
115+
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
116+
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
117117
while(1) {
118118
delay(1);
119119
}

examples/DualRole/MassStorage/msc_file_explorer/msc_file_explorer.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ void setup1() {
7979
while ( !Serial ) {
8080
delay(10); // wait for native usb
8181
}
82-
Serial.printf("Error: CPU Clock = %u, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
83-
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n", cpu_hz);
82+
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
83+
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
8484
while(1) {
8585
delay(1);
8686
}

examples/DualRole/device_info_rp2040/device_info_rp2040.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ void setup1() {
9494
while ( !Serial ) {
9595
delay(10); // wait for native usb
9696
}
97-
Serial.printf("Error: CPU Clock = %u, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
98-
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n", cpu_hz);
97+
Serial.printf("Error: CPU Clock = %lu, PIO USB require CPU clock must be multiple of 120 Mhz\r\n", cpu_hz);
98+
Serial.printf("Change your CPU Clock to either 120 or 240 Mhz in Menu->CPU Speed \r\n");
9999
while(1) {
100100
delay(1);
101101
}

src/Adafruit_TinyUSB.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
#define ADAFRUIT_TINYUSB_H_
2727

2828
// Error message for Core that must select TinyUSB via menu
29-
#if !defined(USE_TINYUSB) && ( defined(ARDUINO_ARCH_SAMD) || \
30-
(defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED)) )
29+
#if !defined(USE_TINYUSB) && \
30+
(defined(ARDUINO_ARCH_SAMD) || \
31+
(defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED)))
3132
#error TinyUSB is not selected, please select it in "Tools->Menu->USB Stack"
3233
#endif
3334

@@ -39,23 +40,23 @@
3940
#include "arduino/Adafruit_USBD_Device.h"
4041

4142
#if CFG_TUD_CDC
42-
#include "arduino/Adafruit_USBD_CDC.h"
43+
#include "arduino/Adafruit_USBD_CDC.h"
4344
#endif
4445

4546
#if CFG_TUD_HID
46-
#include "arduino/hid/Adafruit_USBD_HID.h"
47+
#include "arduino/hid/Adafruit_USBD_HID.h"
4748
#endif
4849

4950
#if CFG_TUD_MIDI
50-
#include "arduino/midi/Adafruit_USBD_MIDI.h"
51+
#include "arduino/midi/Adafruit_USBD_MIDI.h"
5152
#endif
5253

5354
#if CFG_TUD_MSC
54-
#include "arduino/msc/Adafruit_USBD_MSC.h"
55+
#include "arduino/msc/Adafruit_USBD_MSC.h"
5556
#endif
5657

5758
#if CFG_TUD_VENDOR
58-
#include "arduino/webusb/Adafruit_USBD_WebUSB.h"
59+
#include "arduino/webusb/Adafruit_USBD_WebUSB.h"
5960
#endif
6061

6162
// Initialize device hardware, stack, also Serial as CDC
@@ -70,11 +71,11 @@ void TinyUSB_Device_Init(uint8_t rhport);
7071
#include "arduino/Adafruit_USBH_Host.h"
7172

7273
#if CFG_TUH_CDC
73-
#include "arduino/cdc/Adafruit_USBH_CDC.h"
74+
#include "arduino/cdc/Adafruit_USBH_CDC.h"
7475
#endif
7576

7677
#if CFG_TUH_MSC
77-
#include "arduino/msc/Adafruit_USBH_MSC.h"
78+
#include "arduino/msc/Adafruit_USBH_MSC.h"
7879
#endif
7980

8081
#endif

src/arduino/Adafruit_USBH_Host.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class Adafruit_USBH_Host {
5959
//
6060
//// USBHost has a high chance to conflict with other usb stack
6161
//// only define if supported BSP
62-
//#ifdef USE_TINYUSB
63-
//#define USBHost TinyUSBHost
64-
//#endif
62+
// #ifdef USE_TINYUSB
63+
// #define USBHost TinyUSBHost
64+
// #endif
6565

6666
#endif /* ADAFRUIT_USBH_HOST_H_ */

src/arduino/ports/rp2040/tusb_config_rp2040.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,18 @@ extern int serial1_printf(const char *__restrict __format, ...);
100100
// Number of hub devices
101101
#define CFG_TUH_HUB 1
102102

103-
// max device support (excluding hub device)
104-
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1) // hub typically has 4 ports
103+
// max device support (excluding hub device): 1 hub typically has 4 ports
104+
#define CFG_TUH_DEVICE_MAX (3 * CFG_TUH_HUB + 1)
105105

106106
// Enable tuh_edpt_xfer() API
107-
//#define CFG_TUH_API_EDPT_XFER 1
107+
// #define CFG_TUH_API_EDPT_XFER 1
108108

109109
// Number of mass storage
110110
#define CFG_TUH_MSC 1
111111

112112
// Number of HIDs
113-
#define CFG_TUH_HID 4
113+
// typical keyboard + mouse device can have 3,4 HID interfaces
114+
#define CFG_TUH_HID (3 * CFG_TUH_DEVICE_MAX)
114115

115116
// Number of CDC interfaces
116117
#define CFG_TUH_CDC 1

src/class/cdc/cdc_host.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,25 @@ uint8_t tuh_cdc_itf_get_index(uint8_t daddr, uint8_t itf_num)
127127
return TUSB_INDEX_INVALID_8;
128128
}
129129

130-
bool tuh_cdc_itf_get_info(uint8_t idx, tuh_cdc_itf_info_t* info)
130+
bool tuh_cdc_itf_get_info(uint8_t idx, tuh_itf_info_t* info)
131131
{
132132
cdch_interface_t* p_cdc = get_itf(idx);
133133
TU_VERIFY(p_cdc && info);
134134

135-
info->daddr = p_cdc->daddr;
136-
info->bInterfaceNumber = p_cdc->bInterfaceNumber;
137-
info->bInterfaceSubClass = p_cdc->bInterfaceSubClass;
138-
info->bInterfaceProtocol = p_cdc->bInterfaceProtocol;
135+
info->daddr = p_cdc->daddr;
136+
137+
// re-construct descriptor
138+
tusb_desc_interface_t* desc = &info->desc;
139+
desc->bLength = sizeof(tusb_desc_interface_t);
140+
desc->bDescriptorType = TUSB_DESC_INTERFACE;
141+
142+
desc->bInterfaceNumber = p_cdc->bInterfaceNumber;
143+
desc->bAlternateSetting = 0;
144+
desc->bNumEndpoints = 2u + (p_cdc->ep_notif ? 1u : 0u);
145+
desc->bInterfaceClass = TUSB_CLASS_CDC;
146+
desc->bInterfaceSubClass = p_cdc->bInterfaceSubClass;
147+
desc->bInterfaceProtocol = p_cdc->bInterfaceProtocol;
148+
desc->iInterface = 0; // not used yet
139149

140150
return true;
141151
}

src/class/cdc/cdc_host.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,13 @@
7171
// Application API
7272
//--------------------------------------------------------------------+
7373

74-
typedef struct
75-
{
76-
uint8_t daddr;
77-
uint8_t bInterfaceNumber;
78-
uint8_t bInterfaceSubClass;
79-
uint8_t bInterfaceProtocol;
80-
} tuh_cdc_itf_info_t;
81-
8274
// Get Interface index from device address + interface number
8375
// return TUSB_INDEX_INVALID_8 (0xFF) if not found
8476
uint8_t tuh_cdc_itf_get_index(uint8_t daddr, uint8_t itf_num);
8577

8678
// Get Interface information
8779
// return true if index is correct and interface is currently mounted
88-
bool tuh_cdc_itf_get_info(uint8_t idx, tuh_cdc_itf_info_t* info);
80+
bool tuh_cdc_itf_get_info(uint8_t idx, tuh_itf_info_t* info);
8981

9082
// Check if a interface is mounted
9183
bool tuh_cdc_mounted(uint8_t idx);

0 commit comments

Comments
 (0)