mbed library sources: Modified to operate FRDM-KL25Z at 48MHz from internal 32kHz oscillator (nothing else changed).

Fork of mbed-src by mbed official

Embed: (wiki syntax)

« Back to documentation index

InterruptIn Class Reference

InterruptIn Class Reference

A digital interrupt input, used to call a function on a rising or falling edge. More...

#include <InterruptIn.h>

Public Member Functions

 InterruptIn (PinName pin)
 Create an InterruptIn connected to the specified pin.
pFunctionPointer_t rise (void(*fptr)(void))
 Attach a function to call when a rising edge occurs on the input.
pFunctionPointer_t rise_add (void(*fptr)(void))
 Add a function to be called when a rising edge occurs at the end of the call chain.
pFunctionPointer_t rise_add_front (void(*fptr)(void))
 Add a function to be called when a rising edge occurs at the beginning of the call chain.
template<typename T >
pFunctionPointer_t rise (T *tptr, void(T::*mptr)(void))
 Attach a member function to call when a rising edge occurs on the input.
template<typename T >
pFunctionPointer_t rise_add (T *tptr, void(T::*mptr)(void))
 Add a function to be called when a rising edge occurs at the end of the call chain.
template<typename T >
pFunctionPointer_t rise_add_front (T *tptr, void(T::*mptr)(void))
 Add a function to be called when a rising edge occurs at the beginning of the call chain.
bool rise_remove (pFunctionPointer_t pf)
 Remove a function from the list of functions to be called when a rising edge occurs.
pFunctionPointer_t fall (void(*fptr)(void))
 Attach a function to call when a falling edge occurs on the input.
pFunctionPointer_t fall_add (void(*fptr)(void))
 Add a function to be called when a falling edge occurs at the end of the call chain.
pFunctionPointer_t fall_add_front (void(*fptr)(void))
 Add a function to be called when a falling edge occurs at the beginning of the call chain.
template<typename T >
pFunctionPointer_t fall (T *tptr, void(T::*mptr)(void))
 Attach a member function to call when a falling edge occurs on the input.
template<typename T >
pFunctionPointer_t fall_add (T *tptr, void(T::*mptr)(void))
 Add a function to be called when a falling edge occurs at the end of the call chain.
template<typename T >
pFunctionPointer_t fall_add_front (T *tptr, void(T::*mptr)(void))
 Add a function to be called when a falling edge occurs at the beginning of the call chain.
bool fall_remove (pFunctionPointer_t pf)
 Remove a function from the list of functions to be called when a falling edge occurs.
void mode (PinMode pull)
 Set the input pin mode.

Detailed Description

A digital interrupt input, used to call a function on a rising or falling edge.

Example:

 // Flash an LED while waiting for events

 #include "mbed.h"

 InterruptIn event(p16);
 DigitalOut led(LED1);

 void trigger() {
     printf("triggered!\n");
 }

 int main() {
     event.rise(&trigger);
     while(1) {
         led = !led;
         wait(0.25);
     }
 }

Definition at line 55 of file InterruptIn.h.


Constructor & Destructor Documentation

InterruptIn ( PinName  pin )

Create an InterruptIn connected to the specified pin.

Parameters:
pinInterruptIn pin to connect to
name(optional) A string to identify the object

Definition at line 22 of file InterruptIn.cpp.


Member Function Documentation

pFunctionPointer_t fall ( void(*)(void)  fptr )

Attach a function to call when a falling edge occurs on the input.

Parameters:
fptrA pointer to a void function, or 0 to set as none
Returns:
The function object created for 'fptr'

Definition at line 66 of file InterruptIn.cpp.

pFunctionPointer_t fall ( T *  tptr,
void(T::*)(void)  mptr 
)

Attach a member function to call when a falling edge occurs on the input.

Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called
Returns:
The function object created for 'tptr' and 'mptr'

Definition at line 195 of file InterruptIn.h.

pFunctionPointer_t fall_add ( void(*)(void)  fptr )

Add a function to be called when a falling edge occurs at the end of the call chain.

Parameters:
fptrthe function to add
Returns:
The function object created for 'fptr'

Definition at line 171 of file InterruptIn.h.

pFunctionPointer_t fall_add ( T *  tptr,
void(T::*)(void)  mptr 
)

Add a function to be called when a falling edge occurs at the end of the call chain.

Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called
Returns:
The function object created for 'tptr' and 'mptr'

Definition at line 211 of file InterruptIn.h.

pFunctionPointer_t fall_add_front ( void(*)(void)  fptr )

Add a function to be called when a falling edge occurs at the beginning of the call chain.

Parameters:
fptrthe function to add
Returns:
The function object created for 'fptr'

Definition at line 182 of file InterruptIn.h.

pFunctionPointer_t fall_add_front ( T *  tptr,
void(T::*)(void)  mptr 
)

Add a function to be called when a falling edge occurs at the beginning of the call chain.

Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called
Returns:
The function object created for 'tptr' and 'mptr'

Definition at line 224 of file InterruptIn.h.

bool fall_remove ( pFunctionPointer_t  pf )

Remove a function from the list of functions to be called when a falling edge occurs.

Parameters:
pfthe function object to remove
Returns:
true if the function was found and removed, false otherwise

Definition at line 86 of file InterruptIn.cpp.

void mode ( PinMode  pull )

Set the input pin mode.

Parameters:
modePullUp, PullDown, PullNone

Definition at line 35 of file InterruptIn.cpp.

pFunctionPointer_t rise ( T *  tptr,
void(T::*)(void)  mptr 
)

Attach a member function to call when a rising edge occurs on the input.

Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called
Returns:
The function object created for 'tptr' and 'mptr'

Definition at line 113 of file InterruptIn.h.

pFunctionPointer_t rise ( void(*)(void)  fptr )

Attach a function to call when a rising edge occurs on the input.

Parameters:
fptrA pointer to a void function, or 0 to set as none
Returns:
The function object created for 'fptr'

Definition at line 39 of file InterruptIn.cpp.

pFunctionPointer_t rise_add ( void(*)(void)  fptr )

Add a function to be called when a rising edge occurs at the end of the call chain.

Parameters:
fptrthe function to add
Returns:
The function object created for 'fptr'

Definition at line 89 of file InterruptIn.h.

pFunctionPointer_t rise_add ( T *  tptr,
void(T::*)(void)  mptr 
)

Add a function to be called when a rising edge occurs at the end of the call chain.

Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called
Returns:
The function object created for 'tptr' and 'mptr'

Definition at line 129 of file InterruptIn.h.

pFunctionPointer_t rise_add_front ( void(*)(void)  fptr )

Add a function to be called when a rising edge occurs at the beginning of the call chain.

Parameters:
fptrthe function to add
Returns:
The function object created for 'fptr'

Definition at line 100 of file InterruptIn.h.

pFunctionPointer_t rise_add_front ( T *  tptr,
void(T::*)(void)  mptr 
)

Add a function to be called when a rising edge occurs at the beginning of the call chain.

Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called
Returns:
The function object created for 'tptr' and 'mptr'

Definition at line 142 of file InterruptIn.h.

bool rise_remove ( pFunctionPointer_t  pf )

Remove a function from the list of functions to be called when a rising edge occurs.

Parameters:
pfthe function object to remove
Returns:
true if the function was found and removed, false otherwise

Definition at line 59 of file InterruptIn.cpp.