Skip to content

Commit

Permalink
Cadillac: simpler ignition logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Commaremote committed May 25, 2018
1 parent 4e79ecf commit 528f901
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions board/safety/safety_cadillac.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
int cadillac_ignition_started = 0;

static void cadillac_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
int bus_number = (to_push->RDTR >> 4) & 0xFF;
uint32_t addr = to_push->RIR >> 21;

if (addr == 0x135 && bus_number == 0) {
cadillac_ignition_started = 1; //as soona s we receive can msgs, ingition is on
}
}

static void cadillac_init(int16_t param) {
cadillac_ignition_started = 0;
}

static int cadillac_ign_hook() {
return cadillac_ignition_started;
}

// Placeholder file, actual safety is TODO.
const safety_hooks cadillac_hooks = {
.init = alloutput_init,
.rx = default_rx_hook,
.init = cadillac_init,
.rx = cadillac_rx_hook,
.tx = alloutput_tx_hook,
.tx_lin = alloutput_tx_lin_hook,
.ignition = alloutput_ign_hook,
.ignition = cadillac_ign_hook,
.fwd = alloutput_fwd_hook,
};

0 comments on commit 528f901

Please sign in to comment.