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:
@@ -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];
|
||||
|
||||
@@ -56,10 +56,6 @@ TASK_FUNCTION(menusTask)
|
||||
touchPanelInit();
|
||||
#endif
|
||||
|
||||
#if defined(IMU)
|
||||
gyroInit();
|
||||
#endif
|
||||
|
||||
opentxInit();
|
||||
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
|
||||
@@ -133,6 +133,10 @@ void execMixerFrequentActions()
|
||||
|
||||
TASK_FUNCTION(mixerTask)
|
||||
{
|
||||
#if defined(IMU)
|
||||
gyroInit();
|
||||
#endif
|
||||
|
||||
mixerSchedulerInit();
|
||||
mixerSchedulerStart();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user