fix(esp32-c3): drive digital inputs from the SPICE solve (spiceDrivenInputs)

Esp32C3Simulator already had the GPIO_IN plumbing (setPinState -> gpioIn ->
GPIO_IN_REG read) but never opted into connectDigitalInputsToMcu, so a pin
wired to a switch/button was never fed the solved circuit voltage and
digitalRead() ignored the real wiring. Enabling the flag (as AVRSimulator and
RP2040Simulator already do) completes the issue #247 fix: the ESP32-C3 now
reads GPIO2 from the SPICE solve, so toggling the slide switch flips the LED.
BasicParts' button/slide-switch seed already yields to spiceDriven(), so there
is no double-drive.
This commit is contained in:
David Montero 2026-07-09 19:16:37 +02:00
parent f5c1887869
commit 061bb91da1
1 changed files with 8 additions and 0 deletions

View File

@ -112,6 +112,14 @@ const CYCLES_PER_FRAME = Math.round(CPU_HZ / 60);
const CYCLES_PER_TICK = 160_000;
export class Esp32C3Simulator {
// Opt into connectDigitalInputsToMcu: after every SPICE solve the connector
// thresholds each input pin's net voltage and pushes the logic level into the
// GPIO_IN register via setPinState(). So digitalRead() reflects the real
// wiring (a switch/button tied to 3V3 reads HIGH) instead of a hardcoded part
// seed. The connector skips MCU-driven output pins and floating (non-sourced)
// nets, so event-driven parts with no SPICE model keep driving their pins via
// the part layer. Mirrors AVRSimulator / RP2040Simulator.
readonly spiceDrivenInputs = true;
private core: RiscVCore;
private flash: Uint8Array;
private dram: Uint8Array;