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.
This commit is contained in:
Paul Fertser
2020-06-15 15:46:42 +03:00
parent c1dd88ba53
commit 25aee6b661
2 changed files with 5 additions and 2 deletions

View File

@@ -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();

View File

@@ -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 */