Solution to the blocking task - do not expect this to work well however!
Fork of Task330_blocking by
main.cpp
- Committer:
- noutram
- Date:
- 2019-09-18
- Revision:
- 6:2050203fd22b
- Parent:
- 5:a9a9d3b7f62a
File content as of revision 6:2050203fd22b:
#include "mbed.h"
#define N 1000000
#define RELEASED 0
#define PRESSED 1
#include "demo-self-test.hpp"
//Hardware objects
DigitalOut red_led(PE_15); //CountUp is in its critical section
DigitalOut yellow_led(PB_10); //CountDown is in its critical section
DigitalOut green_led(PB_11); //counter != 0
DigitalOut onboardLED(LED1);
DigitalIn button(USER_BUTTON);
DigitalIn sw1(PE_12);
DigitalIn sw2(PE_14);
//The code below is hugely flawed and is only to
//illustrate the problem of blocking hardware
int main() {
//Power On Self Test (POST)
POST();
//Now loop forever
while(1) {
while (sw1 == RELEASED) {};
wait(0.2);
while (sw1 == PRESSED) {};
red_led = !red_led;
wait(0.2);
while (sw2 == RELEASED) {};
wait(0.2);
while (sw2 == PRESSED) {};
green_led = !green_led;
wait(0.2);
//Flash the yellow
yellow_led = !yellow_led;
wait(0.5);
};
}
