Gernot Mörtl
/
3CHEL_Interrupts
IRQ Demo
Revision 0:96fb278b654f, committed 2019-05-23
- Comitter:
- gmoertl
- Date:
- Thu May 23 06:25:18 2019 +0000
- Commit message:
- IRQ Demo
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 96fb278b654f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 23 06:25:18 2019 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" + +InterruptIn fireIrq(p14); +Timeout timeoutIrq; + +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +Serial pc(USBTX, USBRX); + + +// funktion runs in interrupt-context +void fireIrqHandler( void ) +{ + led1 = !led1; + pc.printf("Starting up...\n\r"); +} + +// runs in irq-context +void timeoutIrqHandler( void ) +{ + led2 = 0; +} + +int main() +{ + pc.printf("Starting up...\n\r"); + + fireIrq.fall( &fireIrqHandler ); + fireIrq.rise( &fireIrqHandler ); + + led2 = 1; + timeoutIrq.attach( &timeoutIrqHandler, 3 ); + + while(1) { + wait(5); + } +} \ No newline at end of file
diff -r 000000000000 -r 96fb278b654f mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu May 23 06:25:18 2019 +0000 @@ -0,0 +1,1 @@ +https://github.com/armmbed/mbed-os/#a8e5a4cb0f4facb615c32306d9b509aec07a0b5a