17#pragma GCC diagnostic push
18#pragma GCC diagnostic ignored "-Wunused-function"
19#include "wideband_firmware/for_rusefi/wideband_can.h"
20#pragma GCC diagnostic pop
26#define EVT_BOOTLOADER_ACK EVENT_MASK(0)
37 if (CAN_EID(frame) != WB_ACK) {
45 }
else if (frame.
DLC == 8)
49 auto data =
reinterpret_cast<const wbo::PongData*
>(&frame.
data8[0]);
64 chEvtSignal(t, EVT_BOOTLOADER_ACK);
69 return chEvtWaitAnyTimeout(EVT_BOOTLOADER_ACK, TIME_MS2I(timeout)) != 0;
82 if (hwIndex == 0xff) {
96 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
101 efiPrintf(
"***************************************");
102 efiPrintf(
" WIDEBAND INDEX SET");
103 efiPrintf(
"***************************************");
105 if (hwIndex == 0xff) {
106 efiPrintf(
"Setting all connected widebands to index %d...", index);
108 efiPrintf(
"Setting wideband with hwIndex %d to CAN index %d...", hwIndex, index);
113 efiPrintf(
"Wideband index set failed: no controller detected!");
128 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
142 efiPrintf(
"Wideband sensor type set failed: no controller detected!");
164 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
177 efiPrintf(
"Wideband ping failed: no controller detected!");
180 efiPrintf(
"WBO_RE_DONE");
189 static int counter = 0;
202 for (
size_t i = 0; i < CAN_WBO_COUNT; i++) {
214#if EFI_WIDEBAND_FIRMWARE_UPDATE
218#include "wideband_firmware/for_rusefi/wideband_image.h"
222 size_t totalSize =
sizeof(build_wideband_image_bin);
227 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
232 efiPrintf(
"***************************************");
233 efiPrintf(
" WIDEBAND FIRMWARE UPDATE");
234 efiPrintf(
"***************************************");
235 if (hwIndex != 0xff) {
236 efiPrintf(
"Wideband Update: Rebooting WBO hwIndex %d to bootloader...", hwIndex);
238 efiPrintf(
"Wideband Update: Rebooting any WBO to bootloader...");
243 for (
int i = 0; i < 2; i++) {
249 if ((hwIndex != 0xff) && (i == 0)) {
258 efiPrintf(
"Wideband Update ERROR: Expected ACK from entry to bootloader, didn't get %s.",
259 i ?
"second (from bootloader)" :
"first (from app)");
265 chThdSleepMilliseconds(200);
268 efiPrintf(
"Wideband Update: in update mode, erasing flash...");
278 efiPrintf(
"Wideband Update ERROR: Expected ACK from flash erase command, didn't get one.");
283 efiPrintf(
"Wideband Update: Flash erased! Sending %d bytes...", totalSize);
286 for (
size_t i = 0; i < totalSize; i += 8) {
289 memcpy(&m[0], build_wideband_image_bin + i, 8);
293 efiPrintf(
"Wideband Update ERROR: Expected ACK from data write, didn't get one.");
299 efiPrintf(
"Wideband Update: Update complete! Rebooting controller.");
TunerStudioOutputChannels outputChannels
static float getOrZero(SensorType type)
static EngineAccessor engine
static constexpr engine_configuration_s * engineConfiguration
void handleWidebandCan(const size_t busIndex, const CANRxFrame &frame)
static thread_t * waitingBootloaderThread
void setWidebandSensorType(uint8_t hwIndex, uint8_t type)
bool waitAck(int timeout=1000)
void setWidebandOffsetNoWait(uint8_t hwIndex, uint8_t index)
void pingWideband(uint8_t hwIndex)
static void setStatus(can_wbo_re_status_e status)
void setWidebandOffset(uint8_t hwIndex, uint8_t index)
void updateWidebandFirmware(uint8_t hwIndex)
uint8_t data8[8]
Frame data.
wbo_s canWbo[CAN_WBO_COUNT]
bool heaterControlEnabled
uint8_t canReWidebandCmdStatus
uint8_t canReWidebandFwYear
uint8_t canReWidebandVersion
uint8_t canReWidebandFwDay
uint8_t canReWidebandFwMon
can_wbo_re_hwidx_e reHwidx