BlokasLabs / USBMIDI

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

Attiny85: usbdrvasm165.inc:53: Error: constant value required #6

Closed Harvie closed 5 years ago

Harvie commented 5 years ago

I've been trying to compile this using vusb for digispark (atmega45 with micronucleus bootloader). It seems to me, that some definition is missing:

Line 53 of usbdrvasm165.inc: sbis USBIN, USBMINUS

It gives following errors:

/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc: Assembler messages:
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:53: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:57: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:59: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:61: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:63: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:65: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:67: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:92: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:111: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:140: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:145: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:150: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:157: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:163: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:170: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:177: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:187: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:192: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:198: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:205: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:217: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:222: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:231: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:242: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:250: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:256: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:263: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:271: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:277: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:283: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:290: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:296: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:302: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:308: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:314: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:320: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:327: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:368: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:391: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:393: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:394: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:395: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:404: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:417: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:428: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:440: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:448: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:449: Error: constant value required
/home/harvie/Arduino/libraries/USBMIDI/src/../vusb/usbdrv/usbdrvasm165.inc:450: Error: constant value required
exit status 1
Harvie commented 5 years ago

vusb config should look like this:

USB_CFG_IOPORTNAME=B
USB_CFG_DMINUS_BIT=3
USB_CFG_DPLUS_BIT=4

i've put that at the beginning of vusb/usbconfig.h, but i didn't understood how to do it, so it get automaticaly changed according to selected board...

Digispark guys define it like this. Maybe that's the way to go, since it does automaticaly select the right settings:

/* ---------------------------- Hardware Config ---------------------------- */

#if defined (__AVR_ATtiny44__) || defined (__AVR_ATtiny84__)
#define USB_CFG_IOPORTNAME      B
#define USB_CFG_DMINUS_BIT      1
#define USB_CFG_DPLUS_BIT       2

#elif defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__)
#define USB_CFG_IOPORTNAME      B
#define USB_CFG_DMINUS_BIT      3
#define USB_CFG_DPLUS_BIT       4

#elif defined (__AVR_ATtiny87__) || defined (__AVR_ATtiny167__)
#define USB_CFG_IOPORTNAME      B
#define USB_CFG_DMINUS_BIT      3
#define USB_CFG_DPLUS_BIT       6

#elif defined (__AVR_ATtiny461__) || defined (__AVR_ATtiny861__)
#define USB_CFG_IOPORTNAME      B
#define USB_CFG_DMINUS_BIT      5
#define USB_CFG_DPLUS_BIT       6
#else
/*  ATtiny2313, ATmega8/48/88/168   */
#define USB_CFG_IOPORTNAME      D
#define USB_CFG_DMINUS_BIT      3
#define USB_CFG_DPLUS_BIT       2
#endif
#define USB_CFG_CLOCK_KHZ       (F_CPU/1000)
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
 * 16500 and 20000. The 12.8 MHz and 16.5 MHz versions of the code require no
 * crystal, they tolerate +/- 1% deviation from the nominal frequency. All
 * other rates require a precision of 2000 ppm and thus a crystal!
 * Default if not specified: 12 MHz
 */
#define USB_CFG_CHECK_CRC       0
/* Define this to 1 if you want that the driver checks integrity of incoming
 * data packets (CRC checks). CRC checks cost quite a bit of code size and are
 * currently only available for 18 MHz crystal clock. You must choose
 * USB_CFG_CLOCK_KHZ = 18000 if you enable this option.
 */

/* ----------------------- Optional Hardware Config ------------------------ */

//#define USB_CFG_PULLUP_IOPORTNAME   D
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
 * V+, you can connect and disconnect the device from firmware by calling
 * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
 * This constant defines the port on which the pullup resistor is connected.
 */
//#define USB_CFG_PULLUP_BIT          5
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
 * above) where the 1.5k pullup resistor is connected. See description
 * above for details.
 */
Harvie commented 5 years ago

With these definitions i was able to compile and upload. Digispark then enumerates as micronucleus bootloader and then fails to enumerate once USBMIDI code executes:

[283275.498134] usb 2-1.2: device descriptor read/64, error -71
[283275.721486] usb 2-1.2: device descriptor read/64, error -71
[283275.901500] usb 2-1.2: new low-speed USB device number 91 using ehci-pci
[283276.021492] usb 2-1.2: device descriptor read/64, error -71
[283276.251535] usb 2-1.2: device descriptor read/64, error -71
[283276.358321] usb 2-1-port2: attempt power cycle
[283276.954890] usb 2-1.2: new low-speed USB device number 92 using ehci-pci
[283277.398221] usb 2-1.2: device not accepting address 92, error -71
[283277.471508] usb 2-1.2: new low-speed USB device number 93 using ehci-pci
[283277.911531] usb 2-1.2: device not accepting address 93, error -71
[283277.911653] usb 2-1-port2: unable to enumerate USB device

i even tried inverting USB_CFG_DMINUS_BIT and USB_CFG_DPLUS_BIT

gtrainavicius commented 5 years ago

For setting up your config for pins, either edit usbconfig.h locally, or set up a custom board definition for Arduino, for example, see here: https://github.com/BlokasLabs/Blokas-Boards/blob/master/avr/boards.txt, at the bottom of the file there's -D... arguments to set the preprocessor defines. Boards.txt would be the best option if you want to support multiple boards.

I can't figure out why USBMIDI wouldn't work with Digispark, could you post your sketch and any modifications you've already made, also which board you have selected in Arduino IDE?

Harvie commented 5 years ago

Sketch does not really matter, since USB device does not even enumerate (once it leaves micronucleus bootloader, which enumerates OK), even simple stuff like this:

#include <usbmidi.h>

void setup() {
}

void loop() {
  while(USBMIDI.available()) USBMIDI.read();
}

Basicaly only change i've done was setting this in usbconfig.h unconditionaly:

#define USB_CFG_IOPORTNAME B
#define USB_CFG_DMINUS_BIT 3
#define USB_CFG_DPLUS_BIT 4

In arduino IDE use Digispark (default - 16.5MHz) board from following repository: http://digistump.com/package_digistump_index.json

Using this setup i am able to get following USB MIDI library to work: https://github.com/heartscrytech/DigisparkMIDI

But it can only send MIDI from uC to computer, so i would preffer to use USBMIDI of yours. I even tried adapting usbconfig.h from this library to work with USBMIDI, but still didn't enumerated. (Also i tried same from several other projects that work for me: micronucleus, digisparkkeyboard,...)

As far as compiling goes, no single warning is displayed.

Harvie commented 5 years ago

There already is digispark definition in this file: ~/.arduino15/packages/digistump/hardware/avr/1.6.7/boards.txt

With this definition:

digispark-tiny.name=Digispark (Default - 16.5mhz)
digispark-tiny.upload.using=micronucleusprog
digispark-tiny.upload.protocol=usb
digispark-tiny.upload.tool=micronucleus
digispark-tiny.upload.maximum_size=6012
digispark-tiny.build.mcu=attiny85
digispark-tiny.build.f_cpu=16500000L
digispark-tiny.build.board=AVR_DIGISPARK
digispark-tiny.build.core=tiny
digispark-tiny.build.variant=digispark
digispark-tiny.upload.wait_for_upload_port = false
digispark-tiny.upload.use_1200bps_touch = false
digispark-tiny.upload.disable_flushing = false

So i've added following line to it:

digispark-tiny.build.extra_flags=-DUSB_CFG_IOPORTNAME=B -DUSB_CFG_DMINUS_BIT=3 -DUSB_CFG_DPLUS_BIT=4

But the outcome is the same as when i put it in usbconfig.h. Compiles, bootloader shows up properly and sketch does not enumerate.

Is there something that could cause USBMIDI v-usb operation being disrupted by Micronucleus bootloader? BTW micronucleus uses following fuses:

avrdude -c USBasp -p attiny85 -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xfe:m -B 20

gtrainavicius commented 5 years ago

I suspect the USB init code difference between what DigisparkMIDI does and what this library does could be causing the issue.

Maybe midiUsbInit should make usbDeviceDisconnect call regardless of whether USB_CFG_PULLUP_IOPORT is defined, and have a much bigger delay (like 500ms) before reconnecting USB and calling usbInit.

I don't have an ATTinyXX chips available to try and set up a board similar to Digispark one at the moment, but if you could, it'd be great if you'd experiment with midiUsbInit, trying to make it more similar to what the other MIDI lib does and seeing if it fixes the issue.

Harvie commented 5 years ago

i even added preprocessor debug to sketch:

/* definition to expand macro then apply to pragma message */
#define VALUE_TO_STRING(x) #x
#define VALUE(x) VALUE_TO_STRING(x)
#define VAR_NAME_VALUE(var) #var "="  VALUE(var)

/* Test values */
#pragma message(VAR_NAME_VALUE(USB_CFG_IOPORTNAME))
#pragma message(VAR_NAME_VALUE(USB_CFG_DMINUS_BIT))
#pragma message(VAR_NAME_VALUE(USB_CFG_DPLUS_BIT))

And that indicates the defines are set properly:

UsbMidiConverter.ino:26:51: note: #pragma message: USB_CFG_IOPORTNAME=B
 #pragma message(VAR_NAME_VALUE(USB_CFG_IOPORTNAME))
                                                   ^
UsbMidiConverter.ino:27:51: note: #pragma message: USB_CFG_DMINUS_BIT=3
 #pragma message(VAR_NAME_VALUE(USB_CFG_DMINUS_BIT))
                                                   ^
UsbMidiConverter.ino:28:50: note: #pragma message: USB_CFG_DPLUS_BIT=4
 #pragma message(VAR_NAME_VALUE(USB_CFG_DPLUS_BIT))
                                                  ^
Harvie commented 5 years ago

it'd be great if you'd experiment with midiUsbInit, trying to make it more similar to what the other MIDI lib does and seeing if it fixes the issue.

Ok i may take a look at it...

Harvie commented 5 years ago

I've added following two lines, but it's still not enumerating :-/

static void midiUsbInit(void)
{
        // Activate pull-ups except on USB lines.
        USB_CFG_IOPORT = (uint8_t)~((1 << USB_CFG_DMINUS_BIT) | (1 << USB_CFG_DPLUS_BIT));

        usbDeviceDisconnect(); // HERE ////////////////////////////////////////////////////////////////////////////////
        // All pins input except USB (-> USB reset).
#ifdef USB_CFG_PULLUP_IOPORT // Use usbDeviceConnect()/usbDeviceDisconnect() if available.
        USBDDR = 0;              // We do RESET by deactivating pullup.
        usbDeviceDisconnect();
#else
        USBDDR = (1 << USB_CFG_DMINUS_BIT) | (1 << USB_CFG_DPLUS_BIT);
#endif

        // USB Reset by device only required on Watchdog Reset.
        uint8_t j = 0;
        while (--j) {   /* USB Reset by device only required on Watchdog Reset */
                uint8_t i = 0;
                while (--i);  /* delay >10ms for USB reset */
        }

        usbDeviceConnect(); // HERE ////////////////////////////////////////////////////////////////////////////////
#ifdef USB_CFG_PULLUP_IOPORT
        usbDeviceConnect();
#else
        USBDDR = 0; // Remove USB reset condition.
#endif

        usbInit();
}
gtrainavicius commented 5 years ago

Try increasing the delay. There was some reason why _delay_ms was not used, but can't recall it, try placing _delay_ms(500); before usbDeviceConnect. (may have to also #include <avr/delay.h> at the top)

Harvie commented 5 years ago

I tried both. Adding one more nested loop and using _delay_ms(1000). Didn't helped...

        // USB Reset by device only required on Watchdog Reset.
        uint8_t j = 0;
        while (--j) {   /* USB Reset by device only required on Watchdog Reset */
                uint8_t i = 0;
                while (--i) {  /* delay >10ms for USB reset */
                        uint8_t ij = 0;
                        while (--ij);  /* delay >10ms for USB reset */
                }
        }

        _delay_ms(1000);
Harvie commented 5 years ago

I also tried wrapping the code with cli(); and sei(); like they do...

Harvie commented 5 years ago

The exact same code does not work either...

static void midiUsbInit(void)
{
        cli();
        usbDeviceDisconnect();
        _delay_ms(500); //250
        usbDeviceConnect();

        //wdt_enable(WDTO_1S);
        usbInit();

        sei();
}
gtrainavicius commented 5 years ago

Are you calling USBMIDI.poll() in your loop()?

Harvie commented 5 years ago

No. At least not directly. Tried to add, but didn't helped:

#include <usbmidi.h>

void setup() {
}

void loop() {
  USBMIDI.poll();
  while(USBMIDI.available()) USBMIDI.write(USBMIDI.read());
  USBMIDI.flush();
}
Harvie commented 5 years ago

But it does not work even with empty setup() and loop() I believe that the problem happens earlier than code from arduino sketch takes a place...

gtrainavicius commented 5 years ago

It should have at least USBMIDI.poll() in the loop to do the USB work.

With an empty sketch, with no reference to USBMIDI, the library code would get optimized out by the compiler.

Looks like there's more stuff to set in usbconfig.h (or boards.txt) for ATtiny45/85:

https://github.com/heartscrytech/DigisparkMIDI/blob/master/usbconfig.h#L394

Please try putting:

#define USB_INTR_CFG            PCMSK
#define USB_INTR_CFG_SET        (1<<USB_CFG_DPLUS_BIT)
#define USB_INTR_ENABLE_BIT     PCIE
#define USB_INTR_PENDING_BIT    PCIF
#define USB_INTR_VECTOR         SIG_PIN_CHANGE

at the bottom of your usbconfig.h

Harvie commented 5 years ago

Please try putting: at the bottom of your usbconfig.h

WOW! That actually did the trick! Thank you very much. I was able to send midi message back and forth through loopback on digispark from one linux app to another. Cool.

Now i wonder, how we can work this into the USBMIDI repository in way that it does not break compiling for other boards.

Harvie commented 5 years ago

What do you think about including something like this to the top of your usbconfig.h? These are defaults, that most projects use. That way there will be quite good chance that USBMIDI will properly compile without editing boards.txt

#ifndef USB_CFG_DMINUS_BIT

#if defined (__AVR_ATtiny44__) || defined (__AVR_ATtiny84__)
#define USB_CFG_IOPORTNAME      B
#define USB_CFG_DMINUS_BIT      1
#define USB_CFG_DPLUS_BIT       2

#elif defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__)
#define USB_CFG_IOPORTNAME      B
#define USB_CFG_DMINUS_BIT      3
#define USB_CFG_DPLUS_BIT       4

#elif defined (__AVR_ATtiny87__) || defined (__AVR_ATtiny167__)
#define USB_CFG_IOPORTNAME      B
#define USB_CFG_DMINUS_BIT      3
#define USB_CFG_DPLUS_BIT       6

#elif defined (__AVR_ATtiny461__) || defined (__AVR_ATtiny861__)
#define USB_CFG_IOPORTNAME      B
#define USB_CFG_DMINUS_BIT      5
#define USB_CFG_DPLUS_BIT       6
#else
/*  ATtiny2313, ATmega8/48/88/168   */
#define USB_CFG_IOPORTNAME      D
#define USB_CFG_DMINUS_BIT      3
#define USB_CFG_DPLUS_BIT       2
#endif

#endif
Harvie commented 5 years ago

For the record: i've just tested with fresh copy of USBMIDI 1.1.1 installed through arduino IDE. All i needed to add in order to work on attiny85 digispark were these magic lines:

#define USB_CFG_IOPORTNAME      B
#define USB_CFG_DMINUS_BIT      3
#define USB_CFG_DPLUS_BIT       4

#define USB_INTR_CFG            PCMSK
#define USB_INTR_CFG_SET        (1<<USB_CFG_DPLUS_BIT)
#define USB_INTR_ENABLE_BIT     PCIE
#define USB_INTR_PENDING_BIT    PCIF
#define USB_INTR_VECTOR         SIG_PIN_CHANGE
gtrainavicius commented 5 years ago

WOW! That actually did the trick! Thank you very much.

Great! Could you try reverting midiUsbInit() and any other changes to original, and see whether usbconfig.h changes were the only ones necessary to get it working?

Now i wonder, how we can work this into the USBMIDI repository in way that it does not break compiling for other boards.

The problem with preprocessor conditionals based only on the MCU type is that the same type of MCU can appear on many different boards, with different pinouts used, so this is not good enough.

Looks like builds for Digispark board define ARDUINO_AVRDIGISPARK, this, as well as MCU type defines like \_AVR_ATtiny45__, could be used to predefine the variables for usbconfig.h

However, such a config file would take a lot of time and resources to maintain which I can't do on my own. I would gladly accept a contribution though.

The board preconfiguration file would have to follow these priority rules:

  1. If a variable is defined using -D... command line option, use that value
  2. If exact board and MCU was identified, use the value meant for this combination
  3. Use default value

A quick example on how it could look like for one variable:

usbboard.h:

#ifdef ARDUINO_AVR_DIGISPARK

#   ifndef USB_CFG_DMINUS_BIT
#       if defined (__AVR_ATtiny44__) || defined (__AVR_ATtiny84__)
#           define USB_CFG_DMINUS_BIT 1
#       elif defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__)
#           define USB_CFG_DMINUS_BIT 3
//#     elif ...
#       endif
#   endif // USB_CFG_DMINUS_BIT

// Same for the rest of the variables that must be defined for DIGISPARK boards.
// If the board and MCU combination is not recognized, the variable should be left undefined.

#endif // ARDUINO_AVR_DIGISPARK

Then usbconfig.h could #include "usbboard.h" somewhere near the top.

gtrainavicius commented 5 years ago

For the record: i've just tested with fresh copy of USBMIDI 1.1.1 installed through arduino IDE. All i needed to add in order to work on attiny85 digispark were these magic lines:

Ok, good, was about to ask for this information. :)

Harvie commented 5 years ago

The per-MCU definitions are quite commonly used.

Eg. both digispark and adafruit trinket use the same pinout and they are two biggest players. Honestly i don't even have real digispark. I just googled for cheapest chinese v-usb compatible board to experiment with attiny85 and they have hundreds of various $1 digispark clones all sharing this pinout. So i believe this is really common setup.

I don't think there is point of MIDI library maintaining database of all possible setups. If you have something more exotic, you should have boards.txt entry for that. But i think it's OK to cover these 5 most used cases given that #ifndef condition will ensure that boards.txt will always take the precedence.

Harvie commented 5 years ago

But i don't really know, how to include that USB_INTR_* defines... I can't really tell how common that is... But if we figure out how to detect digispark i would like to include it, as it's very frequent and affordable board.

Harvie commented 5 years ago

It should have at least USBMIDI.poll() in the loop to do the USB work.

I've just read that in README.md, usualy i learn from library examples and none of the examples has poll() call in it. That's why i didn't included it.

I guess this is only needed for V-USB, but not native USB (LUFA), is that true? Also as long as you call flush() it has poll() call in it... I think we should mention this in readme...

gtrainavicius commented 5 years ago

I guess this is only needed for V-USB, but not native USB (LUFA), is that true? Also as long as you call flush() it has poll() call in it... I think we should mention this in readme...

For most portability, it should be called regardless of underlying implementation.

Its absence from examples is my mistake, will fix them soon. :)

But i don't really know, how to include that USBINTR* defines... I can't really tell how common that is... But if we figure out how to detect digispark i would like to include it, as it's very frequent and affordable board.

See the code example I posted above - #ifdef ARDUINO_AVR_DIGISPARK is for detecting 'Digispark' board.

The usbconfig customizations for Digispark may be borrowed from DigisprakMIDI's usbconfig.h, there's variables at the top and bottom.

I'd really appreciate if you could extend the above config example for the rest of the variables required for Digispark boards and give it a spin. The code may be formatted differently, the only important thing is to respect the priority rules defined above. :)

Harvie commented 5 years ago

See the code example I posted above

Should i prepare PR, or you can do it yourself? :-)

gtrainavicius commented 5 years ago

A PR would be great, also you could try it out immediately.

Otherwise I can make the changes towards the end of this week and ask you to test it out.

Harvie commented 5 years ago

you could try it out immediately.

OK. makes sense.

Harvie commented 5 years ago

I think we can close this, but there is just last note:

If you add mention of digispark support to library.properties and README.md, that might attract some new users...

gtrainavicius commented 5 years ago

Hey, I just did that :) Also tagged a new version, so Arduino IDE's library manager will pick up the recent changes.

Thank you for your help!