mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-15 03:53:58 +08:00
6d316f2bc7
date: 2024-06-11T01:36:39 master commit: f8cb04e4a8b032b72a909f68b808a50936184bee
69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
void default_rx_hook(const CANPacket_t *to_push) {
|
|
UNUSED(to_push);
|
|
}
|
|
|
|
// *** no output safety mode ***
|
|
|
|
static safety_config nooutput_init(uint16_t param) {
|
|
UNUSED(param);
|
|
return (safety_config){NULL, 0, NULL, 0};
|
|
}
|
|
|
|
static bool nooutput_tx_hook(const CANPacket_t *to_send) {
|
|
UNUSED(to_send);
|
|
return false;
|
|
}
|
|
|
|
static int default_fwd_hook(int bus_num, int addr) {
|
|
UNUSED(bus_num);
|
|
UNUSED(addr);
|
|
return -1;
|
|
}
|
|
|
|
const safety_hooks nooutput_hooks = {
|
|
.init = nooutput_init,
|
|
.rx = default_rx_hook,
|
|
.tx = nooutput_tx_hook,
|
|
.fwd = default_fwd_hook,
|
|
};
|
|
|
|
// *** all output safety mode ***
|
|
|
|
// Enables passthrough mode where relay is open and bus 0 gets forwarded to bus 2 and vice versa
|
|
const uint16_t ALLOUTPUT_PARAM_PASSTHROUGH = 1;
|
|
bool alloutput_passthrough = false;
|
|
|
|
static safety_config alloutput_init(uint16_t param) {
|
|
controls_allowed = true;
|
|
alloutput_passthrough = GET_FLAG(param, ALLOUTPUT_PARAM_PASSTHROUGH);
|
|
return (safety_config){NULL, 0, NULL, 0};
|
|
}
|
|
|
|
static bool alloutput_tx_hook(const CANPacket_t *to_send) {
|
|
UNUSED(to_send);
|
|
return true;
|
|
}
|
|
|
|
static int alloutput_fwd_hook(int bus_num, int addr) {
|
|
int bus_fwd = -1;
|
|
UNUSED(addr);
|
|
|
|
if (alloutput_passthrough) {
|
|
if (bus_num == 0) {
|
|
bus_fwd = 2;
|
|
}
|
|
if (bus_num == 2) {
|
|
bus_fwd = 0;
|
|
}
|
|
}
|
|
|
|
return bus_fwd;
|
|
}
|
|
|
|
const safety_hooks alloutput_hooks = {
|
|
.init = alloutput_init,
|
|
.rx = default_rx_hook,
|
|
.tx = alloutput_tx_hook,
|
|
.fwd = alloutput_fwd_hook,
|
|
};
|