From ac11732a869f57be1280938ab44acfaa0294e2b4 Mon Sep 17 00:00:00 2001 From: JOhn Aughey Date: Thu, 28 Apr 2016 12:58:37 -0500 Subject: [PATCH] Separate the initialization and main step into two different functions. For testing, it is useful to have the loop be separated from the initialization so that an external function can step through the main loop. --- src/main/main.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/main.c b/src/main/main.c index 49fc7c2466..56e9077d4e 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -26,7 +26,6 @@ #include "common/axis.h" #include "common/color.h" -#include "common/atomic.h" #include "common/maths.h" #include "drivers/nvic.h" @@ -658,7 +657,7 @@ void processLoopback(void) { #define processLoopback() #endif -int main(void) { +void main_init(void) { init(); /* Setup scheduler */ @@ -729,12 +728,22 @@ int main(void) { #ifdef USE_BST setTaskEnabled(TASK_BST_MASTER_PROCESS, true); #endif +} - while (1) { - scheduler(); - processLoopback(); +void main_step(void) { + scheduler(); + processLoopback(); +} + +#ifndef NOMAIN +int main(void) +{ + main_init(); + while(1) { + main_step(); } } +#endif #ifdef DEBUG_HARDFAULTS //from: https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/