[uClinux-dev] uclinux GPIO driver
jwilliams at itee.uq.edu.au
Tue Mar 25 19:58:06 EST 2003
> Thanks for your message for my question.
That's ok, but it is much better to have this conversation on the
uclinux-dev mailing list. That way, in future, other people will also
benefit from the information. I have copied this message to the list,
and set the reply-to field accordingly.
> I am writing a device driver to collect data from GPIO port driven by
It sounds almost identical to a serial port driver.
> My questions are as follows:
> 1) do you mean that I shall write a driver to treat gpio port as a
> char device?
Character devices operate on data one peice at a time. Like a serial
port, or your device that you are doing.
> could you give me a piece of program regarding this
I don't have any, but the entire uclinux source tree is there for you to
look at. Look in /drivers/char, perhaps at mcfserial.c, or something
similar. Also, download the excellent book "Linux Device Drivers", by
Rubini and Corbet. It's free, and you don't get much better than that.
> 2)in your message, you also suggest that I may not need to write a
> driver in using gpio. could u explain it in details?
I am not personally familiar with writing uClinux device drivers,
however everything I have read on this mailing list suggests that what
you want to do is not difficult.
Your use of interrupts may make it a bit harder, and maybe your only
choice is to use a proper device driver. It sounds like your device is
very similar to a serial port driver. When the interrupt is received
you sample the GPIO port and store the value in a buffer. Your driver
provides access to that buffer via calls like open() and read().
Your driver must register the interrupt handler (request_irq()), and
provide the necessary access functions. There are other things as well,
but I do not know the details. The book I told you about will tell you
what you need to know.
More information about the uClinux-dev