Linux Driver

Thread Starter

coolroose

Joined Aug 31, 2010
16
I have this assignment to design a: how do I get started.
Linux Device Driver for the Sensor

to design Linux device drivers for embedded computer systems and to
Understand the operation principles of interrupt
 

Georacer

Joined Nov 25, 2009
5,154
Shouldn't you include a full description of the sensor/peripheral you want to control in your question?
 

Thread Starter

coolroose

Joined Aug 31, 2010
16
Linux Device Driver for the Sensor
Description:​
A device driver is needed to hide the details of devices and provide a set of simple APIs (e.g. open(), close(), read(), write(), etc.). You are given a skeleton code of a Linux parallel port device driver to start with. The driver works with a special device file called “/dev/ppadc0”.​
Ack* is used as interrupt pin for the parallel port. Your sensor device must support additional commands related to interrupt:
#define MSG_INTBETWEEN 0x3 /* set the sensor to trigger interrupt if the ADC result is between Low and High parameters. The Low and High parameters follow the command. That is, the user application
will first write this command, then the Low bound and the High bound. */ #define MSG_INTOUTSIDE 0x4 /* opposite to INBETWEEN, the sensor triggers interrupt if the ADC result is outside the range between Low and High bounds */ #define MSG_INTENABLE 0x5 /* enable the interrupt */ #define MSG_INTDISABLE 0x6 /* disable the interrupt, also clear the pending interrupt */ Your Linux device driver should be able to 1. Support regular file operations including: • open() /* reset the sensor to initial state, get it ready to accept commands and supply data */ • close() /* reset the sensor to initial
state */ • read() /* obtain the most recent ADC result */ • write() /* send commands to the sensor */​

•​
poll() /* sleep until interrupt. The API name is confusing in fact. Details follow.
2. Respond to the interrupt from the sensor device: You need to design an interrupt handling function in
your device driver code, which performs appropriate actions with an interrupt occurs. For the user application, poll() is the API to call. #include <poll.h> int poll(struct pollfd fds[], nfds_t nfds, int imeout); poll() API call puts the caller application into sleep. In our scenario, the API returns once the sensor triggers an interrupt.​

 
Top