ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

Linux Drivers Weeder I/O Boards


Circuit Cellar Online
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.

LINUX DRIVES WEEDER I/O BOARDS

Applications
by Jack Dennon

Start ý Create the Device Driver ý Create the Device ý The Order of Things ý Load the Device Driver ý Call the Test Program ý Remove the Device Driver ý Sources and PDF

CREATE THE DEVICE DRIVER

The header file wtdev2_0.h (all code) is used both by the driver module and by programs that will be making use of the driver. It defines the buffer size, the interrupt, an EOT character, a name for the device, a debug message facility, and a set of IOCTLs that will be used to communicate with the driver.

Similarly, wtdev2_0.c shows the source code for the driver module. The code files are available on the Circuit Cellar web site. Save both files in a convenient working directory.

The corresponding device driver for Linux V.2.2 is only slightly different. Sources for all the programs in this article and the 2.2 version of the driver are in the compressed file weedtech.tgz, which can be downloaded from www.seasurf.com/~jdennon.

To compile this code to create the object module that can be loaded into the kernel by insmod, the compiler needs to be told to access include files from /usr/src/linux/include, and you need to define the __KERNEL__ and MODULE control flags for the preprocessor. It is convenient to encapsulate these details in a little shell script as seen below:

#! /bin/bash
gcc -D__KERNEL__ -I/usr/src/linux/include -DMODULE\
-Wall -O2 -c $1.c -o $1.o

Save this file as mcomp.sh and then mark it executable with the command chmod +x mcomp.sh. When called from the shell prompt using the command mcomp.sh wtdio2_0, the script executes the command:

gcc -D__KERNEL__ -I/usr/src/include -DMODULE\
-Wall -O2 -c wtdio2_0.c -o wtdio2_0.o

This directs gcc to compile the file wtdio2_0.c and create the object file wtdio2_0.o, which contains your kernel device-driver module that can be loaded.

PREVIOUSNEXT


Circuit Cellar provides up-to-date information for engineers. Visit www.circuitcellar.com for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com or subscribe online. ýCircuit Cellar, the Magazine for Computer Applications. Posted with permission.
 
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ