adafruit / Adafruit_TinyUSB_Arduino

Arduino library for TinyUSB
MIT License
450 stars 120 forks source link

Add platformio compatibility #336

Closed CSC-Sendance closed 9 months ago

CSC-Sendance commented 9 months ago

This adds platformio compatibility, when this library is pulled as a gitsubmodule (e.g. in adafruit's nrf52 framework). More infos here: https://docs.platformio.org/en/latest/manifests/library-json/index.html

Related to my efforts of adding "real" platformio compatibility to Adafruit's nrf52 framework, see also https://github.com/adafruit/Adafruit_nRFCrypto/pull/6 .

Hoping for your feedback!

CSC-Sendance commented 9 months ago

I am familliar, but do we also need to add USE_TINYUSB in this json as well ?

Hi - I checked for my favorite example, the nordicnrf52 platform:

If one's using the nordicnrf52 platform via

[env]
platform = nordicnrf52

in platformio, it checks for the TinyUSB library and adds the USE_TINYUSB flag automatically: https://github.com/platformio/builder-framework-arduino-nrf5/blob/6c8589b1058991cd26846690b3ea90b645d2fa18/adafruit.py#L225 ... so I guess it wouldn't be needed for that, strictly.

It would be possible to indicate compatible platforms too. I also checked for esp32, there it's not listed (because, I guess, it's rather optional to use becasue alternatives exist?).

Anyhow, we can just add the USE_TINYUSB flag for good measure in the flags section, since it shouldn't break anything anyway. I will test it for the nrf52840, to make sure.

P.S.: I have added a discussion to the nrf52 "framework" suggesting the platformio support, what is required and how to setup a testing environment: https://github.com/adafruit/Adafruit_nRF52_Arduino/discussions/793 . This also uses the most recent TinyUSB repo commit as git submodule, rather than a really old one, as the original does - with success after some minor namespace issue fixes.

CSC-Sendance commented 9 months ago

I tested it (https://github.com/adafruit/Adafruit_TinyUSB_Arduino/pull/336/commits/02f1321a4840da146421fffd22b3855f45e8ac7d) and haven't run into any issues building and also using (Serial). Tested with https://github.com/CSC-Sendance/Adafruit_nRF52_Arduino/commit/49153b17eae5f7bf678253711c7ad960387deaa3