Core ECU
Top-level ECU context and single-step control loop.
Header: core/ecu_core.h
-
void ecu_init(ecu_t *ecu, const ecu_config_t *cfg)
Initialise the ECU context with the given configuration.
- Parameters:
ecu – [out] ECU context to initialise.
cfg – [in] Configuration parameters.
-
ecu_outputs_t ecu_step(ecu_t *ecu, const ecu_inputs_t *inputs, float dt)
Execute one control-loop iteration.
Reads sensors, updates the state machine, runs PID and fuel scheduling, and returns the computed outputs.
- Parameters:
ecu – [inout] ECU context.
inputs – [in] Current sensor readings and throttle.
dt – [in] Time step in seconds.
- Returns:
Computed outputs for this step.
-
struct ecu_inputs_t
- #include <ecu_core.h>
Raw inputs fed into each control step.
-
struct ecu_outputs_t
- #include <ecu_core.h>
Outputs computed by a single control step.
-
struct ecu_t
- #include <ecu_core.h>
Complete ECU runtime context.
Public Members
-
ecu_config_t config
Active configuration.
-
ecu_fuel_state_t fuel
Fuel scheduling state.
-
ecu_sensor_state_t rpm_sensor
RPM sensor validation state.
-
ecu_sensor_state_t egt_sensor
EGT sensor validation state.
-
ecu_sensor_config_t rpm_sensor_cfg
RPM sensor configuration.
-
ecu_sensor_config_t egt_sensor_cfg
EGT sensor configuration.
-
ecu_map1d_t fuel_map
RPM → base fuel %.
-
ecu_map1d_t egt_limit_map
RPM → max EGT.
-
uint32_t fault_code
Accumulated fault bitmask.
-
ecu_time_t time_ms
Elapsed time in milliseconds.
-
ecu_config_t config