John Kemp
/
interruptin_test
Oddness with multiple \'InterruptIn\'s
main.cpp@1:0228f6b60488, 2011-03-30 (annotated)
- Committer:
- Kemp
- Date:
- Wed Mar 30 15:54:35 2011 +0000
- Revision:
- 1:0228f6b60488
- Parent:
- 0:ba602786a4c1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kemp | 0:ba602786a4c1 | 1 | #include "mbed.h" |
Kemp | 0:ba602786a4c1 | 2 | |
Kemp | 0:ba602786a4c1 | 3 | Serial pc(USBTX, USBRX); |
Kemp | 0:ba602786a4c1 | 4 | |
Kemp | 0:ba602786a4c1 | 5 | InterruptIn button1(p12); |
Kemp | 0:ba602786a4c1 | 6 | InterruptIn button2(p11); |
Kemp | 0:ba602786a4c1 | 7 | InterruptIn button3(p10); |
Kemp | 0:ba602786a4c1 | 8 | |
Kemp | 0:ba602786a4c1 | 9 | void button1_pressed() {pc.printf("Button 1");} |
Kemp | 0:ba602786a4c1 | 10 | void button2_pressed() {pc.printf("Button 2");} |
Kemp | 0:ba602786a4c1 | 11 | void button3_pressed() {pc.printf("Button 3");} |
Kemp | 0:ba602786a4c1 | 12 | |
Kemp | 0:ba602786a4c1 | 13 | int main() |
Kemp | 0:ba602786a4c1 | 14 | { |
Kemp | 0:ba602786a4c1 | 15 | // Set up buttons |
Kemp | 0:ba602786a4c1 | 16 | button1.mode(PullDown); |
Kemp | 1:0228f6b60488 | 17 | button1.rise(&button1_pressed); |
Kemp | 0:ba602786a4c1 | 18 | |
Kemp | 0:ba602786a4c1 | 19 | button2.mode(PullDown); |
Kemp | 1:0228f6b60488 | 20 | button2.rise(&button2_pressed); |
Kemp | 0:ba602786a4c1 | 21 | |
Kemp | 0:ba602786a4c1 | 22 | button3.mode(PullDown); |
Kemp | 1:0228f6b60488 | 23 | button3.rise(&button3_pressed); |
Kemp | 0:ba602786a4c1 | 24 | |
Kemp | 0:ba602786a4c1 | 25 | while (1); |
Kemp | 0:ba602786a4c1 | 26 | } |