wideband/for_rusefi/wideband_can.h

82 lines
1.8 KiB
C
Raw Normal View History

2021-11-06 02:12:29 -07:00
#pragma once
2021-11-06 02:17:50 -07:00
#define RUSEFI_WIDEBAND_VERSION (0xA0)
2021-11-06 02:12:29 -07:00
// ascii "rus"
#define WB_ACK 0x727573
#define WB_BL_HEADER 0x0EF
#define WB_OPCODE_START 0
#define WB_OPCODE_ERASE 1
#define WB_ERASE_TAG 0x5A5A
#define WB_OPCODE_DATA 2
#define WB_OPCODE_REBOOT 3
// 0xEF0'0000
#define WB_BL_ENTER ((WB_BL_HEADER << 4 + WB_OPCODE_START) << 16)
// 0xEF1'5A5A
#define WB_BL_ERASE ((WB_BL_HEADER << 4 + WB_OPCODE_ERASE) << 16 + WB_ERASE_TAG)
// 0xEF2'0000
#define WB_BL_DATA_BASE ((WB_BL_HEADER << 4 + WB_OPCODE_DATA) << 16)
// 0xEF3'0000
#define WB_BL_REBOOT ((WB_BL_HEADER << 4 + WB_OPCODE_REBOOT) << 16)
#define WB_MSG_SET_INDEX 0xEF4'0000
#define WB_MGS_ECU_STATUS 0xEF5'0000
#define WB_DATA_BASE_ADDR 0x190
2021-11-06 02:12:29 -07:00
namespace wbo
{
2022-01-01 21:10:55 -08:00
enum class Fault : uint8_t
{
None = 0,
// First fault code at 3 so it's easier to see
SensorDidntHeat = 3,
SensorOverheat = 4,
SensorUnderheat = 5,
2022-12-01 13:22:19 -08:00
SensorNoHeatSupply = 6,
2022-01-01 21:10:55 -08:00
};
2021-11-06 02:12:29 -07:00
struct StandardData
{
2022-05-18 23:50:58 -07:00
// DO NOT move the version field - its position and format must be
2023-04-27 12:52:06 -07:00
// fixed so that incompatible versions can be identified.
2021-11-06 02:12:29 -07:00
uint8_t Version;
uint8_t Valid;
uint16_t Lambda;
uint16_t TemperatureC;
uint16_t pad;
};
struct DiagData
{
uint16_t Esr;
uint16_t NernstDc;
uint8_t PumpDuty;
Fault Status;
2022-01-04 11:16:46 -08:00
uint8_t HeaterDuty;
uint8_t pad;
2021-11-06 02:12:29 -07:00
};
2022-01-01 21:10:55 -08:00
2022-01-01 21:12:08 -08:00
static const char* describeFault(Fault fault) {
switch (fault) {
case Fault::None:
return "OK";
case Fault::SensorDidntHeat:
return "Sensor failed to heat";
case Fault::SensorOverheat:
return "Sensor overheat";
case Fault::SensorUnderheat:
return "Sensor underheat";
2022-12-01 13:22:19 -08:00
case Fault::SensorNoHeatSupply:
return "Sensor no heat supply";
2022-01-01 21:12:08 -08:00
}
return "Unknown";
}
2022-01-01 21:10:55 -08:00
2021-11-06 02:12:29 -07:00
} // namespace wbo