General touch driver

Collaboration diagram for General touch driver:

Data Structures

struct  touch_point
 Panel coordinate and measurement data of a single touch. More...
struct  touch_calibration_matrix
 Calibration matrix coefficients. More...
struct  touch_event
 Contains touch event type and touch point data. More...

Modules

 4-wire resistive touch driver general implementation
 Board-specific ADC control for resistive touch driver

Defines

#define TOUCH_NR_CALIBRATION_POINTS   3
 Number of calibration points needed for driver.

Typedefs

typedef struct touch_point touch_calibration_points_t [TOUCH_NR_CALIBRATION_POINTS]
 Array to hold calibration points.
typedef void(* touch_event_handler_t )(const struct touch_event *event)
 Pointer to touch event handler function.

Enumerations

enum  touch_event_types
 

Enumeration of different touch event types for the touch_event struct.

More...

Functions

void touch_init (void)
 Initialize the touch driver.
void touch_enable (void)
 Enable touch detection and sampling.
void touch_disable (void)
 Disable touch detection and sampling.
void touch_get_event (struct touch_event *buffer)
 Get last detected touch event from driver to buffer.
bool touch_is_touched (void)
 Return current state of touch driver.
void touch_set_calibration_matrix (const struct touch_calibration_matrix *matrix)
 Assign a calibration matrix to the driver.
void touch_get_calibration_matrix (struct touch_calibration_matrix *buffer)
 Copy calibration matrix from driver to a buffer.
void touch_compute_calibration_matrix (const touch_calibration_points_t points, struct touch_calibration_matrix *matrix)
 Compute a calibration matrix.
void touch_set_event_handler (touch_event_handler_t handler)
 Set touch event handler for driver.
touch_event_handler_t touch_get_event_handler (void)
 Get current touch event handler from driver.

Detailed Description

For resistive touch the driver implementation utilizes GPIO pin interrupts, if needed, for touch detection and the ADC for position measurements.
If CONFIG_SOFTIRQ is defined, the driver will make use of the soft IRQ with ID SOFTIRQ_TOUCH_PROCESS for processing of measurements and calling the current touch event handler function.

Precondition:
For 4-wire resistive touch with XMEGA, the driver needs the following configuration symbols to be defined:
  • CONFIG_TOUCH_PORT_BASE
  • CONFIG_TOUCH_PORT_IRQ_ID
  • CONFIG_TOUCH_PORT_INTLVL
  • CONFIG_TOUCH_ADC_IRQ_ID
  • CONFIG_TOUCH_ADC_INTLVL
  • CONFIG_TOUCH_ADC_PRP
  • CONFIG_TOUCH_XL_PIN
  • CONFIG_TOUCH_XR_PIN
  • CONFIG_TOUCH_YD_PIN
  • CONFIG_TOUCH_YU_PIN
  • CONFIG_TOUCH_OVERSAMPLING
Note:
See pin configuration for details on which pins are driven low or high during touch measurements.

Define Documentation

#define TOUCH_NR_CALIBRATION_POINTS   3

Number of calibration points needed for driver.

Definition at line 176 of file touch.h.


Typedef Documentation

typedef struct touch_point touch_calibration_points_t[TOUCH_NR_CALIBRATION_POINTS]

Array to hold calibration points.

Meant for use with touch_compute_calibration_matrix().

Definition at line 183 of file touch.h.

typedef void(* touch_event_handler_t)(const struct touch_event *event)

Pointer to touch event handler function.

Definition at line 219 of file touch.h.


Enumeration Type Documentation

Enumeration of different touch event types for the touch_event struct.

Definition at line 203 of file touch.h.


Function Documentation

void touch_compute_calibration_matrix ( const touch_calibration_points_t  points,
struct touch_calibration_matrix matrix 
)

Compute a calibration matrix.

Computes the calibration matrix that is used to get the panel coordinates from raw measurements of the touch surface.
This requires that the

Note:
Reference: http://www.embedded.com/story/OEG20020529S0046
Parameters:
points Pointer to array containing calibration points.
matrix Pointer to storage buffer for the calibration matrix.

Definition at line 270 of file touch.c.

References touch_calibration_matrix::a, assert, touch_calibration_matrix::b, touch_calibration_matrix::c, touch_calibration_matrix::d, touch_calibration_matrix::e, touch_calibration_matrix::f, and touch_calibration_matrix::k.

Referenced by touch_calibrate_task_handler().

void touch_disable ( void   ) 

Disable touch detection and sampling.

Disables interrupts for the GPIO and the ADC.

Definition at line 160 of file touch.c.

References cpu_irq_restore(), cpu_irq_save(), touch_priv_adc_disable_int(), and touch_priv_port_disable_int().

Referenced by touch_init().

void touch_enable ( void   ) 

Enable touch detection and sampling.

Resets the driver and touch state, configures GPIO pins for touch detection and enables interrupts for GPIO and the ADC.

Definition at line 137 of file touch.c.

References touch_last_event, TOUCH_NOT_TOUCHED, touch_priv_adc_clear_int_flag(), touch_priv_adc_enable_int(), touch_priv_port_clear_int_flag(), touch_priv_port_enable_int(), touch_priv_port_set_detection(), touch_state, and touch_event::type.

void touch_get_calibration_matrix ( struct touch_calibration_matrix buffer  ) 

Copy calibration matrix from driver to a buffer.

Parameters:
buffer Address of buffer to copy calibration matrix to.

Definition at line 250 of file touch.c.

References assert, and touch_matrix.

void touch_get_event ( struct touch_event buffer  ) 

Get last detected touch event from driver to buffer.

Parameters:
buffer Buffer to store touch event in.

Definition at line 179 of file touch.c.

References assert, cpu_irq_restore(), cpu_irq_save(), and touch_last_event.

touch_event_handler_t touch_get_event_handler ( void   ) 

Get current touch event handler from driver.

Returns:
Address of the currently set handler function.

Definition at line 226 of file touch.c.

References touch_event_handler.

void touch_init ( void   ) 

Initialize the touch driver.

Initializes the GPIO pins and ADC for touch detection and measurements, as well as the driver states.
Must be called before any other function in this driver.

Note:
The touch driver is left disabled, and must be explicitly enabled by use of touch_enable().

Definition at line 111 of file touch.c.

References softirq_set_handler(), touch_disable(), touch_event_handler, touch_last_event, TOUCH_NOT_TOUCHED, touch_priv_adc_init(), touch_priv_port_init(), touch_priv_process_samples(), touch_state, and touch_event::type.

bool touch_is_touched ( void   ) 

Return current state of touch driver.

Return values:
true Driver is sensing a touch.
false Driver is not sensing a touch.

Definition at line 198 of file touch.c.

References touch_last_event, and touch_event::type.

void touch_set_calibration_matrix ( const struct touch_calibration_matrix matrix  ) 

Assign a calibration matrix to the driver.

Parameters:
matrix Address of calibration matrix for the driver to copy.

Definition at line 237 of file touch.c.

References assert, and touch_matrix.

Referenced by touch_calibrate_task_handler().

void touch_set_event_handler ( touch_event_handler_t  handler  ) 

Set touch event handler for driver.

Parameters:
handler Address of new handler function.

Definition at line 210 of file touch.c.

References cpu_irq_restore(), cpu_irq_save(), and touch_event_handler.

Referenced by touch_calibrate_task_handler().

Generated on Thu Apr 29 14:10:01 2010 for display-demo by  doxygen 1.6.3