GreyGnome / EnableInterrupt

New Arduino interrupt library, designed for Arduino Uno/Mega 2560/Leonardo/Due
329 stars 73 forks source link

Identified Error -> multiple definition of `__vector_1' #19

Closed stickbreaker closed 9 years ago

stickbreaker commented 9 years ago

I have been updating my libraries to use This new EnableInterrupt, but I was hitting a wall with this error message: multiple definition of `__vector_1', of course the compiler flags the error in code that has no relationship with the actual cause of the problem. So I just kept simplifying my code until i found what was left.

It turns out the if you use attachInterrupt(), (the Arduino Standard procedure) it produces this collision, now I am converting all of the old attachInterrupt() calls to enableInterrupt().

I think you should add this error message to your FAQ.

chuck.

edit: Solved this error only to create a new error.

I am using EnableInterrupt to add CTS/RTS handshaking to HardwareSerial. It works just fine, BUT, of course there is a but, If I want to use EnableInterrupt in my 'Application' level code, now I get *C:\Documents and Settings\user\My Documents\Arduino\libraries\EnableInterrupt/EnableInterrupt.h:783: multiple definition of `enableInterrupt(unsigned char, void ()(), unsigned char)'**

Here is the how I included EnableInterrupt in HardwareSerial.cpp:

#define EI_ARDUINO_INTERRUPTED_PIN // to support CTS handshaking 
#include "C:\Documents and Settings\user\My Documents\Arduino\libraries\EnableInterrupt\EnableInterrupt.h"
 //To support CTS handshaking 02AUG2015 Chuck Todd

Any Clues how to solve this collision?

Chuck. Edit 27AUG15 19:41MDT

Here is a working solution, still testing, but so far it works. In the 'Application, or Application libraries' instead of #include <EnableInterrupt.h> use this:

extern void enableInterrupt(uint8_t interruptDesignator, void (*userFunction)(void), uint8_t mode);
extern void disableInterrupt(uint8_t interruptDesignator);

Chuck.

GreyGnome commented 8 years ago

Not a bad idea to add this to the FAQ. I will do that for the next release. Meanwhile, as per the FAQ: insert #define LIBCALL_ENABLEINTERRUPT in front of every #include in every one of the files in which you want to use EnableInterrupt library functionality- except one. In that file (often but not necessarily your sketch), just place the #include directive; don't define the LIBCALL_ENABLEINTERRUPT. This will perform an equivalent to what you did. :-)