BlokasLabs / USBMIDI

USB MIDI library for Arduino.
Other
189 stars 14 forks source link

Fixed attiny support as described in #6 #7

Closed Harvie closed 5 years ago

Harvie commented 5 years ago

This sums the discussion from #6 Added board specific code to usbconfig and added poll() to examples. Tested with digispark and it seems to work well.

Harvie commented 5 years ago

Also note that i've used following condition:

#if !defined(USB_CFG_IOPORTNAME) && !defined(USB_CFG_DMINUS_BIT) && !defined(USB_CFG_DPLUS_BIT)

But i think that #ifndef USB_CFG_DMINUS_BIT should be enough. It does not really make sense if somebody defines these 3 values from separate places.

gtrainavicius commented 5 years ago

Thank you for providing this pull request!

I have moved USB_CFG_IOPORTNAME, USB_CFG_DMINUS_BIT and USB_CFG_DPLUS_BIT definitions to be within ARDUINO_AVR_DIGISPARK.

The reason for doing that is the default values for the variables at the bottom for V-USB are meant to use INT0 for interrupt. Not all of the generic definitions that were provided (for example ones for ATtiny45 / ATtiny85) were set up to use INT0, some Digispark variations are using an alternative PCINT interrupt. So if USB port was wired to the pins defined on a non Digispark board, it wouldn't work without also setting up the bottom variables, so then there's little use to have these defaults.

Therefore it makes most sense to keep the predefined values for Digispark boards for now. usbboard.h may be extended to support more prebuilt boards in the future.

Btw, thank you for putting USBMIDI.poll into the examples. 👍