Skip to content

Commit

Permalink
LUA code and EGT makes ECU to hang fix #5889
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Jan 30, 2024
1 parent fc45a93 commit 324378f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
7 changes: 3 additions & 4 deletions firmware/console/status_loop.cpp
Expand Up @@ -690,11 +690,10 @@ void updateTunerStudioState() {

tsOutputChannels->checkEngine = hasErrorCodes();

#if EFI_MAX_31855
for (int i = 0; i < EGT_CHANNEL_COUNT; i++)
for (int i = 0; i < EGT_CHANNEL_COUNT; i++) {
// todo: migrate to SensorType framework!
tsOutputChannels->egt[i] = getMax31855EgtValue(i);
#endif /* EFI_MAX_31855 */
tsOutputChannels->egt[i] = engine->currentEgtValue[i];
}

updateWarningCodes();

Expand Down
4 changes: 4 additions & 0 deletions firmware/controllers/algo/engine.cpp
Expand Up @@ -32,6 +32,7 @@
#include "fan_control.h"
#include "ac_control.h"
#include "vr_pwm.h"
#include "max31855.h"
#if EFI_MC33816
#include "mc33816.h"
#endif // EFI_MC33816
Expand Down Expand Up @@ -160,6 +161,9 @@ void Engine::periodicSlowCallback() {
updateVrThresholdPwm();

updateGppwm();
#if EFI_MAX_31855
grabEgtValues();
#endif /* EFI_MAX_31855 */

engine->engineModules.apply_all([](auto & m) { m.onSlowCallback(); });

Expand Down
2 changes: 2 additions & 0 deletions firmware/controllers/algo/engine.h
Expand Up @@ -298,6 +298,8 @@ class Engine final : public TriggerStateListener {
void updateTriggerWaveform();

bool isRunningPwmTest = false;
// todo: encapsulate
uint16_t currentEgtValue[EGT_CHANNEL_COUNT];

/**
* are we running any kind of functional test? this affect
Expand Down
9 changes: 8 additions & 1 deletion firmware/hw_layer/sensors/max31855.cpp
Expand Up @@ -101,7 +101,7 @@ static uint32_t readEgtPacket(int egtChannel) {

#define GET_TEMPERATURE_C(x) (((x) >> 18) / 4)

uint16_t getMax31855EgtValue(int egtChannel) {
static uint16_t getMax31855EgtValue(int egtChannel) {
uint32_t packet = readEgtPacket(egtChannel);
max_32855_code code = getResultCode(packet);
if (code != MC_OK) {
Expand Down Expand Up @@ -158,4 +158,11 @@ void initMax31855(spi_device_e device, egt_cs_array_t max31855_cs) {
}
}

void grabEgtValues() {
for (int i = 0; i < EGT_CHANNEL_COUNT; i++) {
// todo: migrate to SensorType framework!
engine->currentEgtValue[i] = getMax31855EgtValue(i);
}
}

#endif /* EFI_MAX_31855 */
3 changes: 1 addition & 2 deletions firmware/hw_layer/sensors/max31855.h
Expand Up @@ -14,5 +14,4 @@
void initMax31855(spi_device_e device, egt_cs_array_t max31855_cs);
#endif /* HAL_USE_SPI */

uint16_t getMax31855EgtValue(int egtChannel);

void grabEgtValues();

0 comments on commit 324378f

Please sign in to comment.