2008-03-27 03:58:52     Using the gpio's on the AD7877? [SOLVED]

Document created by Aaronwu Employee on Aug 5, 2013
Version 1Show Document
  • View in full screen mode

2008-03-27 03:58:52     Using the gpio's on the AD7877? [SOLVED]

Mark Urup (DENMARK)

Message: 53102    I've looked through the datasheet of the ad7877 touchscreen chip, and it has four pins that can be used as gpio's.

I would really like to utilize these, but how is this possible?

 

The default behaviour is that gpio4 is output, and the remaining gpio's are analog input.

 

By loading the ad7877 module with "modprobe ad7877 gpio3=1" I can also get gpio3 to work as an output pin, but how do I make them act as input pins?

 

I've been looking at "linux-2.6.x/drivers/input/touchscreen/ad7877.c", for any clues, but with no luck.

 

Thanks in advance.

Mark

QuoteReplyEditDelete

 

 

2008-03-27 09:16:09     Re: Using the gpio's on the AD7877? [SOLVED]

Mark Urup (DENMARK)

Message: 53139    After playing around with the driver, I managed to set the correct registers, and also read the correct values.

 

To make gpio4 work as a input I changed:

#define AD7877_EXTW_GPIO_3_CONF

from 0x1C4

to 0x1C6

 

and added:

#define AD7877_REG_GPIO_READ            0x1d

 

 

and ad7877_gpio4_show(...) now is:

        int testRegister = 16; /* 00010000 */

 

        if (testRegister & ad7877_read(dev,AD7877_REG_GPIO_READ))

                return sprintf(buf, "%u\n", 1);

        else

                return sprintf(buf, "%u\n", 0);

 

and now I can read a change on the input of gpio4.

 

To make aux1 and aux2 work as gpio's I just copied the methods

ad7877_gpio3_show(...) and ad7877_gpio3_store(...) and changed them approiately.

likewise in the __devinit method.

Attachments

    Outcomes