From: Markus S. <msv...@ae...> - 2014-03-18 20:21:12
|
Hi Roque, Next try this: ls /sys/class/gpio/gpio145/ to see what is available for that GPIO. I don't have the time right now to make a complete example, but it won't be hard for you to follow some steps on your own. Here is what I suggest: Have a look here, it basically explains step by step how to set up a gpio for input: http://gumstix.org/software-development/how-to/250-gpio.html Next, to use the edge interrupts, you need to read this carefully: https://www.kernel.org/doc/Documentation/gpio/sysfs.txt In your system start-up script (e.g. /etc/init.d/rcS) you could do something like this: # Set direction of gpio 145 echo in > /sys/class/gpio/gpio145/direction # Request edge interrupts, rising and falling echo both > /sys/class/gpio/gpio145/edge You could also do this from a C program, by opening the files and writing the strings to them. A more permanent way is to set up the gpio is to patch your kernel (board_overo.c file) to set up the gpio(s). Then, in your C program you can do this: int gpio = open("/sys/class/gpio/gpio145/value", O_RDONLY); Then, you can set up a loop that uses poll() or select() to wait for events occurring on the gpio file descriptor. This would probably have to be run from a separate thread. An alternate and less CPU efficient way, that does not involve poll() or select(), would be to set up a loop that periodically (e.g. 10 or 50 times per second) checks the gpio value, and takes action when the value changes. Hope this helps you start. Regards, Markus On 03/18/2014 04:04 PM, Roque Lora wrote: > > Hi Markus, > > Could you give me a small example of using edge (for rising and falling)? > I have these gpio available: > > *gpio15**gpio168**gpiochip160**gpiochip64* > > *gpio144**gpio16**gpiochip0**gpiochip192**gpiochip96* > > *gpio145**gpio164**gpiochip128**gpiochip32* > > > I want to use the gpio145 (I am not using and LCD). > > That would be of great help. > > Regards > > > Hi Roque, > > You can configure GPIO pins for input or output: > http://gumstix.org/software-development/how-to/250-gpio.html > > Additional useful info can be found here: > https://www.kernel.org/doc/Documentation/gpio/sysfs.txt > > If you log into your Overo command line, you can see what GPIOs you have > available by running the command: > ls /sys/class/gpio > > > By using the "edge" property of sysfs GPIOs, you can use poll(), > select() or epoll() to efficiently wait for GPIO input events. > > The Overo has lots of pins that you can use as GPIOs. The thing is, lots > of them are assigned to other functions by default. But, you can change > that by adjusting the pin multiplexing ("pin mux") in the kernel and/or > U-boot to use them. > > Also, if you share more details about your application it would people > here to provide useful info. > > Best wishes > Markus > > > On 03/18/2014 02:53 PM, Roque Lora wrote: > > > > Good afternoon, > > > > I want to set up a pin of an overo fire as a timer in capture mode but > > I do not know where to look for this information. I have read a lot of > > articles and datasheets but it does not work for the distribution that > > I am using, Linaro (Yocto Project). > > > > Could you help me with this? > > > > Best regards > > -- > > Roque Lora > > Graduate Research Assistant of Electrical Engineering > > AggieAir Flying Circus (http://aggieair.usu.edu/) > > Utah State University > > Logan, UT, USA > > > > > > ------------------------------------------------------------------------------ > > Learn Graph Databases - Download FREE O'Reilly Book > > "Graph Databases" is the definitive new guide to graph databases and their > > applications. Written by three acclaimed leaders in the field, > > this first edition is now available. Download your free book today! > >http://p.sf.net/sfu/13534_NeoTech > > > > > > _______________________________________________ > > gumstix-users mailing list > > gumstix-users@... > >https://lists.sourceforge.net/lists/listinfo/gumstix-users > > > 2014-03-18 12:44 GMT-06:00 Roque Lora <roq...@gm... > <mailto:roq...@gm...>>: > > Good afternoon, > > I want to set up a pin of an overo fire as a timer in capture mode > but I do not know where to look for this information. I have read > a lot of articles and datasheets but it does not work for the > distribution that I am using, Linaro (Yocto Project). > > Could you help me with this? > > Best regards > > -- > Roque Lora > Graduate Research Assistant of Electrical Engineering > AggieAir Flying Circus (http://aggieair.usu.edu/) > Utah State University > Logan, UT, USA > > > > > -- > Roque Lora > Graduate Research Assistant of Electrical Engineering > AggieAir Flying Circus (http://aggieair.usu.edu/) > Utah State University > Logan, UT, USA > > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases and their > applications. Written by three acclaimed leaders in the field, > this first edition is now available. Download your free book today! > http://p.sf.net/sfu/13534_NeoTech > > > _______________________________________________ > gumstix-users mailing list > gum...@li... > https://lists.sourceforge.net/lists/listinfo/gumstix-users |