Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stabilizer locked assert when passthrough interface is active #1432

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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