Skip to main content

GPIO API Reference

The GPIO (General Purpose Input/Output) API provides access to 32 programmable I/O pins that can be configured for digital or analog operations. Each pin supports voltages from -25V to +25V for inputs and 0 to 24V for outputs.

Accessing GPIO​

const gpio = tester.gpio;

GPIO Module Methods​

reset()​

Resets all GPIO pins to their default configuration.

await tester.gpio.reset();

Returns: Promise<void> / None


digital(io)​

Access a specific GPIO pin for digital operations.

const pin = tester.gpio.digital(0);

Parameters:

  • io (number / int): GPIO pin number (0-31)

Returns: DigitalIO instance


analog(io)​

Access a specific GPIO pin for analog operations.

const pin = tester.gpio.analog(0);

Parameters:

  • io (number / int): GPIO pin number (0-31)

Returns: AnalogIO instance


hold()​

Holds (freezes) the current state of all GPIO pins. This allows buffering multiple write commands before applying them simultaneously.

await tester.gpio.hold();

Returns: Promise<SyncConfiguration> / SyncConfiguration - Configuration with action: "hold"

note

Prevents external changes to GPIO states until release() is called. Digital and analog writes issued between hold() and release() are buffered on the device and applied together on release.


release()​

Releases the outputs, applying all buffered writes simultaneously. Releasing also switches the device to sync-slave mode: its outputs then follow the SYNC-IN line, so an external master's hold freezes them (see Output synchronization).

await tester.gpio.release();

Returns: Promise<SyncConfiguration> / SyncConfiguration - Configuration with action: "release"


read_config(io)​

Reads back the current configuration of a specific I/O pin.

const config = await tester.gpio.read_config(0);

Parameters:

  • io (number / int): GPIO pin number (0-31)

Returns: Promise<GpioConfiguration> / GpioConfiguration - The pin's current configuration


read_sync()​

Reads the current synchronization hold state. Returns { hold_state: "held" } while outputs are frozen and { hold_state: "released" } otherwise.

const state = await tester.gpio.read_sync();

Returns: Promise<SyncState> / SyncState - The current synchronization hold state

Type: SyncState = { hold_state: "held" | "released" }


DigitalIO Class​

Input thresholds may be equal or in either order. If both input-state comparisons match, the low-threshold comparison takes precedence and reads false. A partial REST PATCH retains omitted thresholds. The typed SDK configure_input method requires both vil and vih.

configure_input(config)​

Configures the pin as a digital input with custom thresholds.

await pin.configure_input({
vil: 0.8, // Input low threshold
vih: 2.0 // Input high threshold
});

Parameters:

  • config (PartialDigitalInputConfiguration):
    • vil (number / float, required): Voltage input low threshold ([-25, 25] V, inclusive)
    • vih (number / float, required): Voltage input high threshold ([-25, 25] V, inclusive)

Returns: Promise<DigitalInputConfiguration> / DigitalInputConfiguration - Full configuration including mode and direction

Exceptions:

  • Throws validation error if vil or vih is outside the inclusive range [-25, 25] V

configure_output(config)​

Configures the pin as a digital output with custom voltage levels and thresholds.

await pin.configure_output({
value: true, // Initial state
vol: 0.0, // Output low voltage
voh: 3.3, // Output high voltage
vil: 0.8, // Optional input low threshold
vih: 2.0 // Optional input high threshold
});

Parameters:

  • config (PartialDigitalOutputConfiguration):
    • value (boolean | number / bool | int, required): Initial output state (true/1 = high, false/0 = low)
    • vol (number / float, required): Voltage output low level (0 to 24V)
    • voh (number / float, required): Voltage output high level (0 to 24V)
    • vil (number / float, optional): Voltage input low threshold ([-25, 25] V, inclusive)
    • vih (number / float, optional): Voltage input high threshold ([-25, 25] V, inclusive)

Returns: Promise<DigitalOutputConfiguration> / DigitalOutputConfiguration - Full configuration

Exceptions:

  • Throws validation error if vol or voh is outside the range [0, 24]
  • Throws validation error if vil or vih is outside the inclusive range [-25, 25] V
note

When vil and vih are omitted, they are automatically deduced from the given voh and vol parameters.


configure_open_drain(config)​

Configures the pin as an open-drain output (useful for I2C, 1-Wire, etc.).

await pin.configure_open_drain({
value: true,
vil: 0.8,
vih: 2.0
});

Parameters:

  • config (PartialOpenDrainConfiguration):
    • value (boolean | number / bool | int, required): Initial state (true = floating/high-Z, false = low)
    • vil (number / float, required): Voltage input low threshold ([-25, 25] V, inclusive)
    • vih (number / float, required): Voltage input high threshold ([-25, 25] V, inclusive)

Returns: Promise<OpenDrainConfiguration> / OpenDrainConfiguration - Full configuration

Exceptions:

  • Throws validation error if vil or vih is outside the inclusive range [-25, 25] V

read()​

Reads the current logical state of the pin.

const state = await pin.read();
console.log("Pin is", state ? "HIGH" : "LOW");

Returns: Promise<boolean> / bool - true for HIGH, false for LOW


write(value)​

Writes a logical value to the pin (must be configured as output).

await pin.write(true); // Set HIGH
await pin.write(false); // Set LOW
await pin.write(1); // Set HIGH (numeric)
await pin.write(0); // Set LOW (numeric)

Parameters:

  • value (boolean | number / bool | int): Value to write (true/1 = HIGH, false/0 = LOW)

Returns: Promise<boolean> / bool - The written value as boolean


AnalogIO Class​

configure_input()​

Configures the pin as an analog input for voltage measurement.

await pin.configure_input();

Returns: Promise<AnalogInputConfiguration> / AnalogInputConfiguration - Configuration with mode "analog" and direction "input"


configure_output(value)​

Configures the pin as an analog output and sets the initial voltage.

await pin.configure_output(3.3); // Set to 3.3V

Parameters:

  • value (number / float): Initial output voltage (0 to 24V)

Returns: Promise<AnalogOutputConfiguration> / AnalogOutputConfiguration - Full configuration

Exceptions:

  • Throws validation error if value is outside the range [0, 24]

read()​

Reads the current analog voltage at the pin.

const voltage = await pin.read();
console.log("Voltage:", voltage, "V");

Returns: Promise<number> / float - Measured voltage in volts


write(value)​

Sets the analog output voltage (must be configured as analog output).

await pin.write(3.3); // Set to 3.3V
await pin.write(5.0); // Set to 5.0V
await pin.write(12.5); // Set to 12.5V

Parameters:

  • value (number / float): Voltage to output (0 to 24V)

Returns: Promise<number> / float - The set voltage

Exceptions:

  • Throws validation error if value is outside the range [0, 24]

Types​

DigitalInputConfiguration​

{
mode: "digital",
direction: "input",
vil: number, // [-25, 25] V, inclusive
vih: number // [-25, 25] V, inclusive
}

DigitalOutputConfiguration​

{
mode: "digital",
direction: "output",
value: boolean,
vol: number, // 0 to 24V
voh: number, // 0 to 24V
vil: number, // [-25, 25] V, inclusive
vih: number // [-25, 25] V, inclusive
}

OpenDrainConfiguration​

{
mode: "digital",
direction: "open_drain",
value: boolean,
vil: number, // [-25, 25] V, inclusive
vih: number // [-25, 25] V, inclusive
}

AnalogInputConfiguration​

{
mode: "analog",
direction: "input"
}

AnalogOutputConfiguration​

{
mode: "analog",
direction: "output",
value?: number // 0 to 24V
}

SyncState​

{ hold_state: "held" | "released" }

Notes​

  • All 32 pins support both digital and analog modes
  • Voltage range: -25 V to +25 V for measured inputs and digital thresholds, 0 to 24 V for outputs. Both ranges are inclusive.
  • Open-drain mode is ideal for protocols requiring external pull-ups (I2C, 1-Wire)
  • When writing digital values, both boolean and number (0/1) are accepted
  • Analog readings provide precise voltage measurements
  • Use hold() and release() for synchronized multi-pin operations