added prescaler for 16 bit pwm in LPC1347 target

Fork of mbed-dev 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.
int read ()
 Read the input, represented as 0 or 1 (int)
 operator int ()
 An operator shorthand for read()
void rise (Callback< void()> func)
 Attach a function to call when a rising edge occurs on the input.
template<typename T , typename M >
void rise (T *obj, M method)
 Attach a member function to call when a rising edge occurs on the input.
void fall (Callback< void()> func)
 Attach a function to call when a falling edge occurs on the input.
template<typename T , typename M >
void fall (T *obj, M method)
 Attach a member function to call when a falling edge occurs on the input.
void mode (PinMode pull)
 Set the input pin mode.
void enable_irq ()
 Enable IRQ.
void disable_irq ()
 Disable IRQ.

Detailed Description

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

Synchronization level: Interrupt safe

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 56 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

void disable_irq (  )

Disable IRQ.

This method depends on hw implementation, might disable one port interrupts. For further information, check gpio_irq_disable().

Definition at line 86 of file InterruptIn.cpp.

void enable_irq (  )

Enable IRQ.

This method depends on hw implementation, might enable one port interrupts. For further information, check gpio_irq_enable().

Definition at line 80 of file InterruptIn.cpp.

void fall ( Callback< void()>  func )

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

Parameters:
funcA pointer to a void function, or 0 to set as none

Definition at line 59 of file InterruptIn.cpp.

void fall ( T *  obj,
method 
)

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

Parameters:
objpointer to the object to call the member function on
methodpointer to the member function to be called

Definition at line 111 of file InterruptIn.h.

void mode ( PinMode  pull )

Set the input pin mode.

Parameters:
modePullUp, PullDown, PullNone

Definition at line 41 of file InterruptIn.cpp.

operator int (  )

An operator shorthand for read()

Definition at line 92 of file InterruptIn.cpp.

int read ( void   )

Read the input, represented as 0 or 1 (int)

Returns:
An integer representing the state of the input pin, 0 for logical 0, 1 for logical 1

Definition at line 36 of file InterruptIn.cpp.

void rise ( Callback< void()>  func )

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

Parameters:
funcA pointer to a void function, or 0 to set as none

Definition at line 47 of file InterruptIn.cpp.

void rise ( T *  obj,
method 
)

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

Parameters:
objpointer to the object to call the member function on
methodpointer to the member function to be called

Definition at line 93 of file InterruptIn.h.