useful content from Move ETB control to a thread #1374

This commit is contained in:
rusefi 2020-04-28 08:05:18 -04:00
parent d25c33492b
commit 44facf1140
2 changed files with 11 additions and 1 deletions

View File

@ -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) {}

View File

@ -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