forked from romioRN/fw-custom-Cat-GDI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
board_configuration.cpp
156 lines (113 loc) · 4.36 KB
/
board_configuration.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "pch.h"
#include "Cat_GDI_meta.h"
static void setInjectorPins() {
engineConfiguration->injectionPins[0] = Gpio::Cat_ingect_H_1;
engineConfiguration->injectionPins[1] = Gpio::Cat_ingect_H_2;
engineConfiguration->injectionPins[2] = Gpio::Cat_ingect_H_3;
engineConfiguration->injectionPins[3] = Gpio::Cat_ingect_H_4;
engineConfiguration->injectionPins[4] = Gpio::Cat_ingect_5;
engineConfiguration->injectionPins[5] = Gpio::Cat_ingect_6;
engineConfiguration->injectionPins[6] = Gpio::Cat_ingect_7;
engineConfiguration->injectionPins[7] = Gpio::Cat_ingect_8;
}
static void setIgnitionPins() {
engineConfiguration->ignitionPins[0] = Gpio::Cat_IGN_1;
engineConfiguration->ignitionPins[1] = Gpio::Cat_IGN_2;
engineConfiguration->ignitionPins[2] = Gpio::Cat_IGN_3;
engineConfiguration->ignitionPins[3] = Gpio::Cat_IGN_4;
engineConfiguration->ignitionPins[4] = Gpio::Cat_IGN_5;
engineConfiguration->ignitionPins[5] = Gpio::Cat_IGN_6;
engineConfiguration->ignitionPins[6] = Gpio::Cat_IGN_7;
engineConfiguration->ignitionPins[7] = Gpio::Cat_IGN_8;
}
static void setEtbConfig() {
// TLE9201 driver
// This chip has three control pins:
// DIR - sets direction of the motor
// PWM - pwm control (enable high, coast low)
// DIS - disables motor (enable low)
// Throttle #1
// PWM pin
engineConfiguration->etbIo[0].controlPin = Gpio::D12;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = Gpio::D10;
// Disable pin
engineConfiguration->etbIo[0].disablePin = Gpio::D11;
// Throttle #2
// PWM pin
engineConfiguration->etbIo[1].controlPin = Gpio::D13;
// DIR pin
engineConfiguration->etbIo[1].directionPin1 = Gpio::D9;
// Disable pin
engineConfiguration->etbIo[1].disablePin = Gpio::D8;
// we only have pwm/dir, no dira/dirb
engineConfiguration->etb_use_two_wires = false;
}
static void setupVbatt() {
// 5.6k high side/10k low side = 1.56 ratio divider
engineConfiguration->analogInputDividerCoefficient = 1.56f;
// 6.34k high side/ 1k low side
engineConfiguration->vbattDividerCoeff = (85.0f / 10.0f);
// Battery sense on PA7
engineConfiguration->vbattAdcChannel = EFI_ADC_7;
engineConfiguration->adcVcc = 3.3f;
}
// PE3 is error LED, configured in board.mk
Gpio getCommsLedPin() {
return Gpio::Unassigned;
}
Gpio getRunningLedPin() {
return Gpio::Unassigned;
}
Gpio getWarningLedPin() {
return Gpio::Unassigned;
}
static void setupDefaultSensorInputs() {
engineConfiguration->triggerInputPins[0] = Cat_DIGITAL_1;
// Direct hall-only cam input
engineConfiguration->camInputs[0] = Cat_DIGITAL_4;
// open question if it's great to have TPS in default TPS - the down-side is for
// vehicles without TPS or for first start without TPS one would have to turn in off
// to avoid cranking corrections based on wrong TPS data
engineConfiguration->tps1_1AdcChannel = Cat_IN_TPS2_1;
engineConfiguration->tps1_2AdcChannel = Cat_IN_TPS1_2;
engineConfiguration->map.sensor.hwChannel = Cat_IN_MAP;
engineConfiguration->clt.adcChannel = Cat_IN_CLT;
engineConfiguration->iat.adcChannel = Cat_IN_IAT;
}
static void setupSdCard() {
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3;
engineConfiguration->sdCardCsPin = Gpio::D2;
engineConfiguration->is_enabled_spi_3 = true;
engineConfiguration->spi3sckPin = Gpio::C10;
engineConfiguration->spi3misoPin = Gpio::C11;
engineConfiguration->spi3mosiPin = Gpio::C12;
}
void setBoardConfigOverrides() {
setupVbatt();
setEtbConfig();
setupSdCard();
engineConfiguration->clt.config.bias_resistor = 2490;
//engineConfiguration->iat.config.bias_resistor = 2490;
//CAN 1 bus overwrites
engineConfiguration->canRxPin = Gpio::D0;
engineConfiguration->canTxPin = Gpio::D1;
//CAN 2 bus overwrites
engineConfiguration->can2RxPin = Gpio::B12;
engineConfiguration->can2TxPin = Gpio::B13;
engineConfiguration->lps25BaroSensorScl = Gpio::B10;
engineConfiguration->lps25BaroSensorSda = Gpio::B11;
engineConfiguration->is_enabled_spi_5 = true;
engineConfiguration->spi5sckPin = Gpio::F7;
engineConfiguration->spi5misoPin = Gpio::F8;
engineConfiguration->spi5mosiPin = Gpio::F9;
}
void setBoardDefaultConfiguration(void) {
setInjectorPins();
setIgnitionPins();
setupDefaultSensorInputs();
engineConfiguration->mainRelayPin = Gpio::Cat_HS_2;
engineConfiguration->fanPin = Gpio::Cat_HS_3;
engineConfiguration->fuelPumpPin = Gpio::Cat_pump_L2;
engineConfiguration->enableSoftwareKnock = true;
}