GPIO¶
GPIO 回读、静态驱动、定时脉冲与脉冲宽度触发配置位于 AqProtocolExerciser。从 aqpxlib.gpio 或 aqpxlib 导入枚举与 payload 类型——不要从 aqpxlib.message 导入。
教程
公开导出¶
| 名称 | 种类 | 用途 |
|---|---|---|
PxIoState |
enum | set_gpio_state、脉冲边沿与回报引脚状态的电平 |
PxGpioWidthTriggerMode |
enum | set_gpio_trigger(..., mode=...) |
PxGpioPinState |
message | get_gpio_state 的返回类型 |
PxGpioTriggerEvent |
message | 处理 gpio_trigger 时的 event_msg.global_event.gpio_trigger |
PxIoState
¶
Logical I/O state for a single GPIO line.
单一 GPIO 线路的逻辑电平。
| 成员 | 含义 |
|---|---|
LOW |
驱动或采样为低 |
HIGH |
驱动或采样为高 |
HIGH_Z |
高阻抗(未主动驱动) |
PxGpioWidthTriggerMode
¶
set_gpio_trigger 的宽度条件选择器。
| 成员 | 含义 |
|---|---|
TRIGGER_PULSE_WIDTH_IN_RANGE |
宽度落在 [min_duration_ns, max_duration_ns] 内时触发(配合 low_pulse / high_pulse) |
TRIGGER_PULSE_WIDTH_OUT_OF_RANGE |
宽度落在该窗口外时触发 |
PxGpioPinState
¶
PxGpioPinState(
pin_idx: int = uint32_field(1),
output_state: Optional[PxIoState] = enum_field(2, optional=True),
input_state: Optional[PxIoState] = enum_field(3, optional=True),
)
get_gpio_state(gpio_idx=…) 返回的单一引脚快照。
| 字段 | 含义 |
|---|---|
pin_idx |
引脚索引 |
output_state |
驱动电平(未驱动/未知时为 None) |
input_state |
采样输入(无法取得时为 None) |
PxGpioTriggerEvent
¶
PxGpioTriggerEvent(
pin_idx: int = uint32_field(1),
pulse_duration: int = uint64_field(2),
pulse_polarity: bool = bool_field(3),
)
gpio_trigger 处理函数的 payload(PxEventMsg.global_event.gpio_trigger)。
| 字段 | 含义 |
|---|---|
pin_idx |
符合条件的引脚 |
pulse_duration |
宽度,单位为纳秒 |
pulse_polarity |
检测到的极性 |
Exerciser 方法¶
AqProtocolExerciser
¶
AqProtocolExerciser class.
| METHOD | DESCRIPTION |
|---|---|
get_gpio_state |
Read electrical state for one GPIO pin. |
set_gpio_state |
Drive a static logic level on one GPIO pin. |
send_gpio_pulse |
Emit one pulse: idle → |
set_gpio_trigger |
Configure GPIO pulse-width triggering (fires |
get_gpio_state
¶
get_gpio_state(gpio_idx: int) -> PxGpioPinState
Read electrical state for one GPIO pin.
The instrument returns status for all pins; this method selects gpio_idx.
| PARAMETER | DESCRIPTION |
|---|---|
|
Index of the pin to read.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PxGpioPinState
|
TYPE:
|
PxGpioPinState
|
and |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
set_gpio_state
¶
send_gpio_pulse
¶
send_gpio_pulse(
gpio_idx: int, active_state: PxIoState, idle_state: PxIoState, active_time_ns: int
) -> None
Emit one pulse: idle → active_state for active_time_ns → idle_state.
Supported only on GPIO indices 8 and 9. Pulse width must be greater than 5 ns and less than 1 second.
| PARAMETER | DESCRIPTION |
|---|---|
|
Pin index; must be
TYPE:
|
|
Level during the active portion of the pulse.
TYPE:
|
|
Level after the pulse completes.
TYPE:
|
|
Width of the active portion in nanoseconds.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
set_gpio_trigger
¶
set_gpio_trigger(
gpio_idx: int,
min_duration_ns: int,
max_duration_ns: int,
low_pulse: bool = False,
high_pulse: bool = False,
mode: PxGpioWidthTriggerMode = TRIGGER_PULSE_WIDTH_IN_RANGE,
) -> None
Configure GPIO pulse-width triggering (fires gpio_trigger global events).
Supported only on GPIO indices 8 and 9. Both duration bounds must be greater than 5 ns and less than 1 second.
| PARAMETER | DESCRIPTION |
|---|---|
|
Pin index; must be
TYPE:
|
|
Minimum pulse width for the condition (nanoseconds).
TYPE:
|
|
Maximum pulse width for the condition (nanoseconds).
TYPE:
|
|
Include low-going pulses when
TYPE:
|
|
Include high-going pulses when
TYPE:
|
|
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |