fixup can silent on elm327 mode

This commit is contained in:
Firmware Batman 2017-08-21 14:28:33 -07:00
parent 54efeae177
commit ddbcd570bc
2 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,5 @@
// IRQs: CAN1_TX, CAN1_RX0, CAN1_SCE, CAN2_TX, CAN2_RX0, CAN2_SCE, CAN3_TX, CAN3_RX0, CAN3_SCE
int can_live = 0, pending_can_live = 0, can_loopback = 0, can_silent = 1;
int can_live = 0, pending_can_live = 0, can_loopback = 0, can_silent = 0xff;
// ********************* instantiate queues *********************
@ -132,7 +132,7 @@ void can_init(uint8_t can_number) {
CAN->BTR |= CAN_BTR_SILM | CAN_BTR_LBKM;
}
if (can_silent) {
if (can_silent & (1 << can_number)) {
CAN->BTR |= CAN_BTR_SILM;
}

View File

@ -251,9 +251,19 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
// this is the only way to leave silent mode
// and it's blocked over WiFi
// Allow ELM security mode to be set over wifi.
if (hardwired || setup->b.wValue.w == SAFETY_ELM327) {
if (hardwired || setup->b.wValue.w == SAFETY_NOOUTPUT || setup->b.wValue.w == SAFETY_ELM327) {
safety_set_mode(setup->b.wValue.w);
can_silent = (setup->b.wValue.w == SAFETY_NOOUTPUT);
switch (setup->b.wValue.w) {
case SAFETY_NOOUTPUT:
can_silent = 0xff;
break;
case SAFETY_ELM327:
can_silent = 0xfe;
break;
default:
can_silent = 0;
break;
}
can_init_all();
}
break;