Giter Club home page Giter Club logo

adafruit_tinyusb_arduino's Introduction

Adafruit TinyUSB Library for Arduino

Build Status License

This library is a Arduino-friendly version of TinyUSB stack. It is designed with structure and APIs that are easily integrated to an Arduino Core.

Features

Device Stack

Supported device class drivers are:

  • Communication (CDC): which is used to implement Serial monitor
  • Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
  • Mass Storage Class (MSC): with multiple LUNs
  • Musical Instrument Digital Interface (MIDI)
  • Video (UVC): work in progress
  • WebUSB with vendor specific class

Host Stack

Host stack is available with either addition of MAX3421E hardware (e.g Host FeatherWing) or rp2040 core (thanks to Pico-PIO-USB). Supported class driver are:

  • Communication (CDC): including vendor usb2uart such as FTDI, CP210x, CH34x
  • MassStorage class

Note: Host stack is still work-in-progress

Supported Cores

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.

Cores with built-in support

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.

Note: For ESP32 port, version before v3.0 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. This limitation is not the case for version from v3.0.

Cores without built-in support

Following is cores without built-in support

  • mbed_rp2040

It is still possible to use TinyUSB but with some limits such as:

  • TinyUSB_Device_Init() need to be manually called in setup()
  • TinyUSB_Device_Task() and/or TinyUSB_Device_FlushCDC() may (or not) need to be manually called in loop()
  • Use SerialTinyUSB name instead of Serial for serial monitor
  • And there could be more other issues, using on these cores should be considered as experimental

Class Driver API

More document to write ...

Porting Guide

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.

Arduino Core Changes

If possible, making changes to core will allow it to have built-in which make it almost transparent to user sketch

  1. Add this repo as submodule (or have local copy) at your ArduioCore/libraries/Adafruit_TinyUSB_Arduino (much like SPI).
  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".
  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.
  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:
  • Use USB IRQn to set flag then invoke function later on after exiting IRQ.
  • Just invoke function after the loop(), within yield(), and delay()
  1. TinyUSB_Device_FlushCDC() should also be called often to send out Serial data as well.
  2. 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 adafruit/circuitpython#2956

Library Changes

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

  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.
  2. TinyUSB_Port_EnterDFU() which is called when device need to enter DFU mode, usually by touch1200 feature
  3. TinyUSB_Port_GetSerialNumber() which is called to get unique MCU Serial ID to used as Serial string descriptor.

adafruit_tinyusb_arduino's People

Contributors

atmakersbill avatar badcd avatar bjc avatar blitzcitydiy avatar brentru avatar csc-sendance avatar dglaude avatar earlephilhower avatar evaherrada avatar fredericaltorres avatar hathach avatar henrygab avatar hoffmannjan avatar kaysievers avatar ladyada avatar lyusupov avatar maxgerhardt avatar mzero avatar nekuneko avatar nico-martin avatar okyeron avatar paintyourdragon avatar siddacious avatar thekitty avatar timonsku avatar tlyu avatar tyeth avatar vanbwodonk avatar westfw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_tinyusb_arduino's Issues

nRF52 crashes with longer strings in .print()

Describe the bug
Passing in strings over a certain length freezes the device.
May be related to buffer overflow? looks like it crashes after 64 characters.

Set up (please complete the following information)

  • nRF52840 Feather Express
  • TinyUSB library version: 0.8.2
  • MacOS 10.15.4
  • Chrome 83

To Reproduce
Steps to reproduce the behavior:

  1. Open webusb_serial example here
  2. change line 79 from
    if ( connected ) usb_web.println("TinyUSB WebUSB Serial example");
    to
    if ( connected ) usb_web.println("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
  3. Compiles & upload as expected
  4. Connect via https://adafruit.github.io/Adafruit_TinyUSB_Arduino/examples/webusb-serial/
  5. Notice expected string gets only partially returned and devices is unresponsive.

Expected behavior
Full string is printed out via web_usb without crashing

Screenshots
If applicable, add screenshots to help explain your problem.
image

Additional context
Seems to work as expected on SAMD21 boards

Tested in Chrome 83.0.4103.14 and Brave browser (Chromium)

Missing header file: Adafruit_TinyUSB_Core.h

Git rev: 7b4814f

Can't compile any of the examples due to missing header file.

Arduino: 1.8.9 (Linux), Board: "SparkFun Pro nRF52840 Mini, s140 6.1.1 r0, Level 0 (Release)"

In file included from /home/bjc/Arduino/libraries/Adafruit_TinyUSB_Arduino/src/Adafruit_TinyUSB.h:28,
                 from /home/bjc/Arduino/libraries/Adafruit_TinyUSB_Arduino/examples/HID/hid_composite/hid_composite.ino:4:
/home/bjc/Arduino/libraries/Adafruit_TinyUSB_Arduino/src/Adafruit_USBD_MSC.h:28:10: fatal error: Adafruit_TinyUSB_Core.h: No such file or directory
 #include "Adafruit_TinyUSB_Core.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board SparkFun Pro nRF52840 Mini.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Arduino Mouse.h and Keyboard.h compatible API and other topics

There is a lot of legacy code that uses the standard Arduino Mouse.h and Keyboard.h API. However many new boards are using TinyUSB rather than the Arduino Stack. I've created a library that has the same interface as Mouse.h and Keyboard.h but then translates those methods into Tiny USB HID methods. You include my "TinyUSB_Mouse.h" and/or "TinyUSB_Keyboard.h" and it automatically detects whether or not you are using the Arduino Stack or the TinyUSB Stack and auto selects between the two.

One difference that I noticed between TinyUSB and the Arduino HID.h is the way you store USB descriptors. Under TinyUSB you use an array of descriptors but Arduino HID.h uses a linked list. As you add new functions, it simply appends the new descriptor to the list. At first I was concerned that I would have to create three separate libraries. One of them for mouse, another for keyboard, and a third one for mouse and keyboard together. However it's working okay with just the two libraries. You can include them both and it works. That's because each has its own separate instance of "Adafruit_USBD_HID usb_hid;"

I still have to wonder if it would be better to create a single HID object and append the descriptors as needed.

I'm opening this issue so that we can have a discussion about the pros and cons of the array versus the linked list.

Meanwhile here is a link to my libraries. I would also like to know if you would welcome having them added to your main repository? I think it would be a very useful feature. I would be happy to submit it as a pull request to add it if you are open to that.
https://github.com/cyborg5/TinyUSB_Mouse_and_Keyboard

HID echo to python example is losing a character (from the buffer?)

Describe the bug
hid_generic_inout.ino example appears to be losing the first character in the buffer. Here is the output from the python script:

Openning HID device with VID = 0x239A
{'path': b'\\\\?\\hid#vid_239a&pid_800f&mi_02#8&1f3020af&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}', 'vendor_id': 9114, 'product_id': 32783, 'serial_number': '84C8D28C5150484347202020FF042C23', 'release_number': 256, 'manufacturer_string': 'Adafruit', 'product_string': 'TinyUSB HID Generic', 'usage_page': 65280, 'usage': 1, 'interface_number': 2}
Send text to HID Device : a
Received from HID Device: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : a
Received from HID Device: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : sa
Received from HID Device: b'a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : s
Received from HID Device: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : ss
Received from HID Device: b's\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : sdf
Received from HID Device: b'df\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : aaaa
Received from HID Device: b'aaa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : a
Received from HID Device: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : aa
Received from HID Device: b'a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : aaa
Received from HID Device: b'aa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Send text to HID Device : Traceback (most recent call last):
  File "hidTest.py", line 15, in <module>
    str_out = input("Send text to HID Device : ").encode('utf-8')
KeyboardInterrupt

Set up (please complete the following information)

  • ItsyBitsy M0, Adafruit SAMD boards V1.6.4
  • TinyUSB library version V0.10.0
  • Win10 2004

To Reproduce
Steps to reproduce the behavior:

  1. Run the example and send the ItsyBitsy some text over the python console.

Expected behavior
The same text I entered would be written back. Instead, it is missing the first character I type.

while(!Serial.available()); crashes with TinyUSB enabled sketch

I've added code to the msc_external_flash.ino example sketch to illustrate the issue. If you replace the loop routine in the sketch with this:

void loop()
{
  Serial.print("Press a key: ");
  while(!Serial.available()){}
  //while(!Serial.available()){delay(50);}
  int c = Serial.read();
  Serial.println("Got key " + String(c));
  delay(500);
}

The sketch will crash. However, if you instead use the other while loop with the delay(50), the sketch works. Perhaps an interrupt issue? The delay() technique can be used as a work-around .

I am running this on an ItsyBitsy M4 Express

Cannot compile for Adafruit Feather M4 CAN (SAME51)

Any time I compile with tinyUSB included, I simply get a nice failure to build with the following setup:

  • Adafruit Feather M4 CAN (SAME51)
  • Adafruit TinyUSB Library 0.10.1
  • Arduino IDE 1.8.13
  • Windows 10 2002 19041
  • Any of the included TinyUSB samples
  • Board set to use TinyUSB stack

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

update to get fix to MIDI sys ex

Adafruit cores that incorporate this variant of the TinyUSB stack have a serious bug that renders it impossible to send MIDI SysEx messages.

The bug was fixed in TinyUSB back in september... but must get pulled in here first, then pulled into relevant cores, to create working base for users' sketches.

I'm hoping that see the fixed TinyUSB can be merged here... so that we can eventually have cores that work for sending MIDI Sys Ex.

[Feature] Setting USB PID in user program

From what I've seen its not possible to change the PID from within the user program because it is being set/overwritten at compile time through the board definition?

I may also be wrong about that. Still learning how tinyusb is setup.
This would help me a great deal if I could change the PID of a board on the fly without making a new board definition in the core.

Conflicts compiling w/tinyusb selected.

I'm getting the following error when building with Arduino 1.8.8... I've updated my boards: am I missing a step here? I get no errors when using the Arduino USB stack, but when I switch I get conflicts.

I'm anxious to use the USB Filesystem with my Arduino projects (thanks!)

"C:\\Users\\billb\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -Os -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD "-D__SKETCH_NAME__=\"\"\"WiiMouse.ino\"\"\"" -DF_CPU=48000000L -DARDUINO=10808 -DARDUINO_TRINKET_M0 -DARDUINO_ARCH_SAMD -DCRYSTALLESS -DADAFRUIT_TRINKET_M0 -D__SAMD21E18A__ -DARM_MATH_CM0PLUS -DUSB_VID=0x239A -DUSB_PID=0x801E -DUSBCON "-DUSB_MANUFACTURER=\"Adafruit\"" "-DUSB_PRODUCT=\"Trinket M0\"" -DUSE_TINYUSB "-IC:\\Users\\billb\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.1\\cores\\arduino/Adafruit_TinyUSB_Core" "-IC:\\Users\\billb\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.1\\cores\\arduino/Adafruit_TinyUSB_Core/tinyusb/src" "-IC:\\Users\\billb\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\billb\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\billb\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.1\\cores\\arduino" "-IC:\\Users\\billb\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.1\\variants\\trinket_m0" "-IC:\\Users\\billb\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.1\\libraries\\Wire" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Mouse\\src" "-IC:\\Users\\billb\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.1\\libraries\\HID" "C:\\Users\\billb\\AppData\\Local\\Temp\\arduino_build_790950\\sketch\\WiiMouse.ino.cpp" -o "C:\\Users\\billb\\AppData\\Local\\Temp\\arduino_build_790950\\sketch\\WiiMouse.ino.cpp.o"
In file included from C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/USB/PluggableUSB.h:23:0,

                 from C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\libraries\HID/HID.h:24,

                 from C:\Program Files (x86)\Arduino\libraries\Mouse\src/Mouse.h:25,

                 from D:\Documents\ArduinoOld\WiiMouse\WiiMouse.ino:5:

C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/USB/USBAPI.h:118:23: error: conflicting declaration 'USBDeviceClass USBDevice'

 extern USBDeviceClass USBDevice;

                       ^

In file included from C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/Adafruit_TinyUSB_Core/Adafruit_TinyUSB_Core.h:35:0,

                 from C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/Arduino.h:129,

                 from C:\Users\billb\AppData\Local\Temp\arduino_build_790950\sketch\WiiMouse.ino.cpp:1:

C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.h:66:29: error: 'USBDevice' has a previous declaration as 'Adafruit_USBD_Device USBDevice'

 extern Adafruit_USBD_Device USBDevice;

                             ^

In file included from C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/USB/PluggableUSB.h:23:0,

                 from C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\libraries\HID/HID.h:24,

                 from C:\Program Files (x86)\Arduino\libraries\Mouse\src/Mouse.h:25,

                 from D:\Documents\ArduinoOld\WiiMouse\WiiMouse.ino:5:

C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/USB/USBAPI.h:189:16: error: conflicting declaration 'Serial_ Serial'

 extern Serial_ Serial;

                ^

In file included from C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/Adafruit_TinyUSB_Core/Adafruit_TinyUSB_Core.h:36:0,

                 from C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/Arduino.h:129,

                 from C:\Users\billb\AppData\Local\Temp\arduino_build_790950\sketch\WiiMouse.ino.cpp:1:

C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\cores\arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_CDC.h:56:26: error: 'Serial' has a previous declaration as 'Adafruit_USBD_CDC Serial'

 extern Adafruit_USBD_CDC Serial;

                          ^

In file included from C:\Program Files (x86)\Arduino\libraries\Mouse\src/Mouse.h:25:0,

                 from D:\Documents\ArduinoOld\WiiMouse\WiiMouse.ino:5:

C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\libraries\HID/HID.h:72:3: error: 'InterfaceDescriptor' does not name a type

   InterfaceDescriptor hid;

   ^

C:\Users\billb\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.1\libraries\HID/HID.h:74:3: error: 'EndpointDescriptor' does not name a type

   EndpointDescriptor  in;

   ^

More supported boards, especially Teensy 4.0 [Feature]

This library is a game changer! I'd love to use this library for other projects that utilize other development boards.

Specifically, I'd love to use the SD Card Mass Storage Device feature with a Teensy 4.0.

It looks like hathach's original library seems to support Teensy 4.0 (https://github.com/hathach/tinyusb/blob/master/docs/boards.md)

But I can't seem to get any of the example files from Adafruit's TinyUSB Library to work on a Teensy 4.0.

Am I missing something? Is there something I can do to read/write on an SD Card in a Teensy 4.0 via the USB port as a Mass Storage Device like you can with Adafruit's M0 & M4 dev boards?

Is support for Teensy 4.0 with this library something that may be possible in the near future?

Thanks!!!

[Bug] WebUSB device fails to enumerate

Since the restructured Core repositories (today), WebUSB devices fail to enumerate on Windows. I dumped the descriptor, but cannot see any obvious difference.

Everything appears to work fine on Linux. Windows works with the code before the Core repository was split out (yesterday).

I tried the webusb_rgb.ino example with the same result. See the attached screenshot:

Unknown USB Device (Device Descriptor Request Failed) Properties 2019-12-21 0_15_02

[Feature] ESP-32 Support

Is your feature request related to a problem? Please describe.

Is there any way this project support ESP32 boards (feather huzzah32), or is this already a thing?

I know that TinyUSB does already support ESP32, not sure if this library does.

[Bug] 0 documentation in this project

Describe the bug
Uh oh, this project has 0 documentation (examples are not documentation)

Set up (please complete the following information)

  • N/A
  • TinyUSB library version 0.8.1
  • N/A
  • N/A

To Reproduce
Steps to reproduce the behavior:

  1. Attempt to write anything that is not covered by examples
  2. ...

Expected behavior
A clear documentation (even one liners in-code) is available

Additional context
I don't think how can anyone use this library w/o documentation. Not even code comments (other than license).

compile warnings

In file included from C:\Users\ladyada\Dropbox\ArduinoSketches\hardware\Adafruit\samd\cores\arduino/Adafruit_TinyUSB_Core/tinyusb/src/tusb.h:65:0,

                 from C:\Users\ladyada\Dropbox\ArduinoSketches\hardware\Adafruit\samd\cores\arduino/Adafruit_TinyUSB_Core/Adafruit_TinyUSB_Core.h:32,

                 from C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_MIDI.h:28,

                 from C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_MIDI.cpp:25:

C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_MIDI.cpp: In member function 'virtual uint16_t Adafruit_USBD_MIDI::getDescriptor(uint8_t, uint8_t*, uint16_t)':

C:\Users\ladyada\Dropbox\ArduinoSketches\hardware\Adafruit\samd\cores\arduino/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h:242:113: warning: narrowing conversion of '(((int)itfnum) + 1)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

   9, TUSB_DESC_CS_INTERFACE, AUDIO_CS_INTERFACE_HEADER, U16_TO_U8S_LE(0x0100), U16_TO_U8S_LE(0x0009), 1, _itfnum+1,\

C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_MIDI.cpp:51:22: note: in expansion of macro 'TUD_MIDI_DESCRIPTOR'

   uint8_t desc[] = { TUD_MIDI_DESCRIPTOR(itfnum, 0, EPOUT, EPIN, EPSIZE) };

                      ^~~~~~~~~~~~~~~~~~~

C:\Users\ladyada\Dropbox\ArduinoSketches\hardware\Adafruit\samd\cores\arduino/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h:244:34: warning: narrowing conversion of '(((int)itfnum) + 1)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

   9, TUSB_DESC_INTERFACE, _itfnum+1, 0, 2, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_MIDI_STREAMING, AUDIO_PROTOCOL_V1, 0,\

C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_MIDI.cpp:51:22: note: in expansion of macro 'TUD_MIDI_DESCRIPTOR'

   uint8_t desc[] = { TUD_MIDI_DESCRIPTOR(itfnum, 0, EPOUT, EPIN, EPSIZE) };

                      ^~~~~~~~~~~~~~~~~~~

In file included from C:\Users\ladyada\Dropbox\ArduinoSketches\hardware\Adafruit\samd\cores\arduino/Adafruit_TinyUSB_Core/tinyusb/src/tusb.h:65:0,

                 from C:\Users\ladyada\Dropbox\ArduinoSketches\hardware\Adafruit\samd\cores\arduino/Adafruit_TinyUSB_Core/Adafruit_TinyUSB_Core.h:32,

                 from C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_HID.h:28,

                 from C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_HID.cpp:25:

C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_HID.cpp: In member function 'virtual uint16_t Adafruit_USBD_HID::getDescriptor(uint8_t, uint8_t*, uint16_t)':

C:\Users\ladyada\Dropbox\ArduinoSketches\hardware\Adafruit\samd\cores\arduino/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h:222:75: warning: narrowing conversion of '((((int)((Adafruit_USBD_HID*)this)->Adafruit_USBD_HID::_protocol) != 0) ? 1 : 0)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

   9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_HID, (_boot_protocol) ? HID_SUBCLASS_BOOT : 0, _boot_protocol, _stridx,\

                                                          ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_HID.cpp:84:24: note: in expansion of macro 'TUD_HID_INOUT_DESCRIPTOR'

     uint8_t desc[] = { TUD_HID_INOUT_DESCRIPTOR(itfnum, 0, _protocol, _desc_report_len, EPOUT, EPIN, CFG_TUD_HID_BUFSIZE, _interval_ms) };

                        ^~~~~~~~~~~~~~~~~~~~~~~~

C:\Users\ladyada\Dropbox\ArduinoSketches\hardware\Adafruit\samd\cores\arduino/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h:209:75: warning: narrowing conversion of '((((int)((Adafruit_USBD_HID*)this)->Adafruit_USBD_HID::_protocol) != 0) ? 1 : 0)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

   9, TUSB_DESC_INTERFACE, _itfnum, 0, 1, TUSB_CLASS_HID, (_boot_protocol) ? HID_SUBCLASS_BOOT : 0, _boot_protocol, _stridx,\

                                                          ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_HID.cpp:94:24: note: in expansion of macro 'TUD_HID_DESCRIPTOR'

     uint8_t desc[] = { TUD_HID_DESCRIPTOR(itfnum, 0, _protocol, _desc_report_len, EPIN, CFG_TUD_HID_BUFSIZE, _interval_ms) };

                        ^~~~~~~~~~~~~~~~~~

C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_HID.cpp: In member function 'bool Adafruit_USBD_HID::keyboardPress(uint8_t, char)':

C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_HID.cpp:170:25: warning: array subscript has type 'char' [-Wchar-subscripts]

   if ( _ascii2keycode[ch][0] ) modifier = KEYBOARD_MODIFIER_LEFTSHIFT;

                         ^

C:\Users\ladyada\Dropbox\ArduinoSketches\libraries\Adafruit_TinyUSB_Arduino\src\Adafruit_USBD_HID.cpp:171:33: warning: array subscript has type 'char' [-Wchar-subscripts]

   keycode[0] = _ascii2keycode[ch][1];

                                 ^

Add option to remove CDC ACM interface

I propose adding a compile time option to remove the CDC ACM port. This allows
Adafruit boards to more closely emulate real USB keyboards, joysticks, etc. The
IAC class descriptor and CDC ACM descriptors confuse some embedded devices such
as KVM switches, old computer BIOS, game consoles, etc.

The PluggableUSB stack has this option. It requires some code patching but
it does work. The symbol is CDC_ENABLED.

I propose using CDC_DISABLED so when it is not defined (the default), the
behavior is unchanged. The symbol can be defined by changing the boards.txt

adafruit_qtpy_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB -DCDC_DISABLED

I use arduino-cli so it is possible to define the symbol without changing
boards.txt. The VID, PID, and other USB parameters can be passed via command
line options so exact emulation is much easier.

The following change applies to this repo.

diff --git a/Adafruit_USBD_Device.cpp b/Adafruit_USBD_Device.cpp
index 1f51925..458c726 100644
--- a/Adafruit_USBD_Device.cpp
+++ b/Adafruit_USBD_Device.cpp
@@ -60,11 +60,17 @@ Adafruit_USBD_Device::Adafruit_USBD_Device(void)
     .bDescriptorType    = TUSB_DESC_DEVICE,
     .bcdUSB             = 0x0200,
 
+#ifdef CDC_DISABLED
+    .bDeviceClass       = 0,
+    .bDeviceSubClass    = 0,
+    .bDeviceProtocol    = 0,
+#else
     // Use Interface Association Descriptor (IAD) for CDC
     // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
     .bDeviceClass       = TUSB_CLASS_MISC,
     .bDeviceSubClass    = MISC_SUBCLASS_COMMON,
     .bDeviceProtocol    = MISC_PROTOCOL_IAD,
+#endif
 
     .bMaxPacketSize0    = CFG_TUD_ENDPOINT0_SIZE,

Changes are required to the SAMD and nrf52 cores to conditionalize the call to
addInterface based on !CDC_DISABLED.

https://github.com/adafruit/ArduinoCore-samd/blob/master/cores/arduino/TinyUSB/Adafruit_TinyUSB_SAMD.cpp#L81

https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/cores/nRF5/TinyUSB/Adafruit_TinyUSB_nRF.cpp#L94

I do not have an nRF52840 board around at the moment but have tested the changes
out on an ItsyBitsy M0.

How to get nRF52840 to communicate with browser via webusb?

I don't have a lot of experience with embedded devices and I am asking this question as a last resort after no replies on SO and Adafruit forum.
Hardware: Arduino Nano 33 BLE

Motivation

Recently I got a SAMD21 board to interact with browser via webusb in 2 ways-

  1. Selecting Arduino from USB Stack with the help of arduino webusb library
  2. Selecting TinyUSB from USB Stack with the help of Adafruit_TinyUSB_Arduino library

Now, arduino webusb doesn't support nRF52840 so far. However TinyUSB does and so does Adafruit_TinyUSB_Arduino, which says -

Supported platform are:
Adafruit_nRF52_Arduino

And again in Adafruit_nRF52_Arduino I see support for nRF52840.

NOTE: I don't have the supported boards for nR52840 , instead I have the latest Arduino Nano 33 BLE

Issue

So I was wondering how should I go about making my nRF52840 board communicate with browser?
The TinyUSB files don't make any sense to me right now. Nor can I make sense of running the webusb example.

Attempts

When I run make Makefile BOARD="feather_nrf52840_express" it outputs -
make: Nothing to be done for 'Makefile'
I chose feather_nrf52840_express as BOARD since the code isn't using any hardware pins so it doesn't matter if the board definitions are wrong. Just the internal core should be okay. But it doesn't work.

I tried another method too -
I ran the given webusb examples of Adafruit_TinyUSB_Arduino but they fail to upload on Nano 33 BLE.


I don't know much about why...perhaps its the mbed core it uses and you have a different core for nRF52 devices ? Or maybe the bootloader is different than what you expect ?

I don't want readily baked answers, I am willing to put in my time and effort. Just need some guidance and right direction on where should I look for porting and being able to build and run examples .

Static descriptor buffer size for large USB configurations?

Enabling 16 virtual wires/jacks at a MIDI device grows the USB configuration/MIDI descriptor to 643 bytes. :) The static buffer in Adafruit_USBD_Device::_desc_cfg[256] cannot carry this.

What could be done about this? Would it be possible to just compose the buffer content on-the-fly/stack and return it from there, or does it need to be static/stay around?

MIDI Echo

Hey ya'll,
Seem to be experiencing an issue where any incoming Midi message gets echo'd back to the sender. Is there a way to prevent this? or is this a bug of some kind?
ItsyBitsy M0
mac osx 10.15.5
even the example program does this.

attached is a screen shot of MIDI Monitor reading midi messages to and from the device. I wrote a simple code to just send out a note on ever second or so. the only code in my Loop is MIDI.read();

Screen Shot 2021-03-25 at 11 46 07 PM

Serial.print not working with TinyUSB

Describe the bug
I've been working with Tiny USB on a Feather M0 Express, Feather M4 Express, and Feather nRF52840 Express and could not get serial monitor output to work. Specifically on the nRF serial output only works if you use a Tools-> Debug:-> Debug 1 level or higher. However on the M0 and M4 when selecting Tools -> USB Stack ->TinyUSB I could not get any serial output from Serial.print("Hello"); regardless of Debug setting or baud rate.

Set up (please complete the following information)

  • Your Board and BSP version: See above
  • TinyUSB library version : Current version
  • Your OS (mac/windows/linux) and its version: Windows 10
  • Arduino IDE:1.8.12
  • Serial debug log if any; Unavailable

To Reproduce
Run any example sketch that has serial output or the following sketch…

void setup() {
  //Serial.begin(9600); 
  Serial.begin(115200);
  //while (! Serial) {};
  Serial.println("Attempting to detect Tiny USB"); 
  #ifdef USE_TINYUSB
    Serial.println("Tiny USB detected");
  #else
    Serial.println("Tiny USB NOT detected");
  #endif  
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

That is a modified version of Blink. The LED does blink however there is no serial output except on the nRF52840 with Debug level greater than zero. Adding or removing "while (! Serial) {};" has no effect.

Expected behavior
Should see serial output

Screenshots
None

Additional context

Crashing on SAMD

Using SAMD Core 1.5.7 and TinyUSB_Arduino 0.7.1 I can't get any of the examples I tried to work, the Serial port never comes back after uploading and Windows reports a malfunctioning USB device.
Tested on SAMD21 and SAMD51.

With just the blink example uploaded but TinyUSB selected it is still working.

I tested generic HID and Keyboard HID. Both crash. I also tried MSC Ramdisk, which shows up after a while and the serial port also comes back but then disappears again after a bit.

Set custom device serial number

Earlier in the year I ported some code from Teensy to M0/M4 and for the application I need to set a custom serial number for the device (the serial number must be formatted a specific way).

setManufacturerDescriptor and setProductDescriptor are available with TinyUSB, but not serial number.

Thus I previously hacked to together changes to create a setSerialDescriptor(); function mimicking setProductDescriptor() and it worked ok in my limited testing (I believe I tested on ItsyBitsy M0 and Neotrellis M4).

I wanted to revisit this now and submit a proper PR.

However, since it's been awhile (since February), I'm a little fuzzy on my previous work. For SAMD21/SAMD51 I believe working around the defs in thegetSerialDescriptor() function in Adafruit_TinyUSB_SAMD.cpp would be required. Is that correct?

Work in progress here: https://github.com/okyeron/Adafruit_TinyUSB_ArduinoCore/tree/CustomSerialDescriptor

[Feature] There is a begin() method, but no end() method. Should there be one?

Is your feature request related to a problem? Please describe.
I'd like to de-init/de-activate USB when it is disconnected and make sure I does not spend CPU cycles on it wasting precious battery. At the moment I only see a begin() method and 0 documentation. Should there be an end() method as it is often implemented in other libraries?

Describe the solution you'd like
Either a documentation on how to disable interface or a clear end() method.

Describe alternatives you've considered
Don't see any alternative really.

Crashing in version 0.9.0

The USB device crashes when uploading any of the examples. I haven't tried all but at least MSC and HID seem to crash.
On SAMD21 tried on Metro M0 and Itsy Bitsy M0

  • Adafruit SAMD Core 1.5.13
  • TinyUSB 0.9.0
  • Windows

[Bug] HID in/out example is not working on SAMD21

The HID in/out example is not working, there is no debug messages printed to the console and the hid raw device is not accessible through node-hid with the provided example code.

Setup

  • Adafruit SAMD 1.5.2
  • TinyUSB 0.5.0
  • Ubuntu 19.04 (same behaviour on 18.04)

To Reproduce
Upload generic in out example to SAMD21 board.

Expected behavior
Should print "Adafruit TinyUSB HID Generic In Out example" to serial console and node.js example should be able to connect and sent data back and forth.

[Feature] keyboardPress method only supports ASCII characters

Is your feature request related to a problem? Please describe.
The "keyboardPress method only allows for transmission of an ASCII character. You cannot for example send function keys or as a special keypresses.

Describe the solution you'd like
I recommend the current "keyboardPress" method be renamed "keyboardPressASCII" and that "keyboardPress" be implemented as a direct call to "tud_hid_keyboard_report". I realize that will break compatibility with any existing applications. If you don't want to rename keyboardPress to keep compatibility then perhaps the new direct method should be named keyboardPressRaw or something similar.

Additional context
Just a general comment I think the code could use a lot more comments or documentation. I would be willing to contribute to that but I'm not that knowledgeable about USB and personally I've only interested in the mouse and keyboard portions of the HID section of the code. I would be willing to collaborate with a more knowledgeable person to add comments and/or write learning guides to further explain how to use this code.

Issue with devices behind a USB hub

With commit adafruit/Adafruit_TinyUSB_ArduinoCore@8096c8a the devices seem no longer working when they are connected behind a USB hub. Directly connecting them to the host's root hub works fine.

Reverting the commit makes the devices appear.

This is a kernel log from Linux (Windows shows similar problems):

[34324.981477] usb 1-3: new high-speed USB device number 120 using xhci_hcd
[34325.122916] usb 1-3: New USB device found, idVendor=0bda, idProduct=5411, bcdDevice= 1.21
[34325.122921] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[34325.122924] usb 1-3: Product: 4-Port USB 2.0 Hub
[34325.122927] usb 1-3: Manufacturer: Generic
[34325.126468] hub 1-3:1.0: USB hub found
[34325.128779] hub 1-3:1.0: 4 ports detected
[34325.416491] usb 1-3.1: new full-speed USB device number 121 using xhci_hcd
[34325.492536] usb 1-3.1: device descriptor read/64, error -71
[34325.671522] usb 1-3.1: device descriptor read/64, error -71
[34325.855503] usb 1-3.1: new full-speed USB device number 122 using xhci_hcd
[34325.931543] usb 1-3.1: device descriptor read/64, error -71
[34326.111541] usb 1-3.1: device descriptor read/64, error -71
[34326.219655] usb 1-3-port1: attempt power cycle
[34326.815518] usb 1-3.1: new full-speed USB device number 123 using xhci_hcd
[34326.829286] usb 1-3.1: device descriptor read/8, error -32
[34326.945371] usb 1-3.1: device descriptor read/8, error -32
[34327.128514] usb 1-3.1: new full-speed USB device number 124 using xhci_hcd
[34327.143060] usb 1-3.1: device descriptor read/8, error -32
[34327.265333] usb 1-3.1: device descriptor read/8, error -32
[34327.371687] usb 1-3-port1: unable to enumerate USB device

usb_hid.end()

As requested by hathach on the forums - https://forums.adafruit.com/viewtopic.php?f=25&t=154636#p770791

Are we able to implement a end/detach function?
Similar to existing request #13

I'm using SAMD51 and unable to resume USB functions after returning from sleep/standby. I believe closing the connection, then sleeping, then reconnecting after waking up is the go.

Cheers,
emtark.

Library dependencies

Hi!

Is it really necessary to have all those library dependencies listed in the file library.properties?

depends=Adafruit SPIFlash, MIDI Library, Adafruit seesaw Library, Adafruit NeoPixel, SdFat - Adafruit Fork, SD, Adafruit Circuit Playground

For example PlatformIO tries to pull in all those dependencies although they are not really required for the sketch to compile as it only uses the Adafruit TinyUSB library.

Question: Proper protocol for sleep on SAMD21

When putting a FeatherM0 to sleep I've always followed the advice from the LowPower library and others to detach the usb first (USBDevice.detach();). The TinyUSB library doesn't seem to have any equivalent functions. How should the USB connection be shut down before putting the board into standby?

I'm not trying to use any of the drag-and-drop features of the TinyUSB library. I'm working on another library that sleeps between logging sensor data. But in the newest SAMD Core the M0 defaults to using TinyUSB so my library won't compile any more.

[Feature] RP2040 Support

Hello there,
I have seen this library and the other tinyUSB library, The non adafruit one is compatible with the raspberry pi pico RP2040. Although the documentation does not list it. I am wondering due to the similarities of the two libraies would this one be compatible with the RP2040? I prefer this one due to its simplicity.

Thanks

[Bug]

Describe the bug
A clear and concise description of what the bug is. Exact error message if it is compilation issue.

Set up (please complete the following information)

  • Your Board and BSP version
  • TinyUSB library version
  • Your OS (mac/windows/linux) and its version
  • Serial debug log if any

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

[Bug] Weird dependency graph that causes compilation failures

Describe the bug
I am working on a project that uses this library from PlatformIO (VSCode), it fails trying to compile a module that I am not even remotely planning on using. Dependency graph is based on depends in library.properties and in case of this library it looks like this:

Scanning dependencies...
Dependency Graph
|-- <usb_hid>
|   |-- <Adafruit TinyUSB Library> 0.8.1
|   |   |-- <Adafruit SPIFlash> 3.1.4
|   |   |   |-- <SPI> 1.0
|   |   |   |-- <SdFat - Adafruit Fork> 1.2.3
|   |   |   |   |-- <SPI> 1.0
|   |   |-- <MIDI Library> 4.3.1
|   |   |-- <Adafruit seesaw Library> 1.3.0
|   |   |   |-- <Adafruit ST7735 and ST7789 Library> 1.5.15
|   |   |   |   |-- <Adafruit GFX Library> 1.7.5
|   |   |   |   |   |-- <Adafruit ILI9341> 1.5.4
|   |   |   |   |   |   |-- <Adafruit STMPE610> 1.1.0
|   |   |   |   |   |   |   |-- <SPI> 1.0
|   |   |   |   |   |   |-- <Adafruit TouchScreen> 1.0.4
|   |   |   |   |   |   |-- <SPI> 1.0
|   |   |   |   |   |-- <SPI> 1.0
|   |   |   |   |-- <SD>
|   |   |   |   |   |-- <SPI> 1.0
|   |   |   |   |-- <SPI> 1.0
|   |   |-- <Adafruit NeoPixel> 1.3.5
|   |   |-- <SdFat - Adafruit Fork> 1.2.3
|   |   |   |-- <SPI> 1.0
|   |   |-- <SD>
|   |   |   |-- <SPI> 1.0
|   |   |-- <Adafruit Circuit Playground> 1.10.4
|   |   |   |-- <SPI> 1.0
|-- <usb_sense>

The compilation failure is:

.platformio/lib/Adafruit STMPE610_ID377/Adafruit_STMPE610.cpp:32:10: fatal error: Wire.h: No such file or directory

For some unknown to me reason this library depends on STMPE610. Which in turn wants Wire.h, which is in turn not available (missing dependency?).

FWIW, it used to compile just fine until some (automated) library updates happened and now I can no longer compile, but again, not sure why would this library come anywhere close to needing touchscreen, circuit playground and other weird dependencies that I see in deps graph.

Set up (please complete the following information)

  • 0.8.1
  • macos, but dont see how that would relate

To Reproduce
Steps to reproduce the behavior:

  1. Use this library in a project
  2. Try to build a project

Expected behavior
Compilation succeeds

Cannot compile usb_hid.mouseButtonRelease(0);

Describe the bug
Adding a statement such as "usb_hid.mouseButtonRelease(0);" causes a compiler error.

C:\Users\Chris.cy\Documents\Arduino\Freedom Wing\my_hid_mouse/my_hid_mouse.ino:72: undefined reference to `Adafruit_USBD_HID::mouseButtonRelease(unsigned char)'

I see in the definition the method is defined as

static inline bool mouseButtonRelease(uint8_t report_id);

Is there some special syntax when invoking a static inline method?

[Bug] webusb-serial issue with Chrome on Android

Describe the bug

On a Samsung S9+ phone, webusb-rgb works fine, webusb-serial will not write text in the receiver window when typed in the sender window.
All demos require connect which works, corresponding LED or NeoPixel light as expected on Connect
So connect code appears 100% ok
Just the echo for Android Chrome may be trouble.
I switched from Samsung keyboard to Google Keyboard, no change
Adafruit test with CPS board and code in GitHub

Set up (please complete the following information)

  • Your Board and BSP version: Circuit Playground Express BSP 1.5.3
  • TinyUSB library version: 0.6.0
  • Your OS (mac/windows/linux) and its version: Samsung S9+ v
  • Serial debug log if any: n/a

To Reproduce
Steps to reproduce the behavior: Normal testing

Expected behavior
Text should be echo to receiver on landing page

MIDI Messages One Message Behind

Describe the bug
Hey all. Not sure this is an issue with your library or the underlying MIDI Library but want to confirm. I am running the Adafruit TinyUSB MIDI version 0.9.0 and my messages appear to be one step behind.

For example the first message the system sees is a NOTE_ON message, but only after I release the note. So hitting three consecutive keys on a virtual midi keyboard shows up like this in the NoteOn and NoteOff handlers:

15:56:27.083 -> Note on: channel = 1, pitch = 60, velocity - 100
15:56:30.077 -> Note off: channel = 1, pitch = 60, velocity - 0
15:56:30.511 -> Note on: channel = 1, pitch = 62, velocity - 100
15:56:31.779 -> Note off: channel = 1, pitch = 62, velocity - 0
15:56:32.143 -> Note on: channel = 1, pitch = 65, velocity - 100

As you can see I released the last note and the last message is a NOTE_ON type. This output is using your midi_test Example sketch with the MIDI sends commented out. Any ideas or pointers? Should I be bugging the maintainers of MIDI Library?

Note: I am on OSX Catalina using CoreMIDI to connect to the board via USB. Thanks!

Set up (please complete the following information)

  • Your Board and BSP version: Feather M4, not sure on BSP
  • TinyUSB library version : 0.9.0
  • Your OS (mac/windows/linux) and its version: Catalina via CoreMIDI
  • Serial debug log if any: see above

To Reproduce
Steps to reproduce the behavior:

  1. Run the midi_test example sketch with no MIDI output
  2. Connect to your board using OSX CoreMIDI and some kind of Virtual Midi Keyboard. Like "vmpk" (Note: I tested several, all with the same results)
  3. Turn on Serial Monitor and start pressing keys
  4. See debug output

Expected behavior
Pressing a note on the virtual KB should result in a NOTE_ON message when first pressed, then a NOTE_OFF message when released. Multiple notes at one time should behave the same.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.