@@ -19,29 +19,50 @@ void cuatro_set_led(uint8_t color, bool enabled) {
19
19
}
20
20
21
21
void cuatro_enable_can_transceiver (uint8_t transceiver , bool enabled ) {
22
- if (transceiver == 1U ) {
23
- set_gpio_output (GPIOB , 7 , !enabled );
24
- } else if (transceiver == 3U ) {
25
- set_gpio_output (GPIOD , 8 , !enabled );
26
- } else {
27
- red_enable_can_transceiver (transceiver , 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
+ }
28
49
}
29
50
}
30
51
31
52
void cuatro_init (void ) {
32
53
red_chiplet_init ();
33
54
34
- // CAN FD 0 transceiver enable (rest are done in red init)
55
+ // CAN transceiver enables
35
56
set_gpio_pullup (GPIOB , 7 , PULL_NONE );
36
57
set_gpio_mode (GPIOB , 7 , MODE_OUTPUT );
37
58
set_gpio_pullup (GPIOD , 8 , PULL_NONE );
38
59
set_gpio_mode (GPIOD , 8 , MODE_OUTPUT );
39
60
40
- // FDCAN2
61
+ // FDCAN3, different pins on this package than the rest of the reds
41
62
set_gpio_pullup (GPIOD , 12 , PULL_NONE );
42
- set_gpio_alternate (GPIOD , 12 , GPIO_AF9_FDCAN2 );
63
+ set_gpio_alternate (GPIOD , 12 , GPIO_AF5_FDCAN3 );
43
64
set_gpio_pullup (GPIOD , 13 , PULL_NONE );
44
- set_gpio_alternate (GPIOD , 13 , GPIO_AF9_FDCAN2 );
65
+ set_gpio_alternate (GPIOD , 13 , GPIO_AF5_FDCAN3 );
45
66
46
67
// C2: SOM GPIO used as input (fan control at boot)
47
68
set_gpio_mode (GPIOC , 2 , MODE_INPUT );
@@ -83,7 +104,7 @@ const board board_cuatro = {
83
104
.init = cuatro_init ,
84
105
.init_bootloader = unused_init_bootloader ,
85
106
.enable_can_transceiver = cuatro_enable_can_transceiver ,
86
- .enable_can_transceivers = red_chiplet_enable_can_transceivers ,
107
+ .enable_can_transceivers = cuatro_enable_can_transceivers ,
87
108
.set_led = cuatro_set_led ,
88
109
.set_can_mode = red_chiplet_set_can_mode ,
89
110
.check_ignition = red_check_ignition ,
0 commit comments