rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
gppwm.h File Reference

Functions

void initGpPwm ()
 
void updateGppwm ()
 

Function Documentation

◆ initGpPwm()

void initGpPwm ( )

Definition at line 31 of file gppwm.cpp.

31 {
32 for (size_t i = 0; i < efi::size(channels); i++) {
33 auto& cfg = engineConfiguration->gppwm[i];
34
35 // If no pin, don't enable this channel.
36 if (!isBrainPinValid(cfg.pin)) {
37 continue;
38 }
39
40 // Determine frequency and whether PWM is enabled
41 float freq = cfg.pwmFrequency;
42 bool usePwm = freq > 0;
43
44 // Setup pin & pwm
45 pins[i].initPin("gp pwm", cfg.pin);
46 if (usePwm) {
47 startSimplePwm(&outputs[i], channelNames[i], &engine->scheduler, &pins[i], freq, 0);
48 }
49
50 // Set up this channel's lookup table
51 tables[i]->initTable(cfg.table, cfg.rpmBins, cfg.loadBins);
52
53 // Finally configure the channel
54 channels[i].init(usePwm, &outputs[i], &pins[i], tables[i], &cfg);
55 }
56}
SingleTimerExecutor scheduler
Definition engine.h:271
void init(bool usePwm, IPwm *pwm, OutputPin *outputPin, const ValueProvider3D *table, const gppwm_channel *config)
void initTable(TValueInit(&table)[TRowNum][TColNum], const TXColumnInit(&columnBins)[TColNum], const TRowInit(&rowBins)[TRowNum])
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
static EngineAccessor engine
Definition engine.h:413
static constexpr engine_configuration_s * engineConfiguration
static OutputPin pins[GPPWM_CHANNELS]
Definition gppwm.cpp:7
static GppwmChannel channels[GPPWM_CHANNELS]
Definition gppwm.cpp:6
static gppwm_Map3D_t *const tables[]
Definition gppwm.cpp:17
static SimplePwm outputs[GPPWM_CHANNELS]
Definition gppwm.cpp:8
static const char * channelNames[GPPWM_CHANNELS]
Definition gppwm.cpp:24
bool isBrainPinValid(brain_pin_e brainPin)
void startSimplePwm(SimplePwm *state, const char *msg, Scheduler *executor, OutputPin *output, float frequency, float dutyCycle, pwm_gen_callback *callback)

Referenced by commonInitEngineController().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateGppwm()

void updateGppwm ( )

Definition at line 58 of file gppwm.cpp.

58 {
59 for (size_t i = 0; i < efi::size(channels); i++) {
60 auto result = channels[i].update(i);
61
62 engine->outputChannels.gppwmOutput[i] = result.Result;
63 engine->outputChannels.gppwmXAxis[i] = result.X;
64 engine->outputChannels.gppwmYAxis[i] = result.Y;
65 }
66}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
GppwmResult update(size_t index)
scaled_channel< uint8_t, 2, 1 > gppwmOutput[4]
scaled_channel< int16_t, 1, 1 > gppwmXAxis[4]
scaled_channel< int16_t, 10, 1 > gppwmYAxis[4]

Referenced by Engine::periodicSlowCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.