Based on the Windows CE6.0 and AK4182 touch screen driver implementation

Source: Internet
Author: User

This drive realizes the ak4182a touch screen sampling function under the FreescaleImx515 platform. All of the data sampling capabilities of the full-bit precision are accomplished by following the Windows CE TOUCH DDSI interface standard on the Windows CE platform.

The driver implements a standard Windows CE touchscreen driver, uses interrupts (Interrupt) to implement pen down detection, interrupts the acquisition of PEN move data with a timer (timer), and simultaneously determines if the pen up state. In this process, the DOT filtering algorithm and the pressure detection algorithm are used to remove the clutter and smoothing, and the last valid original location data is sent to the Windows CE High-level interface for screen correction processing.

The driver completes the sampling under the following hardware conditions:

L PEN down interrupt support

L IMX515 SPI Interface

L 12BIT Sampling

L Screen Resolution 1024x768

L four-wire resistive touch screen

L Pressure Detection support

1. Windows CE 6 Touch Screen Driver Model 1.1 overall model

The touchscreen driver reads the user touch data and converts it to an internal format sent to the Gwes of the WINDOWSCE system. The driver is responsible for converting the sampled raw input data (uncalibrated raw coordinates) to the corrected input data (calibrated coordinates).

The user touches the touch screen, resulting in a pen down interrupt. The interrupt activates the touchscreen-driven automatic sampling routine, which can periodically sample data and user Penup events and send the last corrected data to Gwes, allowing Gwes to get the user's location and display it.

The model logic diagram is as follows.

The driving model is divided into MDD layer and PDD layer.

The MDD layer is responsible for and Gwes interface, and completes the correction algorithm and screen correction and other related work.

The PDD layer is responsible for specific pen down, pen up interrupt response, data sampling, pressure sensing, and algorithm smoothing.


1.2 Model Data Interface definition

N Data Validation Description

Enum Enumtouchpanelsampleflags {

Touchsamplevalidflag = 0x01, (valid for this sample point)

Touchsampledownflag = 0x02, (PEN status, with sample point status "or" Notify upper level after ")

Touchsampleiscalibratedflag = 0x04,

Touchsamplepreviousdownflag = 0x08,

Touchsampleignore = 0x10, (invalid point state)

Touchsamplemouse = 0x40000000

};

N-Touch-driven MDD layer interface

thefollowing table shows the touch screen driver functions.

Programming element

Description

Erroranalysis

This function provides information on the accuracy of the touch-screen calibration.

Touchcalibrate

This function starts the touch screen calibration sequence.

Touchpanelcalibrateapoint

This function converts noncalibrated points to calibrated points.

Touchpaneldisable

This function is disables the touch screen.

Touchpanelenable

This function enables and re-enables the touch screen.

Touchpanelgetdevicecaps

This function is returns information about the capabilities of the touch screen.

Touchpanelinitializecursor

This function provides a opportunity for touch drivers to move the cursor at initialization time.

Touchpanelpowerhandler

This function handles power-state the change notifications.

Touchpanelreadcalibrationabort

This function aborts the currently active call to thetouchpanelcalibrateapoint function.

Touchpanelreadcalibrationpoint

This function initiates the process of getting a calibration point.

Touchpanelsetcalibration

This function initializes calibration information in a global parametervcalcparam, which you can use to convert n Oncalibrated points to calibrated points by thetouchpanelcalibrateapoint function.

Touchpanelsetmode

This function sets mode information for a touch screen device.

N Touch-driven PDD layer interface

Programming element

Description

Ddsitouchpanelattach

This function executes when the MDD ' s DLL entry point receives a DLL_PROCESS_ATTACH message.

Ddsitouchpaneldetach

This function executes when the MDD ' s DLL entry point receives a DLL_PROCESS_DETACH message.

Ddsitouchpaneldisable

This function disables the touch screen device.

Ddsitouchpanelenable

This function applies power to the touch screens device and initializes it for operation.

Ddsitouchpanelgetdevicecaps

This function queries capabilities of the touch screen device.

Ddsitouchpanelgetpoint

This function returns the most recently acquired point and its associated tip state information.

Ddsitouchpanelpowerhandler

This function indicates the driver, the system is entering, or leaving the suspend state.

Ddsitouchpanelsetmode

This function is sets information about the touch screen device.

n Data accuracy Requirements

It is important to note that Windows CE requires that the coordinate information passed after the check is One-fourth pixels closest to the pixel point.

1.3 Smoothing algorithm

WINDOWS CE does not limit how the sample points are smoothed, and is implemented by each OEM manufacturer.

Specific algorithms can include:

1) three points average

2) Three point comparison, take the nearest to do average

。。。。。。

1.4 Correction algorithm

WINDOWS CE implements the most important correction algorithm, which can be used for screen rotation and non-linear processing of different sizes.

Refer to the following catalogue:

Imx51-evk\src\drivers\touchp\mdd\calibrate

2, ak4182a basic principle

The AK4182A chip is a four-wire resistive screen touch controller that supports up to 125khz sample rate and the output data width is 12bit.

The ak4182a chip can perceive a pen down event and produce an interrupt signal to the CPU. The CPU starts the AK4182A sample with a command, which starts the serial output of 12-bit sampled data after the start of the 4th clock.

3 Data acquisition

Each time the x-axis or y-axis is sampled from the ak4182a, it is sampled 3 times in a row to ensure that the data changes in each axis are not too dramatic.

At the same time, when the x-axis is sampled, the z-axis (pressure data) is calculated to meet the requirements, and the point is discarded. Experience has shown that the pressure value is not greater than 1500 advisable.

In general, after acquiring 3 x-axes and 3 y-axis data, a smoothing algorithm is sent. Depending on the delta and y-axis Delta range of the x-axis, the data meets the requirements and is treated as a good or bad point.

The above principles also determine if we want to adjust according to the actual situation of the hardware, it needs to be carefully adjusted:

Dwpressure values in the Eadc_getadcsample

delta_y_coord_variance/in the tsp_evaluatesample () algorithm

Delta_x_coord_variance



4 details of the SPI interface

Since the ak4182a data is only 12 bits and is not a standard SPI interface. Note When we use the IMX51 SPI:

1) You can set the SPI data width is 24 or 32 bits, 24-bit compared to save time, 32 bits some waste.

2) After the CPU side is required to send 8 bits, the data must no longer be sent

3) The CPU side of the data receive, from the CPU to send a 1th bit start, on the synchronous receive, so the data received to do the shift processing.

4) Set the SPI clock is not as high as possible, due to the high resolution of the screen, the touchscreen is large, 15 inches, this requires a sampling time can not be too fast, otherwise it will result in data accuracy is not high. After practical measurement, it is more appropriate to 1.5ms-2ms. DCLK (i.e. sampling speed) can be controlled by setting the SPI clock





Based on the Windows CE6.0 and AK4182 touch screen driver implementation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.