電子發(fā)燒友App

硬聲App

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>類型>參考設(shè)計>AD7879輸入Touch Screen Digitizer Linux Driver

AD7879輸入Touch Screen Digitizer Linux Driver

2021-04-22 | pdf | 192.97KB | 次下載 | 2積分

資料介紹

This version (11 Feb 2016 21:12) was approved by Lars-Peter Clausen.The Previously approved version (05 Sep 2012 14:12) is available.Diff

AD7879 Input Touch Screen Digitizer Linux Driver

Supported Devices

Evaluation Boards

Description

The AD7879/AD7889 is a 12-bit successive approximation ADC with a synchronous serial interface and low on-resistance switches for driving 4-wire resistive touch screens. The AD7879 works with a very low power supply, a single 1.6 V to 3.6V, and features throughput rates of 105 kSPS.

The device includes a shutdown mode, which reduces its current consumption to less than 5 uA.

To reduce the effects of noise from LCDs and other sources, the AD7879 contains a preprocessing block. The preprocessing function consists of a median and an averaging filter. The combination of these two techniques provides a more robust solution, discarding the spurious noise in the signal and keeping only the data of interest. The size of both filters is programmable. Other user-programmable conversion controls include variable acquisition time, and first conversion delay. Up to 16 averages can be taken per conversion. The AD7879 can run in either slave or stand-alone mode, using an automatic conversion sequencer and timer.

The AD7879 has a programmable pin that can operate as either an auxiliary input to the ADC, as a battery monitor, or as a GPIO. There is a programmable interrupt output which can operate in three modes, as a general purpose interrupt to signal when new data is available INT, as an interrupt to indicate when limits are exceeded, or as a pen down interrupt when the screen is touched, PENIRQ. The AD7879 offers temperature and touch-pressure measurement.

It is available in various packages. It has either an SPI (AD7879)(AD7889) or I2C (AD7879-1)(AD7889-1) interface.

See also: uclinux-dist:tslib

See also: AD7877 Touchscreen Device Driver

Configuration

AD7879-1/AD7889-1 I2C Device Address options:

ADD1 ADD0 I2C Address
0 0 0x2C
0 1 0x2D
1 0 0x2E
1 1 0x2F

Software configurable features

Software configurable:

  • First Conversion Delay (128us..4.096ms in steps up 128us)
  • Acquisition Time (2us, 4us, 8us, 16us)
  • Average Filter (2,4,8,16)
  • Median Filter (0,4,8,16)
  • Pen Down Acquisition Interval Timer (550us..9.44ms in steps of 35us)
  • Auxiliary GPIO can be exported to GPIOLIB, and therefore used system-wide

Source Code

Status

Source Mainlined?
git Yes

Files

Example platform device initialization

For compile time configuration, it’s common Linux practice to keep board- and application-specific configuration out of the main driver file, instead putting it into the board support file.

For devices on custom boards, as typical of embedded and SoC-(system-on-chip) based hardware, Linux uses platform_data to point to board-specific structures describing devices and how they are connected to the SoC. This can include available ports, chip variants, preferred modes, default initialization, additional pin roles, and so on. This shrinks the board-support packages (BSPs) and minimizes board and application specific #ifdefs in drivers.

21 Oct 2010 16:10

Touchscreen characteristics vary between boards and models. The platform_data for the device's “struct device” holds this information.

Example Platform / Board file (SPI Interface Version)

Declaring SPI slave devices

Unlike PCI or USB devices, SPI devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each SPI bus segment, and what slave selects these devices are using. For this reason, the kernel code must instantiate SPI devices explicitly. The most common method is to declare the SPI devices by bus number.

This method is appropriate when the SPI bus is a system bus, as in many embedded systems, wherein each SPI bus has a number which is known in advance. It is thus possible to pre-declare the SPI devices that inhabit this bus. This is done with an array of struct spi_board_info, which is registered by calling spi_register_board_info().

For more information see: Documentation/spi/spi-summary

21 Oct 2010 16:10

These snippets are all from the same file. arch/blackfin/mach-bf537/boards/stamp.c:

#include 
?
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
	.model			= 7879,	/* Model = AD7879 */
	.x_plate_ohms		= 620,	/* 620 Ohm from the touch datasheet */
	.pressure_max		= 10000,
	.pressure_min		= 0,
	.first_conversion_delay	= 3,	/* wait 512us before do a first conversion */
	.acquisition_time	= 1,	/* 4us acquisition time per sample */
	.median			= 2,	/* do 8 measurements */
	.averaging		= 1,	/* take the average of 4 middle samples */
	.pen_down_acc_interval	= 255,	/* 9.4 ms */
	.gpio_export		= 1,	/* Export GPIO to gpiolib */
	.gpio_base		= -1,	/* Dynamic allocation */
};
static struct spi_board_info bfin_spi_board_info[] __initdata = {
#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
	{
		.modalias = "ad7879",
		.platform_data = &bfin_ad7879_ts_info,
		.irq = IRQ_PF7,
		.max_speed_hz = 5000000,     /* max spi clock (SCK) speed in HZ */
		.bus_num = 0,
		.chip_select = 1,
		.controller_data = &spi_ad7879_chip_info, /* only needed on Blackfin */
		.mode = SPI_CPHA | SPI_CPOL,
	},
#endif
};

Example Platform / Board file (I2C Interface Version)

Declaring I2C devices

Unlike PCI or USB devices, I2C devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each I2C bus segment, and what address these devices are using. For this reason, the kernel code must instantiate I2C devices explicitly. There are different ways to achieve this, depending on the context and requirements. However the most common method is to declare the I2C devices by bus number.

This method is appropriate when the I2C bus is a system bus, as in many embedded systems, wherein each I2C bus has a number which is known in advance. It is thus possible to pre-declare the I2C devices that inhabit this bus. This is done with an array of struct i2c_board_info, which is registered by calling i2c_register_board_info().

So, to enable such a driver one need only edit the board support file by adding an appropriate entry to i2c_board_info.

For more information see: Documentation/i2c/instantiating-devices

21 Oct 2010 16:10
#include 
?
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
	.model			= 7879,	/* Model = AD7879 */
	.x_plate_ohms		= 620,	/* 620 Ohm from the touch datasheet */
	.pressure_max		= 10000,
	.pressure_min		= 0,
	.first_conversion_delay	= 3,	/* wait 512us before do a first conversion */
	.acquisition_time	= 1,	/* 4us acquisition time per sample */
	.median			= 2,	/* do 8 measurements */
	.averaging		= 1,	/* take the average of 4 middle samples */
	.pen_down_acc_interval	= 255,	/* 9.4 ms */
	.gpio_export		= 1,	/* Export GPIO to gpiolib */
	.gpio_base		= -1,	/* Dynamic allocation */
};
static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
#if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
	{
		I2C_BOARD_INFO("ad7879", 0x2F),
		.irq = IRQ_PG5,
		.platform_data = (void *)&bfin_ad7879_ts_info,
	},
#endif
}

Adding Linux driver support

Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)

The AD7879 Driver depends on CONFIG_SPI or CONFIG_I2C

Input device support
  -*- Generic input layer (needed for keyboard, mouse, ...)
  < >   Support for memoryless force-feedback devices
  < >   Polled input device skeleton
  < >   Sparse keymap support library
        *** Userland interfaces ***
  < >   Mouse interface
  < >   Joystick interface
  <*>   Event interface
  < >   Event debugging
        *** Input Device Drivers ***
  [ ]   Keyboards  --->
  [ ]   Mice  --->
  [ ]   Joysticks/Gamepads  --->
  [ ]   Tablets  --->
  [*]   Touchscreens  --->

 	 --- Touchscreens
 	 < >   ADS7846/TSC2046/AD7873 and AD(S)7843 based touchscreens (NEW)
 	 < >   AD7877 based touchscreens
 	 <*>   Analog Devices AD7879-1/AD7889-1 touchscreen interface (NEW)
 		<*>     support I2C bus connection
 		< >     support SPI bus connection (NEW)

  [ ]   Miscellaneous devices  --->
      Hardware I/O ports  --->

Hardware configuration

Driver testing

Driver compiled as a module

root:~> modprobe evdev
root:~> modprobe ad7879
input: AD7879 Touchscreen as /class/input/input0
ad7879 spi0.1: touchscreen, irq 57

Driver compiled into the kernel

Your kernel startup messages should include something like this

input: AD7879 Touchscreen as /class/input/input0
ad7879 spi0.1: touchscreen, irq 57

Common Problems

In case you see a message like this

spi0.1: Failed to probe AD7879 Touchscreen

This means that the SPI communication and initialization with the AD7879 touchscreen controller/digitizer failed. check bus_num and chip_select in your platform device file

Checking for proper installation

After the kernel boot your device folder should include at least one device node for the touchscreen

root:/> ls -al /dev/input/
drw-r--r--    2 root     root            0 Jan  1 00:03 .
drwxr-xr-x    5 root     root            0 Jan  1 00:03 ..
crw-rw-r--    1 root     root      13,  64 Jan  1 00:03 event0
crw-rw-r--    1 root     root      13,  65 Jan  1 00:03 event1
crw-rw-r--    1 root     root      13,  66 Jan  1 00:03 event2
root:/>

Check that the interrupt is registered.

root:~> cat /proc/interrupts | grep ad7879
57:          0   ad7879

root:~> cat /sys/class/input/input0/name
AD7879 Touchscreen

Use the event_test utility to test proper function

root:/> event_test /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "AD7879 Touchscreen"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 330 (Touch)
  Event type 3 (Absolute)
    Event code 0 (X)
      Value   1268
      Min        0
      Max     4095
    Event code 1 (Y)
      Value   1250
      Min        0
      Max     4095
    Event code 24 (Pressure)
      Value      0
      Min        0
      Max    10000
Testing ... (interrupt to exit)
Event: time 67435.364000, type 1 (Key), code 330 (Touch), value 1
Event: time 67435.364000, type 3 (Absolute), code 0 (X), value 1624
Event: time 67435.364000, type 3 (Absolute), code 1 (Y), value 1514
Event: time 67435.364000, type 3 (Absolute), code 24 (Pressure), value 349
Event: time 67435.364000, -------------- Report Sync ------------
Event: time 67435.408000, type 3 (Absolute), code 0 (X), value 1626
Event: time 67435.408000, type 3 (Absolute), code 1 (Y), value 1516
Event: time 67435.408000, type 3 (Absolute), code 24 (Pressure), value 342
Event: time 67435.408000, -------------- Report Sync ------------
Event: time 67435.452000, type 3 (Absolute), code 1 (Y), value 1514
Event: time 67435.452000, type 3 (Absolute), code 24 (Pressure), value 339
Event: time 67435.452000, -------------- Report Sync ------------
Event: time 67435.496000, type 3 (Absolute), code 0 (X), value 1625
Event: time 67435.496000, type 3 (Absolute), code 24 (Pressure), value 343
Event: time 67435.496000, -------------- Report Sync ------------
Event: time 67435.596000, type 3 (Absolute), code 24 (Pressure), value 0
Event: time 67435.596000, type 1 (Key), code 330 (Touch), value 0
Event: time 67435.596000, -------------- Report Sync ------------

In case you touch the surface and don't receive events, it's likely that something with your /DAV Interrupt is wrong.
check irq number in your platform device file

In case you get a message like: evtest: No such device, it's likely that you have not install the necessary modules

root:/> cat /proc/interrupts
  6:       7898   Blackfin Core Timer
 10:          1   rtc-bfin
 18:          0   BFIN_UART_RX
 19:        105   BFIN_UART_TX
 24:         77   EMAC_RX
 42:          0   PPI ERROR
 57:        168   ad7879
Err:          0
root:/>

Find Input by name

In case you like to find out which input/event interface is connected to your touchscreen, use the sysfs entries

root:/sys/class/input> for i in `find /sys/class/input/ -name name` ; do echo -n "$i : "; cat $i; done
./input2/name : Logitech USB Receive
./input1/name : Logitech USB Receiver
./input0/name : AD7879 Touchscreen

Under the device folder there are auxiliary functions such as GPIO and disable controls

root:/> cd sys/class/input/input0/device/
root:/sys/devices/platform/bfin-spi.0/spi0.1> ls -al
drwxr-xr-x    3 root     root            0 Jan  3 13:02 .
drwxr-xr-x    5 root     root            0 Jan  3 13:02 ..
lrwxrwxrwx    1 root     root            0 Jan  3 13:04 bus -> ../../../../bus/spi
-rw-rw-r--    1 root     root         4096 Jan  3 13:04 disable
lrwxrwxrwx    1 root     root            0 Jan  3 13:04 driver -> ../../../../bus/spi/drivers/ad7879
-rw-rw-r--    1 root     root         4096 Jan  3 13:04 gpio
lrwxrwxrwx    1 root     root            0 Jan  3 13:04 input:input0 -> ../../../../class/input/input0
-r--r--r--    1 root     root         4096 Jan  3 13:04 modalias
drwxr-xr-x    2 root     root            0 Jan  3 13:04 power
lrwxrwxrwx    1 root     root            0 Jan  3 13:04 subsystem -> ../../../../bus/spi
-rw-r--r--    1 root     root         4096 Jan  3 13:04 uevent
root:/sys/devices/platform/bfin-spi.0/spi0.1> cat gpio
0
root:/sys/devices/platform/bfin-spi.0/spi0.1> echo 1 > gpio
root:/sys/devices/platform/bfin-spi.0/spi0.1> cat gpio
1
root:/sys/devices/platform/bfin-spi.0/spi0.1>

More Information

Touchscreen calibration

See the uclinux-dist:tslib page for more information.

Using the AD7879 in Microwin / Nano-X

User Configuration

  • Enable Microwin during Customize Application/Library Settings
  • Manually edit user/microwin/src/config

Enable:
AD7877MOUSE = Y

Disable:
NOMOUSE = N

Testing and Calibration

root:/> nano-X &
210
root:/> nanowm &
211
root:/> nxcal <-- TS Calibration Utility
root:/> nxeyes

Nanox with tslib

For kernel after 2.6.22, “/dev/input/ts*” interface has been deprecated in linux. Nanox need to use tslib for touchscreen. To enable:

####################################################################
# Mouse drivers
# GPMMOUSE      gpm mouse
# SERMOUSE      serial Microsoft, PC, Logitech, PS/2 mice (/dev/psaux)
# SUNMOUSE      Sun Workstation mouse (/dev/sunmouse)
# NOMOUSE       no mouse driver
#
# Touchscreen drivers
# IPAQMOUSE     Compaq iPAQ, Intel Assabet (/dev/h3600_tsraw)
# ZAURUSMOUSE   Sharp Zaurus (/dev/sharp_ts)
# TUXMOUSE      TuxScreen (/dev/ucb1x00-ts)
# ADSMOUSE      Applied Data Systems GC+ (/dev/ts)
# ADS7846MOUSE          ADS7846 chip, PSI OMAP Innovator (/dev/innnovator_ts)
# EPMOUSE       Embedded Planet (/dev/tpanel)
# VHMOUSE       Vtech Helio (/dev/tpanel)
# MTMOUSE       MicroTouch serial (/dev/ttyS1)
# PSIONMOUSE    Psion 5 (/dev/touch_psion)
# YOPYMOUSE     Yopy (/dev/yopy-ts)
# HARRIERMOUSE  NEC Harrier (/dev/tpanel)
# AD7877MOUSE   Analog Devices AD7877/9 Touch Screen Digitizer (/dev/ts0)
# TSLIBMOUSE    Common touchscreen driver using tslib
####################################################################
GPMMOUSE                 = N
SERMOUSE                 = N
SUNMOUSE                 = N
IPAQMOUSE                = N
ZAURUSMOUSE              = N
TUXMOUSE                 = N
ADSMOUSE                 = N
ADS7846MOUSE             = N
EPMOUSE                  = N
VHMOUSE                  = N
MTMOUSE                  = N
PSIONMOUSE               = N
YOPYMOUSE                = N
HARRIERMOUSE             = N
LIRCMOUSE                = N
AD7879MOUSE              = N
TSLIBMOUSE               = Y
NOMOUSE                  = N

Before start nano-x, need to set up uclinux-dist:tslib first (including running ts_calibrate):

root:/> . /etc/tslib.env
root:/> ts_calibrate
root:/> nano-X &
root:/> nanowm &
Network Applications
	[*] links (web browswer)
root:/> links -g http://uclinux.org

   ~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.2.3 |~~~~~~~~~~~~~~~~~~~~~~~~~~
        (c) 2001-2008  The world wide DirectFB Open Source Community
        (c) 2000-2004  Convergence (integrated media) GmbH
      ----------------------------------------------------------------

(*) DirectFB/Core: Single Application Core. (2008-10-08 07:38)
(*) Direct/Thread: Started 'VT Switcher' (235) [CRITICAL OTHER/OTHER 0/0] <12288>...
(*) Direct/Thread: Started 'Keyboard Input' (236) [INPUT OTHER/OTHER 0/0] <12288>...
(*) DirectFB/Input: Keyboard 0.9 (directfb.org)
(*) Direct/Thread: Started 'tslib Input' (237) [INPUT OTHER/OTHER 0/0] <12288>...
(*) DirectFB/Input: tslib touchscreen 0 0.1 (tslib)
(*) DirectFB/Graphics: Generic Software Rasterizer 0.6 (directfb.org)
(*) DirectFB/Core/WM: Default 0.3 (directfb.org)
(*) FBDev/Surface: Allocated 320x240 16 bit RGB16 buffer (index 0) at offset 0 and pitch 640.
(!) DirectFB/FBDev: Panning display failed (x=0 y=0 ywrap=0 vbl=1)!
    --> Invalid argument

Driver Source

Most people should not care about the driver source - it just works as a normal Linux input device. If you are interested, you can look at the driver source at :

下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評論

查看更多

下載排行

本周

  1. 1電子電路原理第七版PDF電子教材免費下載
  2. 0.00 MB  |  1491次下載  |  免費
  3. 2單片機典型實例介紹
  4. 18.19 MB  |  95次下載  |  1 積分
  5. 3S7-200PLC編程實例詳細資料
  6. 1.17 MB  |  27次下載  |  1 積分
  7. 4筆記本電腦主板的元件識別和講解說明
  8. 4.28 MB  |  18次下載  |  4 積分
  9. 5開關(guān)電源原理及各功能電路詳解
  10. 0.38 MB  |  11次下載  |  免費
  11. 6100W短波放大電路圖
  12. 0.05 MB  |  4次下載  |  3 積分
  13. 7基于單片機和 SG3525的程控開關(guān)電源設(shè)計
  14. 0.23 MB  |  4次下載  |  免費
  15. 8基于AT89C2051/4051單片機編程器的實驗
  16. 0.11 MB  |  4次下載  |  免費

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234313次下載  |  免費
  3. 2PADS 9.0 2009最新版 -下載
  4. 0.00 MB  |  66304次下載  |  免費
  5. 3protel99下載protel99軟件下載(中文版)
  6. 0.00 MB  |  51209次下載  |  免費
  7. 4LabView 8.0 專業(yè)版下載 (3CD完整版)
  8. 0.00 MB  |  51043次下載  |  免費
  9. 5555集成電路應(yīng)用800例(新編版)
  10. 0.00 MB  |  33562次下載  |  免費
  11. 6接口電路圖大全
  12. 未知  |  30320次下載  |  免費
  13. 7Multisim 10下載Multisim 10 中文版
  14. 0.00 MB  |  28588次下載  |  免費
  15. 8開關(guān)電源設(shè)計實例指南
  16. 未知  |  21539次下載  |  免費

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935053次下載  |  免費
  3. 2protel99se軟件下載(可英文版轉(zhuǎn)中文版)
  4. 78.1 MB  |  537793次下載  |  免費
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420026次下載  |  免費
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234313次下載  |  免費
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費
  11. 6電路仿真軟件multisim 10.0免費下載
  12. 340992  |  191183次下載  |  免費
  13. 7十天學(xué)會AVR單片機與C語言視頻教程 下載
  14. 158M  |  183277次下載  |  免費
  15. 8proe5.0野火版下載(中文版免費下載)
  16. 未知  |  138039次下載  |  免費