Simon Ford
/
InterruptInDynamic
main.cpp@0:cec8a24790b9, 2009-11-19 (annotated)
- Committer:
- simon
- Date:
- Thu Nov 19 10:51:10 2009 +0000
- Revision:
- 0:cec8a24790b9
- Child:
- 1:62ee7186e613
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:cec8a24790b9 | 1 | #include "mbed.h" |
simon | 0:cec8a24790b9 | 2 | |
simon | 0:cec8a24790b9 | 3 | DigitalOut led1(LED1); |
simon | 0:cec8a24790b9 | 4 | DigitalOut led2(LED2); |
simon | 0:cec8a24790b9 | 5 | InterruptIn interrupt(p5); |
simon | 0:cec8a24790b9 | 6 | |
simon | 0:cec8a24790b9 | 7 | void foo() { |
simon | 0:cec8a24790b9 | 8 | led1 = !led1; |
simon | 0:cec8a24790b9 | 9 | } |
simon | 0:cec8a24790b9 | 10 | |
simon | 0:cec8a24790b9 | 11 | void bar() { |
simon | 0:cec8a24790b9 | 12 | led2 = !led2; |
simon | 0:cec8a24790b9 | 13 | } |
simon | 0:cec8a24790b9 | 14 | |
simon | 0:cec8a24790b9 | 15 | int main() { |
simon | 0:cec8a24790b9 | 16 | while(1) { |
simon | 0:cec8a24790b9 | 17 | interrupt.rise(&foo); |
simon | 0:cec8a24790b9 | 18 | wait(5); |
simon | 0:cec8a24790b9 | 19 | interrupt.rise(&bar); |
simon | 0:cec8a24790b9 | 20 | wait(5); |
simon | 0:cec8a24790b9 | 21 | interrupt.rise(NULL); |
simon | 0:cec8a24790b9 | 22 | wait(5); |
simon | 0:cec8a24790b9 | 23 | } |
simon | 0:cec8a24790b9 | 24 | } |