Diff: main.cpp
- Revision:
- 3:9a3c6c16dc25
- Parent:
- 0:24ccc6d0c391
--- a/main.cpp Tue Oct 10 15:13:26 2017 +0000 +++ b/main.cpp Thu Sep 12 13:56:16 2019 +0000 @@ -4,23 +4,34 @@ // However, pressing and releasing the switch can result in spurious falling edges // which trigger the routine +//Uncomment this if you want to use the onboard LEDs and Blue Switch on a F429ZI +//#define USEONBOARD + //Declare functions void sw1FallingEdge(); //Global Objects +#ifdef USEONBOARD +DigitalOut red_led(LED3); +DigitalOut green_led(LED1); +InterruptIn sw1(USER_BUTTON); +#else DigitalOut red_led(D7); DigitalOut green_led(D5); -InterruptIn sw1(D4); +InterruptIn sw1(D4); +#endif //Interrupt service routine for a rising edge (press) void sw1FallingEdge() { red_led = !red_led; //Toggle the LED } +Serial pc(USBTX, USBRX); + //Main - only has to initialise and sleep int main() { - //Initial logging message - puts("START"); + + pc.set_blocking(true); red_led = 0; green_led = 1; @@ -34,7 +45,10 @@ sleep(); //You can ONLY reach this point if an ISR wakes the CPU - puts("ISR just woke the MPU"); + green_led = !green_led; + + //Any use of the serial port will produce a series of interrupts + //pc.puts("Ping!\n\r"); } //end while