From 5fed925b7fd34f9480dc5359327b8414ebcb0222 Mon Sep 17 00:00:00 2001 From: Hector van der Aa Date: Wed, 3 Jun 2026 11:48:40 +0200 Subject: [PATCH] Updated crank to use macros --- STM32/CM7/Core/Src/tasks/crank.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/STM32/CM7/Core/Src/tasks/crank.c b/STM32/CM7/Core/Src/tasks/crank.c index 36345b8..1ed9823 100644 --- a/STM32/CM7/Core/Src/tasks/crank.c +++ b/STM32/CM7/Core/Src/tasks/crank.c @@ -60,13 +60,10 @@ void crankHandler(void *argument) { if (state_g.crank_state == CYCLE_COMPRESSION && state_g.sync_state == SYNC_OK) { DEBUG_LOG("Spark schedule reached, congrats\n\r"); - uint32_t t_now = ringBufferRead(&state_g.crank_RB, 0); - uint32_t t_prev = ringBufferRead(&state_g.crank_RB, 1); - - uint32_t d1a = t_now - t_prev; + uint32_t d1a = CRANK(0) - CRANK(1); // TODO: Map interpolation rather than SPARK_ADVANCE CONSTANT uint32_t d_spark = d1a * (45 - SPARK_ADVANCE) / 180; - uint32_t t_spark = t_now + d_spark; + uint32_t t_spark = CRANK(0) + d_spark; // TODO: schedule spark } }