LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How to write Device Driver to control LED? (http://www.linuxquestions.org/questions/programming-9/how-to-write-device-driver-to-control-led-159749/)

mcp_achindra 03-19-2004 05:40 AM

How to write Device Driver to control LED?
 
If any one can help me in writing device driver, to handle simple works like controlling a seven segment LCD Display or controlling a Stepper motor or controlling an LED from serial port on Linux System.

I have the option to write a device driver to control the switching of an LED through a serial port on Linux system. I would then extend it to support more complex functioning.

The first stage is to design a device driver to send +ve voltage on Serial Port to which an LED is attached.

Then to design an interface over that.

Then to extend the driver to support complex functions.

But all that on Linux.

I can write code in C to send +ve voltage to serial ports, but am not able to convert that to device driver.

Looking for help and generous support.

nhs 04-01-2004 06:33 AM

Driver writing is a complex task but the O'Reilly book "Linux Device Drivers" is brilliant. In short a module is normally written in C. You define the functions int init_module(void) and void cleanup_module(void) to handle loading and unloading the module. Other functions can be used to create entries into /dev or /proc, write to I/O ports / memory, etc. Note that debugging kernel code is a fair bit harder than debugging a normal program as incorrect code can potentially hang the kernel and you have no access to the standard C libraries (i.e. many useful functions disappear). The O'Reilly book I mentioned is available to read on the web at http://www.xml.com/ldd/chapter/book/index.html and contains a lot more information than I can post.


All times are GMT -5. The time now is 06:43 AM.