From 28ac0c61f0c0cff5c780d8eb1dc039961cd02448 Mon Sep 17 00:00:00 2001 From: rusefillc <48498823+rusefillc@users.noreply.github.com> Date: Mon, 8 Nov 2021 14:01:16 -0500 Subject: [PATCH] Can magic constants (#26) * CAN api * CAN api * CAN api * CAN api Co-authored-by: rusefillc --- firmware/can.cpp | 8 ++++---- for_rusefi/wideband_can.h | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/firmware/can.cpp b/firmware/can.cpp index caba597..8d5bcfa 100644 --- a/firmware/can.cpp +++ b/firmware/can.cpp @@ -30,7 +30,7 @@ static void SendAck() CANTxFrame frame; frame.IDE = CAN_IDE_EXT; - frame.EID = 0x727573; // ascii "rus" + frame.EID = WB_ACK; frame.RTR = CAN_RTR_DATA; frame.DLC = 0; @@ -57,7 +57,7 @@ void CanRxThread(void*) continue; } - if (frame.DLC == 2 && frame.EID == 0xEF5'0000) { + if (frame.DLC == 2 && frame.EID == WB_MGS_ECU_STATUS) { // This is status from ECU - battery voltage and heater enable signal // data0 contains battery voltage in tenths of a volt @@ -69,7 +69,7 @@ void CanRxThread(void*) SetHeaterAllowed(heaterAllowed); } // If it's a bootloader entry request, reboot to the bootloader! - else if (frame.DLC == 0 && frame.EID == 0xEF0'0000) + else if (frame.DLC == 0 && frame.EID == WB_BL_ENTER) { SendAck(); @@ -79,7 +79,7 @@ void CanRxThread(void*) NVIC_SystemReset(); } // Check if it's an "index set" message - else if (frame.DLC == 1 && frame.EID == 0xEF4'0000) + else if (frame.DLC == 1 && frame.EID == WB_MSG_SET_INDEX) { auto newCfg = GetConfiguration(); newCfg.CanIndexOffset = frame.data8[0]; diff --git a/for_rusefi/wideband_can.h b/for_rusefi/wideband_can.h index 6418703..b37dca0 100644 --- a/for_rusefi/wideband_can.h +++ b/for_rusefi/wideband_can.h @@ -2,6 +2,12 @@ #define RUSEFI_WIDEBAND_VERSION (0xA0) +// ascii "rus" +#define WB_ACK 0x727573 +#define WB_BL_ENTER 0xEF0'0000 +#define WB_MSG_SET_INDEX 0xEF4'0000 +#define WB_MGS_ECU_STATUS 0xEF5'0000 + namespace wbo { struct StandardData