Skip to content

Commit 92b4534

Browse files
committed
Readd Adafruit TinyUSB with libArchive=no
1 parent 06e4d4d commit 92b4534

File tree

154 files changed

+33904
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+33904
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Bug Report
2+
description: Report a problem with TinyUSB Library
3+
labels: 'Bug'
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to fill out this bug report!
9+
It's okay to leave some blank if it doesn't apply to your problem.
10+
11+
- type: dropdown
12+
attributes:
13+
label: Operating System
14+
options:
15+
- Linux
16+
- MacOS
17+
- RaspberryPi OS
18+
- Windows 7
19+
- Windows 10
20+
- Windows 11
21+
- Others
22+
validations:
23+
required: true
24+
25+
- type: input
26+
attributes:
27+
label: IDE version
28+
placeholder: e.g Arduino 1.8.15
29+
validations:
30+
required: true
31+
32+
- type: input
33+
attributes:
34+
label: Board
35+
placeholder: e.g Feather nRF52840 Express
36+
validations:
37+
required: true
38+
39+
- type: input
40+
attributes:
41+
label: BSP version
42+
description: Can be found under "Board Manager" menu
43+
validations:
44+
required: true
45+
46+
- type: input
47+
attributes:
48+
label: TinyUSB Library version
49+
placeholder: "Release version or github latest"
50+
validations:
51+
required: true
52+
53+
- type: textarea
54+
attributes:
55+
label: Sketch
56+
placeholder: |
57+
e.g examples/MassStorage/msc_ramdisk.
58+
If it is custom sketch, please provide it as **ATTACHED** files or link to it.
59+
validations:
60+
required: true
61+
62+
- type: textarea
63+
attributes:
64+
label: What happened ?
65+
placeholder: A clear and concise description of what the bug is.
66+
validations:
67+
required: true
68+
69+
- type: textarea
70+
attributes:
71+
label: How to reproduce ?
72+
placeholder: |
73+
1. Go to '...'
74+
2. Click on '....'
75+
3. See error
76+
validations:
77+
required: true
78+
79+
- type: textarea
80+
attributes:
81+
label: Debug Log
82+
placeholder: |
83+
TinyUSB debug log where the issue occurred as attached txt file, best with comments to explain the actual events.
84+
validations:
85+
required: false
86+
87+
- type: textarea
88+
attributes:
89+
label: Screenshots
90+
description: If applicable, add screenshots to help explain your problem.
91+
validations:
92+
required: false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
contact_links:
2+
- name: Adafruit Support Forum
3+
url: https://forums.adafruit.com
4+
about: If you have other questions or need help, post it here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: "[Feature]"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build
2+
3+
on: [pull_request, push, repository_dispatch]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
arduino-platform:
12+
# ESP32S2
13+
- 'funhouse'
14+
- 'magtag'
15+
- 'metroesp32s2'
16+
# nRF52
17+
- 'cpb'
18+
- 'nrf52840'
19+
# RP2040
20+
- 'feather_rp2040_tinyusb'
21+
# SAMD
22+
- 'feather_m4_can_tinyusb'
23+
- 'metro_m0_tinyusb'
24+
- 'metro_m4_tinyusb'
25+
26+
steps:
27+
- name: Setup Python
28+
uses: actions/setup-python@v1
29+
with:
30+
python-version: '3.x'
31+
32+
- name: Checkout code
33+
uses: actions/checkout@v2
34+
35+
- name: Checkout adafruit/ci-arduino
36+
uses: actions/checkout@v2
37+
with:
38+
repository: adafruit/ci-arduino
39+
path: ci
40+
41+
- name: pre-install
42+
run: bash ci/actions_install.sh
43+
44+
- name: test platforms
45+
run: python3 ci/build_platform.py ${{ matrix.arduino-platform }}
46+
47+
clang_and_doxy:
48+
runs-on: ubuntu-latest
49+
needs: build
50+
steps:
51+
- name: Setup Python
52+
uses: actions/setup-python@v1
53+
with:
54+
python-version: '3.x'
55+
56+
- name: Checkout code
57+
uses: actions/checkout@v2
58+
59+
- name: Checkout adafruit/ci-arduino
60+
uses: actions/checkout@v2
61+
with:
62+
repository: adafruit/ci-arduino
63+
path: ci
64+
65+
- name: pre-install
66+
run: bash ci/actions_install.sh
67+
68+
- name: clang
69+
run: python3 ci/run-clang-format.py -r src/arduino
70+
71+
- name: doxygen
72+
env:
73+
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
74+
PRETTYNAME : "Adafruit TinyUSB Library"
75+
run: bash ci/doxy_gen_and_deploy.sh
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/examples/**/build/
2+
/.development
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at . All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Ha Thach for Adafruit Industries
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Adafruit TinyUSB Library for Arduino
2+
3+
[![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)
4+
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.
7+
8+
## Features
9+
10+
Currently only support device mode only, supported class drivers are:
11+
12+
- Communication (CDC): which is used to implement `Serial` monitor
13+
- Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
14+
- Mass Storage Class (MSC): with multiple LUNs
15+
- Musical Instrument Digital Interface (MIDI)
16+
- WebUSB with vendor specific class
17+
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/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+
- [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
30+
31+
ESP32 port relies on Espressif's [esp32-hal-tinyusb.c](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-tinyusb.c) for building usb descriptors which requires all descriptors must be specified in usb objects declaration i.e constructors. Therefore all descriptor-related fields must be part of object declaration and descriptor-related API have no effect afterwards for this port.
32+
33+
### Cores without built-in support
34+
35+
Following is cores without built-in support
36+
37+
- **mbed_rp2040**
38+
39+
It is still possible to use TinyUSB but with some limits such as:
40+
41+
- `TinyUSB_Device_Init()` need to be manually called in setup()
42+
- `TinyUSB_Device_Task()` and/or `TinyUSB_Device_FlushCDC()` may (or not) need to be manually called in loop()
43+
- Use `SerialTinyUSB` name instead of Serial for serial monitor
44+
- And there could be more other issues, using on these cores should be considered as experimental
45+
46+
## Class Driver API
47+
48+
More document to write ...
49+
50+
## Porting Guide
51+
52+
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.
53+
54+
### Arduino Core Changes
55+
56+
If possible, making changes to core will allow it to have built-in which make it almost transparent to user sketch
57+
58+
1. Add this repo as submodule (or have local copy) at your ArduioCore/libraries/Adafruit_TinyUSB_Arduino (much like SPI).
59+
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"`.
60+
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.
61+
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:
62+
- Use USB IRQn to set flag then invoke function later on after exiting IRQ.
63+
- Just invoke function after the loop(), within yield(), and delay()
64+
5. `TinyUSB_Device_FlushCDC()` should also be called often to send out Serial data as well.
65+
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
66+
67+
### Library Changes
68+
69+
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
70+
71+
1. `TinyUSB_Port_InitDevice()` hardware specific (clock, phy) to enable usb hardware then call tud_init(). This API is called as part of TinyUSB_Device_Init() invocation.
72+
2. `TinyUSB_Port_EnterDFU()` which is called when device need to enter DFU mode, usually by touch1200 feature
73+
3. `TinyUSB_Port_GetSerialNumber()` which is called to get unique MCU Serial ID to used as Serial string descriptor.

0 commit comments

Comments
 (0)