Skip to content

Commit 528f901

Browse files
author
Commaremote
committed
Cadillac: simpler ignition logic
1 parent 4e79ecf commit 528f901

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

board/safety/safety_cadillac.h

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
int cadillac_ignition_started = 0;
2+
3+
static void cadillac_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
4+
int bus_number = (to_push->RDTR >> 4) & 0xFF;
5+
uint32_t addr = to_push->RIR >> 21;
6+
7+
if (addr == 0x135 && bus_number == 0) {
8+
cadillac_ignition_started = 1; //as soona s we receive can msgs, ingition is on
9+
}
10+
}
11+
12+
static void cadillac_init(int16_t param) {
13+
cadillac_ignition_started = 0;
14+
}
15+
16+
static int cadillac_ign_hook() {
17+
return cadillac_ignition_started;
18+
}
19+
120
// Placeholder file, actual safety is TODO.
221
const safety_hooks cadillac_hooks = {
3-
.init = alloutput_init,
4-
.rx = default_rx_hook,
22+
.init = cadillac_init,
23+
.rx = cadillac_rx_hook,
524
.tx = alloutput_tx_hook,
625
.tx_lin = alloutput_tx_lin_hook,
7-
.ignition = alloutput_ign_hook,
26+
.ignition = cadillac_ign_hook,
827
.fwd = alloutput_fwd_hook,
928
};
10-

0 commit comments

Comments
 (0)