Skip to content

Commit b7dead7

Browse files
committed
Merge commit 'ad0f372ad' into HEAD
2 parents b574b60 + ad0f372 commit b7dead7

29 files changed

+126
-133
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ repos:
1515
additional_dependencies: ['git+https://github.com/numpy/numpy-stubs', 'types-requests', 'types-atomicwrites',
1616
'types-pycurl']
1717
- repo: https://github.com/astral-sh/ruff-pre-commit
18-
rev: v0.1.14
18+
rev: v0.2.1
1919
hooks:
2020
- id: ruff

board/boards/black.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// ///////////////////// //
2-
// Black Panda + Harness //
3-
// ///////////////////// //
1+
// /////////////////////////////// //
2+
// Black Panda (STM32F4) + Harness //
3+
// /////////////////////////////// //
44

55
void black_enable_can_transceiver(uint8_t transceiver, bool enabled) {
66
switch (transceiver){
@@ -136,7 +136,7 @@ void black_init(void) {
136136
// Set normal CAN mode
137137
black_set_can_mode(CAN_MODE_NORMAL);
138138

139-
// flip CAN0 and CAN2 if we are flipped
139+
// change CAN mapping when flipped
140140
if (harness.status == HARNESS_STATUS_FLIPPED) {
141141
can_flip_buses(0, 2);
142142
}
@@ -165,7 +165,6 @@ const harness_configuration black_harness_config = {
165165
const board board_black = {
166166
.set_bootkick = unused_set_bootkick,
167167
.harness_config = &black_harness_config,
168-
.has_hw_gmlan = false,
169168
.has_obd = true,
170169
.has_spi = false,
171170
.has_canfd = false,

board/boards/board_declarations.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ typedef bool (*board_read_som_gpio)(void);
2121

2222
struct board {
2323
const harness_configuration *harness_config;
24-
const bool has_hw_gmlan;
2524
const bool has_obd;
2625
const bool has_spi;
2726
const bool has_canfd;

board/boards/cuatro.h

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// ////////////////////////// //
2+
// Cuatro (STM32H7) + Harness //
3+
// ////////////////////////// //
4+
15
void cuatro_set_led(uint8_t color, bool enabled) {
26
switch (color) {
37
case LED_RED:
@@ -14,9 +18,52 @@ void cuatro_set_led(uint8_t color, bool enabled) {
1418
}
1519
}
1620

21+
void cuatro_enable_can_transceiver(uint8_t transceiver, bool enabled) {
22+
switch (transceiver) {
23+
case 1U:
24+
set_gpio_output(GPIOB, 7, !enabled);
25+
break;
26+
case 2U:
27+
set_gpio_output(GPIOB, 10, !enabled);
28+
break;
29+
case 3U:
30+
set_gpio_output(GPIOD, 8, !enabled);
31+
break;
32+
case 4U:
33+
set_gpio_output(GPIOB, 11, !enabled);
34+
break;
35+
default:
36+
break;
37+
}
38+
}
39+
40+
void cuatro_enable_can_transceivers(bool enabled) {
41+
uint8_t main_bus = (harness.status == HARNESS_STATUS_FLIPPED) ? 3U : 1U;
42+
for (uint8_t i=1U; i<=4U; i++) {
43+
// Leave main CAN always on for CAN-based ignition detection
44+
if (i == main_bus) {
45+
cuatro_enable_can_transceiver(i, true);
46+
} else {
47+
cuatro_enable_can_transceiver(i, enabled);
48+
}
49+
}
50+
}
51+
1752
void cuatro_init(void) {
1853
red_chiplet_init();
1954

55+
// CAN transceiver enables
56+
set_gpio_pullup(GPIOB, 7, PULL_NONE);
57+
set_gpio_mode(GPIOB, 7, MODE_OUTPUT);
58+
set_gpio_pullup(GPIOD, 8, PULL_NONE);
59+
set_gpio_mode(GPIOD, 8, MODE_OUTPUT);
60+
61+
// FDCAN3, different pins on this package than the rest of the reds
62+
set_gpio_pullup(GPIOD, 12, PULL_NONE);
63+
set_gpio_alternate(GPIOD, 12, GPIO_AF5_FDCAN3);
64+
set_gpio_pullup(GPIOD, 13, PULL_NONE);
65+
set_gpio_alternate(GPIOD, 13, GPIO_AF5_FDCAN3);
66+
2067
// C2: SOM GPIO used as input (fan control at boot)
2168
set_gpio_mode(GPIOC, 2, MODE_INPUT);
2269
set_gpio_pullup(GPIOC, 2, PULL_DOWN);
@@ -46,7 +93,6 @@ void cuatro_init(void) {
4693

4794
const board board_cuatro = {
4895
.harness_config = &red_chiplet_harness_config,
49-
.has_hw_gmlan = false,
5096
.has_obd = true,
5197
.has_spi = true,
5298
.has_canfd = true,
@@ -57,8 +103,8 @@ const board board_cuatro = {
57103
.fan_enable_cooldown_time = 3U,
58104
.init = cuatro_init,
59105
.init_bootloader = unused_init_bootloader,
60-
.enable_can_transceiver = red_chiplet_enable_can_transceiver,
61-
.enable_can_transceivers = red_chiplet_enable_can_transceivers,
106+
.enable_can_transceiver = cuatro_enable_can_transceiver,
107+
.enable_can_transceivers = cuatro_enable_can_transceivers,
62108
.set_led = cuatro_set_led,
63109
.set_can_mode = red_chiplet_set_can_mode,
64110
.check_ignition = red_check_ignition,

board/boards/dos.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// ///////////// //
2-
// Dos + Harness //
3-
// ///////////// //
1+
// /////////////////////// //
2+
// Dos (STM32F4) + Harness //
3+
// /////////////////////// //
44

55
void dos_enable_can_transceiver(uint8_t transceiver, bool enabled) {
66
switch (transceiver){
@@ -168,7 +168,7 @@ void dos_init(void) {
168168
// Set normal CAN mode
169169
dos_set_can_mode(CAN_MODE_NORMAL);
170170

171-
// flip CAN0 and CAN2 if we are flipped
171+
// change CAN mapping when flipped
172172
if (harness.status == HARNESS_STATUS_FLIPPED) {
173173
can_flip_buses(0, 2);
174174
}
@@ -193,7 +193,6 @@ const harness_configuration dos_harness_config = {
193193

194194
const board board_dos = {
195195
.harness_config = &dos_harness_config,
196-
.has_hw_gmlan = false,
197196
.has_obd = true,
198197
#ifdef ENABLE_SPI
199198
.has_spi = true,

board/boards/grey.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// ////////// //
2-
// Grey Panda //
3-
// ////////// //
1+
// //////////////////// //
2+
// Grey Panda (STM32F4) //
3+
// //////////////////// //
44

55
// Most hardware functionality is similar to white panda
66

77
const board board_grey = {
88
.set_bootkick = unused_set_bootkick,
99
.harness_config = &white_harness_config,
10-
.has_hw_gmlan = true,
1110
.has_obd = false,
1211
.has_spi = false,
1312
.has_canfd = false,

board/boards/pedal.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// ///// //
2-
// Pedal //
3-
// ///// //
1+
// ///////////// //
2+
// Pedal STM32F2 //
3+
// ///////////// //
44

55
void pedal_enable_can_transceiver(uint8_t transceiver, bool enabled) {
66
switch (transceiver){
@@ -69,7 +69,6 @@ const harness_configuration pedal_harness_config = {
6969
const board board_pedal = {
7070
.set_bootkick = unused_set_bootkick,
7171
.harness_config = &pedal_harness_config,
72-
.has_hw_gmlan = false,
7372
.has_obd = false,
7473
.has_spi = false,
7574
.has_canfd = false,

board/boards/red.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// ///////////////////// //
2-
// Red Panda + Harness //
3-
// ///////////////////// //
1+
// ///////////////////////////// //
2+
// Red Panda (STM32H7) + Harness //
3+
// ///////////////////////////// //
44

55
void red_enable_can_transceiver(uint8_t transceiver, bool enabled) {
66
switch (transceiver) {
@@ -150,7 +150,7 @@ void red_init(void) {
150150
// Set normal CAN mode
151151
red_set_can_mode(CAN_MODE_NORMAL);
152152

153-
// flip CAN0 and CAN2 if we are flipped
153+
// change CAN mapping when flipped
154154
if (harness.status == HARNESS_STATUS_FLIPPED) {
155155
can_flip_buses(0, 2);
156156
}
@@ -173,7 +173,6 @@ const harness_configuration red_harness_config = {
173173
const board board_red = {
174174
.set_bootkick = unused_set_bootkick,
175175
.harness_config = &red_harness_config,
176-
.has_hw_gmlan = false,
177176
.has_obd = true,
178177
.has_spi = false,
179178
.has_canfd = true,

board/boards/red_chiplet.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// ///////////////////// //
2-
// Red Panda chiplet + Harness //
3-
// ///////////////////// //
1+
// ///////////////////////////////////// //
2+
// Red Panda chiplet (STM32H7) + Harness //
3+
// ///////////////////////////////////// //
44

55
// Most hardware functionality is similar to red panda
66

@@ -133,7 +133,7 @@ void red_chiplet_init(void) {
133133
// Set normal CAN mode
134134
red_chiplet_set_can_mode(CAN_MODE_NORMAL);
135135

136-
// flip CAN0 and CAN2 if we are flipped
136+
// change CAN mapping when flipped
137137
if (harness.status == HARNESS_STATUS_FLIPPED) {
138138
can_flip_buses(0, 2);
139139
}

board/boards/tres.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// /////////////////
2-
// Tres + Harness //
3-
// /////////////////
1+
// ///////////////////////////
2+
// Tres (STM32H7) + Harness //
3+
// ///////////////////////////
44

55
bool tres_ir_enabled;
66
bool tres_fan_enabled;
@@ -72,7 +72,6 @@ void tres_init(void) {
7272

7373
const board board_tres = {
7474
.harness_config = &red_chiplet_harness_config,
75-
.has_hw_gmlan = false,
7675
.has_obd = true,
7776
.has_spi = true,
7877
.has_canfd = true,

0 commit comments

Comments
 (0)