phil dani
/
interrupt_test
Simple Interrupt example
Diff: main.cpp
- Revision:
- 0:5163e0741765
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Aug 29 17:49:47 2013 +0000 @@ -0,0 +1,23 @@ +/* Program 10: Simple interrupt example. External input causes interrupt, while led flashes */ +#include "mbed.h" + +InterruptIn button(p5); //define and name the interrupt input +DigitalOut led(LED1); +DigitalOut flash(LED4); + +void ISR1() { //this is the response to interrupt, i.e. the ISR + led = !led; +} + +int main() { + button.rise(&ISR1); // attach the address of the ISR function to the + // interrupt rising edge + while(1) { // continuous loop, ready to be interrupted + flash = !flash; + /* if(flash=1) + __disable_irq(); //disable interrupts + else + __enable_irq(); //enable interrupts */ + wait(1); + } +}