From 528f901b4d0eae3afa504873504d2a0794dc1137 Mon Sep 17 00:00:00 2001 From: Commaremote <31535535+commaremote@user.noreply.github.com> Date: Fri, 25 May 2018 12:44:46 -0700 Subject: [PATCH] Cadillac: simpler ignition logic --- board/safety/safety_cadillac.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/board/safety/safety_cadillac.h b/board/safety/safety_cadillac.h index 857cf39017e12f..a8924d4c69ecee 100644 --- a/board/safety/safety_cadillac.h +++ b/board/safety/safety_cadillac.h @@ -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, }; -