EnableInterrupt library- to attach interrupts to Arduino pins

Hello,
I would like to announce the first public release of the EnableInterrupt library. As of now, I'm calling it Alpha code, and the release version is 0.2.

You can get it at GitHub - GreyGnome/EnableInterrupt: New Arduino interrupt library, designed for Arduino Uno/Mega 2560/Leonardo/Due. See the wiki here.

The EnableInterrupt library is a new Arduino interrupt library, designed for all versions of the Arduino- at this writing, the Uno (and other ATmega328p-based boards, like the mini), Due, Leonardo (and other ATmega32u4-based boards, like the Micro), and Mega2560 (and other ATmega2560-based boards, like the MegaADK). It enables you to assign an interrupt to pins on your chip that support them, and presents a common interface to all supported chips. This means that on the Arduino Uno and Mega you don't give it an interrupt number, as per attachInterrupt. Rather, your first argument is simply a pin number. Naturally, you must give the number of a pin that's supported on that chip (see the bestiary on the Usage wiki page).

The library also blurs the distinction between the different interrupt types across the different chip types, and presents a single api for an interrupt on a pin. Please read about the interrupt types here.

At the time of this writing the code is only tested on an Arduino Uno and Mega ADK, so it has not been tested on the Due or Leonardo. But the Due is exceptionally simple to code (simply a #define), and the Leonardo is pretty simple, pin-interrupt-wise. But if someone could give me a bug report on those platforms, I'd appreciate it. Thanks.

Will '1284P support be included at some point?

CrossRoads:
Will '1284P support be included at some point?

It seems pretty straightforward- I had 644 support in the PinChangeInt library and I think the 1284p is similar, but I'd have to study the port layout a little bit closer. If the pin-to-pcint correspondence is 328p-like (on ports B, C, and D) and 644-like on port A, then that will help.

That said, I don't have a 1284p so I'll have to ask someone else to debug for me... I thought the 2560 would trivial after the 328p but I had more forgotten letter-replacement errors than I'd like to admit. :fearful:

Well, no promises but the chip looks nice and, time willing, I'll give it a go in a few weeks most likely. Now that this is done / completed / to a point I'm comfortable with / released, I have a couple of other projects to take care of.

I just released version 0.3 of this library, which includes a bugfix from 0.2. From the release notes:

Mon Apr 13 07:49:05 CDT 2015
Version 0.3 - Arjun reported a bug on the Uno platform:

In file included from Interrupt.ino:1:
/Users/arjunmehta94/Documents/Arduino/libraries/EnableInterrupt-master/EnableInterrupt.h: In function 'void __vector_3()':
/Users/arjunmehta94/Documents/Arduino/libraries/EnableInterrupt-master/EnableInterrupt.h:976: error: 'struct functionPointersPortB' has no member named 'pinSix'
/Users/arjunmehta94/Documents/Arduino/libraries/EnableInterrupt-master/EnableInterrupt.h:977: error: 'struct functionPointersPortB' has no member named 'pinSeven'

I have a Duemilanove; I don't know why I never saw that error. Regardless, I have included some
#ifndef lines in to protect that code from getting compiled.

You can get the library here: GitHub - GreyGnome/EnableInterrupt: New Arduino interrupt library, designed for Arduino Uno/Mega 2560/Leonardo/Due. See the wiki here.

I just released version 0.4 of this library, which includes a new performance mode.

You can get the library here. See the wiki here. The new mode is described here. Usage information can be found here.

From the Release Notes:

Fri May 8 07:33:26 CDT 2015
Version 0.4 - New high speed ("HiSpeed") mode. In this mode, the interrupt routine is predefined:
it ONLY updates a variable. This knocks a couple of microseconds off of the interrupt routine times; it greatly reduces the number of registers needed to be pushed/popped, and of course does not require a function call. See the wiki for details, including speed measurements.

Thanks, looks good

I just released version 0.5 of this library, which includes ATmega644/1284(p) support.

You can get the library here. See the wiki here. The new mode is described here. Usage information can be found here.

From the Release Notes:

Fri Jun 12 06:33:20 CDT 2015
Version 0.5 (Alpha) of the library has been released. This release includes support for the ATmega1284p line of processors (includes ATmega644). The Mighty 1284 is used as the basis. As I don't have a 1284-based processor, this code compiles but has not been tested (see examples/Might1284p). Bug reports encouraged and welcomed! It would be great if a 644/1284 owner could upload the Might1284p.ino sketch and interrupt every pin and let me know the results.

Code was refactored so that a lot of utility routines were moved into individual .h files. Now there's a lot of files, which appears ugly, but the old way was a lot uglier to my mind and looked like a big bowl of spaghetti with so many #ifdefs strewn about to handle the different chips. It was getting hard to wade through the code.

CrossRoads:
Will '1284P support be included at some point?

.... Yes. :slight_smile:

Fri Jun 19 09:38:43 CDT 2015
Version 0.6.2 of the library has been released. This version is designed to meet the requirements of the 1.5.x Arduino library spec. No code logic was modified; only files were moved and library.properties and keywords.txt files added.

I hope to see the library in the Arduino IDE (1.5.x and up) library manager soon. I have posted a request to the Github issues page.

You can get the library here. See the wiki here. The High Speed mode is described here. Usage information can be found here.

Finally, direct download link is here

Happiness here and here.

Here is here

Tue Jun 23 06:47:10 CDT 2015

Version 0.7.0 of the library has been released. This release includes compiler directives that allow you
to eliminate unneeded ports and memory allocations, to more efficiently utilize code and static RAM. See SaveMemory · GreyGnome/EnableInterrupt Wiki · GitHub for the new features.

The library is available in the Arduino 1.6.x IDE Library Manager (from the Sketch Menu -> Include Library -> Manage Libraries).

The library's home page is here. See the wiki here. The memory saving features are described here. Usage information can be found here.

Finally, direct download link is here

Happiness here and here.

Tue Jun 23 06:47:10 CDT 2015 Version 0.8.0 of the library has
been released. This release includes a compiler directive that allows you to query a variable and know which pin triggered the interrupt (sorry, this capability is not available on the Due). See Usage · GreyGnome/EnableInterrupt Wiki · GitHub

The library is available in the Arduino 1.6.x IDE Library Manager (from the Sketch Menu -> Include Library -> Manage Libraries).

The library's home page is here. See the wiki here. Usage information can be found here.

Finally, direct download link is here

Happiness here and here.

...Ooops, and v. 0.8.1 is now up. I missed a fix for the ATmega1284. Get it at https://bintray.com/artifact/download/greygnome/generic/enableinterrupt-0.8.1.zip

Version 0.8.2 is now released. Includes bugfixes for issues raised by engwan, MakkyB, and juanricos; HiSpeed mode was not working but now it is. I also received some nice bug reports and testing from TomWS1. Finally, the library.properties file was out of date.

Get it at Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog

This was worth the return visit for , Thanks for your diligence!

Tue Sep 29 06:34:58 CDT 2015
Version 0.9.0 of the EnableInterrupt library has been released. ATtiny support has been added! Support files come from GitHub - damellis/attiny: ATtiny microcontroller support for the Arduino IDE .
Chips supported include ATtiny44/84 and ATtiny 45/85 (including Gemma). As always, bug reports are
welcome at Issues · GreyGnome/EnableInterrupt · GitHub . NOTE: I don't have an ATtiny (yet),
so the only work I could do was to make sure a sample sketch compiled.

The library is available in the Arduino 1.6.x IDE Library Manager (from the Sketch Menu -> Include Library -> Manage Libraries).

The library's home page is here. See the wiki here. Usage information can be found here.

Finally, direct download link is here

Happiness here and here.

Reasons for delay of this release here and here (plus dad duties). Sorry about that :frowning: .

Fri Oct 16 17:01:49 CDT 2015
Version 0.9.1 of the EnableInterrupt library has been released. Arduino Zero support added. Bug fixes in examples/OOSimple (thanks RobertClemenzi). And don't forget about the ATtiny support added in 0.9.0! See the Release Notes in the extras directory for details.

The library is available in the Arduino 1.6.x IDE Library Manager (from the Sketch Menu -> Include Library -> Manage Libraries).

The library's home page is here. See the wiki here. Usage information can be found here.

Finally, direct download link is here

Sat Oct 17 11:56:01 CDT 2015
Version 0.9.2 of the library has been released. I discovered a rather pernicious bug, wherein the library
was setting the global interrupt enable bit. This could cause a serious and difficult-to-debug race condition, as it is not the job of the library to manage that bit. The chips come with interrupts enabled so existing code should not be affected. My thanks to Gammon Forum : Electronics : Microprocessors : Interrupts (the How are interrupts queued? section).

The library is available in the Arduino 1.6.x IDE Library Manager (from the Sketch Menu -> Include Library -> Manage Libraries).

The library's home page is here. See the wiki here. Usage information can be found here.

Finally, direct download link is here

Mon Oct 19 07:45:08 CDT 2015 Version 0.9.3 of the library has been released. Thanks to RobertClemenzi, who pointed out that "Useless.cpp" is not included with the distribution zip file.

The library is available in the Arduino 1.6.x IDE Library Manager (from the Sketch Menu -> Include Library -> Manage Libraries).

The library's home page is here. See the wiki here. Usage information can be found here.

Finally, direct download link is here

Fri Nov 6 19:13:20 CST 2015 Version 0.9.4 of the library has been released. Thanks to RobertClemenzi, who pointed out 2 bugs: 1. A spurious comma in some array definitions caused a compiler warning, and 2. More importantly, it was impossible to use arduinoInterruptedPin if this library was used to support other libraries.

The library is available in the Arduino 1.6.x IDE Library Manager (from the Sketch Menu -> Include Library -> Manage Libraries).

The library's home page is here. See the wiki here. Usage information can be found here.

Finally, direct download link is here

Hi GreyGnome,

First of all - many thanks for putting this awesome library together! Unfortunately, I seem to have a likely simple issue that I cannot resolve on my own, hence this request for help.

I am running Arduino 1.6.6 and am trying to compile the 1284p example from the library. As a target MCU, I have selected what I think is the latest version of the mighty 1284p @ 1 MBPS. When I try to compile, I get the error message that

Mighty1284p:96: error: #error This sketch supports 1284p-based Arduino-likes only.
#error This sketch supports 1284p-based Arduino-likes only.

If I eliminate the IFDEF looking for the MIGHTY1284P in the 1284P example, then the example compiles. I presume that I need a updated version of the processor file to have that definition - where would I find it?