Skip to content

Commit

Permalink
Ignition: made a default hook for GPIO
Browse files Browse the repository at this point in the history
  • Loading branch information
rbiasini committed May 26, 2018
1 parent bea5187 commit d176220
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 32 deletions.
15 changes: 6 additions & 9 deletions board/safety/safety_defaults.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
void default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {}

int default_ign_hook() {
return -1; // use GPIO to determine ignition
}

// *** no output safety mode ***

static void nooutput_init(int16_t param) {
Expand All @@ -14,9 +18,6 @@ static int nooutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
return false;
}

static int nooutput_ign_hook() {
return -1;
}
static int nooutput_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
return -1;
}
Expand All @@ -26,7 +27,7 @@ const safety_hooks nooutput_hooks = {
.rx = default_rx_hook,
.tx = nooutput_tx_hook,
.tx_lin = nooutput_tx_lin_hook,
.ignition = nooutput_ign_hook,
.ignition = default_ign_hook,
.fwd = nooutput_fwd_hook,
};

Expand All @@ -44,10 +45,6 @@ static int alloutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
return true;
}

static int alloutput_ign_hook() {
return -1;
}

static int alloutput_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
return -1;
}
Expand All @@ -57,7 +54,7 @@ const safety_hooks alloutput_hooks = {
.rx = default_rx_hook,
.tx = alloutput_tx_hook,
.tx_lin = alloutput_tx_lin_hook,
.ignition = alloutput_ign_hook,
.ignition = default_ign_hook,
.fwd = alloutput_fwd_hook,
};

6 changes: 1 addition & 5 deletions board/safety/safety_elm327.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ static void elm327_init(int16_t param) {
controls_allowed = 1;
}

static int elm327_ign_hook() {
return -1;
}

static int elm327_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
return -1;
}
Expand All @@ -44,6 +40,6 @@ const safety_hooks elm327_hooks = {
.rx = elm327_rx_hook,
.tx = elm327_tx_hook,
.tx_lin = elm327_tx_lin_hook,
.ignition = elm327_ign_hook,
.ignition = default_ign_hook,
.fwd = elm327_fwd_hook,
};
6 changes: 1 addition & 5 deletions board/safety/safety_ford.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,11 @@ static int ford_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
return -1;
}

static int ford_ign_hook() {
return -1;
}

const safety_hooks ford_hooks = {
.init = ford_init,
.rx = ford_rx_hook,
.tx = ford_tx_hook,
.tx_lin = ford_tx_lin_hook,
.ignition = ford_ign_hook,
.ignition = default_ign_hook,
.fwd = ford_fwd_hook,
};
8 changes: 2 additions & 6 deletions board/safety/safety_honda.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,12 @@ static int honda_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
return -1;
}

static int honda_ign_hook() {
return -1;
}

const safety_hooks honda_hooks = {
.init = honda_init,
.rx = honda_rx_hook,
.tx = honda_tx_hook,
.tx_lin = honda_tx_lin_hook,
.ignition = honda_ign_hook,
.ignition = default_ign_hook,
.fwd = honda_fwd_hook,
};

Expand All @@ -165,6 +161,6 @@ const safety_hooks honda_bosch_hooks = {
.rx = honda_rx_hook,
.tx = honda_tx_hook,
.tx_lin = honda_tx_lin_hook,
.ignition = honda_ign_hook,
.ignition = default_ign_hook,
.fwd = honda_bosch_fwd_hook,
};
8 changes: 2 additions & 6 deletions board/safety/safety_toyota.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ static void toyota_init(int16_t param) {
dbc_eps_torque_factor = param;
}

static int toyota_ign_hook() {
return -1;
}

static int toyota_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
return -1;
}
Expand All @@ -188,7 +184,7 @@ const safety_hooks toyota_hooks = {
.rx = toyota_rx_hook,
.tx = toyota_tx_hook,
.tx_lin = toyota_tx_lin_hook,
.ignition = toyota_ign_hook,
.ignition = default_ign_hook,
.fwd = toyota_fwd_hook,
};

Expand All @@ -203,6 +199,6 @@ const safety_hooks toyota_nolimits_hooks = {
.rx = toyota_rx_hook,
.tx = toyota_tx_hook,
.tx_lin = toyota_tx_lin_hook,
.ignition = toyota_ign_hook,
.ignition = default_ign_hook,
.fwd = toyota_fwd_hook,
};
2 changes: 1 addition & 1 deletion board/safety/safety_toyota_ipas.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const safety_hooks toyota_ipas_hooks = {
.rx = toyota_ipas_rx_hook,
.tx = toyota_ipas_tx_hook,
.tx_lin = toyota_tx_lin_hook,
.ignition = toyota_ign_hook,
.ignition = default_ign_hook,
.fwd = toyota_fwd_hook,
};

0 comments on commit d176220

Please sign in to comment.