[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] Questions about the uClinux GPIO-Driver



Dear Nadine,

If you require more than 6 instances of GPIO, modify the xgpio.c file.

regards,
chun yeow

On 7/6/07, Jose Torres < vonneh@xxxxxxxxx> wrote:
Here is a nice GPIO test program that scans the leds back and forth and counts up after a while. It explains how to use the GPIO driver.
http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/archive/2005/09/msg00117.html


On 7/5/07, 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="" 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 = ""

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/