文書の過去の版を表示しています。
MA-X3xx シリーズは、
を使用することができます。
従来使用していた sysfs GPIO が deprecated で廃止予定のため、libgpiod を利用してアクセスします。
No. | Name | Note |
---|---|---|
1 | DIN_S0 | |
2 | DIN_S1 |
No. | Name(フィルタ無) | Name(フィルタ有) | Note |
---|---|---|---|
1 | EXT_DI0 | Filtered_DI0 | A0 |
2 | EXT_DI1 | Filtered_DI1 | A1 |
… | … | … | … |
11 | EXT_DI10 | Filtered_DI10 | C2 |
12 | EXT_DI11 | Filtered_DI11 | C3 |
13 | EXT_DI12 | Filtered_DI12 | D0 |
14 | EXT_DI13 | Filtered_DI13 | D1 |
… | … | … | … |
23 | EXT_DI22 | Filtered_DI22 | F2 |
24 | EXT_DI23 | Filtered_DI23 | F3 |
※ フィルタについて: 64Hz 2bit シフトレジスタ を利用したステートマシンによるチャタリング除去フィルタが入っています。
root@metis:~# gpioinfo |egrep "DIN_S|DI[0-9]+" line 60: "DIN_S0" unused input active-high line 61: "DIN_S1" unused input active-high line 0: "EXT_DI12" unused input active-high line 1: "EXT_DI13" unused input active-high line 2: "EXT_DI14" unused input active-high line 3: "EXT_DI15" unused input active-high line 4: "EXT_DI16" unused input active-high line 5: "EXT_DI17" unused input active-high line 6: "EXT_DI18" unused input active-high line 7: "EXT_DI19" unused input active-high line 8: "EXT_DI20" unused input active-high line 9: "EXT_DI21" unused input active-high line 10: "EXT_DI22" unused input active-high line 11: "EXT_DI23" unused input active-high line 16: "Filtered_DI12" unused input active-high line 17: "Filtered_DI13" unused input active-high line 18: "Filtered_DI14" unused input active-high line 19: "Filtered_DI15" unused input active-high line 20: "Filtered_DI16" unused input active-high line 21: "Filtered_DI17" unused input active-high line 22: "Filtered_DI18" unused input active-high line 23: "Filtered_DI19" unused input active-high line 24: "Filtered_DI20" unused input active-high line 25: "Filtered_DI21" unused input active-high line 26: "Filtered_DI22" unused input active-high line 27: "Filtered_DI23" unused input active-high line 0: "EXT_DI0" unused input active-high line 1: "EXT_DI1" unused input active-high line 2: "EXT_DI2" unused input active-high line 3: "EXT_DI3" unused input active-high line 4: "EXT_DI4" unused input active-high line 5: "EXT_DI5" unused input active-high line 6: "EXT_DI6" unused input active-high line 7: "EXT_DI7" unused input active-high line 8: "EXT_DI8" unused input active-high line 9: "EXT_DI9" unused input active-high line 10: "EXT_DI10" unused input active-high line 11: "EXT_DI11" unused input active-high line 16: "Filtered_DI0" unused input active-high line 17: "Filtered_DI1" unused input active-high line 18: "Filtered_DI2" unused input active-high line 19: "Filtered_DI3" unused input active-high line 20: "Filtered_DI4" unused input active-high line 21: "Filtered_DI5" unused input active-high line 22: "Filtered_DI6" unused input active-high line 23: "Filtered_DI7" unused input active-high line 24: "Filtered_DI8" unused input active-high line 25: "Filtered_DI9" unused input active-high line 26: "Filtered_DI10" unused input active-high line 27: "Filtered_DI11" unused input active-high root@metis:~#
gpiod パッケージのアプリケーションでアクセスします。
libgpiod を使用してプログラムを作成します。
Nim 用の binding を作成したので、C 言語より簡単にプログラムをすることもできます。
import std/asyncdispatch
import std/times
import nim_gpiod
proc asyncMain() {.async.} =
let di0 = newGpio("DIN_S0", "NimGPIO")
if di0.isNil:
echo "newGpio failed."
quit(1)
while true:
echo "wait event..."
let event = await di0.wait_event(Edge.Both, 10)
let now = now().format("yyyy-MM-dd HH:mm:ss")
echo &"*** {now}: Event! (edge: {event.edge}, value: {event.value})"
waitFor asyncMain()
LED class driver にバインドしています。
root@metis:/sys/class/leds# ls ADC_Power EXT_DO0 EXT_DO6 MSP430_EXT2_TEST MobileLED_R0 PowerLED:G system-status1:g ADC_RESET EXT_DO1 EXT_DO7 MSP430_RST MobileLED_R1 SHUTDOWN_REQ system-status1:r ConsoleEnable EXT_DO2 LED_Drv_Enable MSP430_TEST MobileLED_R2 USBHub_Reset system-status2:g DO_S0 EXT_DO3 MSP430_EXT1_RST MobileLED_G0 PCIe_Power mmc0:: system-status2:r DO_T0 EXT_DO4 MSP430_EXT1_TEST MobileLED_G1 PHY0_Reset mmc1:: system-status3:g EXT_24V_ON EXT_DO5 MSP430_EXT2_RST MobileLED_G2 PHY1_Reset power-stat:r system-status3:r
No. | Name | Note |
---|---|---|
1 | DO_S0 |
No. | Name | Note |
---|---|---|
1 | EXT_DO0 | |
… | … | |
8 | EXT_DO7 |