Skip to content

Commit

Permalink
Merge pull request #1432 from bitcraze/tobba/stabilizer_passthrough_fix
Browse files Browse the repository at this point in the history
Fix stabilizer locked assert when passthrough interface is active
  • Loading branch information
ToveRumar authored Nov 6, 2024
2 parents 200db5d + 5fe241d commit b046745
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/hal/interface/sensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ bool sensorsReadBaro(baro_t *baro);
void sensorsSuspend();
void sensorsResume();

/**
* Check if sensors are suspended (sensor interrupts disabled)
* @return true if they are, else false
*/
bool isSensorsSuspended();
/**
* Set acc mode, one of accModes enum
*/
Expand Down
7 changes: 7 additions & 0 deletions src/hal/src/sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ static const sensorsImplementation_t sensorImplementations[SensorImplementation_
static const sensorsImplementation_t* activeImplementation;
static bool isInit = false;
static const sensorsImplementation_t* findImplementation(SensorImplementation_t implementation);
static bool sensorsSuspended = false;

void sensorsInit(void) {
if (isInit) {
Expand Down Expand Up @@ -208,12 +209,18 @@ void sensorsSetAccMode(accModes accMode) {
void sensorsSuspend()
{
NVIC_DisableIRQ(EXTI15_10_IRQn);
sensorsSuspended = true;
}

void sensorsResume()
{
NVIC_EnableIRQ(EXTI15_10_IRQn);
sensorsSuspended = false;
}

bool isSensorsSuspended(void)
{
return sensorsSuspended;
}

void __attribute__((used)) EXTI14_Callback(void) {
Expand Down
9 changes: 6 additions & 3 deletions src/modules/src/stabilizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,12 @@ void rateSupervisorTask(void *pvParameters) {
}
}
} else {
// Handle the case where the semaphore was not given within the timeout
DEBUG_PRINT("ERROR: stabilizerTask is blocking\n");
ASSERT(false); // For safety, assert if the stabilizer task is blocking to ensure motor shutdown
// Don't assert if sensors are suspended
if (isSensorsSuspended() == false) {
// Handle the case where the semaphore was not given within the timeout
DEBUG_PRINT("ERROR: stabilizerTask is blocking\n");
ASSERT(false); // For safety, assert if the stabilizer task is blocking to ensure motor shutdown
}
}
}
}
Expand Down

0 comments on commit b046745

Please sign in to comment.