xilinx gpio in kernel 2.6
Mirek23
miroslaw.dach at psi.ch
Wed Jul 11 01:52:20 EST 2007
Hi All,
After some time I have found the way how to deal with GPIO driver from the
user space:
First you have to mknod xgpio under /dev :
crw-rw-rw- 1 root root 10, 185 Jun 1 13:59 /dev/xgpio
Example program below shows how to read from the GPIO channel.
To write to the channel change the call:
ioctl(fgpio,XGPIO_IN,&sGpioData); to ioctl(fgpio,XGPIO_OUT,&sGpioData);
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/xgpio_ioctl.h>
main(){
int fgpio =0;
struct xgpio_ioctl_data sGpioData;
/* {
__u32 device;
__u32 mask;
__u32 data;
}*/
sGpioData.device=0; /* N=0,1,2,3-> GPIO DEV NR 2*N (Lower 32 bit part
)
2*N+1 (Upper 32 bit part
)*/
sGpioData.mask=0xffffffff;
sGpioData.data=0x55555555;
fgpio = open ("/dev/xgpio",O_RDWR);
if( fgpio != -1){
ioctl(fgpio,XGPIO_IN,&sGpioData);//pointer here to xgpio_ioctl_data
printf("Dip Swich readout 0x%X\n",sGpioData.data);
}
else
printf("Can not open GPIO\n");
close(fgpio);
}// end main
--
View this message in context: http://www.nabble.com/xilinx-gpio-in-kernel-2.6-tf3670122.html#a11523745
Sent from the linuxppc-embedded mailing list archive at Nabble.com.
More information about the Linuxppc-embedded
mailing list