2010년 3월 23일 화요일

GPIO TEST

GPIO TEST

[커널 설정]
make menuconfig

Device Drivers --->
GPIO Support --->
[*] Debug GPIO calls x x
[*] /sys/class/gpio/... (sysfs interface)


[코드 삽입]
#if 1 // GPIO TEST
int err;

err = gpio_request(S5PC11X_GPJ0(0), "GPJ0");
if (err) {
printk(KERN_ERR "failed to request S5PC11X_GPJ0_0\n");
} else {
err = gpio_export(S5PC11X_GPJ0(0), true);
if (err) {
printk(KERN_ERR "failed to export S5PC11X_GPJ0_0\n");
}
}
#endif


[사용]
# cd /sys/class/gpio/
# ls -l
--w------- root root 4096 1970-01-01 00:12 export
--w------- root root 4096 1970-01-01 00:12 unexport
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip0 -> ../../devices/virtual/gpio/gpiochip0
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip9 -> ../../devices/virtual/gpio/gpiochip9
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip14 -> ../../devices/virtual/gpio/gpiochip14
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip23 -> ../../devices/virtual/gpio/gpiochip23
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip29 -> ../../devices/virtual/gpio/gpiochip29
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip35 -> ../../devices/virtual/gpio/gpiochip35
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip40 -> ../../devices/virtual/gpio/gpiochip40
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip47 -> ../../devices/virtual/gpio/gpiochip47
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip56 -> ../../devices/virtual/gpio/gpiochip56
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip62 -> ../../devices/virtual/gpio/gpiochip62
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip71 -> ../../devices/virtual/gpio/gpiochip71
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip80 -> ../../devices/virtual/gpio/gpiochip80
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip89 -> ../../devices/virtual/gpio/gpiochip89
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip96 -> ../../devices/virtual/gpio/gpiochip96
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip104 -> ../../devices/virtual/gpio/gpiochip104
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip112 -> ../../devices/virtual/gpio/gpiochip112
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip120 -> ../../devices/virtual/gpio/gpiochip120
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip128 -> ../../devices/virtual/gpio/gpiochip128
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip137 -> ../../devices/virtual/gpio/gpiochip137
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip146 -> ../../devices/virtual/gpio/gpiochip146
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip155 -> ../../devices/virtual/gpio/gpiochip155
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip164 -> ../../devices/virtual/gpio/gpiochip164
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip172 -> ../../devices/virtual/gpio/gpiochip172
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip181 -> ../../devices/virtual/gpio/gpiochip181
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip188 -> ../../devices/virtual/gpio/gpiochip188
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip197 -> ../../devices/virtual/gpio/gpiochip197
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip206 -> ../../devices/virtual/gpio/gpiochip206
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip212 -> ../../devices/virtual/gpio/gpiochip212
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip221 -> ../../devices/virtual/gpio/gpiochip221
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip226 -> ../../devices/virtual/gpio/gpiochip226
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip235 -> ../../devices/virtual/gpio/gpiochip235
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip244 -> ../../devices/virtual/gpio/gpiochip244
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip253 -> ../../devices/virtual/gpio/gpiochip253
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip262 -> ../../devices/virtual/gpio/gpiochip262
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip271 -> ../../devices/virtual/gpio/gpiochip271
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip280 -> ../../devices/virtual/gpio/gpiochip280
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip289 -> ../../devices/virtual/gpio/gpiochip289
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip298 -> ../../devices/virtual/gpio/gpiochip298
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip307 -> ../../devices/virtual/gpio/gpiochip307
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip316 -> ../../devices/virtual/gpio/gpiochip316
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip325 -> ../../devices/virtual/gpio/gpiochip325
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip334 -> ../../devices/virtual/gpio/gpiochip334
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip343 -> ../../devices/virtual/gpio/gpiochip343
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip351 -> ../../devices/virtual/gpio/gpiochip351
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip360 -> ../../devices/virtual/gpio/gpiochip360
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip369 -> ../../devices/virtual/gpio/gpiochip369
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip378 -> ../../devices/virtual/gpio/gpiochip378
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip387 -> ../../devices/virtual/gpio/gpiochip387
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip396 -> ../../devices/virtual/gpio/gpiochip396
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip405 -> ../../devices/virtual/gpio/gpiochip405
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip414 -> ../../devices/virtual/gpio/gpiochip414
lrwxrwxrwx root root 1970-01-01 00:12 gpiochip423 -> ../../devices/virtual/gpio/gpiochip423
lrwxrwxrwx root root 1970-01-01 00:01 gpio172 -> ../../devices/virtual/gpio/gpio172
lrwxrwxrwx root root 1970-01-01 00:12 gpio173 -> ../../devices/virtual/gpio/gpio173
lrwxrwxrwx root root 1970-01-01 00:12 gpio186 -> ../../devices/virtual/gpio/gpio186

# cat gpiochip181/label
GPJ1

gpio186 는 GPJ1_5 임을 알 수 있음.

# cd gpio186
# ls -l
-rw-r--r-- root root 4096 1970-01-01 00:00 uevent
lrwxrwxrwx root root 1970-01-01 00:30 subsystem -> ../../../../class/gpio
drwxr-xr-x root root 1970-01-01 00:00 power
-rw-r--r-- root root 4096 1970-01-01 00:30 direction
-rw-r--r-- root root 4096 1970-01-01 00:30 value

# cat direction
in

# echo out > direction

# cat direction
out

# cat value
0

# echo 1 > value

# cat value
1

댓글 없음:

댓글 쓰기