Skip to content

Commit 4224cac

Browse files
committed
rename USBDevice to TinyUSBDevice to avoid name conflict
USBDevice is alias for compatible when USE_TINYUSB is defined
1 parent c9c66d6 commit 4224cac

File tree

22 files changed

+45
-39
lines changed

22 files changed

+45
-39
lines changed

examples/Composite/hid_generic_inout_ramdisk/hid_generic_inout_ramdisk.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ void setup()
6868
usb_hid.begin();
6969

7070
Serial.begin(115200);
71-
Serial.println("Waiting for USBDevice mount");
71+
Serial.println("Waiting for TinyUSBDevice mount");
7272
// wait until device mounted
73-
while( !USBDevice.mounted() ) delay(1);
73+
while( !TinyUSBDevice.mounted() ) delay(1);
7474

7575
Serial.println("Adafruit TinyUSB HID Generic In Out example");
7676
}

examples/Composite/mouse_external_flash/mouse_external_flash.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void loop()
114114
uint32_t const btn = (digitalRead(pin) == activeState);
115115

116116
// Remote wakeup
117-
if ( USBDevice.suspended() && btn )
117+
if ( TinyUSBDevice.suspended() && btn )
118118
{
119119
// Wake up host if we are in suspend mode
120120
// and REMOTE_WAKEUP feature is enabled by host

examples/Composite/mouse_ramdisk/mouse_ramdisk.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void setup()
6666
usb_hid.begin();
6767

6868
Serial.begin(115200);
69-
while( !USBDevice.mounted() ) delay(1); // wait for native usb
69+
while( !TinyUSBDevice.mounted() ) delay(1); // wait for native usb
7070

7171
Serial.println("Adafruit TinyUSB Mouse + Mass Storage (ramdisk) example");
7272
}
@@ -80,7 +80,7 @@ void loop()
8080
uint32_t const btn = (digitalRead(pin) == activeState);
8181

8282
// Remote wakeup
83-
if ( USBDevice.suspended() && btn )
83+
if ( TinyUSBDevice.suspended() && btn )
8484
{
8585
// Wake up host if we are in suspend mode
8686
// and REMOTE_WAKEUP feature is enabled by host

examples/HID/hid_composite/hid_composite.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void setup()
6666
Serial.println("Adafruit TinyUSB HID Composite example");
6767

6868
// wait until device mounted
69-
while( !USBDevice.mounted() ) delay(1);
69+
while( !TinyUSBDevice.mounted() ) delay(1);
7070
}
7171

7272
void loop()
@@ -78,11 +78,11 @@ void loop()
7878
bool btn_pressed = (digitalRead(pin) == activeState);
7979

8080
// Remote wakeup
81-
if ( USBDevice.suspended() && btn_pressed )
81+
if ( TinyUSBDevice.suspended() && btn_pressed )
8282
{
8383
// Wake up host if we are in suspend mode
8484
// and REMOTE_WAKEUP feature is enabled by host
85-
USBDevice.remoteWakeup();
85+
TinyUSBDevice.remoteWakeup();
8686
}
8787

8888
/*------------- Mouse -------------*/

examples/HID/hid_composite_joy_featherwing/hid_composite_joy_featherwing.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void setup()
7777
last_x = ss.analogRead(3);
7878

7979
// wait until device mounted
80-
while( !USBDevice.mounted() ) delay(1);
80+
while( !TinyUSBDevice.mounted() ) delay(1);
8181
}
8282

8383
void loop()
@@ -145,10 +145,10 @@ void loop()
145145

146146
/*------------- Remote Wakeup -------------*/
147147
// Remote wakeup if PC is suspended and we has user interaction with joy feather wing
148-
if ( has_action && USBDevice.suspended() )
148+
if ( has_action && TinyUSBDevice.suspended() )
149149
{
150150
// Wake up only works if REMOTE_WAKEUP feature is enable by host
151151
// Usually this is the case with Mouse/Keyboard device
152-
USBDevice.remoteWakeup();
152+
TinyUSBDevice.remoteWakeup();
153153
}
154154
}

examples/HID/hid_gamepad/hid_gamepad.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ void setup()
4444
usb_hid.begin();
4545

4646
// wait until device mounted
47-
while( !USBDevice.mounted() ) delay(1);
47+
while( !TinyUSBDevice.mounted() ) delay(1);
4848

4949
Serial.println("Adafruit TinyUSB HID Gamepad example");
5050
}
5151

5252
void loop()
5353
{
5454
// // Remote wakeup
55-
// if ( USBDevice.suspended() && btn )
55+
// if ( TinyUSBDevice.suspended() && btn )
5656
// {
5757
// // Wake up host if we are in suspend mode
5858
// // and REMOTE_WAKEUP feature is enabled by host
59-
// USBDevice.remoteWakeup();
59+
// TinyUSBDevice.remoteWakeup();
6060
// }
6161

6262
if ( !usb_hid.ready() ) return;

examples/HID/hid_generic_inout/hid_generic_inout.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void setup()
5252
Serial.begin(115200);
5353

5454
// wait until device mounted
55-
while( !USBDevice.mounted() ) delay(1);
55+
while( !TinyUSBDevice.mounted() ) delay(1);
5656

5757
Serial.println("Adafruit TinyUSB HID Generic In Out example");
5858
}

examples/HID/hid_keyboard/hid_keyboard.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void setup()
5858
}
5959

6060
// wait until device mounted
61-
while( !USBDevice.mounted() ) delay(1);
61+
while( !TinyUSBDevice.mounted() ) delay(1);
6262
}
6363

6464

@@ -68,11 +68,11 @@ void loop()
6868
delay(2);
6969

7070
// // Remote wakeup
71-
// if ( USBDevice.suspended() && btn )
71+
// if ( TinyUSBDevice.suspended() && btn )
7272
// {
7373
// // Wake up host if we are in suspend mode
7474
// // and REMOTE_WAKEUP feature is enabled by host
75-
// USBDevice.remoteWakeup();
75+
// TinyUSBDevice.remoteWakeup();
7676
// }
7777

7878
if ( !usb_hid.ready() ) return;

examples/HID/hid_mouse/hid_mouse.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void setup()
5555
Serial.begin(115200);
5656

5757
// wait until device mounted
58-
while( !USBDevice.mounted() ) delay(1);
58+
while( !TinyUSBDevice.mounted() ) delay(1);
5959

6060
Serial.println("Adafruit TinyUSB HID Mouse example");
6161
}
@@ -72,11 +72,11 @@ void loop()
7272
if (!btn_pressed) return;
7373

7474
// Remote wakeup
75-
if ( USBDevice.suspended() )
75+
if ( TinyUSBDevice.suspended() )
7676
{
7777
// Wake up host if we are in suspend mode
7878
// and REMOTE_WAKEUP feature is enabled by host
79-
USBDevice.remoteWakeup();
79+
TinyUSBDevice.remoteWakeup();
8080
}
8181

8282
if ( usb_hid.ready() )

examples/MIDI/midi_pizza_box_dj/midi_pizza_box_dj.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void setup() {
9494
for(uint8_t i=0; i<FRAMES; i++) lvl[i] = 256;
9595

9696
// Wait until device is enumerated properly before sending MIDI message
97-
while( !USBDevice.mounted() ) delay(1);
97+
while( !TinyUSBDevice.mounted() ) delay(1);
9898
}
9999

100100
///////////////////////////////////////////////////////////////////////////////

examples/MIDI/midi_test/midi_test.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void setup()
5656
Serial.begin(115200);
5757

5858
// wait until device mounted
59-
while( !USBDevice.mounted() ) delay(1);
59+
while( !TinyUSBDevice.mounted() ) delay(1);
6060
}
6161

6262
void loop()

examples/WebUSB/webusb_rgb/webusb_rgb.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void setup()
6868
pixels.show();
6969

7070
// wait until device mounted
71-
while( !USBDevice.mounted() ) delay(1);
71+
while( !TinyUSBDevice.mounted() ) delay(1);
7272

7373
Serial.println("TinyUSB WebUSB RGB example");
7474
}

examples/WebUSB/webusb_serial/webusb_serial.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void setup()
4949
Serial.begin(115200);
5050

5151
// wait until device mounted
52-
while( !USBDevice.mounted() ) delay(1);
52+
while( !TinyUSBDevice.mounted() ) delay(1);
5353

5454
Serial.println("TinyUSB WebUSB Serial example");
5555
}

src/Adafruit_TinyUSB.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "arduino/webusb/Adafruit_USBD_WebUSB.h"
4646

4747
// Initialize device hardware, stack, also Serial as CDC
48-
// Wrapper for USBDevice.begin(rhport)
48+
// Wrapper for TinyUSBDevice.begin(rhport)
4949
void TinyUSB_Device_Init(uint8_t rhport);
5050

5151
#endif

src/arduino/Adafruit_TinyUSB_API.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extern "C" {
3535

3636
void TinyUSB_Device_Init(uint8_t rhport) {
3737
// Init USB Device controller and stack
38-
USBDevice.begin(rhport);
38+
TinyUSBDevice.begin(rhport);
3939
}
4040

4141
// RP2040 has its own implementation since it needs mutex for dual core

src/arduino/Adafruit_USBD_CDC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void Adafruit_USBD_CDC::begin(uint32_t baud) {
7878

7979
_instance = _instance_count++;
8080
this->setStringDescriptor("TinyUSB Serial");
81-
USBDevice.addInterface(*this);
81+
TinyUSBDevice.addInterface(*this);
8282
}
8383

8484
void Adafruit_USBD_CDC::begin(uint32_t baud, uint8_t config) {
@@ -88,7 +88,7 @@ void Adafruit_USBD_CDC::begin(uint32_t baud, uint8_t config) {
8888

8989
void Adafruit_USBD_CDC::end(void) {
9090
// Reset configuration descriptor without Serial as CDC
91-
USBDevice.clearConfiguration();
91+
TinyUSBDevice.clearConfiguration();
9292
_instance_count = 0;
9393
}
9494

src/arduino/Adafruit_USBD_Device.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
enum { STRID_LANGUAGE = 0, STRID_MANUFACTURER, STRID_PRODUCT, STRID_SERIAL };
6262

63-
Adafruit_USBD_Device USBDevice;
63+
Adafruit_USBD_Device TinyUSBDevice;
6464

6565
Adafruit_USBD_Device::Adafruit_USBD_Device(void) {}
6666

@@ -291,15 +291,15 @@ extern "C" {
291291
// Invoked when received GET DEVICE DESCRIPTOR
292292
// Application return pointer to descriptor
293293
uint8_t const *tud_descriptor_device_cb(void) {
294-
return (uint8_t const *)&USBDevice._desc_device;
294+
return (uint8_t const *)&TinyUSBDevice._desc_device;
295295
}
296296

297297
// Invoked when received GET CONFIGURATION DESCRIPTOR
298298
// Application return pointer to descriptor, whose contents must exist long
299299
// enough for transfer to complete
300300
uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
301301
(void)index;
302-
return USBDevice._desc_cfg;
302+
return TinyUSBDevice._desc_cfg;
303303
}
304304

305305
// Invoked when received GET STRING DESCRIPTOR request
@@ -308,7 +308,7 @@ uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
308308
// OS 1.0 Descriptors.
309309
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors
310310
uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
311-
return USBDevice.descriptor_string_cb(index, langid);
311+
return TinyUSBDevice.descriptor_string_cb(index, langid);
312312
}
313313

314314
} // extern C

src/arduino/Adafruit_USBD_Device.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ class Adafruit_USBD_Device {
107107
uint16_t langid);
108108
};
109109

110-
extern Adafruit_USBD_Device USBDevice;
110+
extern Adafruit_USBD_Device TinyUSBDevice;
111+
112+
// USBDevice has a high chance to conflict with other usb stack
113+
// only define if supported BSP
114+
#ifdef USE_TINYUSB
115+
#define USBDevice TinyUSBDevice
116+
#endif
111117

112118
#endif /* ADAFRUIT_USBD_DEVICE_H_ */

src/arduino/hid/Adafruit_USBD_HID.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ uint16_t Adafruit_USBD_HID::getInterfaceDescriptor(uint8_t itfnum, uint8_t *buf,
108108
}
109109

110110
bool Adafruit_USBD_HID::begin(void) {
111-
if (!USBDevice.addInterface(*this)) {
111+
if (!TinyUSBDevice.addInterface(*this)) {
112112
return false;
113113
}
114114

src/arduino/midi/Adafruit_USBD_MIDI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Adafruit_USBD_MIDI::Adafruit_USBD_MIDI(void) : _n_cables(1) {}
4040
void Adafruit_USBD_MIDI::setCables(uint8_t n_cables) { _n_cables = n_cables; }
4141

4242
bool Adafruit_USBD_MIDI::begin(void) {
43-
if (!USBDevice.addInterface(*this))
43+
if (!TinyUSBDevice.addInterface(*this))
4444
return false;
4545

4646
return true;

src/arduino/msc/Adafruit_USBD_MSC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void Adafruit_USBD_MSC::setReadyCallback(uint8_t lun, ready_callback_t cb) {
8787
}
8888

8989
bool Adafruit_USBD_MSC::begin(void) {
90-
if (!USBDevice.addInterface(*this)) {
90+
if (!TinyUSBDevice.addInterface(*this)) {
9191
return false;
9292
}
9393

src/arduino/webusb/Adafruit_USBD_WebUSB.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ Adafruit_USBD_WebUSB::Adafruit_USBD_WebUSB(void) {
127127
}
128128

129129
bool Adafruit_USBD_WebUSB::begin(void) {
130-
if (!USBDevice.addInterface(*this))
130+
if (!TinyUSBDevice.addInterface(*this))
131131
return false;
132132

133133
// WebUSB requires to change USB version from 2.0 to 2.1
134-
USBDevice.setVersion(0x0210);
134+
TinyUSBDevice.setVersion(0x0210);
135135

136136
_webusb_dev = this;
137137
return true;

0 commit comments

Comments
 (0)