ContentsIndex
PreviousUpNext
Interrupts
Functions | Types

 

The External Interrupts API sets up an Interrupt Service Routine (ISR), which is called automatically when an interrupt arrives on one of the interrupt pins (see Table below). The interrupt service cannot preempt execution. When the next interrupt arrives, it will wait for ISR to finish the previous interrupt before its execution starts. 

 

interrupts() and noInterrupts() enable and disable interrupts. If interrupts are disabled, care should be taken to disable them for as short a time as possible. 

 

Table : The Interrupt pins

Board 
int.0 
int.1 
LinkIt ONE 
D2 
D3 

 

You cannot execute any LinkIt APIs in the ISR. This is because the ISR is run in a separate thread which is of a higher priority to the one running the LinkIt Sketch code. When the ISR is executed in this thread, the thread running the Sketch is suspended to wait for execution of the ISR to finish. Where LinkIt APIs need to be executed as a result of the interrupt, this can be achieved by setting a global variable that is then used in the Sketch code to execute the desired APIs. 

 

noInterrupts() doesn? disable all hardware interrupts, only interrupts from the pins. This enables the stable execution of other APIs, but does mean that the application may be interrupted by some events. 

Functions
Function 
Description 
Sets up Interrupt Service Routine (ISR). When an interrupt arrives, the ISR will be called automatically. This interrupt service cannot preempt execution. When the next interrupt arrives, it will wait for ISR to finish the previous interrupt before its execution starts. There are two external interrupts on LinkIt One development board, interrupt 0 (at pin 2) and interrupt 1 (at pin 3). 
Disables ISR. 
Disables interrupt (which can be enabled again by interrupts()). 
Enables interrupt (after it is disabled by noInterrupts()). By default, interrupts make some essential tasks executed in background. Disabling interrupts will make some communication functions unable to work normally and external interaction ignored. Therefore, please pay particular attention when using this function and enable the interrupt again as soon as possible 
Types
Type 
Description 
Definitions Interrupt callback type 
Links