Hello Nadine,
you have to compile the application in a so called "out-of-tree" way.
The attachment includes a Makefile and the C source file of the
application.
If you want to use this setup you still have to adjust the ROOTDIR
variable on top of the Makefile. This variable must point to the
uClinux-dist directory.
Please also make sure that the /dev/xgpio device exists in your root
filesystem and that the major and minor numbers of the device are correct.
Hope this helps,
Hans
Dr. Johann Pfefferl <j.pfefferl@xxxxxxxxx> wrote:
> Hello Nadine,
>
> here is a little program I have written to test the GPIO functionality:
>
> ----------------------- snip ----------------------------------------
> #include <fcntl.h>
> #include <string.h>
> #include <unistd.h>
> #include <errno.h>
> #include <sys/ioctl.h>
> #include <linux/ibm_ocp_gpio.h>
>
> int main(void)
> {
> int r, gpio_dev;
> if(0 < (gpio_dev = open("/dev/xgpio", O_RDWR))) {
> struct ibm_gpio_ioctl_data gpio_info;
> memset(&gpio_info, 0, sizeof(gpio_info));
> gpio_info.device = 0; /* Read the first gpio subdevice */
> /* Mark all pins as input */
> gpio_info.mask = ~0;
> if(0 > (r = ioctl(gpio_dev, IBMGPIO_TRISTATE, &gpio_info)))
> perror("ioctl IBMGPIO_TRISTATE failed: %s", g_strerror(errno));
>
> while(1) {
> gpio_info.device = 0; /* Read the first gpio subdevice */
> if(0 > (r = ioctl(gpio_dev, IBMGPIO_IN, &gpio_info)))
> perror("ioctl failed: r=%d errno=%d %s", r, errno, strerror(errno));
> else
> printf("gpio_info: device=%d mask=%x data=0x%x\n", gpio_info.device, gpio_info.mask, gpio_info.data);
> usleep(100000);
> }
> }
> close(gpio_dev);
> return 0;
> }
> ----------------------- snip ----------------------------------------
>
> It handles only the input of data. If you want to output something you
> have to set the data into the variable
>
> gpio_info.data = 0xblablabla;
>
> and then perform a IBMGPIO_OUT ioctl.
>
> You must set the TRISTATE mask correctly to get input/output working
> correctly for one GPIO subdevice!!!
>
> Hope this helps,
> Johann Pfefferl
>
> Nadine Seyberlich <Serina16@xxxxxxx> wrote:
> > Hi all,
> >
> > i'm writing my diploma thesis, where i have to use the SUZAKU-S (SZ130-U00) with the Microblaze and uClinux as basis. To the Board over the GPIO Pins is external hardware connected.
> > I have seen that there is a ready GPIO-Driver in uClinux. How can I use this driver?
> > How can I respond the driver from a C-Program? Can the GPIO pins be addressed directly or do I have to write a separate module for the adressing? How complex is this way? Does someone have a sample program, where I can see the use of the GPIO driver?
> >
> > Thanks for your help.
> >
> > Nadine
> > --
> > Psssst! Schon vom neuen GMX MultiMessenger gehört?
> > Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
> > ___________________________
> > microblaze-uclinux mailing list
> > microblaze-uclinux@xxxxxxxxxxxxxx
> > Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
> > Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/
>
> --
> Dr. Johann Pfefferl ------------ mailto j.pfefferl at eubus dot net
> Eubus GmbH http://www.eubus.net +++++ http://www.hydraxc.com
> Gollierstr. 70
> D-80339 Muenchen
> Phone: +49 (0)89 45 22 578-67 Fax: +49 (0)89 45 22 578-55
> Registergericht Muenchen HRB 145 336, Ust-Id Nr. DE 225 783 933
> Geschaeftsfuehrer: Volker Ulrich, Peter Sibities
>
> ==
> -o) A computer program does what you tell it to do,
> /\\ not what you want it to do.
> _\_v-
>
> ___________________________
> microblaze-uclinux mailing list
> microblaze-uclinux@xxxxxxxxxxxxxx
> Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
> Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/
--
Dr. Johann Pfefferl ------------ mailto j.pfefferl at eubus dot net
Eubus GmbH http://www.eubus.net +++++ http://www.hydraxc.com
Gollierstr. 70
D-80339 Muenchen
Phone: +49 (0)89 45 22 578-67 Fax: +49 (0)89 45 22 578-55
Registergericht Muenchen HRB 145 336, Ust-Id Nr. DE 225 783 933
Geschaeftsfuehrer: Volker Ulrich, Peter Sibities
==
-o) A computer program does what you tell it to do,
/\\ not what you want it to do.
_\_v-
Attachment:
gpio-test.tar.gz
Description: Binary data