GPIO¶
GPIO 回讀、靜態驅動、定時脈衝與脈衝寬度觸發設定位於 AqProtocolExerciser。從 aqpxlib.gpio 匯入列舉與值型別,從 aqpxlib.event 匯入觸發事件——不要從 aqpxlib.message 匯入。
教學
公開匯出¶
| 名稱 | 種類 | 用途 |
|---|---|---|
GpioState |
enum | set_gpio_state、脈衝邊緣與回報接腳狀態的準位(PxIoState 別名) |
GpioWidthTriggerMode |
enum | set_gpio_trigger(..., mode=...)(PxGpioWidthTriggerMode 別名) |
GpioPinState |
dataclass | get_gpio_state 的回傳型別(PxGpioPinState 別名) |
GpioWidthTriggerConfig |
dataclass | get_gpio_trigger 的回傳型別 |
GpioState
¶
Logical level for one GPIO line.
| METHOD | DESCRIPTION |
|---|---|
to_protobuf |
Encode as a wire |
from_protobuf |
Build from a wire |
單一 GPIO 線路的邏輯準位。
| 成員 | 意義 |
|---|---|
LOW |
驅動或取樣為低 |
HIGH |
驅動或取樣為高 |
HIGH_Z |
高阻抗(未主動驅動) |
GpioWidthTriggerMode
¶
Width-condition selector for set_gpio_trigger.
| METHOD | DESCRIPTION |
|---|---|
to_protobuf |
Encode as a wire |
from_protobuf |
Build from a wire |
set_gpio_trigger 的寬度條件選擇器。
| 成員 | 意義 |
|---|---|
TRIGGER_PULSE_WIDTH_IN_RANGE |
寬度落在 [min_duration_ns, max_duration_ns] 內時觸發(搭配 low_pulse / high_pulse) |
TRIGGER_PULSE_WIDTH_OUT_OF_RANGE |
寬度落在該視窗外時觸發 |
GpioPinState
¶
GpioPinState(
pin_idx: int,
output_state: GpioState | None = None,
input_state: GpioState | None = None,
)
One GPIO pin snapshot from get_gpio_state.
| METHOD | DESCRIPTION |
|---|---|
to_protobuf |
Encode as a wire |
from_protobuf |
Build from a wire |
get_gpio_state(gpio_idx=…) 回傳的單一接腳快照。
| 欄位 | 意義 |
|---|---|
pin_idx |
接腳索引 |
output_state |
驅動準位(未驅動/未知時為 None) |
input_state |
取樣輸入(無法取得時為 None) |
GpioWidthTriggerConfig
¶
GpioWidthTriggerConfig(
pin_idx: int,
min_duration_ns: int,
max_duration_ns: int,
mode: GpioWidthTriggerMode = TRIGGER_PULSE_WIDTH_IN_RANGE,
low_pulse: bool = False,
high_pulse: bool = False,
)
Pulse-width trigger settings for one GPIO pin.
| METHOD | DESCRIPTION |
|---|---|
to_protobuf |
Encode as a wire |
from_protobuf |
Build from a wire |
get_gpio_trigger(gpio_idx=…) 回傳的寬度觸發設定。
PxGpioTriggerEvent
¶
傳給 gpio_trigger 處理函式的事件(來自 aqpxlib.event)。
| 欄位 | 意義 |
|---|---|
pin_idx |
符合條件的接腳 |
pulse_duration |
寬度,單位為奈秒 |
pulse_polarity |
偵測到的極性 |
Exerciser 方法¶
AqProtocolExerciser
¶
AqProtocolExerciser(session: PxSession | None = None, **legacy: object)
AqProtocolExerciser class.
Most callers use :meth:connect instead, which builds the session from
a transport config and connects it. Pass a session here to supply
one yourself: an already-connected session.
| PARAMETER | DESCRIPTION |
|---|---|
|
The :class:
TYPE:
|
|
Present only so the removed
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
| 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_trigger |
Get GPIO pulse-width triggering configuration. |
get_gpio_state
¶
get_gpio_state(gpio_idx: int) -> GpioPinState
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 |
|---|---|
GpioPinState
|
TYPE:
|
GpioPinState
|
and |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
send_gpio_pulse
¶
send_gpio_pulse(
gpio_idx: int, active_state: GpioState, idle_state: GpioState, 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: GpioWidthTriggerMode = 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 |
get_gpio_trigger
¶
get_gpio_trigger(gpio_idx: int) -> GpioWidthTriggerConfig | None
Get GPIO pulse-width triggering configuration.
Supported only on GPIO indices 8 and 9.
| PARAMETER | DESCRIPTION |
|---|---|
|
Pin index; must be
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
GpioWidthTriggerConfig
|
The configuration of the pin. Returns
TYPE:
|