Skip to content

Commit 560b9eb

Browse files
committed
enable to build examples with mbed rp2040
1 parent 8c48f27 commit 560b9eb

File tree

9 files changed

+58
-7
lines changed

9 files changed

+58
-7
lines changed

examples/Composite/mouse_ramdisk/mouse_ramdisk.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ Adafruit_USBD_MSC usb_msc;
4545
// the setup function runs once when you press reset or power the board
4646
void setup()
4747
{
48+
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
49+
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
50+
TinyUSBDevice.begin(0);
51+
#endif
52+
4853
// Set disk vendor id, product id and revision with string up to 8, 16, 4 characters respectively
4954
usb_msc.setID("Adafruit", "Mass Storage", "1.0");
5055

examples/HID/hid_gamepad/hid_gamepad.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ hid_gamepad_report_t gp; // defined in hid.h from Adafruit_TinyUSB_Arduin
3636

3737
void setup()
3838
{
39+
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
40+
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
41+
TinyUSBDevice.begin(0);
42+
#endif
43+
3944
Serial.begin(115200);
4045

4146
usb_hid.setPollInterval(2);

examples/HID/hid_generic_inout/hid_generic_inout.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ Adafruit_USBD_HID usb_hid;
4141
// the setup function runs once when you press reset or power the board
4242
void setup()
4343
{
44+
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
45+
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
46+
TinyUSBDevice.begin(0);
47+
#endif
48+
4449
usb_hid.enableOutEndpoint(true);
4550
usb_hid.setPollInterval(2);
4651
usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));

examples/HID/hid_keyboard/hid_keyboard.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ uint8_t pincount = sizeof(pins)/sizeof(pins[0]);
4040
// the setup function runs once when you press reset or power the board
4141
void setup()
4242
{
43+
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
44+
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
45+
TinyUSBDevice.begin(0);
46+
#endif
47+
4348
usb_hid.setPollInterval(2);
4449
usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
4550
usb_hid.setReportCallback(NULL, hid_report_callback);

examples/HID/hid_mouse/hid_mouse.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ Adafruit_USBD_HID usb_hid;
4343
// the setup function runs once when you press reset or power the board
4444
void setup()
4545
{
46+
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
47+
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
48+
TinyUSBDevice.begin(0);
49+
#endif
50+
4651
// Set up button, pullup opposite to active state
4752
pinMode(pin, activeState ? INPUT_PULLDOWN : INPUT_PULLUP);
4853

examples/MIDI/midi_test/midi_test.ino

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ byte note_sequence[] = {
3838

3939
void setup()
4040
{
41+
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
42+
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
43+
TinyUSBDevice.begin(0);
44+
#endif
45+
4146
pinMode(LED_BUILTIN, OUTPUT);
4247

4348
//usb_midi.setStringDescriptor("TinyUSB MIDI");
@@ -98,13 +103,25 @@ void loop()
98103
void handleNoteOn(byte channel, byte pitch, byte velocity)
99104
{
100105
// Log when a note is pressed.
101-
Serial.printf("Note on: channel = %d, pitch = %d, velocity - %d", channel, pitch, velocity);
102-
Serial.println();
106+
Serial.print("Note on: channel = ");
107+
Serial.print(channel);
108+
109+
Serial.print(" pitch = ");
110+
Serial.print(pitch);
111+
112+
Serial.print(" velocity = ");
113+
Serial.println(velocity);
103114
}
104115

105116
void handleNoteOff(byte channel, byte pitch, byte velocity)
106117
{
107118
// Log when a note is released.
108-
Serial.printf("Note off: channel = %d, pitch = %d, velocity - %d", channel, pitch, velocity);
109-
Serial.println();
119+
Serial.print("Note off: channel = ");
120+
Serial.print(channel);
121+
122+
Serial.print(" pitch = ");
123+
Serial.print(pitch);
124+
125+
Serial.print(" velocity = ");
126+
Serial.println(velocity);
110127
}

examples/MassStorage/msc_ramdisk/msc_ramdisk.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Adafruit_USBD_MSC usb_msc;
2222
void setup()
2323
{
2424
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
25-
// Manual begin() is required on unsupported BSP such as mbed rp2040
26-
// VID/PID, Manufacturer & Product string also need to be set as well
25+
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
2726
TinyUSBDevice.begin(0);
2827
#endif
2928

examples/MassStorage/msc_ramdisk_dual/msc_ramdisk_dual.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ Adafruit_USBD_MSC usb_msc;
2121
// the setup function runs once when you press reset or power the board
2222
void setup()
2323
{
24+
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
25+
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
26+
TinyUSBDevice.begin(0);
27+
#endif
28+
2429
usb_msc.setMaxLun(2);
2530

2631
// Set disk size and callback for Logical Unit 0 (LUN 0)

examples/WebUSB/webusb_serial/webusb_serial.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ int led_pin = LED_BUILTIN;
3838
// the setup function runs once when you press reset or power the board
3939
void setup()
4040
{
41+
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
42+
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
43+
TinyUSBDevice.begin(0);
44+
#endif
45+
4146
pinMode(led_pin, OUTPUT);
4247
digitalWrite(led_pin, LOW);
4348

@@ -49,7 +54,7 @@ void setup()
4954
Serial.begin(115200);
5055

5156
// wait until device mounted
52-
while( !TinyUSBDevice.mounted() ) delay(1);
57+
//while( !TinyUSBDevice.mounted() ) delay(1);
5358

5459
Serial.println("TinyUSB WebUSB Serial example");
5560
}

0 commit comments

Comments
 (0)