1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Only enable PINIOBOX task when needed

Previously the task was always enabled and there's no reason for it to be running if there are no boxID associations.

Saves a few cycles by not running. But has a bigger effect on the scheduler by minimizing the number of active tasks when possible.
This commit is contained in:
Bruce Luckcuck 2020-04-09 19:40:18 -04:00
parent a2aa3f19f4
commit f688227db6
14 changed files with 40 additions and 8 deletions

View file

@ -24,22 +24,26 @@
#include "platform.h" #include "platform.h"
#include "rc_modes.h"
#include "common/bitarray.h" #include "common/bitarray.h"
#include "common/maths.h" #include "common/maths.h"
#include "drivers/time.h" #include "drivers/time.h"
#include "config/config.h"
#include "config/feature.h" #include "config/feature.h"
#include "fc/rc_controls.h"
#include "io/piniobox.h"
#include "pg/pg.h" #include "pg/pg.h"
#include "pg/pg_ids.h" #include "pg/pg_ids.h"
#include "pg/rx.h" #include "pg/rx.h"
#include "config/config.h"
#include "fc/rc_controls.h"
#include "rx/rx.h" #include "rx/rx.h"
#include "rc_modes.h"
#define STICKY_MODE_BOOT_DELAY_US 5e6 #define STICKY_MODE_BOOT_DELAY_US 5e6
boxBitmask_t rcModeActivationMask; // one bit per mode defined in boxId_e boxBitmask_t rcModeActivationMask; // one bit per mode defined in boxId_e
@ -249,4 +253,7 @@ void analyzeModeActivationConditions(void)
activeMacArray[activeMacCount++] = i; activeMacArray[activeMacCount++] = i;
} }
} }
#ifdef USE_PINIOBOX
pinioBoxTaskControl();
#endif
} }

View file

@ -336,7 +336,7 @@ void tasksInit(void)
#endif #endif
#ifdef USE_PINIOBOX #ifdef USE_PINIOBOX
setTaskEnabled(TASK_PINIOBOX, true); pinioBoxTaskControl();
#endif #endif
#ifdef USE_CMS #ifdef USE_CMS

View file

@ -26,14 +26,16 @@
#include "build/debug.h" #include "build/debug.h"
#include "common/utils.h"
#include "common/time.h" #include "common/time.h"
#include "common/utils.h"
#include "msp/msp_box.h" #include "msp/msp_box.h"
#include "pg/pinio.h" #include "pg/pinio.h"
#include "pg/piniobox.h" #include "pg/piniobox.h"
#include "scheduler/scheduler.h"
#include "piniobox.h" #include "piniobox.h"
typedef struct pinioBoxRuntimeConfig_s { typedef struct pinioBoxRuntimeConfig_s {
@ -64,4 +66,15 @@ void pinioBoxUpdate(timeUs_t currentTimeUs)
} }
} }
void pinioBoxTaskControl(void)
{
bool enableTask = false;
for (int i = 0; i < PINIO_COUNT; i++) {
if (pinioBoxRuntimeConfig.boxId[i] != BOXID_NONE && isModeActivationConditionPresent(pinioBoxRuntimeConfig.boxId[i])) {
enableTask = true;
break;
}
}
setTaskEnabled(TASK_PINIOBOX, enableTask);
}
#endif #endif

View file

@ -22,3 +22,4 @@
void pinioBoxInit(const pinioBoxConfig_t *pinioBoxConfig); void pinioBoxInit(const pinioBoxConfig_t *pinioBoxConfig);
void pinioBoxUpdate(timeUs_t currentTimeUs); void pinioBoxUpdate(timeUs_t currentTimeUs);
void pinioBoxTaskControl(void);

View file

@ -1107,4 +1107,5 @@ extern "C" {
void updateRcRefreshRate(timeUs_t) {}; void updateRcRefreshRate(timeUs_t) {};
uint16_t getAverageSystemLoadPercent(void) { return 0; } uint16_t getAverageSystemLoadPercent(void) { return 0; }
bool isMotorProtocolEnabled(void) { return true; } bool isMotorProtocolEnabled(void) { return true; }
void pinioBoxTaskControl(void) {}
} }

View file

@ -598,4 +598,5 @@ bool areSticksActive(uint8_t stickPercentLimit) {
void beeperConfirmationBeeps(uint8_t beepCount) { UNUSED(beepCount); } void beeperConfirmationBeeps(uint8_t beepCount) { UNUSED(beepCount); }
bool crashRecoveryModeActive(void) { return false; } bool crashRecoveryModeActive(void) { return false; }
void pinioBoxTaskControl(void) {}
} }

View file

@ -249,4 +249,5 @@ bool accGetAccumulationAverage(float *) { return false; }
void mixerSetThrottleAngleCorrection(int) {}; void mixerSetThrottleAngleCorrection(int) {};
bool gpsRescueIsRunning(void) { return false; } bool gpsRescueIsRunning(void) { return false; }
bool isFixedWing(void) { return false; } bool isFixedWing(void) { return false; }
void pinioBoxTaskControl(void) {}
} }

View file

@ -396,5 +396,5 @@ bool isFlipOverAfterCrashActive(void) { return false; }
void ws2811LedStripEnable(void) { } void ws2811LedStripEnable(void) { }
void setUsedLedCount(unsigned) { }; void setUsedLedCount(unsigned) { };
void pinioBoxTaskControl(void) {}
} }

View file

@ -456,6 +456,7 @@ extern "C" {
void resetPPMDataReceivedState(void){ } void resetPPMDataReceivedState(void){ }
void failsafeOnValidDataReceived(void) { } void failsafeOnValidDataReceived(void) { }
void failsafeOnValidDataFailed(void) { } void failsafeOnValidDataFailed(void) { }
void pinioBoxTaskControl(void) { }
void rxPwmInit(rxRuntimeState_t *rxRuntimeState, rcReadRawDataFnPtr *callback) void rxPwmInit(rxRuntimeState_t *rxRuntimeState, rcReadRawDataFnPtr *callback)
{ {

View file

@ -655,4 +655,5 @@ void resetTryingToArm(void) {}
void setLedProfile(uint8_t profile) { UNUSED(profile); } void setLedProfile(uint8_t profile) { UNUSED(profile); }
uint8_t getLedProfile(void) { return 0; } uint8_t getLedProfile(void) { return 0; }
void compassStartCalibration(void) {} void compassStartCalibration(void) {}
void pinioBoxTaskControl(void) {}
} }

View file

@ -994,4 +994,5 @@ extern "C" {
bool cmsInMenu; bool cmsInMenu;
uint32_t resumeRefreshAt = 0; uint32_t resumeRefreshAt = 0;
int getArmingDisableFlags(void) {return 0;} int getArmingDisableFlags(void) {return 0;}
void pinioBoxTaskControl(void) {}
} }

View file

@ -243,4 +243,6 @@ float pt1FilterApply(pt1Filter_t *filter, float input)
return 0.0; return 0.0;
} }
void pinioBoxTaskControl(void) {}
} }

View file

@ -254,4 +254,6 @@ extern "C" {
UNUSED(input); UNUSED(input);
return 0.0; return 0.0;
} }
void pinioBoxTaskControl(void) {}
} }

View file

@ -192,4 +192,5 @@ extern "C" {
void updateRcRefreshRate(timeUs_t) {}; void updateRcRefreshRate(timeUs_t) {};
uint16_t getAverageSystemLoadPercent(void) { return 0; } uint16_t getAverageSystemLoadPercent(void) { return 0; }
bool isMotorProtocolEnabled(void) { return false; } bool isMotorProtocolEnabled(void) { return false; }
void pinioBoxTaskControl(void) {}
} }