diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index 0535d98f78..51f61199e4 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -72,6 +72,8 @@ #define EFI_ALTERNATOR_CONTROL TRUE +#define EFI_AUX_PID TRUE + #define EFI_SIGNAL_EXECUTOR_SLEEP FALSE #define EFI_SIGNAL_EXECUTOR_ONE_TIMER TRUE #define EFI_SIGNAL_EXECUTOR_HW_TIMER FALSE diff --git a/firmware/controllers/algo/aux_pid.cpp b/firmware/controllers/algo/aux_pid.cpp index 82d72b3cb4..dc146ae722 100644 --- a/firmware/controllers/algo/aux_pid.cpp +++ b/firmware/controllers/algo/aux_pid.cpp @@ -7,7 +7,34 @@ #include "aux_pid.h" +#if EFI_AUX_PID || defined(__DOXYGEN__) + +EXTERN_ENGINE +; + +// todo: this is to some extent a copy-paste of alternatorController. maybe same loop +// for all PIDs? + +static THD_WORKING_AREA(auxPidThreadStack, UTILITY_THREAD_STACK_SIZE); + +static msg_t auxPidThread(int param) { + UNUSED(param); + chRegSetThreadName("AuxPidController"); + while (true) { + int dt = maxI(10, engineConfiguration->auxPid1DT); + chThdSleepMilliseconds(dt); + + + } +#if defined __GNUC__ + return -1; +#endif +} + void initAuxPid(Logging *sharedLogger) { + chThdCreateStatic(auxPidThreadStack, sizeof(auxPidThreadStack), LOWPRIO, + (tfunc_t) auxPidThread, NULL); } +#endif diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index ac5970786f..2a79ee5c43 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -50,6 +50,7 @@ #include "alternatorController.h" #include "fuel_math.h" #include "settings.h" +#include "aux_pid.h" #if HAL_USE_ADC || defined(__DOXYGEN__) #include "AdcConfiguration.h" @@ -617,6 +618,10 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) { initAlternatorCtrl(sharedLogger); #endif +#if EFI_AUX_PID || defined(__DOXYGEN__) + initAuxPid(sharedLogger); +#endif + #if EFI_ELECTRONIC_THROTTLE_BODY || defined(__DOXYGEN__) initElectronicThrottle(); #endif /* EFI_ELECTRONIC_THROTTLE_BODY */