Skip to content

Commit 1d750a0

Browse files
committed
update example, add note for without built-in support cores
1 parent 560b9eb commit 1d750a0

File tree

10 files changed

+41
-17
lines changed

10 files changed

+41
-17
lines changed

README.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,55 @@
22

33
[![Build Status](https://github.com/adafruit/Adafruit_TinyUSB_Arduino/workflows/Build/badge.svg)](https://github.com/adafruit/Adafruit_TinyUSB_Arduino/actions) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
44

5-
This library is a Arduino-friendly version of [TinyUSB](https://github.com/hathach/tinyusb) stack. It is designed with structure and APIs that are easily integrated to existing or new Arduino Core. Supported platform including:
5+
This library is a Arduino-friendly version of [TinyUSB](https://github.com/hathach/tinyusb) stack.
6+
It is designed with structure and APIs that are easily integrated to an Arduino Core.
67

7-
- [Adafruit_nRF52_Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
8-
- [Adafruit/ArduinoCore-samd](https://github.com/adafruit/ArduinoCore-samd) selectable via menu`Tools->USB Stack->TinyUSB`
9-
- [earlephilhower/arduino-pico](https://github.com/earlephilhower/arduino-pico) selectable via menu `Tools->USB Stack->Adafruit TinyUSB`
8+
## Features
109

11-
Current class drivers supported are
10+
Currently only support device mode only, supported class drivers are:
1211

1312
- Communication (CDC): which is used to implement `Serial` monitor
1413
- Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
1514
- Mass Storage Class (MSC): with multiple LUNs
1615
- Musical Instrument Digital Interface (MIDI)
1716
- WebUSB with vendor specific class
1817

19-
For supported ArduinoCore, to use this library, you only need to have `<Adafruit_TinyUSB.h>` in your sketch. If your ArduinoCore does not support TinyUSB library yet, it is rather simple to port.
18+
## Supported Cores
19+
20+
There are 2 type of supported cores: with and without built-in support for TinyUSB. Built-in support provide seamless integration but requires extra code added to core's source code. Unfortunately it is not always easy or possible to make those modification.
21+
22+
### Cores with built-in support
23+
24+
Following core has Tinyusb as either the primary usb stack or selectable via menu `Tools->USB Stack`. You only need to include `<Adafruit_TinyUSB.h>` in your sketch to use.
25+
26+
- [Adafruit_nRF52_Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
27+
- [adafruit/ArduinoCore-samd](https://github.com/adafruit/ArduinoCore-samd)
28+
- [earlephilhower/arduino-pico](https://github.com/earlephilhower/arduino-pico)
29+
30+
### Cores without built-in support
31+
32+
Following is cores without built-in support
33+
34+
- **mbed_rp2040**
35+
36+
It is still possible to use TinyUSB but with some limits such as:
37+
38+
- `TinyUSB_Device_Init()` need to be manually called in setup()
39+
- `TinyUSB_Device_Task()` and/or `TinyUSB_Device_FlushCDC()` may (or not) need to be manually called in loop()
40+
- Use `SerialTinyUSB` name instead of Serial for serial monitor
41+
- And there could be more other issues, using on these cores should be considered as experimental
2042

2143
## Class Driver API
2244

2345
More document to write ...
2446

2547
## Porting Guide
2648

27-
It is rather easy if you want to integrate TinyUSB lib to your ArduinoCore.
49+
To integrate TinyUSB library to a Arduino core, you will need to make changes to the core for built-in support and library for porting the mcu/platform.
50+
51+
### Arduino Core Changes
2852

29-
### ArduinoCore Changes
53+
If possible, making changes to core will allow it to have built-in which make it almost transparent to user sketch
3054

3155
1. Add this repo as submodule (or have local copy) at your ArduioCore/libraries/Adafruit_TinyUSB_Arduino (much like SPI).
3256
2. Since Serial as CDC is considered as part of the core, we need to have `#include "Adafruit_USBD_CDC.h"` within your `Arduino.h`. For this to work, your `platform.txt` include path need to have `"-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino"`.

examples/Composite/mouse_ramdisk/mouse_ramdisk.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void setup()
4747
{
4848
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
4949
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
50-
TinyUSBDevice.begin(0);
50+
TinyUSB_Device_Init(0);
5151
#endif
5252

5353
// Set disk vendor id, product id and revision with string up to 8, 16, 4 characters respectively

examples/HID/hid_gamepad/hid_gamepad.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void setup()
3838
{
3939
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
4040
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
41-
TinyUSBDevice.begin(0);
41+
TinyUSB_Device_Init(0);
4242
#endif
4343

4444
Serial.begin(115200);

examples/HID/hid_generic_inout/hid_generic_inout.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void setup()
4343
{
4444
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
4545
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
46-
TinyUSBDevice.begin(0);
46+
TinyUSB_Device_Init(0);
4747
#endif
4848

4949
usb_hid.enableOutEndpoint(true);

examples/HID/hid_keyboard/hid_keyboard.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void setup()
4242
{
4343
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
4444
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
45-
TinyUSBDevice.begin(0);
45+
TinyUSB_Device_Init(0);
4646
#endif
4747

4848
usb_hid.setPollInterval(2);

examples/HID/hid_mouse/hid_mouse.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void setup()
4545
{
4646
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
4747
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
48-
TinyUSBDevice.begin(0);
48+
TinyUSB_Device_Init(0);
4949
#endif
5050

5151
// Set up button, pullup opposite to active state

examples/MIDI/midi_test/midi_test.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void setup()
4040
{
4141
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
4242
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
43-
TinyUSBDevice.begin(0);
43+
TinyUSB_Device_Init(0);
4444
#endif
4545

4646
pinMode(LED_BUILTIN, OUTPUT);

examples/MassStorage/msc_ramdisk/msc_ramdisk.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void setup()
2323
{
2424
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
2525
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
26-
TinyUSBDevice.begin(0);
26+
TinyUSB_Device_Init(0);
2727
#endif
2828

2929
// Set disk vendor id, product id and revision with string up to 8, 16, 4 characters respectively

examples/MassStorage/msc_ramdisk_dual/msc_ramdisk_dual.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void setup()
2323
{
2424
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
2525
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
26-
TinyUSBDevice.begin(0);
26+
TinyUSB_Device_Init(0);
2727
#endif
2828

2929
usb_msc.setMaxLun(2);

examples/WebUSB/webusb_serial/webusb_serial.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void setup()
4040
{
4141
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
4242
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
43-
TinyUSBDevice.begin(0);
43+
TinyUSB_Device_Init(0);
4444
#endif
4545

4646
pinMode(led_pin, OUTPUT);

0 commit comments

Comments
 (0)