mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 09:45:37 +03:00
Improved scheduling. Betaflight Port digitalentity/cf-scheduler
Disallow arming if system load > 100 (waiting task count > 1) Dont show inactive tasks in CLI Realtime priority task and guard interval implementation Dynamic guard interval. Bugfix for realtime scheduling hickups Optimisations Compile out CLI command help and CLI tasks command for CJMCU Naming fixes // re-Add Gyro Sync // Fix port issues
This commit is contained in:
parent
8ecd05b911
commit
fa49931b43
13 changed files with 840 additions and 311 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
|
||||
|
@ -112,8 +113,7 @@ static uint32_t recalculateBarometerTotal(uint8_t baroSampleCount, uint32_t pres
|
|||
|
||||
typedef enum {
|
||||
BAROMETER_NEEDS_SAMPLES = 0,
|
||||
BAROMETER_NEEDS_CALCULATION,
|
||||
BAROMETER_NEEDS_PROCESSING
|
||||
BAROMETER_NEEDS_CALCULATION
|
||||
} barometerState_e;
|
||||
|
||||
|
||||
|
@ -121,37 +121,28 @@ bool isBaroReady(void) {
|
|||
return baroReady;
|
||||
}
|
||||
|
||||
void baroUpdate(uint32_t currentTime)
|
||||
uint32_t baroUpdate(void)
|
||||
{
|
||||
static uint32_t baroDeadline = 0;
|
||||
static barometerState_e state = BAROMETER_NEEDS_SAMPLES;
|
||||
|
||||
if ((int32_t)(currentTime - baroDeadline) < 0)
|
||||
return;
|
||||
|
||||
baroDeadline = 0;
|
||||
switch (state) {
|
||||
default:
|
||||
case BAROMETER_NEEDS_SAMPLES:
|
||||
baro.get_ut();
|
||||
baro.start_up();
|
||||
state = BAROMETER_NEEDS_CALCULATION;
|
||||
baroDeadline += baro.up_delay;
|
||||
return baro.up_delay;
|
||||
break;
|
||||
|
||||
case BAROMETER_NEEDS_CALCULATION:
|
||||
baro.get_up();
|
||||
baro.start_ut();
|
||||
baroDeadline += baro.ut_delay;
|
||||
baro.calculate(&baroPressure, &baroTemperature);
|
||||
state = BAROMETER_NEEDS_PROCESSING;
|
||||
break;
|
||||
|
||||
case BAROMETER_NEEDS_PROCESSING:
|
||||
state = BAROMETER_NEEDS_SAMPLES;
|
||||
baroPressureSum = recalculateBarometerTotal(barometerConfig->baro_sample_count, baroPressureSum, baroPressure);
|
||||
state = BAROMETER_NEEDS_SAMPLES;
|
||||
return baro.ut_delay;
|
||||
break;
|
||||
}
|
||||
baroDeadline += micros(); // make sure deadline is set after calling baro callbacks
|
||||
}
|
||||
|
||||
int32_t baroCalculateAltitude(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue