SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
PinConfig.def
Go to the documentation of this file.
1
27#ifndef __ECU_PINCONFIG_DEF__
28
29// @cond
30
31#define __ECU_PINCONFIG_DEF__
32
33#include "Canbus.h"
34#include "ECUGlobalConfig.h"
35#include "PPHelp.h"
36#include "WProgram.h"
37
38#define ANALOG
39#define DIGITAL
40#define NIL 0xDEADBEEF // NOTE: Random number that should not match any inital values
41
42// @endcond
43
47#define CONF_PINS_CANBUS_UPDATE_INTERVAL_MICRO 50000
48
52#define CONF_PINS_ANALOG_WRITE_RESOLUTION 12
53
54// @cond
55
56// Internal Pins
57// Virtual pins that can be used as a canPin, must all be unique to eachother with values 100 - 254
58// Whether the pin is analog or digital depends on which message type it is sent/received on, meaning it is either a digital or analog value.
59#define PINS_INTERNAL_CHARGE_SIGNAL 100
60#define PINS_INTERNAL_START 101
61#define PINS_INTERNAL_BMS_FAULT 102
62#define PINS_INTERNAL_IMD_FAULT 103
63#define PINS_INTERNAL_GEN_FAULT 104
64#define PINS_INTERNAL_STATE 105
65#define PINS_INTERNAL_SYNC 106
66#define PINS_INTERNAL_REVERSE 107
67#define PINS_INTERNAL_TVAGG 108
68
69// Both ECUs
70#define PINS_BOTH_LED 13
71
72// Back ECU Only - ECU0
73#define PINS_BACK_SERVO_OFF 0 // Turn the back servos off
74#define PINS_BACK_TSV_SIGNAL 3 // digital input
75#define PINS_BACK_AIR2 4 // Air 2 control
76#define PINS_BACK_CHARGING_RELAY 5 // On or Off
77#define PINS_BACK_SOUND_DRIVER 6 // Buzzer
78#define PINS_BACK_BRAKE_LIGHT 7 // Brake light On or Off
79#define PINS_BACK_SERVO1_PWM 8 // 0-3.3V Servo control
80#define PINS_BACK_PRECHARGE_RELAY 9 // Precharge relay control
81#define PINS_BACK_AIR1 10 // Precharge Air control
82#define PINS_BACK_FANS_ONOFF 24 // Turn Cooling Fans on or off
83#define PINS_BACK_SHUTDOWN_SIGNAL 25 // digital input
84#define PINS_BACK_HVD_FAULT 26 // Fault pin
85#define PINS_BACK_SERVO2_PWM 30 // 0-3.3V Servo control
86#define PINS_BACK_FAN1_PWM 23 // PWM fan control
87#define PINS_BACK_FAN2_PWM 22 // PWM fan control
88#define PINS_BACK_FAN3_PWM 21 // PWM fan control
89#define PINS_BACK_FAN4_PWM 20 // PWM fan control
90#define PINS_BACK_IMD_FAULT 19 // Fault pin
91#define PINS_BACK_BMS_FAULT 18 // Fault pin
92#define PINS_BACK_PUMP_DAC 66 // DAC pump control 2-2.5V
93
94// Front ECU Only - ECU1
95#define PINS_FRONT_BUTTON_INPUT_OFF 2 // Digital Start Button
96#define PINS_FRONT_WHEEL1 21 // 0-5v R wheel speed
97#define PINS_FRONT_WHEEL0 20 // 0-5v L wheel speed
98#define PINS_FRONT_PEDAL1 A4 // Pedal 2
99#define PINS_FRONT_PEDAL0 A2 // Pedal 1
100#define PINS_FRONT_STEER 15 // -5-5v steering wheel
101#define PINS_FRONT_BRAKE 14 // 0-3.3v brake
102#define PINS_FRONT_IMD_LIGHT 38 // imd led
103#define PINS_FRONT_BMS_LIGHT 37 // bms led
104#define PINS_FRONT_START_LIGHT 36 // start led
105// @endcond
106
107#if CONF_ECU_POSITION == BACK_ECU
108
132#define ECU_PINS \
133 X(PINS_BOTH_LED, DIGITAL, OUTPUT, NIL) \
134 X(PINS_BACK_SERVO_OFF, DIGITAL, OUTPUT, 0) \
135 X(PINS_BACK_TSV_SIGNAL, DIGITAL, INPUT, NIL) \
136 X(PINS_BACK_AIR2, ANALOG, OUTPUT, 0) \
137 X(PINS_BACK_CHARGING_RELAY, DIGITAL, OUTPUT, 1) \
138 X(PINS_BACK_SOUND_DRIVER, ANALOG, OUTPUT, 0) \
139 X(PINS_BACK_BRAKE_LIGHT, ANALOG, OUTPUT, 0) \
140 X(PINS_BACK_SERVO1_PWM, ANALOG, OUTPUT, NIL) \
141 X(PINS_BACK_PRECHARGE_RELAY, ANALOG, OUTPUT, 0) \
142 X(PINS_BACK_AIR1, ANALOG, OUTPUT, 0) \
143 X(PINS_BACK_FANS_ONOFF, DIGITAL, OUTPUT, 0) \
144 X(PINS_BACK_SHUTDOWN_SIGNAL, DIGITAL, INPUT, NIL) \
145 X(PINS_BACK_HVD_FAULT, DIGITAL, INPUT, NIL) \
146 X(PINS_BACK_SERVO2_PWM, ANALOG, OUTPUT, NIL) \
147 X(PINS_BACK_FAN1_PWM, ANALOG, OUTPUT, 0) \
148 X(PINS_BACK_FAN2_PWM, ANALOG, OUTPUT, 0) \
149 X(PINS_BACK_FAN3_PWM, ANALOG, OUTPUT, 0) \
150 X(PINS_BACK_FAN4_PWM, ANALOG, OUTPUT, 0) \
151 X(PINS_BACK_IMD_FAULT, DIGITAL, INPUT, NIL) \
152 X(PINS_BACK_BMS_FAULT, DIGITAL, INPUT, NIL) \
153 X(PINS_BACK_PUMP_DAC, ANALOG, OUTPUT, 0)
154
172#define PINS_CANBUS_ANALOG_IN \
173 X(ADD_CANPIN_ANALOG0, PINS_FRONT_PEDAL0) \
174 X(ADD_CANPIN_ANALOG0, PINS_FRONT_PEDAL1) \
175 X(ADD_CANPIN_ANALOG1, PINS_FRONT_WHEEL1) \
176 X(ADD_CANPIN_ANALOG1, PINS_FRONT_WHEEL0) \
177 X(ADD_CANPIN_ANALOG2, PINS_FRONT_STEER) \
178 X(ADD_CANPIN_ANALOG2, PINS_FRONT_BRAKE) \
179 X(ADD_CANPIN_ANALOG4, PINS_INTERNAL_TVAGG)
180
184#define PINS_CANBUS_ANALOG_OUT \
185 X(ADD_CANPIN_ANALOG3, PINS_INTERNAL_STATE)
186
204#define PINS_CANBUS_DIGITAL_IN \
205 X(ADD_CANPIN_DIGITAL1, PINS_INTERNAL_CHARGE_SIGNAL) \
206 X(ADD_CANPIN_DIGITAL1, PINS_INTERNAL_SYNC) \
207 X(ADD_CANPIN_DIGITAL1, PINS_INTERNAL_REVERSE) \
208 X(ADD_CANPIN_DIGITAL1, PINS_FRONT_BUTTON_INPUT_OFF)
209
213#define PINS_CANBUS_DIGITAL_OUT \
214 X(ADD_CANPIN_DIGITAL0, PINS_INTERNAL_START) \
215 X(ADD_CANPIN_DIGITAL0, PINS_INTERNAL_BMS_FAULT) \
216 X(ADD_CANPIN_DIGITAL0, PINS_INTERNAL_IMD_FAULT) \
217 X(ADD_CANPIN_DIGITAL0, PINS_INTERNAL_GEN_FAULT)
218
219#else
220#define ECU_PINS \
221 X(PINS_BOTH_LED, DIGITAL, OUTPUT, NIL) \
222 X(PINS_FRONT_BUTTON_INPUT_OFF, DIGITAL, INPUT, NIL) \
223 X(PINS_FRONT_WHEEL1, ANALOG, INPUT, NIL) \
224 X(PINS_FRONT_WHEEL0, ANALOG, INPUT, NIL) \
225 X(PINS_FRONT_PEDAL1, ANALOG, INPUT, NIL) \
226 X(PINS_FRONT_PEDAL0, ANALOG, INPUT, NIL) \
227 X(PINS_FRONT_STEER, ANALOG, INPUT, NIL) \
228 X(PINS_FRONT_BRAKE, ANALOG, INPUT, NIL) \
229 X(PINS_FRONT_IMD_LIGHT, DIGITAL, OUTPUT, 0) \
230 X(PINS_FRONT_BMS_LIGHT, DIGITAL, OUTPUT, 0) \
231 X(PINS_FRONT_START_LIGHT, DIGITAL, OUTPUT, 0)
232
233#define PINS_CANBUS_ANALOG_IN \
234 X(ADD_CANPIN_ANALOG3, PINS_INTERNAL_STATE)
235
236#define PINS_CANBUS_ANALOG_OUT \
237 X(ADD_CANPIN_ANALOG0, PINS_FRONT_PEDAL0) \
238 X(ADD_CANPIN_ANALOG0, PINS_FRONT_PEDAL1) \
239 X(ADD_CANPIN_ANALOG1, PINS_FRONT_WHEEL1) \
240 X(ADD_CANPIN_ANALOG1, PINS_FRONT_WHEEL0) \
241 X(ADD_CANPIN_ANALOG2, PINS_FRONT_STEER) \
242 X(ADD_CANPIN_ANALOG2, PINS_FRONT_BRAKE) \
243 X(ADD_CANPIN_ANALOG4, PINS_INTERNAL_TVAGG)
244
245#define PINS_CANBUS_DIGITAL_IN \
246 X(ADD_CANPIN_DIGITAL0, PINS_INTERNAL_START) \
247 X(ADD_CANPIN_DIGITAL0, PINS_INTERNAL_BMS_FAULT) \
248 X(ADD_CANPIN_DIGITAL0, PINS_INTERNAL_IMD_FAULT) \
249 X(ADD_CANPIN_DIGITAL0, PINS_INTERNAL_GEN_FAULT)
250
251#define PINS_CANBUS_DIGITAL_OUT \
252 X(ADD_CANPIN_DIGITAL1, PINS_INTERNAL_CHARGE_SIGNAL) \
253 X(ADD_CANPIN_DIGITAL1, PINS_INTERNAL_SYNC) \
254 X(ADD_CANPIN_DIGITAL1, PINS_INTERNAL_REVERSE) \
255 X(ADD_CANPIN_DIGITAL1, PINS_FRONT_BUTTON_INPUT_OFF)
256
257#endif
258
259#endif // __ECU_PINCONFIG_DEF__
FlexCAN_T4 wrapper.
Configure global build properties.
Compilation of various helpful preprocessor macros.