diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 0e1187aca2..059d04cee5 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -387,6 +387,11 @@ void EtbController::update(efitick_t nowNt) { } #if !EFI_UNIT_TEST +/** + * Things running on a timer (instead of a thread) don't participate it the RTOS's thread priority system, + * and operate essentially "first come first serve", which risks starvation. + * Since ETB is a safety critical device, we need the hard RTOS guarantee that it will be scheduled over other less important tasks. + */ #include "periodic_thread_controller.h" struct EtbImpl final : public EtbController, public PeriodicController<512> { EtbImpl() : PeriodicController("ETB", NORMALPRIO + 3, ETB_LOOP_FREQUENCY) {} diff --git a/firmware/controllers/actuators/electronic_throttle.h b/firmware/controllers/actuators/electronic_throttle.h index 2b9db1df18..375b3f2eed 100644 --- a/firmware/controllers/actuators/electronic_throttle.h +++ b/firmware/controllers/actuators/electronic_throttle.h @@ -7,7 +7,12 @@ #pragma once -// https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem +/** + * Hard code ETB update speed. + * Since this is a safety critical system with no real reason for a user to ever need to change the update rate, + * it's locked to 500hz, along with the ADC. + * https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem + */ #define ETB_LOOP_FREQUENCY 500 #define DEFAULT_ETB_PWM_FREQUENCY 800