[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] Questions about the uClinux GPIO-Driver
Hi all,
thanks for the answers!
If I want to use the GPIO to read and write my hardware, where do I have to save my Application in the uClinux-tree? Does it belong to /uClinux-dist/user ?
I want to write a simple driver like "Hello World" to test it:
---------------------------------------
#include <linux/init.h>
#include <linux/module.h>
#include <linux/init.h>
static int __init leddrv_init(void)
{
printk("Hello world!\n");
return (0);
}
static void __exit leddrv_exit(void)
{
printk("Goodbye!\n");
return;
}
module_init(leddrv_init);
module_exit(leddrv_exit);
---------------------------------------
(I got the driver from the book: Embedded Linux - Praktische Umsetzung mit uClinux; Brinker, Degenhardt, Kupris)
I have saved it to: /uClinux-dist/linux-2.4.x/drivers/char/leddrv1.c is this the right place? The book compiles this driver with: "m68k-elf-gcc -D__KERNEL__ -DMODULE -O1 -c leddrv1.c -o leddrv.o"
I tried it with "mb-gcc -D__KERNEL__ -DMODULE -O1 -c leddrv1.c -o leddrv.o" (there is no "m68k-elf-gcc") and got the following errors/warning:
leddrv1.c:1:26: linux/kernel.h: No such file or directory
leddrv1.c:2:26: linux/module.h: No such file or directory
leddrv1.c:3:24: linux/init.h: No such file or directory
leddrv1.c:5: error: parse error before "leddrv_init"
leddrv1.c:10: error: parse error before "leddrv_exit"
leddrv1.c:15: warning: parameter names (without types) in function declaration
leddrv1.c:15: warning: data definition has no type or storage class
leddrv1.c:16: warning: parameter names (without types) in function declaration
leddrv1.c:16: warning: data definition has no type or storage class
Could someone help me?
Nadine
-------- Original-Nachricht --------
Datum: Mon, 9 Jul 2007 09:56:57 +0800
Von: "Yeoh Chun Yeow" <yeohchunyeow@xxxxxxxxx>
An: microblaze-uclinux@xxxxxxxxxxxxxx
Betreff: 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<http://www.itee.uq.edu.au/%7Elistarch/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=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<http://www.itee.uq.edu.au/%7Ejwilliams/mblaze-uclinux>
> > > > Mailing List Archive :
> > >
> http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/<http://www.itee.uq.edu.au/%7Elistarch/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<http://www.itee.uq.edu.au/%7Ejwilliams/mblaze-uclinux>
> > > Mailing List Archive :
> > >
> http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/<http://www.itee.uq.edu.au/%7Elistarch/microblaze-uclinux/>
> > >
> > >
> >
--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
___________________________
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/