api / mbed / trunk / InterruptIn

InterruptIn

class InterruptIn : public Base

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);
    }
}
InterruptInA digital interrupt input, used to call a function on a rising or falling edge
Functions
InterruptInCreate an InterruptIn connected to the specified pin
riseAttach a function to call when a rising edge occurs on the input
riseAttach a member function to call when a rising edge occurs on the input
fallAttach a function to call when a falling edge occurs on the input
fallAttach a member function to call when a falling edge occurs on the input
modeSet the input pin mode

Functions

InterruptIn

InterruptIn(PinName pin,  
const char *name =  NULL)

Create an InterruptIn connected to the specified pin

Variables

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

rise

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

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

Variables

fptrA pointer to a void function, or 0 to set as none

rise

template<typename T> void rise(*tptr,
void (T::*mptr)(void))

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

Variables

tptrpointer to the object to call the member function on
mptrpointer to the member function to be called

fall

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

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

Variables

fptrA pointer to a void function, or 0 to set as none

fall

template<typename T> void fall(*tptr,
void (T::*mptr)(void))

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

Variables

tptrpointer to the object to call the member function on
mptrpointer to the member function to be called

mode

void mode(PinMode pull)

Set the input pin mode

Variables

modePullUp, PullDown, PullNone
class InterruptIn : public Base
A digital interrupt input, used to call a function on a rising or falling edge
InterruptIn(PinName pin,  
const char *name =  NULL)
Create an InterruptIn connected to the specified pin
void rise(void (*fptr)(void))
Attach a function to call when a rising edge occurs on the input
void fall(void (*fptr)(void))
Attach a function to call when a falling edge occurs on the input
void mode(PinMode pull)
Set the input pin mode