From: Mirek23 <miroslaw.dach@psi.ch>
To: linuxppc-embedded@ozlabs.org
Subject: Re: xilinx gpio in kernel 2.6
Date: Tue, 10 Jul 2007 08:52:20 -0700 (PDT) [thread overview]
Message-ID: <11523745.post@talk.nabble.com> (raw)
In-Reply-To: <10285090.post@talk.nabble.com>
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.
next prev parent reply other threads:[~2007-07-10 15:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-30 15:01 xilinx gpio in kernel 2.6 Mirek23
2007-05-02 12:33 ` Mirek23
2007-07-10 15:52 ` Mirek23 [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-04-30 15:05 Mirek23
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11523745.post@talk.nabble.com \
--to=miroslaw.dach@psi.ch \
--cc=linuxppc-embedded@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).