From eb7fc13fa01b1c8a89d9b2fe9cc6b57fd5cf9db5 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 2 Dec 2021 16:32:20 +0100 Subject: [PATCH] Let the button disable blinking --- main.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 491cd90..f198995 100644 --- a/main.c +++ b/main.c @@ -95,12 +95,9 @@ void exti0_isr (void) { // NB: For some reason it is at the begining in the examples // It needs to be here (possibly because of reordering, when this was at the end, I usually got the interrupt twice). - if (!running) { - direction = FORWARD; - } else { - direction = direction == FORWARD ? BACKWARD : FORWARD; - } - running = true; + // Toggle TIM6 in order to disable blinking + // Code inspired by libopencm3 source, since we cannot read the status otherwise… + TIM_CR1(TIM6) ^= TIM_CR1_CEN; } void tim6_isr (void) {