Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
libraries/tests/mbed/interruptin_2/main.cpp@1:d96dbedaebdb, 2016-11-04 (annotated)
- Committer:
- nexpaq
- Date:
- Fri Nov 04 20:54:50 2016 +0000
- Revision:
- 1:d96dbedaebdb
- Parent:
- 0:6c56fb4bc5f0
Removed extra directories for other platforms
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nexpaq | 0:6c56fb4bc5f0 | 1 | #include "mbed.h" |
| nexpaq | 0:6c56fb4bc5f0 | 2 | |
| nexpaq | 0:6c56fb4bc5f0 | 3 | #if !DEVICE_INTERRUPTIN |
| nexpaq | 0:6c56fb4bc5f0 | 4 | #error [NOT_SUPPORTED] InterruptIn is not supported |
| nexpaq | 0:6c56fb4bc5f0 | 5 | #endif |
| nexpaq | 0:6c56fb4bc5f0 | 6 | |
| nexpaq | 0:6c56fb4bc5f0 | 7 | #if defined(TARGET_LPC4088) |
| nexpaq | 0:6c56fb4bc5f0 | 8 | InterruptIn button(p18); |
| nexpaq | 0:6c56fb4bc5f0 | 9 | InterruptIn button1(p17); |
| nexpaq | 0:6c56fb4bc5f0 | 10 | InterruptIn button2(p16); |
| nexpaq | 0:6c56fb4bc5f0 | 11 | InterruptIn button3(p15); |
| nexpaq | 0:6c56fb4bc5f0 | 12 | InterruptIn button4(p14); |
| nexpaq | 0:6c56fb4bc5f0 | 13 | InterruptIn button5(p13); |
| nexpaq | 0:6c56fb4bc5f0 | 14 | InterruptIn button6(p12); |
| nexpaq | 0:6c56fb4bc5f0 | 15 | InterruptIn button7(p11); |
| nexpaq | 0:6c56fb4bc5f0 | 16 | InterruptIn button8(p10); |
| nexpaq | 0:6c56fb4bc5f0 | 17 | InterruptIn button9(p9); |
| nexpaq | 0:6c56fb4bc5f0 | 18 | DigitalOut led(LED1); |
| nexpaq | 0:6c56fb4bc5f0 | 19 | DigitalOut flash(LED4); |
| nexpaq | 0:6c56fb4bc5f0 | 20 | |
| nexpaq | 0:6c56fb4bc5f0 | 21 | #elif defined(TARGET_LPC1114) |
| nexpaq | 0:6c56fb4bc5f0 | 22 | InterruptIn button(p30); // SW2 (User switch) |
| nexpaq | 0:6c56fb4bc5f0 | 23 | InterruptIn button1(p5); |
| nexpaq | 0:6c56fb4bc5f0 | 24 | InterruptIn button2(p6); |
| nexpaq | 0:6c56fb4bc5f0 | 25 | InterruptIn button3(p7); |
| nexpaq | 0:6c56fb4bc5f0 | 26 | InterruptIn button4(p9); |
| nexpaq | 0:6c56fb4bc5f0 | 27 | InterruptIn button5(p10); |
| nexpaq | 0:6c56fb4bc5f0 | 28 | InterruptIn button6(p12); |
| nexpaq | 0:6c56fb4bc5f0 | 29 | InterruptIn button7(p13); |
| nexpaq | 0:6c56fb4bc5f0 | 30 | InterruptIn button8(p14); |
| nexpaq | 0:6c56fb4bc5f0 | 31 | InterruptIn button9(p15); |
| nexpaq | 0:6c56fb4bc5f0 | 32 | DigitalOut led(LED1); |
| nexpaq | 0:6c56fb4bc5f0 | 33 | DigitalOut flash(LED2); |
| nexpaq | 0:6c56fb4bc5f0 | 34 | |
| nexpaq | 0:6c56fb4bc5f0 | 35 | #elif defined(TARGET_SAMR21G18A) |
| nexpaq | 0:6c56fb4bc5f0 | 36 | InterruptIn button (PA28); /*SW0*/ |
| nexpaq | 0:6c56fb4bc5f0 | 37 | InterruptIn button1(PA06); |
| nexpaq | 0:6c56fb4bc5f0 | 38 | InterruptIn button2(PA07); |
| nexpaq | 0:6c56fb4bc5f0 | 39 | InterruptIn button3(PB03); |
| nexpaq | 0:6c56fb4bc5f0 | 40 | InterruptIn button4(PA16); |
| nexpaq | 0:6c56fb4bc5f0 | 41 | InterruptIn button5(PA17); |
| nexpaq | 0:6c56fb4bc5f0 | 42 | InterruptIn button6(PA05); |
| nexpaq | 0:6c56fb4bc5f0 | 43 | InterruptIn button7(PA04); |
| nexpaq | 0:6c56fb4bc5f0 | 44 | InterruptIn button8(PA14); |
| nexpaq | 0:6c56fb4bc5f0 | 45 | InterruptIn button9(PA15); |
| nexpaq | 0:6c56fb4bc5f0 | 46 | DigitalOut led(LED1); |
| nexpaq | 0:6c56fb4bc5f0 | 47 | DigitalOut flash(PA22); /*1 LED Available*/ |
| nexpaq | 0:6c56fb4bc5f0 | 48 | |
| nexpaq | 0:6c56fb4bc5f0 | 49 | #elif defined(TARGET_SAMD21J18A) |
| nexpaq | 0:6c56fb4bc5f0 | 50 | InterruptIn button (PA15); /*SW0*/ |
| nexpaq | 0:6c56fb4bc5f0 | 51 | InterruptIn button1(PA16); |
| nexpaq | 0:6c56fb4bc5f0 | 52 | InterruptIn button2(PB01); |
| nexpaq | 0:6c56fb4bc5f0 | 53 | InterruptIn button3(PA18); |
| nexpaq | 0:6c56fb4bc5f0 | 54 | InterruptIn button4(PA03); |
| nexpaq | 0:6c56fb4bc5f0 | 55 | InterruptIn button5(PA04); |
| nexpaq | 0:6c56fb4bc5f0 | 56 | InterruptIn button6(PA05); |
| nexpaq | 0:6c56fb4bc5f0 | 57 | InterruptIn button7(PA06); |
| nexpaq | 0:6c56fb4bc5f0 | 58 | InterruptIn button8(PA07); |
| nexpaq | 0:6c56fb4bc5f0 | 59 | InterruptIn button9(PA28); |
| nexpaq | 0:6c56fb4bc5f0 | 60 | DigitalOut led(LED1); |
| nexpaq | 0:6c56fb4bc5f0 | 61 | DigitalOut flash(PA27); /*1 LED Available*/ |
| nexpaq | 0:6c56fb4bc5f0 | 62 | |
| nexpaq | 0:6c56fb4bc5f0 | 63 | #elif defined(TARGET_SAMD21G18A) |
| nexpaq | 0:6c56fb4bc5f0 | 64 | InterruptIn button (PB23); /*SW0*/ |
| nexpaq | 0:6c56fb4bc5f0 | 65 | InterruptIn button1(PA02); |
| nexpaq | 0:6c56fb4bc5f0 | 66 | InterruptIn button2(PA03); |
| nexpaq | 0:6c56fb4bc5f0 | 67 | InterruptIn button3(PA10); |
| nexpaq | 0:6c56fb4bc5f0 | 68 | InterruptIn button4(PA11); |
| nexpaq | 0:6c56fb4bc5f0 | 69 | InterruptIn button5(PA20); |
| nexpaq | 0:6c56fb4bc5f0 | 70 | InterruptIn button6(PA21); |
| nexpaq | 0:6c56fb4bc5f0 | 71 | InterruptIn button7(PA09); |
| nexpaq | 0:6c56fb4bc5f0 | 72 | InterruptIn button8(PA16); |
| nexpaq | 0:6c56fb4bc5f0 | 73 | InterruptIn button9(PA17); |
| nexpaq | 0:6c56fb4bc5f0 | 74 | DigitalOut led(LED1); |
| nexpaq | 0:6c56fb4bc5f0 | 75 | DigitalOut flash(PA19); /*1 LED Available*/ |
| nexpaq | 0:6c56fb4bc5f0 | 76 | |
| nexpaq | 0:6c56fb4bc5f0 | 77 | #elif defined(TARGET_SAML21J18A) |
| nexpaq | 0:6c56fb4bc5f0 | 78 | InterruptIn button (PA02); /*SW0*/ |
| nexpaq | 0:6c56fb4bc5f0 | 79 | InterruptIn button1(PA16); |
| nexpaq | 0:6c56fb4bc5f0 | 80 | InterruptIn button2(PA17); |
| nexpaq | 0:6c56fb4bc5f0 | 81 | InterruptIn button3(PA15); |
| nexpaq | 0:6c56fb4bc5f0 | 82 | InterruptIn button4(PA19); |
| nexpaq | 0:6c56fb4bc5f0 | 83 | InterruptIn button5(PA04); |
| nexpaq | 0:6c56fb4bc5f0 | 84 | InterruptIn button6(PA05); |
| nexpaq | 0:6c56fb4bc5f0 | 85 | InterruptIn button7(PA06); |
| nexpaq | 0:6c56fb4bc5f0 | 86 | InterruptIn button8(PA07); |
| nexpaq | 0:6c56fb4bc5f0 | 87 | InterruptIn button9(PB08); |
| nexpaq | 0:6c56fb4bc5f0 | 88 | DigitalOut led(LED1); |
| nexpaq | 0:6c56fb4bc5f0 | 89 | DigitalOut flash(PA27); /*1 LED Available*/ |
| nexpaq | 0:6c56fb4bc5f0 | 90 | |
| nexpaq | 0:6c56fb4bc5f0 | 91 | #elif defined(TARGET_SAMG55J19) |
| nexpaq | 0:6c56fb4bc5f0 | 92 | InterruptIn button (PA02); /*SW0*/ |
| nexpaq | 0:6c56fb4bc5f0 | 93 | InterruptIn button1(PA17); |
| nexpaq | 0:6c56fb4bc5f0 | 94 | InterruptIn button2(PA26); |
| nexpaq | 0:6c56fb4bc5f0 | 95 | InterruptIn button3(PA25); |
| nexpaq | 0:6c56fb4bc5f0 | 96 | InterruptIn button4(PA00); |
| nexpaq | 0:6c56fb4bc5f0 | 97 | InterruptIn button5(PA23); |
| nexpaq | 0:6c56fb4bc5f0 | 98 | InterruptIn button6(PA24); |
| nexpaq | 0:6c56fb4bc5f0 | 99 | InterruptIn button7(PA29); |
| nexpaq | 0:6c56fb4bc5f0 | 100 | InterruptIn button8(PB10); |
| nexpaq | 0:6c56fb4bc5f0 | 101 | InterruptIn button9(PA10); |
| nexpaq | 0:6c56fb4bc5f0 | 102 | DigitalOut led(LED1); |
| nexpaq | 0:6c56fb4bc5f0 | 103 | DigitalOut flash(PA14); /*1 LED Available*/ |
| nexpaq | 0:6c56fb4bc5f0 | 104 | |
| nexpaq | 0:6c56fb4bc5f0 | 105 | #else |
| nexpaq | 0:6c56fb4bc5f0 | 106 | InterruptIn button(p30); |
| nexpaq | 0:6c56fb4bc5f0 | 107 | InterruptIn button1(p29); |
| nexpaq | 0:6c56fb4bc5f0 | 108 | InterruptIn button2(p28); |
| nexpaq | 0:6c56fb4bc5f0 | 109 | InterruptIn button3(p27); |
| nexpaq | 0:6c56fb4bc5f0 | 110 | InterruptIn button4(p26); |
| nexpaq | 0:6c56fb4bc5f0 | 111 | InterruptIn button5(p25); |
| nexpaq | 0:6c56fb4bc5f0 | 112 | InterruptIn button6(p24); |
| nexpaq | 0:6c56fb4bc5f0 | 113 | InterruptIn button7(p23); |
| nexpaq | 0:6c56fb4bc5f0 | 114 | InterruptIn button8(p22); |
| nexpaq | 0:6c56fb4bc5f0 | 115 | InterruptIn button9(p21); |
| nexpaq | 0:6c56fb4bc5f0 | 116 | DigitalOut led(LED1); |
| nexpaq | 0:6c56fb4bc5f0 | 117 | DigitalOut flash(LED4); |
| nexpaq | 0:6c56fb4bc5f0 | 118 | #endif |
| nexpaq | 0:6c56fb4bc5f0 | 119 | |
| nexpaq | 0:6c56fb4bc5f0 | 120 | void flip() { |
| nexpaq | 0:6c56fb4bc5f0 | 121 | led = !led; |
| nexpaq | 0:6c56fb4bc5f0 | 122 | } |
| nexpaq | 0:6c56fb4bc5f0 | 123 | |
| nexpaq | 0:6c56fb4bc5f0 | 124 | int main() { |
| nexpaq | 0:6c56fb4bc5f0 | 125 | flash = 0; |
| nexpaq | 0:6c56fb4bc5f0 | 126 | led = 0; |
| nexpaq | 0:6c56fb4bc5f0 | 127 | #if defined(TARGET_LPC1114) |
| nexpaq | 0:6c56fb4bc5f0 | 128 | button.mode(PullUp); |
| nexpaq | 0:6c56fb4bc5f0 | 129 | #endif |
| nexpaq | 0:6c56fb4bc5f0 | 130 | button.rise(&flip); // attach the address of the flip function to the rising edge |
| nexpaq | 0:6c56fb4bc5f0 | 131 | button1.rise(&flip); |
| nexpaq | 0:6c56fb4bc5f0 | 132 | button2.rise(&flip); |
| nexpaq | 0:6c56fb4bc5f0 | 133 | button3.rise(&flip); |
| nexpaq | 0:6c56fb4bc5f0 | 134 | button4.rise(&flip); |
| nexpaq | 0:6c56fb4bc5f0 | 135 | button5.rise(&flip); |
| nexpaq | 0:6c56fb4bc5f0 | 136 | button6.rise(&flip); |
| nexpaq | 0:6c56fb4bc5f0 | 137 | button7.rise(&flip); |
| nexpaq | 0:6c56fb4bc5f0 | 138 | button8.rise(&flip); |
| nexpaq | 0:6c56fb4bc5f0 | 139 | button9.rise(&flip); |
| nexpaq | 0:6c56fb4bc5f0 | 140 | |
| nexpaq | 0:6c56fb4bc5f0 | 141 | while(1) { // wait around, interrupts will interrupt this! |
| nexpaq | 0:6c56fb4bc5f0 | 142 | flash = !flash; |
| nexpaq | 0:6c56fb4bc5f0 | 143 | wait(0.25); |
| nexpaq | 0:6c56fb4bc5f0 | 144 | } |
| nexpaq | 0:6c56fb4bc5f0 | 145 | } |