arduino / ArduinoCore-API

Hardware independent layer of the Arduino cores defining the official API
https://www.arduino.cc/reference/en/
GNU Lesser General Public License v2.1
202 stars 117 forks source link

Each core provides a different USBAPI #141

Open Legion2 opened 3 years ago

Legion2 commented 3 years ago

The Arduino Core API defines a very low level USB api in api/USBAPI.h. This API is implemented by the avr core in cores/arduino/USBCore.cpp. But it is not implemented by samd core, which implements the same functionality but in its own USBDeviceClass class. The USB implementation in megaavr core (USBCore.cpp) is a copy of the avr usb implementation with some deviations. The mbed core implements its own version of the PluggableUSBModule.

As a result, each core implements its own USB API which is incompatible with the others, there exist many code duplicates and users of the USB API have to understand and adapt their code to each individual core implementation.

Are there any plans to improve this situation?

dogtopus commented 2 years ago

This is one of the biggest reason if not the only reason I don't like Arduino/Arduino-compatibles despite its quite mature ecosystem.

PluggableUSB was pretty ambitious when it came out but in the end it's practically nothing but an internal implementation detail.

vChavezB commented 1 year ago

Yes unfortunately the api for drivers such as usb are not compatible. What I have learned is that the Arduino ecosystem is only useful for one time prototypes but does not scale well enough as you need to modify the software to integrate it into different hardware. Example of this are the libraries that support multiple boards. They typically use #if #ifdef to mitigate the differences in API.