Copy 1
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 #include "SwitchManager.hpp" 00003 00004 #define N 1000000 00005 #define RELEASED 0 00006 #define PRESSED 1 00007 00008 //Function prototypes 00009 void isr1(); 00010 void isr2(); 00011 void isrTick(); 00012 00013 //Hardware objects 00014 DigitalOut red_led(PE_15); //CountUp is in its critical section 00015 DigitalOut yellow_led(PB_10); //CountDown is in its critical section 00016 DigitalOut green_led(PB_11); //counter != 0 00017 DigitalOut onboardLED(LED1); 00018 00019 InterruptIn sw1(PE_12); 00020 InterruptIn sw2(PE_14); 00021 Ticker yellowTick; 00022 00023 void toggleYellowISR() { 00024 yellow_led = !yellow_led; 00025 } 00026 00027 int main() { 00028 00029 //Light up 00030 red_led = 1; 00031 yellow_led = 1; 00032 green_led = 1; 00033 onboardLED = 0; 00034 00035 //Interrupt controlled red led using sw1 00036 SwitchManager sm1(sw1, red_led); 00037 00038 //Interrupt controlled red led using sw2 00039 SwitchManager sm2(sw2, green_led); 00040 00041 //Simple ticker 00042 yellowTick.attach(&toggleYellowISR, 0.5); 00043 00044 //Now loop forever 00045 while(1) { 00046 sleep(); 00047 }; 00048 } 00049 00050
Generated on Sat Aug 6 2022 10:24:05 by 1.7.2