gpio diagnostic: use PIN_UNKNOWN for pins with no diagsotic

This commit is contained in:
Andrey Gusakov 2024-01-28 18:35:14 +03:00 committed by rusefillc
parent 292601fa70
commit 483056746c
14 changed files with 23 additions and 19 deletions

View File

@ -28,7 +28,9 @@
/* diagnostic for brain pins
* can be combination of few bits
* defined as bit mask */
* defined as bit mask
* PIN_UNKNOWN is reported for pins with no diagnostic support, like on-chip gpio
*/
typedef enum __attribute__ ((__packed__))
{
PIN_OK = 0,
@ -38,7 +40,7 @@ typedef enum __attribute__ ((__packed__))
PIN_OVERLOAD = 0x08,
PIN_DRIVER_OVERTEMP = 0x10,
PIN_DRIVER_OFF = 0x20,
PIN_INVALID = 0x80
PIN_UNKNOWN = 0x80
} brain_pin_diag_e;
// see also PWM_PHASE_MAX_WAVE_PER_PWM

View File

@ -79,7 +79,7 @@ static void benchOff(OutputPin* output) {
static char pin_error[64];
brain_pin_diag_e diag = output->getDiag();
if (diag == PIN_INVALID) {
if (diag == PIN_UNKNOWN) {
efiPrintf("No Diag on this pin");
} else {
pinDiag2string(pin_error, sizeof(pin_error), diag);

View File

@ -210,7 +210,7 @@ void SensorChecker::onSlowCallback() {
}
auto diag = pin.getDiag();
if (diag != PIN_OK && diag != PIN_INVALID) {
if (diag != PIN_OK && diag != PIN_UNKNOWN) {
unhappyInjector = 1 + i;
auto code = getCodeForInjector(i, diag);
@ -235,7 +235,7 @@ void SensorChecker::onSlowCallback() {
}
auto diag = pin.getDiag();
if (diag != PIN_OK && diag != PIN_INVALID) {
if (diag != PIN_OK && diag != PIN_UNKNOWN) {
auto code = getCodeForIgnition(i, diag);
char description[32];

View File

@ -657,10 +657,12 @@ void OutputPin::setDefaultPinState(pin_output_mode_e outputMode) {
brain_pin_diag_e OutputPin::getDiag() const {
#if BOARD_EXT_GPIOCHIPS > 0
return gpiochips_getDiag(brainPin);
#else
return PIN_OK;
if (!brain_pin_is_onchip(brainPin)) {
return gpiochips_getDiag(brainPin);
}
#endif
// TODO: add hook to board code for custom diagnostic, like it is done on S105
return PIN_UNKNOWN;
}
void initMiscOutputPins() {

View File

@ -305,7 +305,7 @@ int gpiochips_readPad(brain_pin_e pin)
/**
* @brief Get diagnostic for given gpio
* @details actual output value depend on gpiochip capabilities
* returns PIN_INVALID in case of pin not belong to any gpio chip
* returns PIN_UNKNOWN in case of pin not belong to any gpio chip
* returns PIN_OK in case of chip does not support getting diagnostic
* else return brain_pin_diag_e from gpiochip driver;
*/
@ -314,7 +314,7 @@ brain_pin_diag_e gpiochips_getDiag(brain_pin_e pin) {
gpiochip *chip = gpiochip_find(pin);
if (!chip)
return PIN_INVALID;
return PIN_UNKNOWN;
return chip->chip->getDiag(pin - chip->base);
}

View File

@ -616,7 +616,7 @@ int L9779::readPad(size_t pin) {
brain_pin_diag_e L9779::getDiag(size_t pin)
{
if (pin >= L9779_SIGNALS)
return PIN_INVALID;
return PIN_UNKNOWN;
if (pin < L9779_OUTPUTS)
return getOutputDiag(pin);

View File

@ -593,7 +593,7 @@ brain_pin_diag_e Mc33810::getDiag(size_t pin)
int diag = PIN_OK;
if (pin >= MC33810_DIRECT_OUTPUTS)
return PIN_INVALID;
return PIN_UNKNOWN;
if (pin < 4) {
/* OUT drivers */

View File

@ -372,7 +372,7 @@ brain_pin_diag_e Mc33972::getDiag(size_t pin) {
brain_pin_diag_e diag = PIN_OK;
if (pin >= MC33972_INPUTS)
return PIN_INVALID;
return PIN_UNKNOWN;
/* one diag bit for all pins */
if (i_state & FLAG_THERM)

View File

@ -112,7 +112,7 @@ int ProtectedGpios::readPad(size_t pin) {
brain_pin_diag_e ProtectedGpios::getDiag(size_t pin) {
if (pin >= PROTECTED_CHANNEL_COUNT) {
return PIN_INVALID;
return PIN_UNKNOWN;
}
return m_channels[pin].getDiag();

View File

@ -409,7 +409,7 @@ brain_pin_diag_e Tle6240::getDiag(size_t pin)
int diagVal;
if (pin >= TLE6240_OUTPUTS)
return PIN_INVALID;
return PIN_UNKNOWN;
val = (diag[(pin > 7) ? 1 : 0] >> ((pin % 8) * 2)) & 0x03;
if (val == 0x3)

View File

@ -1040,7 +1040,7 @@ brain_pin_diag_e Tle8888::getInputDiag(unsigned int pin)
brain_pin_diag_e Tle8888::getDiag(size_t pin)
{
if (pin >= TLE8888_SIGNALS)
return PIN_INVALID;
return PIN_UNKNOWN;
if (pin < TLE8888_OUTPUTS)
return getOutputDiag(pin);

View File

@ -177,7 +177,7 @@ brain_pin_diag_e Tle9104::getDiag(size_t pin) {
off_diag = diag_off >> 6;
break;
default:
return PIN_INVALID;
return PIN_UNKNOWN;
}
// on diag has 3 bits

View File

@ -114,7 +114,7 @@ void pinDiag2string(char *buffer, size_t size, brain_pin_diag_e pin_diag) {
/* use autogeneraged helpers here? */
if (pin_diag == PIN_OK) {
chsnprintf(buffer, size, "Ok");
} else if (pin_diag != PIN_INVALID) {
} else if (pin_diag != PIN_UNKNOWN) {
chsnprintf(buffer, size, "%s%s%s%s%s%s",
pin_diag & PIN_DRIVER_OFF ? "driver_off " : "",
pin_diag & PIN_OPEN ? "open_load " : "",

View File

@ -242,7 +242,7 @@ enable2ndByteCanID = false
; TpsState
etbCutCodeList = bits, U08, [0:7], "None", "engine stopped", "TPS error", "PPS error", "TPS noise", "PID noise", "Lua", "Manual", "N/A", "Redundancy", "PPS noise"
outputDiagErrorList = bits, U08, [0:3], "Not used", "No error", "Open Load", "Short to Gnd", "Short to Battery", "Overload", "Driver Overtemp", "Driver disabled", "Invalid"
outputDiagErrorList = bits, U08, [0:3], "Not used", "No error", "Open Load", "Short to Gnd", "Short to Battery", "Overload", "Driver Overtemp", "Driver disabled", "Unknown"
[ConstantsExtensions]
; defaultValue is used to provide TunerStudio with a value to use in the case of