From 5603d5323930de347d0cb0f2f3439ab5f5c1defe Mon Sep 17 00:00:00 2001 From: LEdoianX Date: Thu, 14 Apr 2016 13:14:16 +0200 Subject: [PATCH] Wait for button press at beginning Bonus: added a FIXME to non-working code --- main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index b298553..cf66351 100644 --- a/main.c +++ b/main.c @@ -33,10 +33,13 @@ void inline wait (int ticks) { // This works in libopenocm3 examples int main (void) { setup(); + gpio_unset(GPIOC, GPIO8 | GPIO9); + while (gpio_get(GPIOA, GPIO0) == 0); + // Array of what leds should be on uint16_t states[4] = {0, GPIO9, GPIO8, GPIO9 | GPIO8}; enum {FORWARD, BACKWARD} direction = FORWARD; - bool pressed = false; + bool pressed = true; char state; while (true) { @@ -48,7 +51,7 @@ int main (void) { } state = (direction == FORWARD ? (state + 1)%4 : (/*state+4-1*/ state+3)%4 ); - gpio_set(GPIOC, states[state]); + gpio_set(GPIOC, states[state]); //FIXME: This doesn't work, as it does not write 0s to unmentioned pins!! wait(DELAY); } return 0;