XMEGA 4-wire resistive touch driver internals
[4-wire resistive touch driver general implementation]

Collaboration diagram for XMEGA 4-wire resistive touch driver internals:

Defines

#define touch_priv_adc_get_y   touch_priv_adc_get_x
 Return mean of XL and XR ADC measurements.

Functions

static __always_inline void touch_priv_port_init (void)
 Initialize port for touch detection.
static __always_inline void touch_priv_port_enable_int (void)
 Enable interrupt for touch detection.
static __always_inline void touch_priv_port_disable_int (void)
 Disable interrupt for touch detection.
static __always_inline bool touch_priv_port_is_int_flag_set (void)
 Return current state of port interrupt flag.
static __always_inline void touch_priv_port_clear_int_flag (void)
 Clear the port interrupt flag.
static __always_inline void touch_priv_port_set_detection (void)
 Configure port for touch detection.
static __always_inline void touch_priv_port_set_gradient_x (void)
 Configure port for gradient on X touch surface.
static __always_inline void touch_priv_port_set_gradient_y (void)
 Configure port for gradient on Y touch surface.
static __always_inline void touch_priv_adc_init (void)
 Initialize the ADC for readings from touch surfaces.
static __always_inline void touch_priv_adc_enable_int (void)
 Enable ADC interrupts.
static __always_inline void touch_priv_adc_disable_int (void)
 Disable ADC interrupts.
static __always_inline void touch_priv_adc_clear_int_flag (void)
 Clear the interrupt flag for ADC.
static __always_inline void touch_priv_adc_set_surface_y (void)
 Start ADC scan sequence to measure position on Y surface.
static __always_inline void touch_priv_adc_set_surface_x (void)
 Set ADC scan sequence to measure position on X surface.
static __always_inline void touch_priv_adc_start (void)
 Trigger AD conversions.
static __always_inline uint16_t touch_priv_adc_get_x (void)
 Return mean of YD and YU ADC measurements.

Pin mask macros for convenience



#define TOUCH_XL_MASK   (1U << CONFIG_TOUCH_XL_PIN)
#define TOUCH_XR_MASK   (1U << CONFIG_TOUCH_XR_PIN)
#define TOUCH_YD_MASK   (1U << CONFIG_TOUCH_YD_PIN)
#define TOUCH_YU_MASK   (1U << CONFIG_TOUCH_YU_PIN)
#define TOUCH_X_MASK   (TOUCH_XL_MASK | TOUCH_XR_MASK)
#define TOUCH_Y_MASK   (TOUCH_YD_MASK | TOUCH_YU_MASK)

Detailed Description

These functions default to pin interrupt type 0 for touch detection and assume that the sense pins are on the same port with which the ADC is associated, i.e., port A for ADCA and port B for ADCB.

The ADC is configured for measurements from both "ends" of the tri-stated touch surfaces for improved accuracy, and an interrupt is only generated when both conversions have been made.


Define Documentation

#define touch_priv_adc_get_y   touch_priv_adc_get_x

Return mean of XL and XR ADC measurements.

Note:
Measurements are computed in the same way for both X and Y surfaces.

Definition at line 346 of file touch.h.

Referenced by touch_priv_adc_handler().


Function Documentation

static __always_inline void touch_priv_adc_clear_int_flag ( void   )  [static]

Clear the interrupt flag for ADC.

Definition at line 266 of file touch.h.

References ADC_BIT, and adc_write_reg.

Referenced by touch_enable().

static __always_inline void touch_priv_adc_disable_int ( void   )  [static]

Disable ADC interrupts.

Sets level for ADC interrupt on channel 1 to OFF.

Definition at line 256 of file touch.h.

References ADCCH_BF, ADCCH_INTLVL_OFF, and adcch_write_reg.

Referenced by touch_disable().

static __always_inline void touch_priv_adc_enable_int ( void   )  [static]

Enable ADC interrupts.

Sets configured level for ADC interrupt on channel 1.

Definition at line 244 of file touch.h.

References ADCCH_BF, and adcch_write_reg.

Referenced by touch_enable().

static __always_inline uint16_t touch_priv_adc_get_x ( void   )  [static]

Return mean of YD and YU ADC measurements.

This function returns the mean of the last YD and YU ADC readings.

Definition at line 324 of file touch.h.

References adc_read_reg.

Referenced by touch_priv_adc_handler().

static __always_inline void touch_priv_adc_init ( void   )  [static]

Initialize the ADC for readings from touch surfaces.

Initializes ADC reference selection, channels 0 and 1, and clock prescaling.

Definition at line 218 of file touch.h.

References ADC_BF, ADC_BIT, ADC_PRESCALER_DIV512, ADC_REFSEL_INTVCC, ADC_RESOLUTION_12BIT, adc_write_reg, ADCCH_BF, ADCCH_INPUTMODE_SINGLEENDED, and adcch_write_reg.

Referenced by touch_init().

static __always_inline void touch_priv_adc_set_surface_x ( void   )  [static]

Set ADC scan sequence to measure position on X surface.

Configure ADC channel 0 and 1 to measure from YD and YU, then trigger conversions on both channels.

Definition at line 297 of file touch.h.

References ADCCH_BF, and adcch_write_reg.

Referenced by touch_priv_port_handler().

static __always_inline void touch_priv_adc_set_surface_y ( void   )  [static]

Start ADC scan sequence to measure position on Y surface.

Configure ADC channel 0 and 1 to measure from XL and XR, then trigger conversions on both channels.

The voltage on the XL and XR pins depends on the position along the Y axis. By reading both XL and XR, the effect of touch proximity to either of these pins is negated.

Definition at line 282 of file touch.h.

References ADCCH_BF, and adcch_write_reg.

Referenced by touch_priv_adc_handler().

static __always_inline void touch_priv_adc_start ( void   )  [static]

Trigger AD conversions.

Starts conversions on ADC channels 0 and 1.

Definition at line 311 of file touch.h.

References ADC_BF, ADC_BIT, ADC_CHSTART_0, ADC_CHSTART_1, and adc_write_reg.

Referenced by touch_priv_adc_handler(), and touch_priv_port_handler().

static __always_inline void touch_priv_port_clear_int_flag ( void   )  [static]

Clear the port interrupt flag.

Definition at line 147 of file touch.h.

References PORT_BIT, and port_write_reg.

Referenced by touch_enable(), and touch_priv_process_samples().

static __always_inline void touch_priv_port_disable_int ( void   )  [static]

Disable interrupt for touch detection.

Definition at line 115 of file touch.h.

References PORT_BFINS, port_read_reg, and port_write_reg.

Referenced by touch_disable(), and touch_priv_port_handler().

static __always_inline void touch_priv_port_enable_int ( void   )  [static]

Enable interrupt for touch detection.

Definition at line 100 of file touch.h.

References PORT_BFINS, port_read_reg, and port_write_reg.

Referenced by touch_enable(), and touch_priv_process_samples().

static __always_inline void touch_priv_port_init ( void   )  [static]

Initialize port for touch detection.

Configure interrupt mask on Y pins, and prepare their output for voltage gradient.

Definition at line 84 of file touch.h.

References port_write_reg.

Referenced by touch_init().

static __always_inline bool touch_priv_port_is_int_flag_set ( void   )  [static]

Return current state of port interrupt flag.

Return values:
true Interrupt flag is set.
false Interrupt flag is not set.

Definition at line 132 of file touch.h.

References PORT_BIT, and port_read_reg.

Referenced by touch_priv_process_samples().

static __always_inline void touch_priv_port_set_detection ( void   )  [static]

Configure port for touch detection.

Touch detection is done by use of a low-level interrupt.
This requires one touch surface to be grounded, and the other to have pull-up and the interrupt sensing enabled.
In this function, X is grounded and Y used for the sensing.

Definition at line 161 of file touch.h.

References PORT_BF, PORT_PINCTRL_ISC_LEVEL, PORT_PINCTRL_PULLUP, port_write_reg, and portcfg_write_reg.

Referenced by touch_enable(), and touch_priv_adc_handler().

static __always_inline void touch_priv_port_set_gradient_x ( void   )  [static]

Configure port for gradient on X touch surface.

Definition at line 179 of file touch.h.

References PORT_BF, PORT_PINCTRL_TOTEM, port_write_reg, and portcfg_write_reg.

Referenced by touch_priv_port_handler().

static __always_inline void touch_priv_port_set_gradient_y ( void   )  [static]

Configure port for gradient on Y touch surface.

To be able to detect the position along the Y axis, the YD and YU pins must have different potentials, and the XL and XR pins be configured as tristated inputs before using them for measurements with ADC.

Definition at line 200 of file touch.h.

References PORT_BF, PORT_PINCTRL_TOTEM, port_write_reg, and portcfg_write_reg.

Referenced by touch_priv_adc_handler().

Generated on Thu Apr 29 15:18:24 2010 for display-training by  doxygen 1.6.3