diff --git a/src/core/looptime.c b/src/core/looptime.c index f3ca9e1c6..0dcbf7b19 100644 --- a/src/core/looptime.c +++ b/src/core/looptime.c @@ -89,4 +89,6 @@ void looptime_update() { if (flags.arm_state) { state.armtime += state.looptime; } + + state.loop_counter++; } \ No newline at end of file diff --git a/src/core/main.c b/src/core/main.c index da3cc9bb9..b887006fb 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -9,34 +9,27 @@ #include "core/looptime.h" #include "core/profile.h" #include "core/project.h" +#include "core/scheduler.h" #include "driver/adc.h" -#include "driver/fmc.h" #include "driver/gpio.h" #include "driver/motor.h" -#include "driver/reset.h" #include "driver/rgb_led.h" -#include "driver/serial.h" -#include "driver/spi.h" #include "driver/time.h" +#include "driver/timer.h" #include "driver/usb.h" -#include "flight/control.h" #include "flight/filter.h" -#include "flight/gestures.h" #include "flight/imu.h" #include "flight/pid.h" #include "flight/sixaxis.h" #include "io/blackbox.h" #include "io/buzzer.h" #include "io/led.h" -#include "io/rgb_led.h" -#include "io/usb_configurator.h" #include "io/vbat.h" #include "io/vtx.h" #include "osd/render.h" -#include "rx/rx.h" -#include "util/util.h" -__attribute__((__used__)) void memory_section_init() { +__attribute__((__used__)) void +memory_section_init() { #ifdef USE_FAST_RAM extern uint8_t _fast_ram_start; extern uint8_t _fast_ram_end; @@ -73,6 +66,8 @@ __attribute__((__used__)) void memory_section_init() { } __attribute__((__used__)) int main() { + scheduler_init(); + // init timer so we can use delays etc time_init(); looptime_init(); @@ -137,85 +132,7 @@ __attribute__((__used__)) int main() { blackbox_init(); imu_init(); - osd_clear(); - perf_counter_init(); - - looptime_reset(); - - while (1) { - // updates looptime counters & runs auto detect - looptime_update(); - - perf_counter_start(PERF_COUNTER_TOTAL); - - // read gyro and accelerometer data - perf_counter_start(PERF_COUNTER_GYRO); - sixaxis_read(); - perf_counter_end(PERF_COUNTER_GYRO); - - // all flight calculations and motors - perf_counter_start(PERF_COUNTER_CONTROL); - control(); - perf_counter_end(PERF_COUNTER_CONTROL); - - perf_counter_start(PERF_COUNTER_MISC); - - // attitude calculations for level mode - imu_calc(); - - // battery low logic - vbat_calc(); - - // check gestures - if (flags.on_ground && !flags.gestures_disabled) { - gestures(); - } - // handle led commands - led_update(); - -#if (RGB_LED_NUMBER > 0) - // RGB led control - rgb_led_lvc(); -#ifdef RGB_LED_DMA - rgb_dma_start(); -#endif -#endif - - buzzer_update(); - vtx_update(); - - perf_counter_end(PERF_COUNTER_MISC); - - // receiver function - perf_counter_start(PERF_COUNTER_RX); - rx_update(); - perf_counter_end(PERF_COUNTER_RX); - - perf_counter_start(PERF_COUNTER_BLACKBOX); - const uint8_t blackbox_active = blackbox_update(); - perf_counter_end(PERF_COUNTER_BLACKBOX); - - if (!blackbox_active) { - perf_counter_start(PERF_COUNTER_OSD); - osd_display(); - perf_counter_end(PERF_COUNTER_OSD); - } - - if (usb_detect()) { - flags.usb_active = 1; -#ifndef ALLOW_USB_ARMING - if (flags.arm_switch) - flags.arm_safety = 1; // final safety check to disallow arming during USB operation -#endif - usb_configurator(); - } else { - flags.usb_active = 0; - motor_test.active = 0; - } - - perf_counter_end(PERF_COUNTER_TOTAL); - perf_counter_update(); - } // end loop -} \ No newline at end of file + scheduler_run(); +} diff --git a/src/core/scheduler.c b/src/core/scheduler.c new file mode 100644 index 000000000..91ab7cc6c --- /dev/null +++ b/src/core/scheduler.c @@ -0,0 +1,184 @@ +#include "core/scheduler.h" + +#include +#include + +#include "core/debug.h" +#include "core/looptime.h" +#include "driver/time.h" +#include "flight/control.h" +#include "io/usb_configurator.h" +#include "tasks.h" +#include "util/cbor_helper.h" + +#define TASK_AVERAGE_SAMPLES 32 +#define TASK_RUNTIME_REDUCTION 0.75 +#define TASK_RUNTIME_MARGIN 1.25 +#define TASK_RUNTIME_BUFFER 10 + +#define US_TO_CYCLES(us) ((us)*TICKS_PER_US) +#define CYCLES_TO_US(cycles) ((cycles) / TICKS_PER_US) + +static FAST_RAM uint32_t task_queue_size = 0; +static FAST_RAM task_t *task_queue[TASK_MAX]; +static FAST_RAM task_t *active_task = NULL; + +static bool task_queue_contains(task_t *task) { + for (uint32_t i = 0; i < task_queue_size; i++) { + if (task_queue[i] == task) { + return true; + } + } + return false; +} + +static bool task_queue_push(task_t *task) { + if (task_queue_size >= TASK_MAX || task_queue_contains(task)) { + return false; + } + for (uint32_t i = 0; i < TASK_MAX; i++) { + if (task_queue[i] != NULL && task_queue[i]->priority <= task->priority) { + continue; + } + + memcpy(task_queue + i + 1, task_queue + i, (task_queue_size - i) * sizeof(task_t *)); + task_queue[i] = task; + task_queue_size++; + return true; + } + return false; +} + +static bool task_should_run(const uint32_t start_cycles, uint8_t task_mask, task_t *task) { + if ((task_mask & task->mask) == 0) { + // task shall not run in this firmware state + return false; + } + + const int32_t time_left = US_TO_CYCLES(state.looptime_autodetect - TASK_RUNTIME_BUFFER) - (time_cycles() - start_cycles); + if (task->priority != TASK_PRIORITY_REALTIME && task->runtime_worst > time_left) { + // we dont have any time left this loop and task is not realtime + task->runtime_worst *= TASK_RUNTIME_REDUCTION; + return false; + } + + return true; +} + +static void task_run(task_t *task) { + const volatile uint32_t start = time_cycles(); + task->last_run_time = start; + + task->runtime_flags = 0; + active_task = task; + task->func(); + active_task = NULL; + + const volatile uint32_t time_taken = time_cycles() - start; + task->runtime_current = time_taken; + + if (task->runtime_flags & TASK_FLAG_SKIP_STATS) { + return; + } + + if (time_taken < task->runtime_min) { + task->runtime_min = time_taken; + } + + task->runtime_avg_sum -= task->runtime_avg; + task->runtime_avg_sum += time_taken; + task->runtime_avg = task->runtime_avg_sum / TASK_AVERAGE_SAMPLES; + + if (time_taken > task->runtime_max) { + task->runtime_max = time_taken; + } + + if (task->runtime_worst < (task->runtime_avg * TASK_RUNTIME_MARGIN)) { + task->runtime_worst = task->runtime_avg * TASK_RUNTIME_MARGIN; + } +} + +void task_reset_runtime() { + if (active_task == NULL) { + return; + } + active_task->runtime_flags |= TASK_FLAG_SKIP_STATS; + looptime_reset(); +} + +void scheduler_init() { + looptime_init(); + + for (uint32_t i = 0; i < TASK_MAX; i++) { + task_queue_push(&tasks[i]); + } +} + +void scheduler_run() { + looptime_reset(); + + while (1) { + const volatile uint32_t cycles = time_cycles(); + + uint8_t task_mask = TASK_MASK_DEFAULT; + if (flags.in_air || flags.arm_state) { + task_mask |= TASK_MASK_IN_AIR; + } else { + task_mask |= TASK_MASK_ON_GROUND; + } + + for (uint32_t i = 0; i < task_queue_size; i++) { + task_t *task = task_queue[i]; + if (task_should_run(cycles, task_mask, task)) { + task_run(task); + } + } + + looptime_update(); + } +} + +#ifdef DEBUG + +#define ENCODE_CYCLES(val) \ + { \ + const uint32_t us = CYCLES_TO_US(val); \ + CBOR_CHECK_ERROR(res = cbor_encode_uint32(enc, &us)); \ + } + +cbor_result_t cbor_encode_task_stats(cbor_value_t *enc) { + CBOR_CHECK_ERROR(cbor_result_t res = cbor_encode_array_indefinite(enc)); + + for (uint32_t i = 0; i < TASK_MAX; i++) { + CBOR_CHECK_ERROR(res = cbor_encode_map_indefinite(enc)); + + CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "name")); + CBOR_CHECK_ERROR(res = cbor_encode_str(enc, tasks[i].name)); + + CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "last")); + ENCODE_CYCLES(tasks[i].last_run_time) + + CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "current")); + ENCODE_CYCLES(tasks[i].runtime_current) + + CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "min")); + ENCODE_CYCLES(tasks[i].runtime_min) + + CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "avg")); + ENCODE_CYCLES(tasks[i].runtime_avg) + + CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "max")); + ENCODE_CYCLES(tasks[i].runtime_max) + + CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "worst")); + ENCODE_CYCLES(tasks[i].runtime_worst) + + CBOR_CHECK_ERROR(res = cbor_encode_end_indefinite(enc)); + } + + CBOR_CHECK_ERROR(res = cbor_encode_end_indefinite(enc)); + + return res; +} + +#endif \ No newline at end of file diff --git a/src/core/scheduler.h b/src/core/scheduler.h new file mode 100644 index 000000000..fb4dfc05c --- /dev/null +++ b/src/core/scheduler.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +#include + +void scheduler_init(); +void scheduler_run(); + +void task_reset_runtime(); + +cbor_result_t cbor_encode_task_stats(cbor_value_t *enc); \ No newline at end of file diff --git a/src/core/tasks.c b/src/core/tasks.c new file mode 100644 index 000000000..e0fbee0c5 --- /dev/null +++ b/src/core/tasks.c @@ -0,0 +1,61 @@ +#include "tasks.h" + +#include + +#include "driver/serial.h" +#include "driver/usb.h" +#include "flight/control.h" +#include "flight/gestures.h" +#include "flight/imu.h" +#include "flight/sixaxis.h" +#include "io/blackbox.h" +#include "io/buzzer.h" +#include "io/led.h" +#include "io/usb_configurator.h" +#include "io/vbat.h" +#include "io/vtx.h" +#include "osd/render.h" +#include "profile.h" +#include "project.h" +#include "rx/rx.h" + +void task_main() { + // all flight calculations and motors + control(); + + // attitude calculations for level mode + imu_calc(); + + // battery low logic + vbat_calc(); + + // check gestures + if (flags.on_ground && !flags.gestures_disabled) { + gestures(); + } + + // handle led commands + led_update(); + +#if (RGB_LED_NUMBER > 0) + // RGB led control + rgb_led_lvc(); +#ifdef RGB_LED_DMA + rgb_dma_start(); +#endif +#endif + + buzzer_update(); +} + +FAST_RAM task_t tasks[TASK_MAX] = { + [TASK_GYRO] = CREATE_TASK("GYRO", TASK_MASK_ALWAYS, TASK_PRIORITY_REALTIME, sixaxis_read), + [TASK_MAIN] = CREATE_TASK("MAIN", TASK_MASK_ALWAYS, TASK_PRIORITY_REALTIME, task_main), + [TASK_RX] = CREATE_TASK("RX", TASK_MASK_ALWAYS, TASK_PRIORITY_HIGH, rx_update), +#ifdef ENABLE_BLACKBOX + [TASK_BLACKBOX] = CREATE_TASK("BLACKBOX", TASK_MASK_ALWAYS, TASK_PRIORITY_MEDIUM, blackbox_update), +#endif + [TASK_OSD] = CREATE_TASK("OSD", TASK_MASK_ALWAYS, TASK_PRIORITY_MEDIUM, osd_display), + [TASK_VTX] = CREATE_TASK("VTX", TASK_MASK_ON_GROUND, TASK_PRIORITY_LOW, vtx_update), + [TASK_USB] = CREATE_TASK("USB", TASK_MASK_ON_GROUND, TASK_PRIORITY_LOW, usb_configurator), +}; \ No newline at end of file diff --git a/src/core/tasks.h b/src/core/tasks.h new file mode 100644 index 000000000..65dedf939 --- /dev/null +++ b/src/core/tasks.h @@ -0,0 +1,79 @@ +#pragma once + +#include +#include + +#include "project.h" + +typedef enum { + TASK_GYRO, + TASK_RX, + TASK_MAIN, + TASK_USB, + TASK_OSD, +#ifdef ENABLE_BLACKBOX + TASK_BLACKBOX, +#endif + TASK_VTX, + + TASK_MAX + +} task_id_t; +typedef enum { + TASK_PRIORITY_REALTIME, + TASK_PRIORITY_HIGH, + TASK_PRIORITY_MEDIUM, + TASK_PRIORITY_LOW, +} task_priority_t; + +typedef enum { + TASK_MASK_DEFAULT = (0x1 << 0), + TASK_MASK_ON_GROUND = (0x1 << 1), + TASK_MASK_IN_AIR = (0x1 << 2), + + TASK_MASK_ALWAYS = 0xFF, +} task_mask_t; + +typedef enum { + TASK_FLAG_SKIP_STATS = (0x1 << 0), +} task_flag_t; + +typedef void (*task_function_t)(); +typedef bool (*task_poll_function_t)(); + +typedef struct { + const char *name; + + uint8_t mask; + task_priority_t priority; + task_function_t func; + + uint32_t last_run_time; + + uint32_t runtime_flags; + uint32_t runtime_current; + uint32_t runtime_min; + uint32_t runtime_avg; + uint32_t runtime_worst; + uint32_t runtime_max; + + uint32_t runtime_avg_sum; +} task_t; + +#define CREATE_TASK(p_name, p_mask, p_priority, p_func) \ + { \ + .name = p_name, \ + .mask = p_mask, \ + .priority = p_priority, \ + .func = p_func, \ + .last_run_time = 0, \ + .runtime_flags = 0, \ + .runtime_current = 0, \ + .runtime_min = UINT32_MAX, \ + .runtime_avg = 0, \ + .runtime_worst = 0, \ + .runtime_max = 0, \ + .runtime_avg_sum = 0, \ + } + +extern task_t tasks[TASK_MAX]; \ No newline at end of file diff --git a/src/flight/control.h b/src/flight/control.h index b4105f97e..5383a482c 100644 --- a/src/flight/control.h +++ b/src/flight/control.h @@ -3,9 +3,9 @@ #include #include "core/failloop.h" +#include "core/looptime.h" #include "core/project.h" #include "rx/rx.h" - #include "util/vector.h" #define ANGLE_PID_SIZE 2 @@ -43,10 +43,10 @@ extern control_flags_t flags; typedef struct { failloop_t failloop; - uint16_t looptime_autodetect; + looptime_t looptime_autodetect; float looptime; // looptime in seconds - uint32_t looptime_us; // looptime in us uint32_t loop_counter; // number of loops ran + uint32_t looptime_us; // looptime in us float uptime; // running sum of looptimes float armtime; // running sum of looptimes (while armed) uint32_t cpu_load; // micros we have had left last loop @@ -109,6 +109,7 @@ typedef struct { MEMBER(failloop, uint8_t) \ MEMBER(looptime_autodetect, uint16_t) \ MEMBER(looptime, float) \ + MEMBER(loop_counter, uint32_t) \ MEMBER(looptime_us, uint32_t) \ MEMBER(loop_counter, uint32_t) \ MEMBER(uptime, float) \ diff --git a/src/flight/gestures.c b/src/flight/gestures.c index 67b5316f2..e8b181e2d 100644 --- a/src/flight/gestures.c +++ b/src/flight/gestures.c @@ -3,6 +3,7 @@ #include "core/flash.h" #include "core/looptime.h" #include "core/profile.h" +#include "core/scheduler.h" #include "flight/control.h" #include "flight/pid.h" #include "flight/sixaxis.h" @@ -43,7 +44,7 @@ void gestures() { number_of_increments[i][j] = 0; // reset loop time - looptime_reset(); + task_reset_runtime(); break; } case GESTURE_UUU: { diff --git a/src/io/blackbox.c b/src/io/blackbox.c index 3da275883..e37fd9035 100644 --- a/src/io/blackbox.c +++ b/src/io/blackbox.c @@ -10,7 +10,6 @@ #ifdef USE_BLACKBOX static blackbox_t blackbox; - static uint8_t blackbox_enabled = 0; static uint8_t blackbox_rate = 0; @@ -92,34 +91,33 @@ static uint32_t blackbox_rate_div() { return (1000000 / state.looptime_autodetect) / profile.blackbox.sample_rate_hz; } -uint8_t blackbox_update() { +void blackbox_update() { blackbox_device_result_t flash_result = blackbox_device_update(); if (flash_result == BLACKBOX_DEVICE_WAIT) { // flash is still detecting, dont do anything - return 0; + return; } // flash is either idle or writing, do blackbox if ((!flags.arm_state || !rx_aux_on(AUX_BLACKBOX)) && blackbox_enabled == 1) { blackbox_device_finish(); blackbox_enabled = 0; - return 0; + return; } else if ((flags.arm_state && flags.turtle_ready == 0 && rx_aux_on(AUX_BLACKBOX)) && blackbox_enabled == 0) { if (blackbox_device_restart(profile.blackbox.field_flags, blackbox_rate_div(), state.looptime_autodetect)) { blackbox_rate = blackbox_rate_div(); blackbox_enabled = 1; blackbox.loop = 0; } - return 0; + return; } if (blackbox_enabled == 0) { - return 0; + return; } if ((state.loop_counter % blackbox_rate) != 0) { - // tell the rest of the code that flash is occuping the spi bus - return flash_result == BLACKBOX_DEVICE_WRITE; + return; } blackbox.loop++; @@ -147,9 +145,6 @@ uint8_t blackbox_update() { blackbox.cpu_load = state.cpu_load; blackbox_device_write(profile.blackbox.field_flags, &blackbox); - - // tell the rest of the code that flash is occuping the spi bus - return flash_result == BLACKBOX_DEVICE_WRITE; } #else void blackbox_init() {} diff --git a/src/io/blackbox.h b/src/io/blackbox.h index c09c6221f..2e3f2f393 100644 --- a/src/io/blackbox.h +++ b/src/io/blackbox.h @@ -52,4 +52,4 @@ cbor_result_t cbor_encode_blackbox_t(cbor_value_t *enc, const blackbox_t *b, con void blackbox_init(); void blackbox_set_debug(uint8_t index, int16_t data); -uint8_t blackbox_update(); \ No newline at end of file +void blackbox_update(); \ No newline at end of file diff --git a/src/io/blackbox_device.c b/src/io/blackbox_device.c index 7f9876a55..ca292ec59 100644 --- a/src/io/blackbox_device.c +++ b/src/io/blackbox_device.c @@ -4,6 +4,7 @@ #include "core/looptime.h" #include "core/project.h" +#include "core/scheduler.h" #include "io/blackbox_device_flash.h" #include "io/blackbox_device_sdcard.h" #include "util/cbor_helper.h" @@ -114,7 +115,7 @@ void blackbox_device_reset() { blackbox_device_header.magic = BLACKBOX_HEADER_MAGIC; blackbox_device_header.file_num = 0; - looptime_reset(); + task_reset_runtime(); } bool blackbox_device_restart(uint32_t field_flags, uint32_t blackbox_rate, uint32_t looptime) { diff --git a/src/io/msp.c b/src/io/msp.c index bd836e236..f1e80fb19 100644 --- a/src/io/msp.c +++ b/src/io/msp.c @@ -6,16 +6,17 @@ #include "core/debug.h" #include "core/flash.h" #include "core/looptime.h" +#include "core/scheduler.h" #include "driver/motor.h" #include "driver/reset.h" #include "driver/serial.h" #include "driver/serial_4way.h" #include "flight/control.h" +#include "io/quic.h" #include "io/usb_configurator.h" -#include "quic.h" +#include "io/vtx.h" #include "util/crc.h" #include "util/util.h" -#include "vtx.h" enum { MSP_REBOOT_FIRMWARE = 0, @@ -488,7 +489,7 @@ static void msp_process_serial_cmd(msp_t *msp, msp_magic_t magic, uint16_t cmd, } if (!flags.arm_state && msp->device != MSP_DEVICE_SPI_RX) { flash_save(); - looptime_reset(); + task_reset_runtime(); } msp_send_reply(msp, magic, cmd, NULL, 0); break; diff --git a/src/io/quic.c b/src/io/quic.c index 7c5a89af0..53a796f7c 100644 --- a/src/io/quic.c +++ b/src/io/quic.c @@ -7,6 +7,7 @@ #include "core/debug.h" #include "core/flash.h" #include "core/profile.h" +#include "core/scheduler.h" #include "driver/motor.h" #include "driver/serial.h" #include "driver/serial_4way.h" @@ -191,7 +192,7 @@ static void get_quic(quic_t *quic, cbor_value_t *dec) { } #ifdef DEBUG case QUIC_VAL_PERF_COUNTERS: { - res = cbor_encode_perf_counters(&enc); + res = cbor_encode_task_stats(&enc); check_cbor_error(QUIC_CMD_GET); quic_send(quic, QUIC_CMD_GET, QUIC_FLAG_NONE, encode_buffer, cbor_encoder_len(&enc)); break; diff --git a/src/io/usb_configurator.c b/src/io/usb_configurator.c index 7b90a5cf4..6b31d9264 100644 --- a/src/io/usb_configurator.c +++ b/src/io/usb_configurator.c @@ -8,6 +8,7 @@ #include "core/looptime.h" #include "core/profile.h" #include "core/project.h" +#include "core/scheduler.h" #include "driver/reset.h" #include "driver/serial.h" #include "driver/usb.h" @@ -141,6 +142,19 @@ void usb_serial_passthrough(serial_ports_t port, uint32_t baudrate, uint8_t stop #pragma GCC diagnostic ignored "-Wdouble-promotion" // This function will be where all usb send/receive coms live void usb_configurator() { + if (!usb_detect()) { + flags.usb_active = 0; + motor_test.active = 0; + return; + } + + flags.usb_active = 1; +#ifndef ALLOW_USB_ARMING + if (flags.arm_switch) { + flags.arm_safety = 1; // final safety check to disallow arming during USB operation + } +#endif + uint32_t buffer_size = 1; static uint8_t buffer[BUFFER_SIZE]; @@ -200,6 +214,6 @@ void usb_configurator() { } // this will block and handle all usb traffic while active - looptime_reset(); + task_reset_runtime(); } #pragma GCC diagnostic pop \ No newline at end of file diff --git a/src/osd/render.c b/src/osd/render.c index 776321b41..517fc66d8 100644 --- a/src/osd/render.c +++ b/src/osd/render.c @@ -9,6 +9,7 @@ #include "core/looptime.h" #include "core/profile.h" #include "core/project.h" +#include "core/scheduler.h" #include "driver/osd.h" #include "driver/time.h" #include "flight/control.h" @@ -280,8 +281,7 @@ void osd_save_exit() { for (int j = 0; j < 3; j++) number_of_increments[i][j] = 0; - // reset loop time - maybe not necessary cause it gets reset in the next screen clear - looptime_reset(); + task_reset_runtime(); if (osd_state.reboot_fc_requested) NVIC_SystemReset(); diff --git a/src/rx/express_lrs_radio.c b/src/rx/express_lrs_radio.c index 83dadbc1a..14debbcd1 100644 --- a/src/rx/express_lrs_radio.c +++ b/src/rx/express_lrs_radio.c @@ -4,6 +4,7 @@ #include "core/looptime.h" #include "core/project.h" +#include "core/scheduler.h" #include "util/util.h" #if defined(USE_RX_SPI_EXPRESS_LRS) @@ -136,7 +137,7 @@ void elrs_set_rate(uint8_t index, int32_t freq, bool invert_iq, uint32_t flrc_sy sx128x_set_busy_timeout(100); current_rate = index; - looptime_reset(); + task_reset_runtime(); } void elrs_enter_rx(volatile uint8_t *packet) { diff --git a/src/rx/frsky_redpine.c b/src/rx/frsky_redpine.c index 10dcb784c..37c233621 100644 --- a/src/rx/frsky_redpine.c +++ b/src/rx/frsky_redpine.c @@ -4,6 +4,7 @@ #include "core/flash.h" #include "core/looptime.h" #include "core/profile.h" +#include "core/scheduler.h" #include "driver/spi_cc2500.h" #include "driver/time.h" #include "flight/control.h" @@ -179,7 +180,7 @@ static uint8_t redpine_handle_packet() { flags.failsafe = 1; protocol_state = FRSKY_STATE_INIT; rx_redpine_init(); - looptime_reset(); + task_reset_runtime(); } break; } diff --git a/src/rx/stick_wizard.c b/src/rx/stick_wizard.c index a5399c249..6e06f33ef 100644 --- a/src/rx/stick_wizard.c +++ b/src/rx/stick_wizard.c @@ -4,6 +4,7 @@ #include "core/looptime.h" #include "core/profile.h" #include "core/project.h" +#include "core/scheduler.h" #include "driver/time.h" #include "flight/control.h" #include "io/led.h" @@ -144,7 +145,7 @@ static void rx_stick_calibration_wizard() { flash_save(); flash_load(); - looptime_reset(); + task_reset_runtime(); flags.gestures_disabled = 0; state.stick_calibration_wizard = STICK_WIZARD_SUCCESS;