
Updated
Dependencies: mbed
Revision 0:24ccc6d0c391, committed 2016-03-09
- Comitter:
- noutram
- Date:
- Wed Mar 09 11:56:33 2016 +0000
- Commit message:
- Read for lab
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 24ccc6d0c391 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 09 11:56:33 2016 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" + +// This uses INTERRUPTS to detect a falling edge of the switch input +// However, pressing and releasing the switch can result in spurious falling edges +// which trigger the routine + +//Declare functions +void sw1FallingEdge(); + +//Global Objects +DigitalOut red_led(D7); +DigitalOut green_led(D5); +InterruptIn sw1(D4); + +//Interrupt service routine for a rising edge (press) +void sw1FallingEdge() { + red_led = !red_led; //Toggle the LED +} + +//Main - only has to initialise and sleep +int main() { + //Initial logging message + puts("START"); + red_led = 0; + green_led = 1; + + //Configure interrupts, wait for first rising edge + sw1.fall(&sw1FallingEdge); + + //Main Polling Loop + while (true) { + + //Put CPU back to sleep + sleep(); + + //You can ONLY reach this point if an ISR wakes the CPU + puts("ISR just woke the MPU"); + + } //end while + +}
diff -r 000000000000 -r 24ccc6d0c391 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 09 11:56:33 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3 \ No newline at end of file