Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | #pragma once | |||
2 | ||||
3 | #define RUSEFI_WIDEBAND_VERSION (0xA0) | |||
4 | ||||
5 | // ascii "rus" | |||
6 | #define WB_ACK 0x727573 | |||
7 | ||||
8 | #define WB_BL_HEADER 0x0EF | |||
9 | #define WB_OPCODE_START 0 | |||
10 | #define WB_OPCODE_ERASE 1 | |||
11 | #define WB_ERASE_TAG 0x5A5A | |||
12 | #define WB_OPCODE_DATA 2 | |||
13 | #define WB_OPCODE_REBOOT 3 | |||
14 | #define WB_OPCODE_SET_INDEX 4 | |||
15 | #define WB_OPCODE_ECU_STATUS 5 | |||
16 | #define WB_OPCODE_PING 6 | |||
17 | #define WB_OPCODE_SET_SENS_TYPE 7 | |||
18 | ||||
19 | #define WB_BL_BASE (WB_BL_HEADER << 4) | |||
20 | #define WB_BL_CMD(opcode, extra) (((WB_BL_BASE | (opcode)) << 16) | (extra)) | |||
21 | ||||
22 | #define WB_BL_CMD_MASK 0X0FFF0000 | |||
23 | ||||
24 | #define WB_MSG_GET_HEADER(id) (((id) >> 20) & 0XFFF) | |||
25 | #define WB_MSG_GET_OPCODE(id) (((id) >> 16) & 0XF) | |||
26 | #define WB_MSG_GET_EXTRA(id) ((id) & 0XFFFF) | |||
27 | ||||
28 | // 0xEF0'0000 | |||
29 | #define WB_BL_ENTER WB_BL_CMD(WB_OPCODE_START, 0) | |||
30 | // 0xEF1'5A5A | |||
31 | #define WB_BL_ERASE WB_BL_CMD(WB_OPCODE_ERASE, WB_ERASE_TAG) | |||
32 | // 0xEF2'0000 | |||
33 | #define WB_BL_DATA_BASE WB_BL_CMD(WB_OPCODE_DATA, 0) | |||
34 | // 0xEF3'0000 | |||
35 | #define WB_BL_REBOOT WB_BL_CMD(WB_OPCODE_REBOOT, 0) | |||
36 | // 0xEF4'0000 | |||
37 | #define WB_MSG_SET_INDEX WB_BL_CMD(WB_OPCODE_SET_INDEX, 0) | |||
38 | // 0xEF5'0000 | |||
39 | #define WB_MGS_ECU_STATUS WB_BL_CMD(WB_OPCODE_ECU_STATUS, 0) | |||
40 | // 0xEF6'0000 | |||
41 | #define WB_MSG_PING WB_BL_CMD(WB_OPCODE_PING, 0) | |||
42 | // 0xEF7'0000 | |||
43 | #define WB_MSG_SET_SENS_TYPE WB_BL_CMD(WB_OPCODE_SET_SENS_TYPE, 0) | |||
44 | ||||
45 | #define WB_DATA_BASE_ADDR 0x190 | |||
46 | ||||
47 | // we transmit every 10ms | |||
48 | #define WBO_TX_PERIOD_MS 10 | |||
49 | ||||
50 | namespace wbo | |||
51 | { | |||
52 | enum class Fault : uint8_t | |||
53 | { | |||
54 | None = 0, | |||
55 | ||||
56 | // No CAN communication | |||
57 | CanSilent = 1, | |||
58 | // Heating is not allowed | |||
59 | NotAllowed = 2, | |||
60 | // First fault code at 3 so it's easier to see blink code | |||
61 | SensorDidntHeat = 3, | |||
62 | SensorOverheat = 4, | |||
63 | SensorUnderheat = 5, | |||
64 | SensorNoHeatSupply = 6, | |||
65 | }; | |||
66 | ||||
67 | enum class SensorType : uint8_t { | |||
68 | LSU49 = 0, | |||
69 | LSU42 = 1, | |||
70 | LSUADV = 2, | |||
71 | LSU49_FAE = 3, | |||
72 | }; | |||
73 | ||||
74 | struct StandardData | |||
75 | { | |||
76 | // DO NOT move the version field - its position and format must be | |||
77 | // fixed so that incompatible versions can be identified. | |||
78 | uint8_t Version; | |||
79 | uint8_t Valid; | |||
80 | ||||
81 | uint16_t Lambda; | |||
82 | uint16_t TemperatureC; | |||
83 | ||||
84 | uint16_t pad; | |||
85 | }; | |||
86 | ||||
87 | struct DiagData | |||
88 | { | |||
89 | uint16_t Esr; | |||
90 | uint16_t NernstDc; | |||
91 | uint8_t PumpDuty; | |||
92 | Fault Status; | |||
93 | ||||
94 | uint8_t HeaterDuty; | |||
95 | uint8_t pad; | |||
96 | }; | |||
97 | ||||
98 | struct PongData | |||
99 | { | |||
100 | uint8_t hwId; | |||
101 | uint8_t Version; | |||
102 | ||||
103 | // FW build date | |||
104 | uint8_t year; // starting from 2000 | |||
105 | uint8_t month; | |||
106 | uint8_t day; | |||
107 | ||||
108 | uint8_t reserved[3]; | |||
109 | }; | |||
110 | ||||
111 | 1 | static inline const char* describeFault(Fault fault) { | ||
112 |
1/8✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
1 | switch (fault) { | |
113 | ✗ | case Fault::None: | ||
114 | ✗ | return "OK"; | ||
115 | ✗ | case Fault::CanSilent: | ||
116 | ✗ | return "CAN silent"; | ||
117 | ✗ | case Fault::NotAllowed: | ||
118 | ✗ | return "Heating not allowed"; | ||
119 | ✗ | case Fault::SensorDidntHeat: | ||
120 | ✗ | return "Sensor failed to heat"; | ||
121 | ✗ | case Fault::SensorOverheat: | ||
122 | ✗ | return "Sensor overheat"; | ||
123 | ✗ | case Fault::SensorUnderheat: | ||
124 | ✗ | return "Sensor underheat"; | ||
125 |
1/1✓ Decision 'true' taken 1 time.
|
1 | case Fault::SensorNoHeatSupply: | |
126 | 1 | return "Sensor no heat supply"; | ||
127 | } | |||
128 | ||||
129 | ✗ | return "Unknown"; | ||
130 | } | |||
131 | ||||
132 | } // namespace wbo | |||
133 |