|
LCC Fusion Project 1.0
LCC Automation
|
One-stop pin self-test utility with a single dispatcher entry point. More...
#include <PstTestPins.h>
Public Types | |
| enum class | Type : uint8_t { IO , Input , Output , OpenDrain , ADC , I2C_SDA , I2C_SCL , PWM , Button , UART_RX , UART_TX , McpInput , Unknown } |
| Declares the intended role of the pin so the dispatcher can run sensible tests. More... | |
Public Member Functions | |
| PstTestPins () | |
| Default constructor (no configuration needed for ESP32). | |
| bool | testPin (uint8_t pin, Type type, const char *label=nullptr) const |
| Run the appropriate self-test(s) for a pin based on its Type. More... | |
| bool | testMcpInput (Adafruit_MCP23017 *pMcp, uint8_t mcpPin, const char *name) const |
| Run an input-only test on a port expander pin. More... | |
| bool | testOpen (uint8_t pin, const char *label=nullptr, bool gentle=false) const |
| Run only the "open" heuristic on a pin. More... | |
| bool | testShorted (uint8_t pin, const char *label=nullptr, bool gentle=false) const |
| Run only the "shorted" heuristic on a pin. More... | |
Static Public Member Functions | |
| static void | set_led (uint8_t pin, bool on) |
| Convenience: drive an indicator LED with active-LOW polarity. More... | |
| static void | init_led (uint8_t pin) |
| Initialize an indicator LED pin (OUTPUT, start OFF). More... | |
Private Member Functions | |
| bool | _testUartTx (uint8_t pin, const char *label) const |
| UART-aware TX test (no loopback/jumpers required). More... | |
| bool | _testOpen (uint8_t pin, const char *name, bool gentle=false) const |
| Heuristic "open” check using internal pulls. More... | |
| bool | _testShorted (uint8_t pin, const char *name, bool gentle=false) const |
| Detects pins stuck HIGH or LOW using internal pulls. More... | |
| bool | _testDriveRead (uint8_t pin, const char *name) const |
| Output toggle/readback sanity check. More... | |
| bool | _testOpenDrain (uint8_t pin, const char *name) const |
| Open-drain verification: LOW drive then released HIGH (via pull-up). More... | |
| bool | _testAdc (uint8_t pin, const char *name) const |
| ADC sanity check using ESP32 calibrated read (millivolts). More... | |
| bool | _testI2cLineCheck (uint8_t pin, const char *name, const char *lineName) const |
| Preferred I²C line health check (no pulls, then diagnostic “nudge”). More... | |
Static Private Member Functions | |
| static bool | _isInputOnly (uint8_t pin) |
| Returns true if a GPIO is input-only on ESP32 (GPIO 34-39). More... | |
| static bool | _hasInternalPulls (uint8_t pin) |
| Returns true if the pin supports internal pull resistors. More... | |
One-stop pin self-test utility with a single dispatcher entry point.
GPIO self‑test utility for LCC Fusion cards.
The dispatcher PstTestPins::testPin chooses appropriate checks based on PstTestPins::Type:
PstTestPins performs a suite of simple electrical checks on ESP32 pins (and MCP23017 expander pins) to help builders verify correct wiring and soldering before firmware initialization. Tests include checking for stuck pins, opens, shorts between power rails, basic drive/readback functionality and, for open‑drain and UART pins, appropriate biasing. Results are printed via the global g_serialIO using human‑readable language. Use testPin() to run tests appropriate for a given pin’s intended role (see Type).
Definition at line 62 of file PstTestPins.h.
|
strong |
Declares the intended role of the pin so the dispatcher can run sensible tests.
| Enumerator | |
|---|---|
| IO | General‑purpose pin capable of input and output |
| Input | Digital input only |
| Output | Digital output |
| OpenDrain | Open‑drain output: active LOW when driven, HIGH when released |
| ADC | Analog input channel |
| I2C_SDA | I²C data line (SDA); should idle HIGH |
| I2C_SCL | I²C clock line (SCL); should idle HIGH |
| PWM | PWM‑capable output; test performs a simple HIGH/LOW toggle |
| Button | Momentary input such as a push‑button |
| UART_RX | UART receive pin; DFPlayer TX -> ESP32 RX; uses gentle bias |
| UART_TX | UART transmit pin; ESP32 TX -> DFPlayer RX; idles HIGH |
| McpInput | Input on an MCP23017 expander; tested via testMcpInput() |
| Unknown | Unspecified or unsupported pin type |
Definition at line 68 of file PstTestPins.h.
|
inlinestaticprivate |
Returns true if the pin supports internal pull resistors.
| pin | GPIO number. |
Definition at line 295 of file PstTestPins.h.


|
inlinestaticprivate |
Returns true if a GPIO is input-only on ESP32 (GPIO 34-39).
| pin | GPIO number. |
Definition at line 285 of file PstTestPins.h.

|
inlineprivate |
ADC sanity check using ESP32 calibrated read (millivolts).
Sets 11 dB attenuation (valid up to ~3.3 V), averages several samples, and flags likely shorts: near 0 mV (short to GND) or near 3.3 V (short to 3V3).
| pin | ADC-capable GPIO (ADC1 recommended). |
| name | Label printed in logs. |
Definition at line 532 of file PstTestPins.h.


|
inlineprivate |
Output toggle/readback sanity check.
Skips driving input-only pins. For others:
| pin | GPIO under test. |
| name | Label printed in logs. |
Definition at line 459 of file PstTestPins.h.


|
inlineprivate |
Preferred I²C line health check (no pulls, then diagnostic “nudge”).
Procedure: 1) Observe the line as INPUT (no internal pull). A healthy, powered bus idles HIGH. 2) If LOW, briefly enable INPUT_PULLUP:
| pin | GPIO to check. |
| name | Label for logs. |
| lineName | "SDA" or "SCL" (for messages). |
Definition at line 575 of file PstTestPins.h.


|
inlineprivate |
Heuristic "open” check using internal pulls.
When gentle is false (default), performs a full up/down nudge:
When gentle is true (UART-safe), avoids PULLDOWN (never weakly drives LOW):
Skips nudges on input-only pins (no internal pulls).
| pin | GPIO under test. |
| name | Label printed in logs. |
| gentle | If true, avoid INPUT_PULLDOWN and use a UART-safe probe. |
Definition at line 319 of file PstTestPins.h.


|
inlineprivate |
Open-drain verification: LOW drive then released HIGH (via pull-up).
Procedure:
| pin | GPIO under test. |
| name | Label printed in logs. |
Definition at line 496 of file PstTestPins.h.


|
inlineprivate |
Detects pins stuck HIGH or LOW using internal pulls.
When gentle is false (default), performs a full up/down nudge:
When gentle is true (UART-safe), avoids PULLDOWN; we only test the ability to go HIGH:
Skips nudges on input-only pins (no internal pulls).
| pin | GPIO under test. |
| name | Label printed in logs. |
| gentle | If true, avoid INPUT_PULLDOWN and use a UART-safe probe. |
Definition at line 397 of file PstTestPins.h.


|
inlineprivate |
UART-aware TX test (no loopback/jumpers required).
Behavior:
| pin | ESP32 TX GPIO (connected to DFPlayer RX). |
| label | Label printed in logs. |
Definition at line 267 of file PstTestPins.h.


|
inlinestatic |
Initialize an indicator LED pin (OUTPUT, start OFF).
| pin | LED GPIO. |
Definition at line 115 of file PstTestPins.h.


|
inlinestatic |
Convenience: drive an indicator LED with active-LOW polarity.
| pin | LED GPIO. |
| on | True to turn LED on (drives LOW), false to turn off (drives HIGH). |
Definition at line 106 of file PstTestPins.h.

|
inline |
Run an input-only test on a port expander pin.
Configures the specified MCP23017 pin as a pulled‑up input and prints whether it reads LOW (wired to ground) or HIGH (floating). It does not drive the pin or change its OLAT register, so it is safe to call for unconnected inputs. If pMcp is null the function logs a warning and returns false.
| pMcp | Pointer to a configured Adafruit_MCP23017 instance. |
| mcpPin | MCP23017 pin number (0–15) to test. |
| name | Optional label used in log messages; defaults to "MCP_PIN". |
| true | The test completed (always informational; does not flag failure). |
| false | pMcp was null and the test did not run. |
Definition at line 205 of file PstTestPins.h.

|
inline |
Run only the "open" heuristic on a pin.
| pin | GPIO under test. |
| label | Optional label for logs. |
| gentle | If true, performs a gentle open check (avoids INPUT_PULLDOWN; uses only unbiased read + PULLUP). |
Definition at line 238 of file PstTestPins.h.

|
inline |
Run the appropriate self-test(s) for a pin based on its Type.
| pin | ESP32 GPIO number (e.g., 21). |
| type | Intended role (determines which checks run). |
| label | Optional user label for messages (e.g., "I2C_SDA"); falls back to "PIN". |
Dispatch map:
Definition at line 143 of file PstTestPins.h.


|
inline |
Run only the "shorted" heuristic on a pin.
| pin | GPIO under test. |
| label | Optional label for logs. |
| gentle | If true, performs a gentle short check (avoids INPUT_PULLDOWN; uses only unbiased read + PULLUP). |
Definition at line 250 of file PstTestPins.h.
