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​
- NodeJS
- Python
- Rust
const gpio = tester.gpio;
gpio = tester.gpio
let 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()).
- NodeJS
- Python
- Rust
await tester.gpio.reset();
tester.gpio.reset()
tester.gpio.reset()?;
Returns: Promise<void> / None / Result<(), At1000Error>
digital(io)​
Access a specific GPIO pin for digital operations.
- NodeJS
- Python
- Rust
const pin = tester.gpio.digital(0);
pin = tester.gpio.digital(0)
let 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.
- NodeJS
- Python
- Rust
const pin = tester.gpio.analog(0);
pin = tester.gpio.analog(0)
let 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.
- NodeJS
- Python
- Rust
const pwm = tester.gpio.pwm(18);
pwm = tester.gpio.pwm(18)
let 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.
- NodeJS
- Python
- Rust
await tester.gpio.hold();
tester.gpio.hold()
tester.gpio.hold()?;
Returns: Promise<SyncConfiguration> / SyncConfiguration / Result<(), At1000Error> - Configuration with action: "hold" (nothing in Rust)
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).
- NodeJS
- Python
- Rust
await tester.gpio.release();
tester.gpio.release()
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.
- NodeJS
- Python
- Rust
const config = await tester.gpio.read_config(0);
config = tester.gpio.read_config(0)
let config = tester.gpio.digital(0)?.read_config()?;
// or, through an analog handle
let config = tester.gpio.analog(0)?.read_config()?;
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.
- NodeJS
- Python
- Rust
const state = await tester.gpio.read_sync();
state = tester.gpio.read_sync()
let state = 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.
- NodeJS
- Python
- Rust
await pin.configure_input({
vil: 0.8, // Input low threshold
vih: 2.0 // Input high threshold
});
pin.configure_input(vil=0.8, vih=2.0)
use ikalogic_at1000::DigitalInputConfig;
let pin = tester.gpio.digital(0)?;
pin.configure_input(DigitalInputConfig {
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
vilorvihis outside the inclusive range [-25, 25] V
configure_output(config)​
Configures the pin as a digital output with custom voltage levels and thresholds.
- NodeJS
- Python
- Rust
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
});
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
)
use ikalogic_at1000::DigitalOutputConfig;
let pin = tester.gpio.digital(0)?;
pin.configure_output(DigitalOutputConfig {
value: true, // Initial state
vol: 0.0, // Output low voltage
voh: 3.3, // Output high voltage
vil: Some(0.8), // Optional input low threshold
vih: Some(2.0), // Optional input high threshold
})?;
Parameters:
config(PartialDigitalOutputConfiguration/DigitalOutputConfig, whoseDefaultlets a struct literal name onlyvalue,volandvohand 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
volorvohis outside the range [0, 24] - Throws validation error if
vilorvihis outside the inclusive range [-25, 25] V 400 INVALID_VALUEifvohis not greater thanvol. The Rust SDK rejects it before sending, withAt1000Error::InvalidInput
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.).
- NodeJS
- Python
- Rust
await pin.configure_open_drain({
value: true,
vil: 0.8,
vih: 2.0
});
pin.configure_open_drain(
value=True,
vil=0.8,
vih=2.0
)
use ikalogic_at1000::OpenDrainConfig;
let pin = tester.gpio.digital(0)?;
pin.configure_open_drain(OpenDrainConfig {
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
vilorvihis outside the inclusive range [-25, 25] V
read()​
Reads the current logical state of the pin.
- NodeJS
- Python
- Rust
const state = await pin.read();
console.log("Pin is", state ? "HIGH" : "LOW");
state = pin.read()
print("Pin is", "HIGH" if state else "LOW")
let pin = tester.gpio.digital(0)?;
let state = pin.read()?;
println!("Pin is {}", if state { "HIGH" } else { "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).
- NodeJS
- Python
- Rust
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)
pin.write(True) # Set HIGH
pin.write(False) # Set LOW
pin.write(1) # Set HIGH (numeric)
pin.write(0) # Set LOW (numeric)
let pin = tester.gpio.digital(0)?;
pin.write(true)?; // Set HIGH
pin.write(false)?; // Set LOW
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.
- NodeJS
- Python
- Rust
await pin.configure_input();
pin.configure_input()
let pin = tester.gpio.analog(0)?;
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.
- NodeJS
- Python
- Rust
await pin.configure_output(3.3); // Set to 3.3V
pin.configure_output(3.3) # Set to 3.3V
let pin = tester.gpio.analog(0)?;
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.
- NodeJS
- Python
- Rust
const voltage = await pin.read();
console.log("Voltage:", voltage, "V");
voltage = pin.read()
print(f"Voltage: {voltage} V")
let pin = tester.gpio.analog(0)?;
let voltage = pin.read()?;
println!("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).
- NodeJS
- Python
- Rust
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
pin.write(3.3) # Set to 3.3V
pin.write(5.0) # Set to 5.0V
pin.write(12.5) # Set to 12.5V
let pin = tester.gpio.analog(0)?;
pin.write(3.3)?; // Set to 3.3V
pin.write(5.0)?; // Set to 5.0V
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).
- NodeJS
- Python
- Rust
const pwm = tester.gpio.pwm(17);
await pwm.configure_input({ vcc: 3.3 });
pwm = tester.gpio.pwm(17)
pwm.configure_input(vcc=3.3)
use ikalogic_at1000::PwmInputConfig;
let pwm = tester.gpio.pwm(17)?;
pwm.configure_input(PwmInputConfig { vcc: Some(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 whatevervccis.
Returns: Promise<PwmConfig> / PwmConfig / Result<PwmConfig, At1000Error>
Exceptions:
- Throws validation error if
vccis outside [1.8, 3.3] V INVALID_VALUEif the pin is not a PWM inputCONFIGURATION_CONFLICTif the channel is in useUNSAFE_PIN_VOLTAGEif 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.
- NodeJS
- Python
- Rust
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
pwm = tester.gpio.pwm(18)
config = pwm.configure_output(frequency=1000, vcc=3.3, duration=10)
print(config.frequency) # frequency actually generated
use std::time::Duration;
use ikalogic_at1000::{PwmConfig, PwmOutputConfig};
let pwm = tester.gpio.pwm(18)?;
let config = pwm.configure_output(PwmOutputConfig {
frequency: 1000.0,
vcc: Some(3.3),
duration: Some(Duration::from_secs(10)),
})?;
if let PwmConfig::Output { frequency, .. } = config {
println!("{frequency}"); // frequency actually generated
}
Parameters:
options(PwmOutputOptions/ keyword arguments /PwmOutputConfig, whoseDefaultlets a struct literal name onlyfrequencyand end with..Default::default()):frequency(number/float/f64, required): Requested frequency in Hz, from 91.55 Hz to 7.5 MHzvcc(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 (Durationin Rust), in (0, 86400], that is up to 24 h. When omitted, the output runs until it is disabled.durationis 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
vccordurationis out of range, orfrequencyis not a positive number INVALID_VALUEif the pin is not a PWM output, orfrequencyis outside [91.55 Hz, 7.5 MHz]CONFIGURATION_CONFLICTif the channel is in useUNSAFE_PIN_VOLTAGEif the pin fails the voltage check
disable()​
Disables PWM on the pin. An output stops generating.
- NodeJS
- Python
- Rust
await pwm.disable();
pwm.disable()
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.
- NodeJS
- Python
- Rust
const config = await pwm.read_config();
config = pwm.read_config()
let config = 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.
- NodeJS
- Python
- Rust
const m = await pwm.measure({ timeout: 2 });
if (m.status === 'ok') {
console.log(m.frequency, m.duty_cycle);
}
m = pwm.measure(timeout=2)
if m.status == "ok":
print(m.frequency, m.duty_cycle)
use std::time::Duration;
let m = pwm.measure(Duration::from_secs(2))?;
if let Some(stats) = m.stats {
println!("{} {}", stats.frequency, stats.duty_cycle);
}
Parameters:
options(PwmMeasureOptions, optional / keyword argument /DurationorNonein Rust):timeout(number/float/Duration, optional): Longest capture in seconds (Durationin 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
timeoutis outside [0.1, 60] INVALID_VALUEif the pin is a PWM outputINVALID_CONFIGURATIONif PWM is disabled on the pinINTERNAL_ERROR(HTTP 500) if the AT1000 could not keep up with the capture. Retry the measurement
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
booleanandnumber(0/1) are accepted in JavaScript and Python; RustDigitalIo::writetakes aboolonly - Analog readings provide precise voltage measurements
- Use
hold()andrelease()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