1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

Fix BST // Sync motor to PID loop (less CPU)

This commit is contained in:
borisbstyle 2016-03-02 14:05:26 +01:00
parent 24b4d37d43
commit 795feddf71
4 changed files with 5 additions and 17 deletions

View file

@ -668,14 +668,6 @@ int main(void) {
rescheduleTask(TASK_GYROPID, targetLooptime); rescheduleTask(TASK_GYROPID, targetLooptime);
setTaskEnabled(TASK_GYROPID, true); setTaskEnabled(TASK_GYROPID, true);
setTaskEnabled(TASK_MOTOR, true);
if (feature(FEATURE_ONESHOT125)) {
rescheduleTask(TASK_MOTOR, constrain(lrintf((1.0f / masterConfig.motor_pwm_rate) * 1000000), 250, 3500));
} else {
rescheduleTask(TASK_MOTOR, 1000);
}
if(sensors(SENSOR_ACC)) { if(sensors(SENSOR_ACC)) {
setTaskEnabled(TASK_ACCEL, true); setTaskEnabled(TASK_ACCEL, true);
switch(targetLooptime) { // Switch statement kept in place to change acc rates in the future switch(targetLooptime) { // Switch statement kept in place to change acc rates in the future
@ -732,6 +724,10 @@ int main(void) {
#ifdef TRANSPONDER #ifdef TRANSPONDER
setTaskEnabled(TASK_TRANSPONDER, feature(FEATURE_TRANSPONDER)); setTaskEnabled(TASK_TRANSPONDER, feature(FEATURE_TRANSPONDER));
#endif #endif
#ifdef USE_BST
setTaskEnabled(TASK_BST_READ_WRITE, true);
setTaskEnabled(TASK_BST_MASTER_PROCESS, true);
#endif
while (1) { while (1) {
scheduler(); scheduler();

View file

@ -766,6 +766,7 @@ void taskMainPidLoopCheck(void) {
static uint8_t pidUpdateCountdown; static uint8_t pidUpdateCountdown;
if (runTaskMainSubprocesses) { if (runTaskMainSubprocesses) {
taskMotorUpdate();
subTasksMainPidLoop(); subTasksMainPidLoop();
runTaskMainSubprocesses = false; runTaskMainSubprocesses = false;
} }

View file

@ -44,7 +44,6 @@ typedef enum {
/* Actual tasks */ /* Actual tasks */
TASK_SYSTEM = 0, TASK_SYSTEM = 0,
TASK_GYROPID, TASK_GYROPID,
TASK_MOTOR,
TASK_ATTITUDE, TASK_ATTITUDE,
TASK_ACCEL, TASK_ACCEL,
TASK_SERIAL, TASK_SERIAL,

View file

@ -23,7 +23,6 @@
#include "scheduler.h" #include "scheduler.h"
void taskMainPidLoopCheck(void); void taskMainPidLoopCheck(void);
void taskMotorUpdate(void);
void taskUpdateAccelerometer(void); void taskUpdateAccelerometer(void);
void taskHandleSerial(void); void taskHandleSerial(void);
void taskUpdateAttitude(void); void taskUpdateAttitude(void);
@ -59,13 +58,6 @@ cfTask_t cfTasks[TASK_COUNT] = {
.subTaskName = "GYRO", .subTaskName = "GYRO",
.taskFunc = taskMainPidLoopCheck, .taskFunc = taskMainPidLoopCheck,
.desiredPeriod = 1000, .desiredPeriod = 1000,
.staticPriority = TASK_PRIORITY_HIGH,
},
[TASK_MOTOR] = {
.taskName = "MOTOR",
.taskFunc = taskMotorUpdate,
.desiredPeriod = 1000,
.staticPriority = TASK_PRIORITY_REALTIME, .staticPriority = TASK_PRIORITY_REALTIME,
}, },