GCC Code Coverage Report


Directory: ./
File: firmware/controllers/actuators/gppwm/gppwm.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 65.0% 13 0 20
Functions: 100.0% 2 0 2
Branches: 62.5% 5 0 8
Decisions: 62.5% 5 - 8

Line Branch Decision Exec Source
1
2 #include "pch.h"
3
4 #include "gppwm_channel.h"
5
6 static GppwmChannel channels[GPPWM_CHANNELS];
7 static OutputPin pins[GPPWM_CHANNELS];
8 static SimplePwm outputs[GPPWM_CHANNELS];
9
10 typedef Map3D<GPPWM_RPM_COUNT, GPPWM_LOAD_COUNT, uint8_t, int16_t, int16_t> gppwm_Map3D_t;
11
12 static gppwm_Map3D_t table1{"gppwm1"};
13 static gppwm_Map3D_t table2{"gppwm2"};
14 static gppwm_Map3D_t table3{"gppwm3"};
15 static gppwm_Map3D_t table4{"gppwm4"};
16
17 static gppwm_Map3D_t* const tables[] = {
18 &table1,
19 &table2,
20 &table3,
21 &table4,
22 };
23
24 static const char *channelNames[GPPWM_CHANNELS] = { "GPPWM#1",
25 "GPPWM#2",
26 "GPPWM#3",
27 "GPPWM#4",
28 };
29
30
31 584 void initGpPwm() {
32
2/2
✓ Branch 1 taken 2336 times.
✓ Branch 2 taken 584 times.
2/2
✓ Decision 'true' taken 2336 times.
✓ Decision 'false' taken 584 times.
2920 for (size_t i = 0; i < efi::size(channels); i++) {
33 2336 auto& cfg = engineConfiguration->gppwm[i];
34
35 // If no pin, don't enable this channel.
36
1/2
✓ Branch 1 taken 2336 times.
✗ Branch 2 not taken.
1/2
✓ Decision 'true' taken 2336 times.
✗ Decision 'false' not taken.
2336 if (!isBrainPinValid(cfg.pin)) {
37 2336 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 584 }
57
58 1085 void updateGppwm() {
59
2/2
✓ Branch 1 taken 4340 times.
✓ Branch 2 taken 1085 times.
2/2
✓ Decision 'true' taken 4340 times.
✓ Decision 'false' taken 1085 times.
5425 for (size_t i = 0; i < efi::size(channels); i++) {
60 4340 auto result = channels[i].update(i);
61
62 4340 engine->outputChannels.gppwmOutput[i] = result.Result;
63 4340 engine->outputChannels.gppwmXAxis[i] = result.X;
64 4340 engine->outputChannels.gppwmYAxis[i] = result.Y;
65 }
66 1085 }
67