rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Typedefs | Functions | Variables
gppwm.cpp File Reference

Typedefs

typedef Map3D< GPPWM_RPM_COUNT, GPPWM_LOAD_COUNT, uint8_t, int16_t, int16_t > gppwm_Map3D_t
 

Functions

void initGpPwm ()
 
void updateGppwm ()
 

Variables

static GppwmChannel channels [GPPWM_CHANNELS]
 
static OutputPin pins [GPPWM_CHANNELS]
 
static SimplePwm outputs [GPPWM_CHANNELS]
 
static gppwm_Map3D_t table1 {"gppwm1"}
 
static gppwm_Map3D_t table2 {"gppwm2"}
 
static gppwm_Map3D_t table3 {"gppwm3"}
 
static gppwm_Map3D_t table4 {"gppwm4"}
 
static gppwm_Map3D_t *const tables []
 
static const charchannelNames [GPPWM_CHANNELS]
 

Typedef Documentation

◆ gppwm_Map3D_t

typedef Map3D<GPPWM_RPM_COUNT, GPPWM_LOAD_COUNT, uint8_t, int16_t, int16_t> gppwm_Map3D_t

Definition at line 10 of file gppwm.cpp.

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:

Variable Documentation

◆ channelNames

const char* channelNames[GPPWM_CHANNELS]
static
Initial value:
= { "GPPWM#1",
"GPPWM#2",
"GPPWM#3",
"GPPWM#4",
}

Definition at line 24 of file gppwm.cpp.

24 { "GPPWM#1",
25"GPPWM#2",
26"GPPWM#3",
27"GPPWM#4",
28 };

Referenced by initGpPwm().

◆ channels

GppwmChannel channels[GPPWM_CHANNELS]
static

Definition at line 6 of file gppwm.cpp.

Referenced by initGpPwm(), and updateGppwm().

◆ outputs

SimplePwm outputs[GPPWM_CHANNELS]
static

Definition at line 8 of file gppwm.cpp.

Referenced by initGpPwm().

◆ pins

OutputPin pins[GPPWM_CHANNELS]
static

Definition at line 7 of file gppwm.cpp.

Referenced by initGpPwm().

◆ table1

gppwm_Map3D_t table1 {"gppwm1"}
static

Definition at line 12 of file gppwm.cpp.

12{"gppwm1"};

◆ table2

gppwm_Map3D_t table2 {"gppwm2"}
static

Definition at line 13 of file gppwm.cpp.

13{"gppwm2"};

◆ table3

gppwm_Map3D_t table3 {"gppwm3"}
static

Definition at line 14 of file gppwm.cpp.

14{"gppwm3"};

◆ table4

gppwm_Map3D_t table4 {"gppwm4"}
static

Definition at line 15 of file gppwm.cpp.

15{"gppwm4"};

◆ tables

gppwm_Map3D_t* const tables[]
static
Initial value:
= {
}
static gppwm_Map3D_t table2
Definition gppwm.cpp:13
static gppwm_Map3D_t table1
Definition gppwm.cpp:12
static gppwm_Map3D_t table4
Definition gppwm.cpp:15
static gppwm_Map3D_t table3
Definition gppwm.cpp:14

Definition at line 17 of file gppwm.cpp.

17 {
18 &table1,
19 &table2,
20 &table3,
21 &table4,
22};

Referenced by initGpPwm().

Go to the source code of this file.