Red Bird Racing VCU v2
 
Loading...
Searching...
No Matches
BoardConfig.h
Go to the documentation of this file.
1/**
2 * @file BoardConfig.h
3 * @author Planeson, Red Bird Racing
4 * @date 2026-01-15
5 * @version 2.0.1
6 * @brief Board configuration for the VCU (Vehicle Control Unit)
7 * @details This file defines the board configuration and pin mappings for different versions of the VCU and for Arduino Uno.
8 * Define the appropriate macro to select the desired board configuration.
9 *
10 * @par Options
11 * - @c USE_ARDUINO_PINS: Use Arduino Uno pin numbers
12 * - @c USE_VCU_V2: Use VCU V2 pin numbers
13 * - @c USE_VCU_V3: Use VCU V3 pin numbers
14 * - @c USE_3CH_CAN: Use 3 channel CAN dev board pin numbers
15 * - @c USE_VCU_V3_2: Use VCU V3.2 pin numbers
16 * - Undefined: no pins defined, intentional compilation error
17 *
18 * @note Only one option should be uncommented at a time.
19 */
20
21#ifndef BOARDCONFIG_H
22#define BOARDCONFIG_H
23
24// select the board configuration to use
25#define USE_VCU_V3_2
26
27// VCU v3.2
28
29#ifdef USE_VCU_V3_2
30
31#define OUT_4 PIN_PB0
32#define OUT_5 PIN_PC2
33#define OUT_6 PIN_PC3
34#define OUT_7 PIN_PC4
35
36// === CAN bus pins ===
37#define CS_CAN_DL PIN_PD1 // CAN 3
38#define CS_CAN_BMS PIN_PB2 // CAN 2
39#define CS_CAN_MOTOR PIN_PB1 // CAN 1
40
41// === APPS and Brake pins ===
42#define APPS_5V PIN_A6
43#define APPS_3V3 PIN_A7
44#define BRAKE_IN PIN_PC0
45#define HALL_SENSOR PIN_PC1
46
47// VCU brake light
48#define BRAKE_LIGHT PIN_PD5 // P=Out1
49
50// === Drive mode ===
51#define FRG PIN_PD7 // P=Out3
52#define DRIVE_MODE_BTN PIN_PC5 // IGN_5V
53
54// === Buzzer for car status ===
55#define BUZZER PIN_PD6 // P=Out2
56
57// === Button active state ===
58#define BUTTON_ACTIVE HIGH
59
60// === MCP2515 crystal frequency ===
61#define MCP2515_CRYSTAL_FREQ MCP_20MHZ
62#endif // USE_VCU_V3_2
63
64// VCU v3
65
66#ifdef USE_VCU_V3
67// === CAN bus pins ===
68#define CS_CAN_MOTOR PIN_PB2
69#define CS_CAN_BMS PIN_PB1
70#define CS_CAN_DL PIN_PD5 // Datalogger
71
72// === APPS and Brake pins ===
73#define APPS_5V PIN_PC0
74#define APPS_3V3 PIN_PC1
75#define BRAKE_5V_OUT PIN_PC2
76#define BRAKE_IN PIN_PC3
77
78// === Drive mode ===
79#define FRG PIN_PB0
80#define DRIVE_MODE_BTN PIN_PC4
81
82// === Buzzer for car status ===
83#define BUZZER PIN_PD4
84
85// === BMS HV start failed LED ===
86// #define BMS_FAILED_LED PIN_PD4
87
88// === Button active state ===
89#define BUTTON_ACTIVE HIGH
90
91// === MCP2515 crystal frequency ===
92#define MCP2515_CRYSTAL_FREQ MCP_20MHZ
93
94// end of VCU v3
95
96#endif // USE_VCU_V3
97
98// 3 channel CAN dev board
99
100#ifdef USE_3CH_CAN
101
102#define OUT_4 PIN_PD4
103#define OUT_5 PIN_PD5
104#define OUT_6 PIN_PD6
105#define OUT_7 PIN_PD7
106
107// === CAN bus pins ===
108#define CS_CAN_MOTOR PIN_PB2
109#define CS_CAN_BMS PIN_PB1
110#define CS_CAN_DL PIN_PB0
111
112// === APPS and Brake pins ===
113#define APPS_5V PIN_PC0
114#define APPS_3V3 PIN_PC1
115#define BRAKE_IN PIN_PC2
116#define HALL_SENSOR PIN_PC3
117
118// VCU brake light
119#define BRAKE_LIGHT PIN_PD2
120
121// === Drive mode ===
122#define FRG PIN_PD3 // = drive mode LED, soft relay
123#define DRIVE_MODE_BTN PIN_PC4
124
125// === Buzzer for car status ===
126#define BUZZER PIN_PD4
127
128// === BMS HV start failed LED ===
129#define BMS_FAILED_LED PIN_PD5
130
131// === Button active state ===
132#define BUTTON_ACTIVE LOW
133
134// === MCP2515 crystal frequency ===
135#define MCP2515_CRYSTAL_FREQ MCP_20MHZ
136#endif // USE_3CH_CAN
137
138// VCU v2
139#ifdef USE_VCU_V2
140// === CAN bus pins ===
141#define CS_CAN_MOTOR PIN_PB2
142#define CS_CAN_BMS PIN_PB1 // unused
143#define CS_CAN_DL PIN_PD5 // Datalogger
144
145// === APPS and Brake pins ===
146#define APPS_5V PIN_PC0
147
148#define APPS_3V3 PIN_PC1
149
150#define BRAKE_IN PIN_PC2
151
152// VCU brake light
153#define BRAKE_LIGHT PIN_PC3
154
155// === Drive mode ===
156#define FRG PIN_PB0
157
158#define DRIVE_MODE_BTN PIN_PC4
159
160// === Buzzer for car status ===
161#define BUZZER PIN_PD4
162
163// === BMS HV start failed LED ===
164// #define BMS_FAILED_LED PIN_PD4
165
166// === Button active state ===
167#define BUTTON_ACTIVE HIGH
168
169// === MCP2515 crystal frequency ===
170#define MCP2515_CRYSTAL_FREQ MCP_16MHZ
171// end of VCU v2
172
173#endif // USE_VCU_V2
174
175#ifdef USE_ARDUINO_PINS
176
177// === CAN bus pin for arduino testing ===
178#define CS_CAN_MOTOR 9
179#define CS_CAN_BMS 10
180#define CS_CAN_DL 11 // Datalogger
181
182// === APPS and Brake pins ===
183#define APPS_5V A0
184#define APPS_3V3 A1
185#define BRAKE_5V_OUT A2
186#define BRAKE_IN A3
187
188// === Drive mode ===
189#define FRG 4
190#define DRIVE_MODE_BTN 5
191// === Buzzer for car status ===
192#define BUZZER 6
193
194// === BMS HV start failed LED ===
195// #define BMS_FAILED_LED PIN_PD4
196
197// === Button active state ===
198#define BUTTON_ACTIVE HIGH
199
200// === MCP2515 crystal frequency ===
201#define MCP2515_CRYSTAL_FREQ MCP_8MHZ
202
203#endif // USE_ARDUINO_PINS
204
205#define CAN_RATE CAN_500KBPS
206
207#endif // BOARDCONFIG_H