Skip to content

Commit d9f1e61

Browse files
committed
Cadillac: simplified the ignition code by removing the timeout logic and resetting controls_allowed = 0 at each init
1 parent 293fd1a commit d9f1e61

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

board/safety/safety_cadillac.h

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const int CADILLAC_STEER_MAX = 150; // 1s
2-
const int CADILLAC_IGNITION_TIMEOUT = 1000000; // 1s
32
// real time torque limit to prevent controls spamming
43
// the real time limit is 1500/sec
54
const int CADILLAC_MAX_RT_DELTA = 75; // max delta torque allowed for real time checks
@@ -11,7 +10,6 @@ const int CADILLAC_DRIVER_TORQUE_FACTOR = 4;
1110

1211
int cadillac_ign = 0;
1312
int cadillac_cruise_engaged_last = 0;
14-
uint32_t cadillac_ts_ign_last = 0;
1513
int cadillac_rt_torque_last = 0;
1614
int cadillac_desired_torque_last = 0;
1715
uint32_t cadillac_ts_last = 0;
@@ -31,9 +29,8 @@ static void cadillac_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
3129
}
3230

3331
// this message isn't all zeros when ignition is on
34-
if ((addr == 0x160) && (bus_number == 0) && to_push->RDLR) {
35-
cadillac_ign = 1;
36-
cadillac_ts_ign_last = TIM2->CNT; // reset timer when ign is received
32+
if (addr == 0x160 && bus_number == 0) {
33+
cadillac_ign = to_push->RDLR > 0;
3734
}
3835

3936
// enter controls on rising edge of ACC, exit controls on ACC off
@@ -131,15 +128,11 @@ static int cadillac_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
131128
}
132129

133130
static void cadillac_init(int16_t param) {
131+
controls_allowed = 0;
134132
cadillac_ign = 0;
135133
}
136134

137135
static int cadillac_ign_hook() {
138-
uint32_t ts = TIM2->CNT;
139-
uint32_t ts_elapsed = get_ts_elapsed(ts, cadillac_ts_ign_last);
140-
if (ts_elapsed > CADILLAC_IGNITION_TIMEOUT) {
141-
cadillac_ign = 0;
142-
}
143136
return cadillac_ign;
144137
}
145138

0 commit comments

Comments
 (0)