Commit 40c8dda 1 parent 69be556 commit 40c8dda Copy full SHA for 40c8dda
File tree 1 file changed +8
-9
lines changed
1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 1
1
const int STEER_MAX = 150 ; // 1s
2
2
const int CADILLAC_IGNITION_TIMEOUT = 1000000 ; // 1s
3
3
4
- int cadillac_can_seen = 0 ;
4
+ int cadillac_ign = 0 ;
5
5
int cadillac_cruise_engaged_last = 0 ;
6
6
uint32_t cadillac_ts_last = 0 ;
7
7
8
8
static void cadillac_rx_hook (CAN_FIFOMailBox_TypeDef * to_push ) {
9
9
int bus_number = (to_push -> RDTR >> 4 ) & 0xFF ;
10
10
uint32_t addr = to_push -> RIR >> 21 ;
11
11
12
- // this message isn't all zeros when car is on
12
+ // this message isn't all zeros when ignition is on
13
13
if ((addr == 0x160 ) && (bus_number == 0 ) && to_push -> RDLR ) {
14
- cadillac_can_seen = 1 ;
15
- cadillac_ts_last = TIM2 -> CNT ; // reset timer when gear msg is received
14
+ cadillac_ign = 1 ;
15
+ cadillac_ts_last = TIM2 -> CNT ; // reset timer when ign is received
16
16
}
17
17
18
18
// enter controls on rising edge of ACC, exit controls on ACC off
@@ -44,17 +44,16 @@ static int cadillac_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
44
44
}
45
45
46
46
static void cadillac_init (int16_t param ) {
47
- cadillac_can_seen = 0 ;
47
+ cadillac_ign = 0 ;
48
48
}
49
49
50
50
static int cadillac_ign_hook () {
51
51
uint32_t ts = TIM2 -> CNT ;
52
52
uint32_t ts_elapsed = get_ts_elapsed (ts , cadillac_ts_last );
53
- if ((ts_elapsed > CADILLAC_IGNITION_TIMEOUT ) || (!cadillac_can_seen )) {
54
- cadillac_can_seen = 0 ;
55
- return 0 ;
53
+ if (ts_elapsed > CADILLAC_IGNITION_TIMEOUT ) {
54
+ cadillac_ign = 0 ;
56
55
}
57
- return 1 ;
56
+ return cadillac_ign ;
58
57
}
59
58
60
59
// Placeholder file, actual safety is TODO.
You can’t perform that action at this time.
0 commit comments