看板 LinuxDev 關於我們 聯絡資訊
請教一下各位 我利用linux 系統存取 parallel port 其中 http://www.bioinspired.com/users/ajg112/electronics/parallelPort.shtml D0~D7 是一個byte的資料 我想一次只針對一個bit來作寫入的動作,不知道它是否有相對應的函式/api之類的 以下這是網路上看到的code #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <asm/io.h> #define base 0x378 /* printer port base address */ #define value 255 /* numeric value to send to printer port */ main(int argc, char **argv) { if (ioperm(base,1,1)) fprintf(stderr, "Couldn't get the port at %x\n", base), exit(1); outb(value, base); //這一段是針一個byte作寫入的動作 } 而我想要作是的一次只寫一個bit 例如 D0 = 1;之類的 另外請問 如果 我要透過parallel取得目標裝置所發出來的信號 那parallel port D0~D7的腳要如何取對方送來的資料? 它是否有輸出輸入方向的設定問題?! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.218.239.206
TroyLee:先讀進來, 看你要set還是clr那個bit, 設定上去在寫進去 04/07 21:10
elpam:去讀一下spec吧 google得到..還有人寫module的tutorial 04/07 23:10
elpam:然後記得bios要設對 04/07 23:12
markchen:事實上我現在比較煩惱的是否有函式針一個BIT作寫入的動作 04/08 00:30
kenlo1980:樓上可以寫 MACRO 啊,很多 code 都這樣做。 04/08 02:12
kenlo1980:或是 in 進來後用 | 1 然後再 out 啊。 04/08 02:15