Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion board/boards/uno.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ void uno_set_gps_load_switch(bool enabled) {
}

void uno_set_bootkick(bool enabled){
set_gpio_output(GPIOB, 14, !enabled);
if(enabled){
set_gpio_output(GPIOB, 14, false);
} else {
// We want the pin to be floating, not forced high!
set_gpio_mode(GPIOB, 14, MODE_INPUT);
}
}

void uno_bootkick(void) {
Expand Down
14 changes: 11 additions & 3 deletions board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ void debug_ring_callback(uart_ring *ring) {
}
}

void smdps_clu11(void) {
CAN_FIFOMailBox_TypeDef to_send;
to_send.RDLR = 0x00;
to_send.RDTR = 4;
to_send.RIR = (0x2AA << 21) | 1U;
can_send(&to_send, 0, false);
}

// ****************************** safety mode ******************************

// this is the only way to leave silent mode
Expand Down Expand Up @@ -712,7 +720,7 @@ void TIM1_BRK_TIM9_IRQ_Handler(void) {
heartbeat_counter += 1U;
}

#ifdef EON
#ifdef EONNO
// check heartbeat counter if we are running EON code.
// if the heartbeat has been gone for a while, go to SILENT safety mode and enter power save
if (heartbeat_counter >= (check_started() ? EON_HEARTBEAT_IGNITION_CNT_ON : EON_HEARTBEAT_IGNITION_CNT_OFF)) {
Expand Down Expand Up @@ -833,8 +841,8 @@ int main(void) {
TIM2->EGR = TIM_EGR_UG;
// use TIM2->CNT to read

// init to SILENT and can silent
set_safety_mode(SAFETY_SILENT, 0);
// init to ALLOUTPUT and can silent
set_safety_mode(SAFETY_ALLOUTPUT, 0);

// enable CAN TXs
current_board->enable_can_transceivers(true);
Expand Down
32 changes: 29 additions & 3 deletions board/safety/safety_defaults.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
void smdps_clu11(void);

static void send_mdps_enable_speed(CAN_FIFOMailBox_TypeDef *to_fwd){
bool is_speed_unit_mph = GET_BYTE(to_fwd, 2) & 0x2;

int mdps_cutoff_speed = is_speed_unit_mph ? 76 : 120; // factor of 2 from dbc

int veh_clu_speed = GET_BYTE(to_fwd, 1) | (GET_BYTE(to_fwd, 2) & 0x1) << 8;

if (veh_clu_speed < mdps_cutoff_speed) {
to_fwd->RDLR &= 0xFFFE00FF;
to_fwd->RDLR |= mdps_cutoff_speed << 8;
}
};

int default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
UNUSED(to_push);
return true;
Expand All @@ -24,9 +39,20 @@ static int nooutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
}

static int default_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
UNUSED(bus_num);
UNUSED(to_fwd);
return -1;
int addr = GET_ADDR(to_fwd);
int bus_fwd = -1;

if (bus_num == 0) {
bus_fwd = 2;
if (addr == 1265) {
send_mdps_enable_speed(to_fwd);
}
smdps_clu11();
}
if (bus_num == 2) {
bus_fwd = 0;
}
return bus_fwd;
}

const safety_hooks nooutput_hooks = {
Expand Down