From 5aaed41cac7933e54cabecd76db0450ca511183e Mon Sep 17 00:00:00 2001 From: Rob Riggs Date: Sun, 20 Oct 2019 15:31:53 -0500 Subject: [PATCH] Fix modulator configuration issue when running without battery. Update version to 1.1.5. --- Inc/main.h | 2 ++ Src/main.c | 5 +++++ TNC/IOEventTask.cpp | 3 +++ TNC/KissHardware.cpp | 2 +- TNC/ModulatorTask.cpp | 4 ++++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Inc/main.h b/Inc/main.h index 7ef18bd..66e94aa 100644 --- a/Inc/main.h +++ b/Inc/main.h @@ -55,6 +55,7 @@ /* USER CODE BEGIN Includes */ #include +#include /* USER CODE END Includes */ /* Private define ------------------------------------------------------------*/ @@ -163,6 +164,7 @@ extern int go_back_to_sleep; extern int usb_wake_state; extern int charging_enabled; extern int reset_button; +extern osMutexId hardwareInitMutexHandle; #define CxxErrorHandler() _Error_Handler(const_cast(__FILE__), __LINE__) diff --git a/Src/main.c b/Src/main.c index 56a97e2..5b65f58 100644 --- a/Src/main.c +++ b/Src/main.c @@ -144,6 +144,7 @@ osStaticTimerDef_t usbShutdownTimerControlBlock; /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ +osMutexId hardwareInitMutexHandle; int lost_power = 0; int reset_requested = 0; @@ -501,6 +502,10 @@ int main(void) /* USER CODE BEGIN RTOS_MUTEX */ /* add mutexes, ... */ + osMutexDef(hardwareInitMutex); + hardwareInitMutexHandle = osMutexCreate(osMutex(hardwareInitMutex)); + osMutexWait(hardwareInitMutexHandle, osWaitForever); + /* USER CODE END RTOS_MUTEX */ /* USER CODE BEGIN RTOS_SEMAPHORES */ diff --git a/TNC/IOEventTask.cpp b/TNC/IOEventTask.cpp index 2c9e242..148fafc 100644 --- a/TNC/IOEventTask.cpp +++ b/TNC/IOEventTask.cpp @@ -61,7 +61,10 @@ void startIOEventTask(void const*) hardware.store(); } + osMutexRelease(hardwareInitMutexHandle); + if (!go_back_to_sleep) { + hardware.debug(); audio::init_log_volume(); diff --git a/TNC/KissHardware.cpp b/TNC/KissHardware.cpp index 1328a22..c4296d6 100644 --- a/TNC/KissHardware.cpp +++ b/TNC/KissHardware.cpp @@ -26,7 +26,7 @@ int powerOffViaUSB(void) namespace mobilinkd { namespace tnc { namespace kiss { -const char FIRMWARE_VERSION[] = "1.1.4"; +const char FIRMWARE_VERSION[] = "1.1.5"; const char HARDWARE_VERSION[] = "Mobilinkd TNC3 2.1.1"; Hardware& settings() diff --git a/TNC/ModulatorTask.cpp b/TNC/ModulatorTask.cpp index 8dff187..286a52f 100644 --- a/TNC/ModulatorTask.cpp +++ b/TNC/ModulatorTask.cpp @@ -3,6 +3,7 @@ #include "ModulatorTask.hpp" #include "KissHardware.hpp" +#include "main.h" mobilinkd::tnc::SimplexPTT simplexPtt; mobilinkd::tnc::MultiplexPTT multiplexPtt; @@ -69,6 +70,9 @@ void startModulatorTask(void const*) { using namespace mobilinkd::tnc::kiss; + // Wait until hardware is initialized before creating modulator. + osMutexWait(hardwareInitMutexHandle, osWaitForever); + modulator = &(getModulator()); encoder = &(getEncoder());