GCC Code Coverage Report


Directory: ./
File: firmware/controllers/tcu/gear_controller.cpp
Date: 2025-11-16 14:52:24
Coverage Exec Excl Total
Lines: 82.2% 60 0 73
Functions: 100.0% 8 0 8
Branches: 72.0% 18 0 25
Decisions: 72.0% 18 - 25

Line Branch Decision Exec Source
1 #include "pch.h"
2
3 #include "gear_controller.h"
4
5 #if EFI_TCU
6 4 void GearControllerBase::init() {
7 4 initTransmissionController();
8 4 }
9
10 4 void GearControllerBase::initTransmissionController() {
11
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 switch (engineConfiguration->transmissionControllerMode) {
12 case TransmissionControllerMode::SimpleTransmissionController :
13 transmissionController = getSimpleTransmissionController();
14 break;
15
1/1
✓ Decision 'true' taken 4 times.
4 case TransmissionControllerMode::Generic4 :
16 4 transmissionController = getGeneric4TransmissionController();
17 4 break;
18 case TransmissionControllerMode::Gm4l6x :
19 transmissionController = getGm4l6xTransmissionController();
20 break;
21 default :
22 transmissionController = NULL;
23 return;
24 }
25 4 transmissionController->init();
26 }
27
28 4825 void GearControllerBase::update() {
29
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4825 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 4825 times.
4825 if (transmissionController == NULL) {
30 initTransmissionController();
31
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4825 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 4825 times.
4825 } else if (transmissionController->getMode() != engineConfiguration->transmissionControllerMode) {
32 // TODO de-init here to allow change without power cycling
33 initTransmissionController();
34 }
35
36 // check if it was init'd (it wouldn't be if set to NONE)
37
1/2
✓ Branch 0 taken 4825 times.
✗ Branch 1 not taken.
1/2
✓ Decision 'true' taken 4825 times.
✗ Decision 'false' not taken.
4825 if (transmissionController != NULL) {
38 // We are responsible for telling the transmission controller
39 // what gear we want.
40 4825 transmissionController->update(getDesiredGear());
41 }
42
43 // Post state to TS
44 4825 postState();
45 4825 }
46
47 14494 gear_e GearControllerBase::getDesiredGear() const {
48 14494 return desiredGear;
49 }
50
51 9 gear_e GearControllerBase::setDesiredGear(gear_e gear) {
52 9 desiredGear = gear;
53 9 return getDesiredGear();
54 }
55
56 4825 void GearControllerBase::postState() {
57 #if EFI_TUNER_STUDIO
58 4825 engine->outputChannels.tcuDesiredGear = getDesiredGear();
59 #endif
60 4825 }
61
62 593 void initGearController() {
63
3/3
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 589 times.
593 switch (engineConfiguration->gearControllerMode) {
64
1/1
✓ Decision 'true' taken 1 time.
1 case GearControllerMode::ButtonShift :
65 1 engine->gearController = getButtonShiftController();
66 1 break;
67
1/1
✓ Decision 'true' taken 3 times.
3 case GearControllerMode::Generic :
68 3 engine->gearController = getGenericGearController();
69 3 break;
70
1/1
✓ Decision 'true' taken 589 times.
589 default :
71 589 engine->gearController = NULL;
72 589 return;
73 }
74 4 engine->gearController->init();
75 }
76
77 59 float* GearControllerBase::getRangeStateArray(int i) {
78 // I don't remember why I put manual +/- first.
79 // I think maybe I had some concern about them needing to override under-specified ranges?
80 // e.g. with it this way, you could put 2 in the cells for +/- pins in everything else.
81 // So this way might make it a little easier/foolproof to configure, but not necessary.
82
11/12
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
59 switch (i) {
83
1/1
✓ Decision 'true' taken 14 times.
14 case 1 :
84 14 return config->tcu_rangePlus;
85 break;
86
1/1
✓ Decision 'true' taken 6 times.
6 case 2 :
87 6 return config->tcu_rangeMinus;
88 break;
89
1/1
✓ Decision 'true' taken 6 times.
6 case 3 :
90 6 return config->tcu_rangeP;
91 break;
92
1/1
✓ Decision 'true' taken 6 times.
6 case 4 :
93 6 return config->tcu_rangeR;
94 break;
95
1/1
✓ Decision 'true' taken 6 times.
6 case 5 :
96 6 return config->tcu_rangeN;
97 break;
98
1/1
✓ Decision 'true' taken 6 times.
6 case 6 :
99 6 return config->tcu_rangeD;
100 break;
101
1/1
✓ Decision 'true' taken 3 times.
3 case 7 :
102 3 return config->tcu_rangeM;
103 break;
104
1/1
✓ Decision 'true' taken 3 times.
3 case 8 :
105 3 return config->tcu_rangeM3;
106 break;
107
1/1
✓ Decision 'true' taken 3 times.
3 case 9 :
108 3 return config->tcu_rangeM2;
109 break;
110
1/1
✓ Decision 'true' taken 3 times.
3 case 10 :
111 3 return config->tcu_rangeM1;
112 break;
113
1/1
✓ Decision 'true' taken 3 times.
3 case 11 :
114 3 return config->tcu_rangeLow;
115 break;
116 default:
117 return NULL;
118 }
119 }
120 #endif // EFI_TCU
121