mirror of https://github.com/commaai/panda.git
add a safety mode counter
This commit is contained in:
parent
a6797a213e
commit
2d4cb05cf1
|
@ -699,6 +699,7 @@ void TIM1_BRK_TIM9_IRQHandler(void) {
|
|||
|
||||
// on to the next one
|
||||
uptime_cnt += 1U;
|
||||
safety_mode_cnt += 1U;
|
||||
}
|
||||
TIM9->SR = 0;
|
||||
}
|
||||
|
|
|
@ -96,13 +96,14 @@ const safety_hook_config safety_hook_registry[] = {
|
|||
};
|
||||
|
||||
int set_safety_hooks(uint16_t mode, int16_t param) {
|
||||
int set_status = -1; // not set
|
||||
safety_mode_cnt = 0U; // reset safety mode timer
|
||||
int set_status = -1; // not set
|
||||
int hook_config_count = sizeof(safety_hook_registry) / sizeof(safety_hook_config);
|
||||
for (int i = 0; i < hook_config_count; i++) {
|
||||
if (safety_hook_registry[i].id == mode) {
|
||||
current_hooks = safety_hook_registry[i].hooks;
|
||||
current_safety_mode = safety_hook_registry[i].id;
|
||||
set_status = 0; // set
|
||||
set_status = 0; // set
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,5 +55,8 @@ int gas_interceptor_prev = 0;
|
|||
// This is set by USB command 0xdf
|
||||
bool long_controls_allowed = true;
|
||||
|
||||
// time since safety mode has been changed
|
||||
uint32_t safety_mode_cnt = 0U;
|
||||
|
||||
// avg between 2 tracks
|
||||
#define GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + ((GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2 ) / 2)
|
||||
|
|
Loading…
Reference in New Issue