Skip to content

Commit 8f58b13

Browse files
committed
readme update
1 parent 18ea164 commit 8f58b13

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,44 @@
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 works with platform that includes [TinyUSB stack](https://github.com/hathach/tinyusb), typically you will see **Adafruit_TinyUSB_Core** inside core folder. Supported platform are:
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:
66

77
- [Adafruit_nRF52_Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
88
- [Adafruit ArduinoCore-samd](https://github.com/adafruit/ArduinoCore-samd) **TinyUSB** must be selected in menu `Tools->USB Stack`
99

10-
In addition to CDC that provided by the platform core, this library provide platform-independent for
10+
Current class drivers supported are
1111

12+
- Communication (CDC): which is used to implement `Serial` monitor
1213
- Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
1314
- Mass Storage Class (MSC): with multiple LUNs
1415
- Musical Instrument Digital Interface (MIDI)
1516
- WebUSB with vendor specific class
1617

18+
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.
19+
20+
## Class Driver API
21+
1722
More document to write ...
23+
24+
## Porting Guide
25+
26+
It is rather easy if you want to integrate TinyUSB lib to your ArduinoCore.
27+
28+
### ArduinoCore Changes
29+
30+
1. Add this repo as submodule (or have local copy) at your ArduioCore/libraries/Adafruit_TinyUSB_Arduino (much like SPI).
31+
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"`.
32+
3. In your `main.cpp` before setup() invoke the `TinyUSB_Device_Init(rhport)`. This will initialize usb device hardware and tinyusb stack and also include Serial as an instance of CDC class.
33+
4. `TinyUSB_Device_Task()` must be called whenever there is new USB event. Depending on your core and MCU with or without RTOS. There are many ways to run the task. For example:
34+
- Use USB IRQn to set flag then invoke function later on after exiting IRQ.
35+
- Just invoke function after the loop(), within yield(), and delay()
36+
5. `TinyUSB_Device_FlushCDC()` should also be called often to send out Serial data as well.
37+
6. Note: For low power platform that make use of WFI()/WFE(), extra care is required before mcu go into low power mode. Check out my PR to circuipython for reference https://github.com/adafruit/circuitpython/pull/2956
38+
39+
### Library Changes
40+
41+
In addition to core changes, library need to be ported to your platform. Don't worry, tinyusb stack has already done most of heavy-lifting. You only need to write a few APIs
42+
43+
1. `TinyUSB_Port_InitDeviceController()` hardware specific (clock, phy) to enable usb hardware. This API is called as part of TinyUSB_Device_Init() invocation.
44+
2. `TinyUSB_Port_EnterDFU()` which is called when device need to enter DFU mode, usually by touch1200 feature
45+
3. `TinyUSB_Port_GetSerialNumber()` which is called to get unique MCU Serial ID to used as Serial string descriptor.

0 commit comments

Comments
 (0)