From: Peck H K. <pk...@me...> - 2008-07-24 14:23:04
|
Hi there, I am sorry for my poor knowledge on programming in C and linux. I will greatly appreciate if anyone can enlighten me on how I can implement an ISR on one of the GPIOs line on the gumstix. I am hoping to initiate an high priority interrupt whenever a trigger edge is detected on the GPIO line (from GPIO(58) to GPIO (73)). I am using the function "gpio-event" (which has been developed by Dave Hylands) to detect the GPIO events. I have been advised by Dave to look at an example code in gpio-event-drv.c for hints on implementing such interrupts. I was also reading the archive and I found this: http://www.nabble.com/PXA270-Interrupt-Help-td16275103.html which directed me to the command "request_irq" to register an interrupt. Am I right to assume that all the gpio monitoring events have to done within the interrupt dispatch function when the request_irq is called up. What I do not understand is the procedure to set up an interrupt properly, like having the need to initialize the interrupt ID and stop all other interrupts and proceed the ISR by using "spin_lock_irqsave" and "free_irq". Also how should I define the gpio line number in IRQ_GPIO and device ID? I will greatly appreciate if anyone can direct me with some basic examples to set up the ISR to start with? In fact, I just need a simple ISR to execute a specific function (which then reads the gpio-events). Also does gumstix allows Non-Maskable Interrupts? Is any of the GPIOs line configurable to NMI? I assume that it will set the GPIO line to the highest priority, because I am hoping to detect the GPIO trigger pulses at a relatively high rate. Thanks for any help in advance. Peck |
From: Dave H. <dhy...@gm...> - 2008-07-24 14:34:40
|
Hi Peck, > I will greatly appreciate if anyone can enlighten me on how I can implement > an ISR on one of the GPIOs line on the gumstix. I am hoping to initiate an > high priority interrupt whenever a trigger edge is detected on the GPIO line > (from GPIO(58) to GPIO (73)). I am using the function "gpio-event" (which > has been developed by Dave Hylands) to detect the GPIO events. > > > > I have been advised by Dave to look at an example code in gpio-event-drv.c > for hints on implementing such interrupts. I was also reading the archive > and I found this: > http://www.nabble.com/PXA270-Interrupt-Help-td16275103.html which directed > me to the command "request_irq" to register an interrupt. Am I right to > assume that all the gpio monitoring events have to done within the interrupt > dispatch function when the request_irq is called up. What I do not > understand is the procedure to set up an interrupt properly, like having the > need to initialize the interrupt ID and stop all other interrupts and > proceed the ISR by using "spin_lock_irqsave" and "free_irq". Also how > should I define the gpio line number in IRQ_GPIO and device ID? To register an irq for GPIO 58, for example, you would do: static irqreturn_t gpio_irq( int irq, void *dev_id ) { ... Do stuff in response to IRQ .... } and you'd register it using: request_irq( IRQ_GPIO( 58 ), gpio_irq, IRQF_TRIGGER_RISING, "MyName", NULL ); All of the setup stuff which is mentioned in the link you sent is only needed if you do "to the metal" PXA programming. When using linux, linux already takes care of all of those details, and you just need to call request_irq (which is exactly what gpio-event-drv.c does). > I will greatly appreciate if anyone can direct me with some basic examples > to set up the ISR to start with? In fact, I just need a simple ISR to > execute a specific function (which then reads the gpio-events). Also does > gumstix allows Non-Maskable Interrupts? Is any of the GPIOs line > configurable to NMI? I assume that it will set the GPIO line to the highest > priority, because I am hoping to detect the GPIO trigger pulses at a > relatively high rate. If you're trying to integrate this with gpio-event functionality, then you should just modify the gpio_event_irq function that exists in gpio-event-drv.c I don't believe that there are NMIs on the ARM. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ |
From: Peck H K. <pk...@me...> - 2008-07-24 18:16:07
|
Hi Dave, Thanks once again for your quick response. I tried to implement exactly as what you suggested, however I had the following error when I tried to "make" the executable file (spi1867zd): /usr/local/gumstix-buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-uclib c-gcc -O2 -M spi1867zd.c > .depend In file included from /usr/local/gumstix-buildroot/build_arm_nofpu/staging_dir/bin-ccache/../lib/g cc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/sys-include/linux/int errupt.h:11, from spi1867zd.c:29: /usr/local/gumstix-buildroot/build_arm_nofpu/staging_dir/bin-ccache/../lib/g cc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/sys-include/linux/har dirq.h:55:2: #error PREEMPT_ACTIVE is too low! make: *** [depend] Error 1 I have included the header file for the interrupt i.e. <linux/interrupt.h>. Before it could not recognize "IRQF_TRIGGER_RISING". What should I do with the variables "irq" and "dev_id" in the gpio_irq call? As in your codes in gpio-event-drv.c, I used the term (void)irq. Is this ok? Am I missing something here? I greatly appreciate your kind advice on this. Best regards, Peck -----Original Message----- From: gum...@li... [mailto:gum...@li...] On Behalf Of Dave Hylands Sent: 24 July 2008 15:35 To: General mailing list for gumstix users. Subject: Re: [Gumstix-users] Interrupt service routine in gumstix Hi Peck, > I will greatly appreciate if anyone can enlighten me on how I can implement > an ISR on one of the GPIOs line on the gumstix. I am hoping to initiate an > high priority interrupt whenever a trigger edge is detected on the GPIO line > (from GPIO(58) to GPIO (73)). I am using the function "gpio-event" (which > has been developed by Dave Hylands) to detect the GPIO events. > > > > I have been advised by Dave to look at an example code in gpio-event-drv.c > for hints on implementing such interrupts. I was also reading the archive > and I found this: > http://www.nabble.com/PXA270-Interrupt-Help-td16275103.html which directed > me to the command "request_irq" to register an interrupt. Am I right to > assume that all the gpio monitoring events have to done within the interrupt > dispatch function when the request_irq is called up. What I do not > understand is the procedure to set up an interrupt properly, like having the > need to initialize the interrupt ID and stop all other interrupts and > proceed the ISR by using "spin_lock_irqsave" and "free_irq". Also how > should I define the gpio line number in IRQ_GPIO and device ID? To register an irq for GPIO 58, for example, you would do: static irqreturn_t gpio_irq( int irq, void *dev_id ) { ... Do stuff in response to IRQ .... } and you'd register it using: request_irq( IRQ_GPIO( 58 ), gpio_irq, IRQF_TRIGGER_RISING, "MyName", NULL ); All of the setup stuff which is mentioned in the link you sent is only needed if you do "to the metal" PXA programming. When using linux, linux already takes care of all of those details, and you just need to call request_irq (which is exactly what gpio-event-drv.c does). > I will greatly appreciate if anyone can direct me with some basic examples > to set up the ISR to start with? In fact, I just need a simple ISR to > execute a specific function (which then reads the gpio-events). Also does > gumstix allows Non-Maskable Interrupts? Is any of the GPIOs line > configurable to NMI? I assume that it will set the GPIO line to the highest > priority, because I am hoping to detect the GPIO trigger pulses at a > relatively high rate. If you're trying to integrate this with gpio-event functionality, then you should just modify the gpio_event_irq function that exists in gpio-event-drv.c I don't believe that there are NMIs on the ARM. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ gumstix-users mailing list gum...@li... https://lists.sourceforge.net/lists/listinfo/gumstix-users |
From: Dave H. <dhy...@gm...> - 2008-07-24 18:56:30
|
Hi Peck, > I tried to implement exactly as what you suggested, however I had the > following error when I tried to "make" the executable file (spi1867zd): > > /usr/local/gumstix-buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-uclib > c-gcc -O2 -M spi1867zd.c > .depend > In file included from > /usr/local/gumstix-buildroot/build_arm_nofpu/staging_dir/bin-ccache/../lib/g > cc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/sys-include/linux/int > errupt.h:11, > from spi1867zd.c:29: > /usr/local/gumstix-buildroot/build_arm_nofpu/staging_dir/bin-ccache/../lib/g > cc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/sys-include/linux/har > dirq.h:55:2: #error PREEMPT_ACTIVE is too low! > make: *** [depend] Error 1 When building kernel modules, you need to make sure that you're using a Makefile designed to work as part fo the kernel build, and not trying to call gcc yourself. For example, the above looks like you're using a user-mode makefile to try and compile kernel sources, which won't work. The makefile included with gpio-event have two Makefiles wrapped into one. When you do make kernel-module it then does the appropriate invocation of make to build the kernel module using the kernel build system: kernel-module: $(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules and the kernel side of the Makefile consists of just one line: obj-m := gpio-event-drv.o > I have included the header file for the interrupt i.e. <linux/interrupt.h>. > Before it could not recognize "IRQF_TRIGGER_RISING". What should I do with > the variables "irq" and "dev_id" in the gpio_irq call? As in your codes in > gpio-event-drv.c, I used the term (void)irq. Is this ok? Casting to void tells the compiler you're not going to use the variables and eliminates the "unused argument" warnings. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ |
From: Richard E. P. I. <rpe...@ci...> - 2008-07-25 02:32:46
|
Evening, Since the basic Gumstix device only requires 5v of power and the USB port on a computer can provide that much, has anyone made and/or tested such a configuration? Richard |
From: Chris D. <chr...@gm...> - 2008-07-25 14:42:29
|
On Fri, Jul 25, 2008 at 1:19 AM, Drew <dr...@dr...> wrote: > I imagine the amps required to power various boards wouldn't be enough, at > least not with the verdex series, I believe you can power the connex or > basix (I can't remember which) via USB in the default configuration. Yes, it can be done with connex. I've powered my connex + gpsstix + custom daughercard with a small LCD display attached all from USB. Never tried it on verdex, though. Chris |
From: Dave H. <dhy...@gm...> - 2008-07-25 14:54:08
|
Hi guys, On Fri, Jul 25, 2008 at 7:42 AM, Chris Dollar <chr...@gm...> wrote: > On Fri, Jul 25, 2008 at 1:19 AM, Drew <dr...@dr...> wrote: >> I imagine the amps required to power various boards wouldn't be enough, at >> least not with the verdex series, I believe you can power the connex or >> basix (I can't remember which) via USB in the default configuration. > Yes, it can be done with connex. I've powered my connex + gpsstix + > custom daughercard with a small LCD display attached all from USB. > Never tried it on verdex, though. It should work on both connex and verdex. Normally, the host provides the juice, and since the connex can act as a device it's a natural fit. However, you should be able to do it with a verdex as well. The big thing to remember, is that if you are providing the 5v from a real host, then they often implement the 500 mA limit that the USB spec allows for, which means that not all combinations of boards will work (i.e. especially wifi). Some of the boards may require the addition of a bead or jumper wire in order to connect things up properly. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ |
From: Richard E. P. I. <rpe...@ci...> - 2008-07-25 20:46:58
|
Did you make your own cables, or did you find a place to purchase them? Richard Chris Dollar wrote: > On Fri, Jul 25, 2008 at 1:19 AM, Drew <dr...@dr...> wrote: >> I imagine the amps required to power various boards wouldn't be enough, at >> least not with the verdex series, I believe you can power the connex or >> basix (I can't remember which) via USB in the default configuration. > Yes, it can be done with connex. I've powered my connex + gpsstix + > custom daughercard with a small LCD display attached all from USB. > Never tried it on verdex, though. > > Chris > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > gumstix-users mailing list > gum...@li... > https://lists.sourceforge.net/lists/listinfo/gumstix-users > |
From: Peck H K. <pk...@me...> - 2008-07-24 20:27:43
|
Hi Dave, I tried to follow what you did in your Makefile for gpio-event program, hoping that I can combine the two Makefiles (kernel module and my program) together but when I tried to make the file, I received more errors (specific to bitmap.h, cpumask.h, interrupt.h) than the previous time. I am not really sure about the gpio-event-drv.o which you mentioned. But I am sure that I have done something stupid here. I will appreciate if you can enlighten me if I have specific any of the paths incorrectly: ifeq ($(DEBUG),y) CFLAGS += -O -g # -O is need to expand inlines else CFLAGS += -O2 endif ifneq ($(KERNELRELEASE),) # call from kernel build system obj-m := gpio-event-drv.o else TARGET = spi1867zd PWD := $(shell pwd) GUMSTIX_BUILDROOT = /usr/local/gumstix-buildroot BUILD_ARM = $(wildcard $(GUMSTIX_BUILDROOT)/build_arm*) KERNELDIR ?= $(wildcard $(BUILD_ARM)/linux-*) CROSS_COMPILE = $(patsubst %gcc, %, $(wildcard $(BUILD_ARM)/staging_dir/bin/arm-linux-uclibc*-gcc)) default: user-apps kernel-module user-apps: $(TARGET) TARGET_ARCH=-Os -march=armv5te -mtune=xscale -Wa,-mcpu=xscale CC = $(CROSS_COMPILE)gcc LDLIBS += -lpthread .PHONY: all all: depend $(TARGET) SRCS = $(TARGET).c OBJS = $(SRCS:.c=.o) $(TARGET) : $(OBJS) kernel-module: $(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules endif clean: rm -rf $(OBJS) core .depend $(TARGET) depend .depend dep: $(CC) $(CFLAGS) $(CPPFLAGS) -M $(SRCS) > .depend ifeq (.depend,$(wildcard .depend)) include .depend endif Thanks. Peck -----Original Message----- From: gum...@li... [mailto:gum...@li...] On Behalf Of Dave Hylands Sent: 24 July 2008 19:57 To: General mailing list for gumstix users. Subject: Re: [Gumstix-users] Interrupt service routine in gumstix Hi Peck, > I tried to implement exactly as what you suggested, however I had the > following error when I tried to "make" the executable file (spi1867zd): > > /usr/local/gumstix-buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-uclib > c-gcc -O2 -M spi1867zd.c > .depend > In file included from > /usr/local/gumstix-buildroot/build_arm_nofpu/staging_dir/bin-ccache/../lib/g > cc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/sys-include/linux/int > errupt.h:11, > from spi1867zd.c:29: > /usr/local/gumstix-buildroot/build_arm_nofpu/staging_dir/bin-ccache/../lib/g > cc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/sys-include/linux/har > dirq.h:55:2: #error PREEMPT_ACTIVE is too low! > make: *** [depend] Error 1 When building kernel modules, you need to make sure that you're using a Makefile designed to work as part fo the kernel build, and not trying to call gcc yourself. For example, the above looks like you're using a user-mode makefile to try and compile kernel sources, which won't work. The makefile included with gpio-event have two Makefiles wrapped into one. When you do make kernel-module it then does the appropriate invocation of make to build the kernel module using the kernel build system: kernel-module: $(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules and the kernel side of the Makefile consists of just one line: obj-m := gpio-event-drv.o > I have included the header file for the interrupt i.e. <linux/interrupt.h>. > Before it could not recognize "IRQF_TRIGGER_RISING". What should I do with > the variables "irq" and "dev_id" in the gpio_irq call? As in your codes in > gpio-event-drv.c, I used the term (void)irq. Is this ok? Casting to void tells the compiler you're not going to use the variables and eliminates the "unused argument" warnings. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ gumstix-users mailing list gum...@li... https://lists.sourceforge.net/lists/listinfo/gumstix-users |
From: Dave H. <dhy...@gm...> - 2008-07-24 23:25:49
|
Hi Peck, > I tried to follow what you did in your Makefile for gpio-event program, > hoping that I can combine the two Makefiles (kernel module and my program) > together but when I tried to make the file, I received more errors (specific > to bitmap.h, cpumask.h, interrupt.h) than the previous time. I am not really > sure about the gpio-event-drv.o which you mentioned. But I am sure that I > have done something stupid here. So, based on your makefile, spi1867zd.c is a source file for a user-mode program. You can't put kernel stuff (like interrupt handlers) inside a user-mode program. You can only do that inside the kernel. Trying to #include kernel header files from within a user-mode program will also typically cause lots of the kinds of errors that you're seeing. In gpio-event, gpio-event-drv.c is kernel mode code, and gpio-event.c is user-mode code. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ |
From: Drew <dr...@dr...> - 2008-07-25 07:19:29
|
I imagine the amps required to power various boards wouldn't be enough, at least not with the verdex series, I believe you can power the connex or basix (I can't remember which) via USB in the default configuration. Regards, Drew -----Original Message----- From: gum...@li... [mailto:gum...@li...] On Behalf Of Richard E. Perlotto II Sent: 25 July 2008 03:31 To: General mailing list for gumstix users. Subject: [Gumstix-users] 5v Power Supply via USB? Evening, Since the basic Gumstix device only requires 5v of power and the USB port on a computer can provide that much, has anyone made and/or tested such a configuration? Richard ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ gumstix-users mailing list gum...@li... https://lists.sourceforge.net/lists/listinfo/gumstix-users |