Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
no is not, you can activate the GPIO in the kernel and use command like:
echo "1" > gpio32/value
echo "0" > gpio32/value
to turn on and off an led on the GPIO line.
In fact - it is platform specific (although GPIO is very similar, like a standard in most HW implementations, only specific / small details would differ) but this is why you have drivers.
Above code seems to be a driver to interact with LEDs connected to some of SoC gpio pins.
Code:
static int sbc2440_leds_ioctl(
struct inode *inode,
struct file *file,
unsigned int cmd,
unsigned long arg)
is the implementation of a code that turns on or of (depending on cmd being true or false) an LED indexed by 'arg'.
Code:
static int __init dev_init(void)
is used to turn them of on a module load (init) and to set up a configuration*.
(configuration of GPIO pins that these LEDs are connected to - GPIOs can be configured to be either input (if used e.g. for switches / buttons etc) or as OUTPUT (if used to control something, e.g. an LED).
Last edited by formiaczek; 11-17-2011 at 06:36 PM.
Reason: forgot to put the description
I figure how that driver works, but that driver is very limited to that chip, so I enable the standard gpio libraries in linux, so my c code would work in any ARM32 processor that has linux in it(with the gpio in the kernel enable), I found this couple of pages very useful, but thanks formiaczek for taking the time to explain that part of the code.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.