From 69b878b1c848b4e1b56983b8967b500dcfba5ece Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 5 Apr 2021 15:05:23 +1000 Subject: [PATCH] Organise main tasks into order of priority --- source/Core/Src/main.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/source/Core/Src/main.cpp b/source/Core/Src/main.cpp index dc881a60..1f3c2875 100644 --- a/source/Core/Src/main.cpp +++ b/source/Core/Src/main.cpp @@ -4,14 +4,11 @@ * Main.cpp bootstraps the device and then hands over to FreeRTOS and the threads */ +#include "main.hpp" #include "BSP.h" -#include "LIS2DH12.hpp" #include "Settings.h" #include "cmsis_os.h" -#include -#include -#include -#include +#include "power.hpp" uint8_t DetectedAccelerometerVersion = 0; bool settingsWereReset = false; // FreeRTOS variables @@ -46,28 +43,25 @@ int main(void) { settingsWereReset = restoreSettings(); // load the settings from flash resetWatchdog(); /* Create the thread(s) */ - /* definition and creation of POWTask - Power management for QC */ - osThreadStaticDef(POWTask, startPOWTask, osPriorityAboveNormal, 0, POWTaskStackSize, POWTaskBuffer, &POWTaskControlBlock); - POWTaskHandle = osThreadCreate(osThread(POWTask), NULL); - - /* definition and creation of GUITask - The OLED control & update*/ - osThreadStaticDef(GUITask, startGUITask, osPriorityBelowNormal, 0, GUITaskStackSize, GUITaskBuffer, &GUITaskControlBlock); - GUITaskHandle = osThreadCreate(osThread(GUITask), NULL); /* definition and creation of PIDTask - Heating control*/ osThreadStaticDef(PIDTask, startPIDTask, osPriorityRealtime, 0, PIDTaskStackSize, PIDTaskBuffer, &PIDTaskControlBlock); PIDTaskHandle = osThreadCreate(osThread(PIDTask), NULL); + /* definition and creation of POWTask - Power management for QC */ + osThreadStaticDef(POWTask, startPOWTask, osPriorityAboveNormal, 0, POWTaskStackSize, POWTaskBuffer, &POWTaskControlBlock); + POWTaskHandle = osThreadCreate(osThread(POWTask), NULL); + /* definition and creation of MOVTask - Accelerometer management */ osThreadStaticDef(MOVTask, startMOVTask, osPriorityNormal, 0, MOVTaskStackSize, MOVTaskBuffer, &MOVTaskControlBlock); MOVTaskHandle = osThreadCreate(osThread(MOVTask), NULL); + + /* definition and creation of GUITask - The OLED control & update*/ + osThreadStaticDef(GUITask, startGUITask, osPriorityBelowNormal, 0, GUITaskStackSize, GUITaskBuffer, &GUITaskControlBlock); + GUITaskHandle = osThreadCreate(osThread(GUITask), NULL); + resetWatchdog(); -#ifdef POW_PD - if (usb_pd_detect() == true) { - // Spawn all of the USB-C processors - fusb302_start_processing(); - } -#endif + /* Start scheduler */ osKernelStart(); /* We should never get here as control is now taken by the scheduler */