panda/board/safety/safety_defaults.h

56 lines
1.2 KiB
C
Raw Normal View History

2017-07-17 11:20:08 -06:00
void default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {}
2018-05-25 19:20:55 -06:00
int default_ign_hook() {
return -1; // use GPIO to determine ignition
}
2017-07-17 11:20:08 -06:00
// *** no output safety mode ***
2018-01-26 00:57:04 -07:00
static void nooutput_init(int16_t param) {
2017-08-22 14:44:11 -06:00
controls_allowed = 0;
2017-07-17 11:20:08 -06:00
}
2017-07-21 00:36:06 -06:00
static int nooutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
2017-07-17 11:20:08 -06:00
return false;
}
2017-07-21 00:36:06 -06:00
static int nooutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
2017-07-17 11:20:08 -06:00
return false;
}
static int default_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
return -1;
}
2017-07-17 11:20:08 -06:00
const safety_hooks nooutput_hooks = {
.init = nooutput_init,
.rx = default_rx_hook,
.tx = nooutput_tx_hook,
.tx_lin = nooutput_tx_lin_hook,
2018-05-25 19:20:55 -06:00
.ignition = default_ign_hook,
.fwd = default_fwd_hook,
2017-07-17 11:20:08 -06:00
};
// *** all output safety mode ***
2018-01-26 00:57:04 -07:00
static void alloutput_init(int16_t param) {
2017-08-22 14:44:11 -06:00
controls_allowed = 1;
2017-07-17 11:20:08 -06:00
}
2017-07-21 00:36:06 -06:00
static int alloutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
return true;
2017-07-17 11:20:08 -06:00
}
2017-07-21 00:36:06 -06:00
static int alloutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
return true;
2017-07-17 11:20:08 -06:00
}
const safety_hooks alloutput_hooks = {
.init = alloutput_init,
.rx = default_rx_hook,
.tx = alloutput_tx_hook,
.tx_lin = alloutput_tx_lin_hook,
2018-05-25 19:20:55 -06:00
.ignition = default_ign_hook,
.fwd = default_fwd_hook,
2017-07-17 11:20:08 -06:00
};