Closed RobertClemenzi closed 8 years ago
Thanks, Robert. I will fix this.
By making arduinoInterruptedPin volatile, any part of the sketch can simply reference it. The function is unnecessary in my view. Let me know if I don't understand something about that.
Regarding the variable, in the latest code I have fixed it by defining the variable in the #ifndef LIBCALL_ENABLEINTERRUPT. Then I added a #else clause and declared the variable there. Like this:
#ifndef LIBCALL_ENABLEINTERRUPT
#ifdef EI_ARDUINO_INTERRUPTED_PIN
volatile uint8_t arduinoInterruptedPin=0;
#endif
...(a lot of library code here)...
#else
#ifdef EI_ARDUINO_INTERRUPTED_PIN
extern volatile uint8_t arduinoInterruptedPin;
#endif
#endif
I tested your solution and it works.
I think it would be easier for others to follow if you keep the extern declaration in the header section instead of placing it at the end, but that is just one opinion.
0.9.4 is being uploaded as I speak.
I agree with you about the extern declaration- sorry, I missed it in this release. I will change the logic of the #ifdef and put it at the beginning but I will roll that into the next release. For now it works which is key.
I am going to close this. The change you suggested is in the source file and will be included in the next release, so I don't think we need to leave this issue open. Thanks for the bug report!
When debugging code I placed in a library, the arduinoInterruptedPin variable would have been a big help, but was not available. The reason is that variables can not be defined in header files that are included in multiple source files. When they are, a multiple definition error is generated. The EnableInterrupt library is implemented as a header file with 2 sections,
My suggested solution is to
In the Arduino C implementation, function prototypes can be included via a header file in multiple source files without any problem. The function should simply return the value of the variable. This modification should allow all existing code that uses the variable to continue operating without any changes, and will allow libraries to also access the interrupting pin numbers.
The following is code that I have tested. You may use it if you like, or change what ever makes sense. I am not trying to tell you what to do, just making a suggestion.
I also defined the variable as volatile because it is set via an interrupt routine.