Arduino Interrupts VUSB intergration

Hi! I'm trying to use the Arduino port of the V-USB AVR library in order to develop a custom HID device. If I simulate my physical device behavior and just use VUSB, everything works. If I use my physical device and send debug information only through Serial communication, everything works. Unfortunately when I try to compile a project using both I get this error:

core.a(WInterrupts.c.o): In function `__vector_1':
C:\Standalone\Programmazione\arduino-1.0.1\hardware\arduino\cores\arduino/WInterrupts.c:273: multiple definition of `__vector_1'
USBDriver\usbdrvasm.S.o:(.text+0x32): first defined here

As I understand, the problem should be caused by the fact that my device is using the interrupt on digital pin 3 and the attachInterrupt function on the software side, while VUSB uses digital pin 2 and reimplements the interrupts functions. Looking around the basic solution is to simply disable the Arduino interrupts functions... however I need them for my device.

How can I use both things at the same time?


I have exactly the same issue as you! Did you find a solution?

I'm using PS2Keyboard 2.4 & Vusb-for-arduino-005.

Thank you, PS: I created a new post in French for my issue:

I know, that this topic is quite old, but I’ve found it looking for a solution for exactly the same problem. (V-USB current version)

Using attachInterrupt on pin 3 (as V-USB is configured for 2) triggers WInterrupts library to load. WInterrupts defines for whatever purposes INT0_vect and INT1_vect. But one of them was already defined by V-USB library (depends on which pin VUSB was configured: pin 2 - INT0 or pin 3 - INT1). So there is the collision.

Probably there is a possibility to modify WInterrupts or VUSB library. But it’s dirty and I do not like to do things that way.

The solution was to not use WInterrupts library. Since attachInterrupt is just an easy way to setup interrupt, it has to be possible to set it by hand, the hard way. And it is!

So I just found some examples of configuring interrupt and make it for INT1. This page is extremely helpful. And my configuration (for FALLING):

// activate external interrupt 1
  EICRA &= ~(bit(ISC10) | bit (ISC11)); // clear existing flags
  EICRA |= (0<<ISC10)|(1<<ISC11);
  EIFR   =  bit (INTF1);    // clear flag for interrupt 1
  EIMSK |=  bit (INT1);     // enable it

and of course:

ISR(INT1_vect) {
  //do something on interrupt

And it is awesome now ^^.