New boards could have DAC0 & DAC1 on different pins. DAC0 & DAC1 pins are defined on each variant.h file, so it is not needed to reference to pins A0 & A1. With this change the code is more generic. Changes affect to analogWrite & analogRead functions.
This allows to compose the descriptor programmatically. The calling code
can compose a MIDI descriptor with up to 16 virtual wires/jacks at
initialization time.
Tested with the tinyusb -> MIDI -> midi_test example. This commit should
not change any behavior, future extensions of the calling MIDI device
will make use of it.
Huge USB configurations might need more than 256 bytes for the
config descriptor buffer. MIDI devices with 16 virtual ports
grow the descriptor to 600+ bytes.
This call replaces the built-in buffer with the supllied buffer. The
call copies the content of the old buffer to the new buffer:
uint8_t buf[1024];
USBDevice.setDescriptorBuffer(buf, sizeof(buf));
Set the USB descriptor strings. I accepts UTF-8 strings with
codepoints up to 16 bit.
void setup() {
USBDevice.setManufacturer("MyManufacturer");
USBDevice.setProduct("MyProduct");
}
In some cases the power value in the device descriptor needs to
be set to a lower value, commonly 20 mA, to not get rejected by iOS
devices.
The classic USB stack reads USB_CONFIG_POWER, this adds the same
logic to tinyusb.
TinyUSB adds new warnings to the compilation process. Operations
inside of {} initializers get propagated to 'int' but get assigned
to uint8_t.
Add static casts to to uint8_t to avoid a bunch of warnings like this:
cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_CDC.cpp: In member function
'virtual uint16_t Adafruit_USBD_CDC::getDescriptor(uint8_t, uint8_t*, uint16_t)':
cores/arduino/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h:172:74: warning:
narrowing conversion of '(((int)itfnum) + 1)' from 'int' to 'uint8_t
{aka unsigned char}' inside { } [-Wnarrowing]
5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_CALL_MANAGEMENT, 0, (_itfnum) + 1,\
Add 'const' declaration to avoid:
cores/arduino/pulse.c: In function 'pulseIn':
cores/arduino/pulse.c:44:29: warning: initialization discards
'const' qualifier from pointer target type [enabled by default]
volatile uint32_t *port = &(PORT->Group[p.ulPort].IN.reg);
^
TinyUSB does not match the exported serial numbers of the classic USB
stack.
The current code serializes the 32-bit words backwards, and the byte
nibbles are also backwards serialized.
A SAMD51 is exported like:
EFADAF3113347335020202938343E0FF
while it should read:
13FADAFE5337433139202020FF0E3438
- match timer and timer handler
- lower interrupt priority (0 seems to big for a simple tone)
- be sure 'toneIsActive' is always set (if previous tone was using a different pin, it's not set
Export the unique hardware serial number from the SAMD51 MCU
to the USB device descriptor.
Remove the concatenation of the USB class device string, it is
superfluous, and an USB interface property should not become a
part of the USB device property.
Tested on SAMD21 and SAMD51:
Before:
SAMD21: 10BD8E4051504C3750202020FF0B1410MIDI
SAMD51: MIDI
After:
SAMD21: 10BD8E4051504C3750202020FF0B1410
SAMD51: AAFC165853574E514D202020FF083C44
* Reverted 1MHz clock generator to GCLK5 instead GCLK7
Fixed the clock divider of 1MHz clock generator to be 48 (its source is DFLL which clocking at 48MHz, so 48 / 48 = 1, it was 48 / 24 = 2).
Updated the PLLs to the proper Ratio afetr the change of the 1MHz clock source.
Disabled GCLK_GENCTRL_DIVSEL reg on the 12MHz clock generator, since this caused the clock to be 1.5MHz.
* Fixed a description comment.
AR_INTERNAL was removed in #74. Because of this, non-SAMD51 boards fail because AR_INTERNAL isn't defined.
This also define AR_INTERNAL_2V23, which is also used for non-SAMD51
boards.
* Fix pulseIn() on SAMD51 by writing it in plain C, so that
the CM0+-specific pulse_asm won't need to be linked.
The SAMD51 is fast enough that we can time pulses with micros()
Tested with a bunch of pulse lengths from <1us to >1s
* Implement a new delayMicroseconds() function for SAMD51
This version enables the "Debug Watchpoint and Trace" module (DWT)
in startup.c and then uses the 32bit cycle counter that is part
of DWT to count cycles indepenent of instruction timing.
Tested for good accuracy with various values between 1 and 2000us.
the CM0+-specific pulse_asm won't need to be linked.
The SAMD51 is fast enough that we can time pulses with micros()
Tested with a bunch of pulse lengths from <1us to >1s