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: analog input, value 0, every level and threshold at 0. It also stops PWM on IO 17, 18, 21 and 22 and restores the PWM defaults, and releases the sync, which returns the device to sync-slave mode (see release()).

await tester.gpio.reset();

Returns: Promise<void> / None / Result<(), At1000Error>


digital(io)​

Access a specific GPIO pin for digital operations.

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

Parameters:

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

Returns: DigitalIO instance / Result<DigitalIo, At1000Error> in Rust


analog(io)​

Access a specific GPIO pin for analog operations.

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

Parameters:

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

Returns: AnalogIO instance / Result<AnalogIo, At1000Error> in Rust


pwm(io)​

Access a PWM-capable pin. IO 17 and 21 measure, IO 18 and 22 generate. See PWM measurement and generation.

const pwm = tester.gpio.pwm(18);

Parameters:

  • io (number / int / usize): GPIO pin number. Only 17, 18, 21 and 22 support PWM; the device rejects the others when the handle is used.

Returns: PwmIO instance / Result<PwmIo, At1000Error> in Rust


hold()​

Holds the outputs. Writes issued after hold() are stored on the device, and the pins keep their current levels until release() applies them all at once.

await tester.gpio.hold();

Returns: Promise<SyncConfiguration> / SyncConfiguration / Result<(), At1000Error> - Configuration with action: "hold" (nothing in Rust)

note

Holding makes this device the sync master: it drives the sync signal, so daisy-chained devices in sync-slave mode hold their outputs too (see Output synchronization). Reads are not affected: read() keeps measuring the pin, which still shows the level from before the hold. 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 / Result<(), At1000Error> - Configuration with action: "release" (nothing in Rust)


read_config(io)​

Reads back the current configuration of a specific I/O pin. In Rust, read it through a pin handle: digital(io)?.read_config() and analog(io)?.read_config() return the same configuration, whatever the pin's mode.

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

Parameters:

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

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


read_sync()​

Reads the observed synchronization hold state. Returns { hold_state: "held" } while the outputs are withheld, whether this device holds them with hold() or, in sync-slave mode, an external master holds them, and { hold_state: "released" } otherwise.

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

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

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


DigitalIO Class​

A digital input reads false at or below vil and true at or above vih. Between the two thresholds it keeps the level it last reported (hysteresis). 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.

Every configure_* call, and a pin reset(), fails with 409 CONFIGURATION_CONFLICT while I2C, SPI, UART or PWM drives the pin; see pin alternate functions.

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 / DigitalInputConfig):
    • vil (number / float / f64, required): Voltage input low threshold ([-25, 25] V, inclusive)
    • vih (number / float / f64, required): Voltage input high threshold ([-25, 25] V, inclusive)

Returns: Promise<DigitalInputConfiguration> / DigitalInputConfiguration / Result<GpioConfiguration, At1000Error> - 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 / DigitalOutputConfig, whose Default lets a struct literal name only value, vol and voh and end with ..Default::default()):
    • value (boolean | number / bool | int / bool, required): Initial output state (true/1 = high, false/0 = low)
    • vol (number / float / f64, required): Voltage output low level (0 to 24V)
    • voh (number / float / f64, required): Voltage output high level (0 to 24V)
    • vil (number / float / Option<f64>, optional): Voltage input low threshold ([-25, 25] V, inclusive)
    • vih (number / float / Option<f64>, optional): Voltage input high threshold ([-25, 25] V, inclusive)

Returns: Promise<DigitalOutputConfiguration> / DigitalOutputConfiguration / Result<GpioConfiguration, At1000Error> - 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
  • 400 INVALID_VALUE if voh is not greater than vol. The Rust SDK rejects it before sending, with At1000Error::InvalidInput
note

When vil and vih are omitted, they are deduced from voh and vol: vil = vol + (voh - vol) / 4 and vih = voh - (voh - vol) / 4. For vol = 0 and voh = 3.3, that is vil = 0.825 V and vih = 2.475 V.


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 / OpenDrainConfig):
    • value (boolean | number / bool | int / bool, required): Initial state (true = floating/high-Z, false = low)
    • vil (number / float / f64, required): Voltage input low threshold ([-25, 25] V, inclusive)
    • vih (number / float / f64, required): Voltage input high threshold ([-25, 25] V, inclusive)

Returns: Promise<OpenDrainConfiguration> / OpenDrainConfiguration / Result<GpioConfiguration, At1000Error> - 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 / Result<bool, At1000Error> - 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 / bool): Value to write (true/1 = HIGH, false/0 = LOW)

Returns: Promise<boolean> / bool / Result<bool, At1000Error> - 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 / Result<GpioConfiguration, At1000Error> - 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 / f64): Initial output voltage (0 to 24V)

Returns: Promise<AnalogOutputConfiguration> / AnalogOutputConfiguration / Result<GpioConfiguration, At1000Error> - 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 / Result<f64, At1000Error> - 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 / f64): Voltage to output (0 to 24V)

Returns: Promise<number> / float / Result<f64, At1000Error> - The set voltage

Exceptions:

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

PwmIO Class​

PWM measurement on IO 17 and 21, square-wave generation on IO 18 and 22. Enabling PWM fails with CONFIGURATION_CONFLICT while I2C, SPI, UART or the other PWM pin of the same channel is enabled, and with UNSAFE_PIN_VOLTAGE if the pin reads below −0.5 V or above vcc + 0.5 V. Device errors surface as an ApiError carrying the code in JavaScript and Python, and as At1000Error::Api(err) with an ErrorCode in err.code in Rust, such as ErrorCode::ConfigurationConflict. See PWM measurement and generation for the pin roles, channel sharing and timing details.

configure_input(options?)​

Enables PWM measurement on an input pin (IO 17 or 21).

const pwm = tester.gpio.pwm(17);
await pwm.configure_input({ vcc: 3.3 });

Parameters:

  • options (PwmInputOptions, optional / keyword arguments / PwmInputConfig):
    • vcc (number / float / Option<f64>, optional): Highest voltage the pin accepts, [1.8, 3.3] V, inclusive. When omitted, the device keeps its current setting. The input thresholds stay at about 0.8–1.35 V whatever vcc is.

Returns: Promise<PwmConfig> / PwmConfig / Result<PwmConfig, At1000Error>

Exceptions:

  • Throws validation error if vcc is outside [1.8, 3.3] V
  • INVALID_VALUE if the pin is not a PWM input
  • CONFIGURATION_CONFLICT if the channel is in use
  • UNSAFE_PIN_VOLTAGE if the pin fails the voltage check

configure_output(options)​

Starts square-wave generation (about 50 % duty) on an output pin (IO 18 or 22). The device generates the closest frequency it can produce and returns it in frequency. Changing frequency or duration of a running output restarts it: the level shifter is off for about 100 ms, and duration counts from this call.

const pwm = tester.gpio.pwm(18);
const config = await pwm.configure_output({ frequency: 1000, vcc: 3.3, duration: 10 });
console.log(config.frequency); // frequency actually generated

Parameters:

  • options (PwmOutputOptions / keyword arguments / PwmOutputConfig, whose Default lets a struct literal name only frequency and end with ..Default::default()):
    • frequency (number / float / f64, required): Requested frequency in Hz, from 91.55 Hz to 7.5 MHz
    • vcc (number / float / Option<f64>, optional): High level driven on the pin, [1.8, 3.3] V, inclusive. When omitted, the device keeps its current setting.
    • duration (number / float / Option<Duration>, optional): Run time in seconds (Duration in Rust), in (0, 86400], that is up to 24 h. When omitted, the output runs until it is disabled. duration is always sent, so omitting it clears a duration set by an earlier call.

Returns: Promise<PwmConfig> / PwmConfig / Result<PwmConfig, At1000Error> - with frequency set to the generated frequency (in PwmConfig::Output in Rust)

Exceptions:

  • Throws validation error if vcc or duration is out of range, or frequency is not a positive number
  • INVALID_VALUE if the pin is not a PWM output, or frequency is outside [91.55 Hz, 7.5 MHz]
  • CONFIGURATION_CONFLICT if the channel is in use
  • UNSAFE_PIN_VOLTAGE if the pin fails the voltage check

disable()​

Disables PWM on the pin. An output stops generating.

await pwm.disable();

Returns: Promise<PwmConfig> / PwmConfig / Result<PwmConfig, At1000Error>


read_config()​

Reads the PWM configuration of the pin. On an output whose timed run has ended, enabled is false.

const config = await pwm.read_config();

Returns: Promise<PwmConfig> / PwmConfig / Result<PwmConfig, At1000Error>


measure(options?)​

Runs one capture on an enabled input pin. The pin is sampled at 30 MHz. The capture runs until it holds at least one full cycle and 100 ms have passed, and ends on a rising edge; timeout ends it whatever the edges. The HTTP request timeout is extended automatically to timeout + 2 s. In Rust, measure(None) uses the default timeout of 5 s, and measure(timeout) takes a Duration.

const m = await pwm.measure({ timeout: 2 });
if (m.status === 'ok') {
console.log(m.frequency, m.duty_cycle);
}

Parameters:

  • options (PwmMeasureOptions, optional / keyword argument / Duration or None in Rust):
    • timeout (number / float / Duration, optional): Longest capture in seconds (Duration in Rust), [0.1, 60], that is 100 ms to 60 s. Default 5

Returns: Promise<PwmMeasurement> / PwmMeasurement / Result<PwmMeasurement, At1000Error>

Exceptions:

  • Throws validation error if timeout is outside [0.1, 60]
  • INVALID_VALUE if the pin is a PWM output
  • INVALID_CONFIGURATION if PWM is disabled on the pin
  • INTERNAL_ERROR (HTTP 500) if the AT1000 could not keep up with the capture. Retry the measurement
caution

Signals up to 5 MHz are measured accurately. Above about 6 MHz (pulses shorter than about 67 ns), the samples alias silently and the result is wrong without any error.


Types​

DigitalInputConfiguration​

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

Rust: ikalogic_at1000::DigitalInputConfig

pub struct DigitalInputConfig {
pub vil: f64,
pub vih: f64,
}

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
}

Rust: ikalogic_at1000::DigitalOutputConfig

pub struct DigitalOutputConfig {
pub value: bool,
pub vol: f64,
pub voh: f64,
pub vil: Option<f64>,
pub vih: Option<f64>,
}

DigitalOutputConfig implements Default, so a struct literal can name only value, vol and voh and leave vil and vih at None: DigitalOutputConfig { value: false, vol: 0.0, voh: 3.3, ..Default::default() }. The default voh of 0 V is rejected by configure_output, so always set it.

OpenDrainConfiguration​

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

Rust: ikalogic_at1000::OpenDrainConfig

pub struct OpenDrainConfig {
pub value: bool,
pub vil: f64,
pub vih: f64,
}

AnalogInputConfiguration​

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

Rust: no analog configuration struct. configure_input() takes no argument and returns GpioConfiguration.

AnalogOutputConfiguration​

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

Rust: no analog configuration struct. configure_output() takes the voltage as an f64 and returns GpioConfiguration.

GpioConfiguration​

What every configure call and read_config() return: in JavaScript and Python, one of the five configurations above.

DigitalInputConfiguration | DigitalOutputConfiguration | OpenDrainConfiguration
| AnalogInputConfiguration | AnalogOutputConfiguration

Rust: ikalogic_at1000::GpioConfiguration. The Rust SDK has no per-mode configuration type: configure_input, configure_output, configure_open_drain, reset and read_config all return this enum, whose variant holds only the fields of the pin's mode. mode() and direction() return the pin's GpioMode and GpioDirection. Other carries a mode and direction pairing the SDK does not model.

#[non_exhaustive]
pub enum GpioConfiguration {
AnalogInput,
AnalogOutput { value: f64 },
DigitalInput { vil: f64, vih: f64 },
DigitalOutput { value: bool, vol: f64, voh: f64, vil: f64, vih: f64 },
OpenDrain { value: bool, vil: f64, vih: f64 },
Other { mode: GpioMode, direction: GpioDirection },
}

#[non_exhaustive]
pub enum GpioMode { Analog, Digital, Unknown(String) }

#[non_exhaustive]
pub enum GpioDirection { Input, Output, OpenDrain, Unknown(String) }

pub enum GpioValue { Digital(bool), Analog(f64) }

GpioConfiguration, PwmConfig and the enums the device reports (GpioMode, GpioDirection, PwmDirection, PwmStatus and HoldState) are #[non_exhaustive], so a match on them needs a _ arm. The reported enums end with Unknown(String), which keeps a value from a newer firmware verbatim.

PwmConfig​

Returned by every PwmIO configure call, disable() and read_config(). Also the data of the gpio.pwm_config event.

{
enabled: boolean,
direction: "input" | "output",
vcc: number, // 1.8 to 3.3 V
frequency?: number, // outputs only: generated frequency in Hz
duration?: number // outputs only: run time in s requested at the last start; absent when running until disabled
}

Rust: ikalogic_at1000::PwmConfig, an enum whose variant holds only the fields of the pin's role, so the frequency of an output is a plain f64. enabled(), vcc() and direction() return those fields whatever the role. Other carries a role the SDK does not model.

#[non_exhaustive]
pub enum PwmConfig {
Input { enabled: bool, vcc: f64 },
Output { enabled: bool, vcc: f64, frequency: f64, duration: Option<Duration> },
Other { enabled: bool, vcc: f64, direction: PwmDirection },
}

#[non_exhaustive]
pub enum PwmDirection { Input, Output, Unknown(String) }

PwmInputOptions / PwmOutputOptions / PwmMeasureOptions​

JavaScript options of configure_input, configure_output and measure. Python takes the same fields as keyword arguments.

PwmInputOptions = { vcc?: number }
PwmOutputOptions = { frequency: number, vcc?: number, duration?: number }
PwmMeasureOptions = { timeout?: number }

Rust: ikalogic_at1000::PwmInputConfig and ikalogic_at1000::PwmOutputConfig. measure takes no options struct: measure(None) uses the default timeout and measure(timeout) takes it as a Duration.

pub struct PwmInputConfig {
pub vcc: Option<f64>,
}

pub struct PwmOutputConfig {
pub frequency: f64,
pub vcc: Option<f64>,
pub duration: Option<Duration>,
}

Both implement Default, so a struct literal can name only the fields it sets, as in PwmOutputConfig { frequency: 1000.0, vcc: Some(3.3), ..Default::default() }. The default frequency of 0 Hz is rejected by configure_output, so always set it.

PwmMeasurement​

Returned by measure(). A discriminated union on status; the statistics are present only when status is "ok" and cover whole cycles from the first to the last captured rising edge. Times are in seconds. In Python, status is typed PwmStatus = Literal["ok", "timeout"].

{
status: "ok" | "timeout",
level: boolean, // line level at the end of the capture
edges: number,
cycles: number,
duration: number, // captured time
// status "ok" only:
frequency: number, // Hz
duty_cycle: number, // %
period: number, period_min: number, period_max: number,
high_time: number, high_time_min: number, high_time_max: number,
low_time: number, low_time_min: number, low_time_max: number
}

Rust: ikalogic_at1000::PwmMeasurement. The statistics are grouped in stats, which is None on a timeout, and every time is a Duration. Each PwmTimeStats holds the average and its extremes: period.avg, period.min and period.max are period, period_min and period_max above.

pub struct PwmMeasurement {
pub status: PwmStatus,
pub level: bool,
pub edges: u64,
pub cycles: u64,
pub duration: Duration,
pub stats: Option<PwmStats>,
}

pub struct PwmStats {
pub frequency: f64,
pub duty_cycle: f64,
pub period: PwmTimeStats,
pub high_time: PwmTimeStats,
pub low_time: PwmTimeStats,
}

pub struct PwmTimeStats {
pub min: Duration,
pub avg: Duration,
pub max: Duration,
}

#[non_exhaustive]
pub enum PwmStatus { Ok, Timeout, Unknown(String) }

SyncState​

{ hold_state: "held" | "released" }

Rust: ikalogic_at1000::SyncState

pub struct SyncState {
pub hold_state: HoldState,
}

#[non_exhaustive]
pub enum HoldState { Released, Held, Unknown(String) }

Notes​

  • All 32 pins support both digital and analog modes, except while an interface uses them: a pin that I2C, SPI, UART or PWM drives cannot be configured as a GPIO, and those interfaces cannot be enabled while one of their pins is configured as anything but an analog input. See pin alternate functions
  • 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 in JavaScript and Python; Rust DigitalIo::write takes a bool only
  • Analog readings provide precise voltage measurements
  • Use hold() and release() for synchronized multi-pin operations
  • IO 17, 18, 21 and 22 also support PWM measurement and generation through pwm(io); see PWM measurement and generation
  • To run many I/O steps in a single request, use a command sequence