GDI error codes

This commit is contained in:
rusefi 2023-06-12 00:38:13 -04:00
parent 1e60b23e8f
commit 11612c66a5
2 changed files with 25 additions and 7 deletions

View File

@ -14,6 +14,18 @@
void initMc33816(); void initMc33816();
enum class McFault : uint8_t
{
None = 0,
NoFlash = 1,
UnderVoltageAfter = 2,
NoComm = 3,
flag0 = 4,
UnderVoltage5 = 5,
Driven = 6,
UnderVoltage7 = 7,
};
class Pt2001Base { class Pt2001Base {
public: public:
// Reinitialize the PT2001 chip, returns true if successful // Reinitialize the PT2001 chip, returns true if successful
@ -22,12 +34,18 @@ public:
// Disable the PT2001 chip. // Disable the PT2001 chip.
void shutdown(); void shutdown();
void onError(McFault fault) {
this->fault = fault;
}
// Re-read timing configuration and reconfigure the chip. This is safe to call while operating. // Re-read timing configuration and reconfigure the chip. This is safe to call while operating.
void setTimings(); void setTimings();
// Set the boost voltage target. This is safe to call while operating. // Set the boost voltage target. This is safe to call while operating.
void setBoostVoltage(float volts); void setBoostVoltage(float volts);
McFault fault = McFault::None;
private: private:
// SPI tx/rx helpers // SPI tx/rx helpers
void send(uint16_t tx) { void send(uint16_t tx) {

View File

@ -436,14 +436,14 @@ bool Pt2001Base::restart() {
clearDriverStatus(); // Initial clear necessary clearDriverStatus(); // Initial clear necessary
uint16_t status = readDriverStatus(); uint16_t status = readDriverStatus();
if (checkUndervoltV5(status)) { if (checkUndervoltV5(status)) {
onError("MC33 5V Under-Voltage!"); onError(McFault::UnderVoltage5);
shutdown(); shutdown();
return false; return false;
} }
uint16_t chipId = readId(); uint16_t chipId = readId();
if (!validateChipId(chipId)) { if (!validateChipId(chipId)) {
onError("No comm with MC33"); onError(McFault::NoComm);
shutdown(); shutdown();
return false; return false;
} }
@ -456,7 +456,7 @@ bool Pt2001Base::restart() {
// current configuration of REG_MAIN would toggle flag0 from LOW to HIGH // current configuration of REG_MAIN would toggle flag0 from LOW to HIGH
flag0after = readFlag0(); flag0after = readFlag0();
if (flag0before || !flag0after) { if (flag0before || !flag0after) {
onError("MC33 flag0 transition no buena"); onError(McFault::flag0);
shutdown(); shutdown();
return false; return false;
} }
@ -475,14 +475,14 @@ bool Pt2001Base::restart() {
sleepMs(10); sleepMs(10);
if (!checkFlash()) { if (!checkFlash()) {
onError("MC33 no flash"); onError(McFault::NoFlash);
shutdown(); shutdown();
return false; return false;
} }
status = readDriverStatus(); status = readDriverStatus();
if (checkUndervoltVccP(status)) { if (checkUndervoltVccP(status)) {
onError("MC33 VccP (7V) Under-Voltage!"); onError(McFault::UnderVoltage7);
shutdown(); shutdown();
return false; return false;
} }
@ -492,14 +492,14 @@ bool Pt2001Base::restart() {
sleepMs(10); // Give it a moment sleepMs(10); // Give it a moment
status = readDriverStatus(); status = readDriverStatus();
if (!checkDrivenEnabled(status)) { if (!checkDrivenEnabled(status)) {
onError("MC33 Driven did not stick!"); onError(McFault::Driven);
shutdown(); shutdown();
return false; return false;
} }
status = readDriverStatus(); status = readDriverStatus();
if (checkUndervoltVccP(status)) { if (checkUndervoltVccP(status)) {
onError("MC33 VccP Under-Voltage After Driven"); // Likely DC-DC LS7 is dead! onError(McFault::UnderVoltageAfter); // Likely DC-DC LS7 is dead!
shutdown(); shutdown();
return false; return false;
} }