fix: Various issues related to IMU sensor (#3171)

* fix(imu): reset error counter on successful IMU query

Please note that the HAL already handles busy I2C bus, so that we should not run into the case where the bus is used and another query is started. However, if that happens, HAL_BUSY will be returned, which leads to -1 being returned in our functions, thus increasing the error count until the sensor stops working.

* fix(imu): move imu init into mixer task

Fixes a race condition between init and use.
This commit is contained in:
Raphael Coeffic
2023-02-15 16:05:39 +10:00
committed by GitHub
parent 3695930242
commit bf23791fdf
3 changed files with 9 additions and 4 deletions
+5
View File
@@ -54,6 +54,11 @@ void Gyro::wakeup()
return;
}
// reset error count on each
// successful query to avoid
// stopping the sensor forever
errors = 0;
int16_t gx = values[0];
int16_t gy = values[1];
// int16_t gz = values[2];
-4
View File
@@ -56,10 +56,6 @@ TASK_FUNCTION(menusTask)
touchPanelInit();
#endif
#if defined(IMU)
gyroInit();
#endif
opentxInit();
#if defined(PWR_BUTTON_PRESS)
+4
View File
@@ -133,6 +133,10 @@ void execMixerFrequentActions()
TASK_FUNCTION(mixerTask)
{
#if defined(IMU)
gyroInit();
#endif
mixerSchedulerInit();
mixerSchedulerStart();