Merge pull request #1515 from martinbudden/bf_fc_tasks
Tidy fc_tasks.c - remove unnecessary wrapper functions
This commit is contained in:
commit
60b3e22d76
|
@ -85,11 +85,6 @@ static void taskUpdateAccelerometer(uint32_t currentTime)
|
||||||
imuUpdateAccelerometer(&masterConfig.accelerometerTrims);
|
imuUpdateAccelerometer(&masterConfig.accelerometerTrims);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taskUpdateAttitude(uint32_t currentTime)
|
|
||||||
{
|
|
||||||
imuUpdateAttitude(currentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void taskHandleSerial(uint32_t currentTime)
|
static void taskHandleSerial(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
UNUSED(currentTime);
|
UNUSED(currentTime);
|
||||||
|
@ -103,13 +98,6 @@ static void taskHandleSerial(uint32_t currentTime)
|
||||||
mspSerialProcess(ARMING_FLAG(ARMED) ? MSP_SKIP_NON_MSP_DATA : MSP_EVALUATE_NON_MSP_DATA, mspFcProcessCommand);
|
mspSerialProcess(ARMING_FLAG(ARMED) ? MSP_SKIP_NON_MSP_DATA : MSP_EVALUATE_NON_MSP_DATA, mspFcProcessCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BEEPER
|
|
||||||
static void taskUpdateBeeper(uint32_t currentTime)
|
|
||||||
{
|
|
||||||
beeperUpdate(currentTime); //call periodic beeper handler
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void taskUpdateBattery(uint32_t currentTime)
|
static void taskUpdateBattery(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
#ifdef USE_ADC
|
#ifdef USE_ADC
|
||||||
|
@ -133,12 +121,6 @@ static void taskUpdateBattery(uint32_t currentTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool taskUpdateRxCheck(uint32_t currentTime, uint32_t currentDeltaTime)
|
|
||||||
{
|
|
||||||
UNUSED(currentDeltaTime);
|
|
||||||
return rxUpdate(currentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void taskUpdateRxMain(uint32_t currentTime)
|
static void taskUpdateRxMain(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
processRx(currentTime);
|
processRx(currentTime);
|
||||||
|
@ -163,18 +145,6 @@ static void taskUpdateRxMain(uint32_t currentTime)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GPS
|
|
||||||
static void taskProcessGPS(uint32_t currentTime)
|
|
||||||
{
|
|
||||||
// if GPS feature is enabled, gpsThread() will be called at some intervals to check for stuck
|
|
||||||
// hardware, wrong baud rates, init GPS if needed, etc. Don't use SENSOR_GPS here as gpsUdate() can and will
|
|
||||||
// change this based on available hardware
|
|
||||||
if (feature(FEATURE_GPS)) {
|
|
||||||
gpsUpdate(currentTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MAG
|
#ifdef MAG
|
||||||
static void taskUpdateCompass(uint32_t currentTime)
|
static void taskUpdateCompass(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
|
@ -198,17 +168,6 @@ static void taskUpdateBaro(uint32_t currentTime)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SONAR
|
|
||||||
static void taskUpdateSonar(uint32_t currentTime)
|
|
||||||
{
|
|
||||||
UNUSED(currentTime);
|
|
||||||
|
|
||||||
if (sensors(SENSOR_SONAR)) {
|
|
||||||
sonarUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(BARO) || defined(SONAR)
|
#if defined(BARO) || defined(SONAR)
|
||||||
static void taskCalculateAltitude(uint32_t currentTime)
|
static void taskCalculateAltitude(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
|
@ -224,15 +183,6 @@ static void taskCalculateAltitude(uint32_t currentTime)
|
||||||
}}
|
}}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_DASHBOARD
|
|
||||||
static void taskUpdateDashboard(uint32_t currentTime)
|
|
||||||
{
|
|
||||||
if (feature(FEATURE_DASHBOARD)) {
|
|
||||||
dashboardUpdate(currentTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TELEMETRY
|
#ifdef TELEMETRY
|
||||||
static void taskTelemetry(uint32_t currentTime)
|
static void taskTelemetry(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
|
@ -244,33 +194,6 @@ static void taskTelemetry(uint32_t currentTime)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LED_STRIP
|
|
||||||
static void taskLedStrip(uint32_t currentTime)
|
|
||||||
{
|
|
||||||
if (feature(FEATURE_LED_STRIP)) {
|
|
||||||
ledStripUpdate(currentTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TRANSPONDER
|
|
||||||
static void taskTransponder(uint32_t currentTime)
|
|
||||||
{
|
|
||||||
if (feature(FEATURE_TRANSPONDER)) {
|
|
||||||
transponderUpdate(currentTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef OSD
|
|
||||||
static void taskUpdateOsd(uint32_t currentTime)
|
|
||||||
{
|
|
||||||
if (feature(FEATURE_OSD)) {
|
|
||||||
osdUpdate(currentTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void fcTasksInit(void)
|
void fcTasksInit(void)
|
||||||
{
|
{
|
||||||
schedulerInit();
|
schedulerInit();
|
||||||
|
@ -365,14 +288,14 @@ cfTask_t cfTasks[TASK_COUNT] = {
|
||||||
|
|
||||||
[TASK_ATTITUDE] = {
|
[TASK_ATTITUDE] = {
|
||||||
.taskName = "ATTITUDE",
|
.taskName = "ATTITUDE",
|
||||||
.taskFunc = taskUpdateAttitude,
|
.taskFunc = imuUpdateAttitude,
|
||||||
.desiredPeriod = 1000000 / 100,
|
.desiredPeriod = 1000000 / 100,
|
||||||
.staticPriority = TASK_PRIORITY_MEDIUM,
|
.staticPriority = TASK_PRIORITY_MEDIUM,
|
||||||
},
|
},
|
||||||
|
|
||||||
[TASK_RX] = {
|
[TASK_RX] = {
|
||||||
.taskName = "RX",
|
.taskName = "RX",
|
||||||
.checkFunc = taskUpdateRxCheck,
|
.checkFunc = rxUpdateCheck,
|
||||||
.taskFunc = taskUpdateRxMain,
|
.taskFunc = taskUpdateRxMain,
|
||||||
.desiredPeriod = 1000000 / 50, // If event-based scheduling doesn't work, fallback to periodic scheduling
|
.desiredPeriod = 1000000 / 50, // If event-based scheduling doesn't work, fallback to periodic scheduling
|
||||||
.staticPriority = TASK_PRIORITY_HIGH,
|
.staticPriority = TASK_PRIORITY_HIGH,
|
||||||
|
@ -395,7 +318,7 @@ cfTask_t cfTasks[TASK_COUNT] = {
|
||||||
#ifdef BEEPER
|
#ifdef BEEPER
|
||||||
[TASK_BEEPER] = {
|
[TASK_BEEPER] = {
|
||||||
.taskName = "BEEPER",
|
.taskName = "BEEPER",
|
||||||
.taskFunc = taskUpdateBeeper,
|
.taskFunc = beeperUpdate,
|
||||||
.desiredPeriod = 1000000 / 100, // 100 Hz
|
.desiredPeriod = 1000000 / 100, // 100 Hz
|
||||||
.staticPriority = TASK_PRIORITY_LOW,
|
.staticPriority = TASK_PRIORITY_LOW,
|
||||||
},
|
},
|
||||||
|
@ -404,7 +327,7 @@ cfTask_t cfTasks[TASK_COUNT] = {
|
||||||
#ifdef GPS
|
#ifdef GPS
|
||||||
[TASK_GPS] = {
|
[TASK_GPS] = {
|
||||||
.taskName = "GPS",
|
.taskName = "GPS",
|
||||||
.taskFunc = taskProcessGPS,
|
.taskFunc = gpsUpdate,
|
||||||
.desiredPeriod = 1000000 / 10, // GPS usually don't go raster than 10Hz
|
.desiredPeriod = 1000000 / 10, // GPS usually don't go raster than 10Hz
|
||||||
.staticPriority = TASK_PRIORITY_MEDIUM,
|
.staticPriority = TASK_PRIORITY_MEDIUM,
|
||||||
},
|
},
|
||||||
|
@ -431,8 +354,8 @@ cfTask_t cfTasks[TASK_COUNT] = {
|
||||||
#ifdef SONAR
|
#ifdef SONAR
|
||||||
[TASK_SONAR] = {
|
[TASK_SONAR] = {
|
||||||
.taskName = "SONAR",
|
.taskName = "SONAR",
|
||||||
.taskFunc = taskUpdateSonar,
|
.taskFunc = sonarUpdate,
|
||||||
.desiredPeriod = 1000000 / 20,
|
.desiredPeriod = 70000, // 70ms required so that SONAR pulses do not interfer with each other
|
||||||
.staticPriority = TASK_PRIORITY_LOW,
|
.staticPriority = TASK_PRIORITY_LOW,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
@ -449,7 +372,7 @@ cfTask_t cfTasks[TASK_COUNT] = {
|
||||||
#ifdef TRANSPONDER
|
#ifdef TRANSPONDER
|
||||||
[TASK_TRANSPONDER] = {
|
[TASK_TRANSPONDER] = {
|
||||||
.taskName = "TRANSPONDER",
|
.taskName = "TRANSPONDER",
|
||||||
.taskFunc = taskTransponder,
|
.taskFunc = transponderUpdate,
|
||||||
.desiredPeriod = 1000000 / 250, // 250 Hz
|
.desiredPeriod = 1000000 / 250, // 250 Hz
|
||||||
.staticPriority = TASK_PRIORITY_LOW,
|
.staticPriority = TASK_PRIORITY_LOW,
|
||||||
},
|
},
|
||||||
|
@ -458,7 +381,7 @@ cfTask_t cfTasks[TASK_COUNT] = {
|
||||||
#ifdef USE_DASHBOARD
|
#ifdef USE_DASHBOARD
|
||||||
[TASK_DASHBOARD] = {
|
[TASK_DASHBOARD] = {
|
||||||
.taskName = "DASHBOARD",
|
.taskName = "DASHBOARD",
|
||||||
.taskFunc = taskUpdateDashboard,
|
.taskFunc = dashboardUpdate,
|
||||||
.desiredPeriod = 1000000 / 10,
|
.desiredPeriod = 1000000 / 10,
|
||||||
.staticPriority = TASK_PRIORITY_LOW,
|
.staticPriority = TASK_PRIORITY_LOW,
|
||||||
},
|
},
|
||||||
|
@ -466,7 +389,7 @@ cfTask_t cfTasks[TASK_COUNT] = {
|
||||||
#ifdef OSD
|
#ifdef OSD
|
||||||
[TASK_OSD] = {
|
[TASK_OSD] = {
|
||||||
.taskName = "OSD",
|
.taskName = "OSD",
|
||||||
.taskFunc = taskUpdateOsd,
|
.taskFunc = osdUpdate,
|
||||||
.desiredPeriod = 1000000 / 60, // 60 Hz
|
.desiredPeriod = 1000000 / 60, // 60 Hz
|
||||||
.staticPriority = TASK_PRIORITY_LOW,
|
.staticPriority = TASK_PRIORITY_LOW,
|
||||||
},
|
},
|
||||||
|
@ -483,7 +406,7 @@ cfTask_t cfTasks[TASK_COUNT] = {
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
[TASK_LEDSTRIP] = {
|
[TASK_LEDSTRIP] = {
|
||||||
.taskName = "LEDSTRIP",
|
.taskName = "LEDSTRIP",
|
||||||
.taskFunc = taskLedStrip,
|
.taskFunc = ledStripUpdate,
|
||||||
.desiredPeriod = 1000000 / 100, // 100 Hz
|
.desiredPeriod = 1000000 / 100, // 100 Hz
|
||||||
.staticPriority = TASK_PRIORITY_LOW,
|
.staticPriority = TASK_PRIORITY_LOW,
|
||||||
},
|
},
|
||||||
|
|
|
@ -325,8 +325,10 @@ void resumeRxSignal(void)
|
||||||
failsafeOnRxResume();
|
failsafeOnRxResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rxUpdate(uint32_t currentTime)
|
bool rxUpdateCheck(uint32_t currentTime, uint32_t currentDeltaTime)
|
||||||
{
|
{
|
||||||
|
UNUSED(currentDeltaTime);
|
||||||
|
|
||||||
resetRxSignalReceivedFlagIfNeeded(currentTime);
|
resetRxSignalReceivedFlagIfNeeded(currentTime);
|
||||||
|
|
||||||
if (isRxDataDriven()) {
|
if (isRxDataDriven()) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ extern rxRuntimeConfig_t rxRuntimeConfig; //!!TODO remove this extern, only need
|
||||||
struct modeActivationCondition_s;
|
struct modeActivationCondition_s;
|
||||||
void rxInit(const rxConfig_t *rxConfig, const struct modeActivationCondition_s *modeActivationConditions);
|
void rxInit(const rxConfig_t *rxConfig, const struct modeActivationCondition_s *modeActivationConditions);
|
||||||
void useRxConfig(const rxConfig_t *rxConfigToUse);
|
void useRxConfig(const rxConfig_t *rxConfigToUse);
|
||||||
bool rxUpdate(uint32_t currentTime);
|
bool rxUpdateCheck(uint32_t currentTime, uint32_t currentDeltaTime);
|
||||||
bool rxIsReceivingSignal(void);
|
bool rxIsReceivingSignal(void);
|
||||||
bool rxAreFlightChannelsValid(void);
|
bool rxAreFlightChannelsValid(void);
|
||||||
void calculateRxChannelsAndUpdateFailsafe(uint32_t currentTime);
|
void calculateRxChannelsAndUpdateFailsafe(uint32_t currentTime);
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
|
||||||
#include "common/maths.h"
|
#include "common/maths.h"
|
||||||
#include "common/axis.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#include "fc/runtime_config.h"
|
|
||||||
|
|
||||||
#include "config/feature.h"
|
#include "config/feature.h"
|
||||||
|
|
||||||
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
#include "sensors/sensors.h"
|
#include "sensors/sensors.h"
|
||||||
#include "sensors/battery.h"
|
#include "sensors/battery.h"
|
||||||
#include "sensors/sonar.h"
|
#include "sensors/sonar.h"
|
||||||
|
@ -88,8 +88,9 @@ static int32_t applySonarMedianFilter(int32_t newSonarReading)
|
||||||
return newSonarReading;
|
return newSonarReading;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sonarUpdate(void)
|
void sonarUpdate(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
|
UNUSED(currentTime);
|
||||||
hcsr04_start_reading();
|
hcsr04_start_reading();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ extern int16_t sonarCfAltCm;
|
||||||
extern int16_t sonarMaxAltWithTiltCm;
|
extern int16_t sonarMaxAltWithTiltCm;
|
||||||
|
|
||||||
void sonarInit(const sonarConfig_t *sonarConfig);
|
void sonarInit(const sonarConfig_t *sonarConfig);
|
||||||
void sonarUpdate(void);
|
void sonarUpdate(uint32_t currentTime);
|
||||||
int32_t sonarRead(void);
|
int32_t sonarRead(void);
|
||||||
int32_t sonarCalculateAltitude(int32_t sonarDistance, float cosTiltAngle);
|
int32_t sonarCalculateAltitude(int32_t sonarDistance, float cosTiltAngle);
|
||||||
int32_t sonarGetLatestAltitude(void);
|
int32_t sonarGetLatestAltitude(void);
|
||||||
|
|
Loading…
Reference in New Issue