Vishal Kotcherlakota
/
event_source
A simple program that triggers a GPIO rise/fall event when data arrives on the virtual COM port via USB.
Revision 0:a46083c93e2b, committed 2015-06-17
- Comitter:
- dishbreak
- Date:
- Wed Jun 17 22:47:01 2015 +0000
- Commit message:
- Initial commit
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 a46083c93e2b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jun 17 22:47:01 2015 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" + +InterruptIn button(p28); +DigitalOut led(LED1); +DigitalOut flash(LED4); +DigitalOut sigPin(p18); +Serial pc(USBTX, USBRX); + +void led_on() { + led = !led; +} + +void led_off() { + led = 0; +} + +void on_pc_rcv() { + pc.getc(); + led = 1; + sigPin = 1; + wait(0.25); + sigPin = 0; + led = 0; +} + +int main() { + pc.attach(&on_pc_rcv); + button.rise(&led_on); + button.fall(&led_off); + while(1) { // wait around, interrupts will interrupt this! + flash = !flash; + wait(0.25); + } +} \ No newline at end of file
diff -r 000000000000 -r a46083c93e2b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jun 17 22:47:01 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file