Vishal Kotcherlakota
/
event_source
A simple program that triggers a GPIO rise/fall event when data arrives on the virtual COM port via USB.
main.cpp
- Committer:
- dishbreak
- Date:
- 2015-06-17
- Revision:
- 0:a46083c93e2b
File content as of revision 0:a46083c93e2b:
#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); } }