From 25aee6b661ea239cd9a0b7e92fefc4429e780cd6 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Mon, 15 Jun 2020 15:46:42 +0300 Subject: [PATCH] Move I2CSemaphore creation outside postRToSInit The code assumes that whenever scheduler is running I2CSemaphore is available. Initialising it in a task might lead to race conditions and is also not happening at all if the task is disabled (for debugging or due to lack of need for a particular usecase). The race condition can't happen with the current code though, as GUI task has lower priority than the MOV task, and they're the only tasks that currently use I2C. However, this might change in the future with the code refactoring or introduction of new features. --- workspace/TS100/Core/BSP/Miniware/postRTOS.cpp | 4 ++-- workspace/TS100/Core/Src/main.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/workspace/TS100/Core/BSP/Miniware/postRTOS.cpp b/workspace/TS100/Core/BSP/Miniware/postRTOS.cpp index fa55ab11..e8a78a1d 100644 --- a/workspace/TS100/Core/BSP/Miniware/postRTOS.cpp +++ b/workspace/TS100/Core/BSP/Miniware/postRTOS.cpp @@ -9,9 +9,9 @@ #include "task.h" #include "I2C_Wrapper.hpp" #include "fusbpd.h" + +// Initialisation to be performed with scheduler active void postRToSInit() { - // Any after RTos setup - FRToSI2C::FRToSInit(); #ifdef POW_PD //Spawn all of the USB-C processors fusb302_start_processing(); diff --git a/workspace/TS100/Core/Src/main.cpp b/workspace/TS100/Core/Src/main.cpp index 89d2bc45..ed4e7637 100644 --- a/workspace/TS100/Core/Src/main.cpp +++ b/workspace/TS100/Core/Src/main.cpp @@ -85,6 +85,9 @@ int main(void) { resetWatchdog(); + /* Init the IPC objects */ + FRToSI2C::FRToSInit(); + /* Start scheduler */ osKernelStart(); /* We should never get here as control is now taken by the scheduler */