This commit is contained in:
rusefi 2020-10-19 22:04:06 -04:00
parent c25bf07abf
commit ca89cf9b95
3 changed files with 44 additions and 12 deletions

View File

@ -29,6 +29,9 @@
#include "sensor.h" #include "sensor.h"
#include "gppwm.h" #include "gppwm.h"
#include "tachometer.h" #include "tachometer.h"
#if EFI_MC33816
#include "mc33816.h"
#endif // EFI_MC33816
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
#include "tunerstudio_outputs.h" #include "tunerstudio_outputs.h"
@ -257,6 +260,10 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
vBattForTle8888 = sensors.vBatt; vBattForTle8888 = sensors.vBatt;
#endif /* BOARD_TLE8888_COUNT */ #endif /* BOARD_TLE8888_COUNT */
#if EFI_MC33816
initMc33816IfNeeded();
#endif // EFI_MC33816
engineState.running.injectorLag = getInjectorLag(sensors.vBatt PASS_ENGINE_PARAMETER_SUFFIX); engineState.running.injectorLag = getInjectorLag(sensors.vBatt PASS_ENGINE_PARAMETER_SUFFIX);
#endif #endif
} }

View File

@ -20,13 +20,14 @@
#include "mc33816.h" #include "mc33816.h"
#include "mc33816_memory_map.h" #include "mc33816_memory_map.h"
#include "engine_configuration.h" #include "engine.h"
#include "efi_gpio.h" #include "efi_gpio.h"
#include "hardware.h" #include "hardware.h"
#include "mc33816_data.h" #include "mc33816_data.h"
#include "mpu_util.h" #include "mpu_util.h"
#include "voltage.h"
EXTERN_CONFIG; EXTERN_ENGINE;
static OutputPin chipSelect; static OutputPin chipSelect;
@ -427,18 +428,20 @@ static void download_register(int r_target) {
spiUnselect(driver); spiUnselect(driver);
} }
static bool haveMc33816 = false;
void initMc33816(Logging *sharedLogger) { void initMc33816(Logging *sharedLogger) {
logger = sharedLogger; logger = sharedLogger;
// //
// see setTest33816EngineConfiguration for default configuration // see setTest33816EngineConfiguration for default configuration
// Pins // Pins
if (CONFIG(mc33816_cs) == GPIO_UNASSIGNED) if (CONFIG(mc33816_cs) == GPIO_UNASSIGNED ||
return; CONFIG(mc33816_rstb) == GPIO_UNASSIGNED ||
if (CONFIG(mc33816_rstb) == GPIO_UNASSIGNED) CONFIG(mc33816_driven) == GPIO_UNASSIGNED
return; ) {
if (CONFIG(mc33816_driven) == GPIO_UNASSIGNED)
return; return;
}
if (CONFIG(mc33816_flag0) != GPIO_UNASSIGNED) { if (CONFIG(mc33816_flag0) != GPIO_UNASSIGNED) {
efiSetPadMode("mc33816 flag0", CONFIG(mc33816_flag0), getInputMode(PI_DEFAULT)); efiSetPadMode("mc33816 flag0", CONFIG(mc33816_flag0), getInputMode(PI_DEFAULT));
} }
@ -469,6 +472,7 @@ void initMc33816(Logging *sharedLogger) {
addConsoleAction("mc33_restart", mcRestart); addConsoleAction("mc33_restart", mcRestart);
//addConsoleActionI("mc33_send", sendWord); //addConsoleActionI("mc33_send", sendWord);
haveMc33816 = true;
mcRestart(); mcRestart();
} }
@ -486,6 +490,11 @@ static void mcRestart() {
driven.setValue(0); // ensure driven is off driven.setValue(0); // ensure driven is off
if (engine->sensors.vBatt < LOW_VBATT) {
scheduleMsg(logger, "GDI not Restarting until we see VBatt");
return;
}
// Does starting turn this high to begin with?? // Does starting turn this high to begin with??
spiUnselect(driver); spiUnselect(driver);
@ -503,7 +512,7 @@ static void mcRestart() {
mcClearDriverStatus(); // Initial clear necessary mcClearDriverStatus(); // Initial clear necessary
mcDriverStatus = readDriverStatus(); mcDriverStatus = readDriverStatus();
if(checkUndervoltV5(mcDriverStatus)){ if (checkUndervoltV5(mcDriverStatus)) {
firmwareError(OBD_PCM_Processor_Fault, "MC33 5V Under-Voltage!"); firmwareError(OBD_PCM_Processor_Fault, "MC33 5V Under-Voltage!");
mcShutdown(); mcShutdown();
return; return;
@ -541,15 +550,14 @@ static void mcRestart() {
// Finished downloading, let's run the code // Finished downloading, let's run the code
enable_flash(); enable_flash();
if(!check_flash()) if (!check_flash()) {
{
firmwareError(OBD_PCM_Processor_Fault, "MC33 no flash"); firmwareError(OBD_PCM_Processor_Fault, "MC33 no flash");
mcShutdown(); mcShutdown();
return; return;
} }
mcDriverStatus = readDriverStatus(); mcDriverStatus = readDriverStatus();
if(checkUndervoltVccP(mcDriverStatus)){ if (checkUndervoltVccP(mcDriverStatus)) {
firmwareError(OBD_PCM_Processor_Fault, "MC33 VccP (7V) Under-Voltage!"); firmwareError(OBD_PCM_Processor_Fault, "MC33 VccP (7V) Under-Voltage!");
mcShutdown(); mcShutdown();
return; return;
@ -574,4 +582,19 @@ static void mcRestart() {
} }
} }
void initMc33816IfNeeded() {
if (!haveMc33816) {
return;
}
static bool isInitializaed = false;
if (engine->sensors.vBatt < LOW_VBATT) {
isInitializaed = false;
} else {
if (!isInitializaed) {
mcRestart();
isInitializaed = true;
}
}
}
#endif /* EFI_MC33816 */ #endif /* EFI_MC33816 */

View File

@ -27,3 +27,5 @@ enum {
}; };
void initMc33816(Logging *logger); void initMc33816(Logging *logger);
void initMc33816IfNeeded();