|
Modules | |
| XMEGA 4-wire resistive touch driver internals | |
Enumerations | |
| enum | touch_states { TOUCH_DISABLED, TOUCH_NOT_TOUCHED, TOUCH_READING_X, TOUCH_READING_Y, TOUCH_PROCESSING, TOUCH_TOUCHED } |
Driver state names. More... | |
Functions | |
| static void | touch_priv_port_handler (void *int_data) |
| Interrupt handler for touch detection. | |
| static void | touch_priv_adc_handler (void *int_data) |
| Interrupt handler for AD conversions. | |
| static void | touch_priv_process_samples (void *int_data) |
| Process touch samples. | |
| 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_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. | |
| 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. | |
Variables | |
| static enum touch_states | touch_state |
| Current driver state. | |
| static struct touch_event | touch_last_event |
| Last detected touch event. | |
| static uint16_t | touch_raw_x |
| Temporary raw sample value for X surface. | |
| static uint16_t | touch_raw_y |
| Temporary raw sample value for Y surface. | |
| static struct touch_calibration_matrix | touch_matrix |
| Calibration matrix for the driver. | |
| touch_event_handler_t | touch_event_handler |
| Current touch event handler (set to NULL if no handler should be called). | |
Definition of interrupt handlers for touch detection and reading | |
|
| |
| INTC_DEFINE_HANDLER (CONFIG_TOUCH_PORT_IRQ_ID, touch_priv_port_handler, CONFIG_TOUCH_PORT_INTLVL) | |
| INTC_DEFINE_HANDLER (CONFIG_TOUCH_ADC_IRQ_ID, touch_priv_adc_handler, CONFIG_TOUCH_ADC_INTLVL) | |
This driver makes use of low level interrupts for touch detection, and an ADC for touch position measurements.
| enum touch_states |
Driver state names.
| 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
| 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.
| 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.
| 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.
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.
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.
| 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_priv_adc_handler | ( | void * | int_data | ) | [static] |
Interrupt handler for AD conversions.
Handles and triggers raw measurements of position on the touch surfaces.
After measurements are completed, a soft IRQ is either raised or touch_priv_process_samples() called directly, depending on configuration.
| int_data | Not used here. |
Definition at line 460 of file touch.c.
References assert, softirq_raise(), touch_priv_adc_get_x(), touch_priv_adc_get_y, touch_priv_adc_set_surface_y(), touch_priv_adc_start(), touch_priv_port_set_detection(), touch_priv_port_set_gradient_y(), touch_priv_process_samples(), TOUCH_PROCESSING, touch_raw_x, touch_raw_y, TOUCH_READING_X, TOUCH_READING_Y, and touch_state.
| void touch_priv_port_handler | ( | void * | int_data | ) | [static] |
Interrupt handler for touch detection.
Disables itself and triggers the first touch position measurement.
The first measurements are done on the X surface of the touch panel.
| int_data | Not used here. |
Definition at line 430 of file touch.c.
References assert, TOUCH_NOT_TOUCHED, touch_priv_adc_set_surface_x(), touch_priv_adc_start(), touch_priv_port_disable_int(), touch_priv_port_set_gradient_x(), touch_raw_x, touch_raw_y, TOUCH_READING_X, touch_state, and TOUCH_TOUCHED.
| void touch_priv_process_samples | ( | void * | int_data | ) | [static] |
Process touch samples.
Uses the calibration matrix to compute touch position in panel coordinates from the current raw touch measurements.
The driver and touch states are updated according to the event, and its handler (if set) is called if a new event was in fact detected.
| int_data | Not used here. |
Definition at line 330 of file touch.c.
References touch_calibration_matrix::a, touch_calibration_matrix::b, touch_calibration_matrix::c, touch_calibration_matrix::d, touch_calibration_matrix::e, touch_calibration_matrix::f, touch_calibration_matrix::k, touch_point::panel_x, touch_point::panel_y, touch_event::point, touch_point::raw_x, touch_point::raw_y, touch_event_handler, touch_last_event, touch_matrix, TOUCH_NOT_TOUCHED, touch_priv_port_clear_int_flag(), touch_priv_port_enable_int(), touch_priv_port_is_int_flag_set(), touch_raw_x, touch_raw_y, touch_state, TOUCH_TOUCHED, and touch_event::type.
Referenced by touch_init(), and touch_priv_adc_handler().
| void touch_set_calibration_matrix | ( | const struct touch_calibration_matrix * | matrix | ) |
Assign a calibration matrix to the driver.
| 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.
| 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().
Current touch event handler (set to NULL if no handler should be called).
Definition at line 85 of file touch.c.
Referenced by touch_get_event_handler(), touch_init(), touch_priv_process_samples(), and touch_set_event_handler().
struct touch_event touch_last_event [static] |
Last detected touch event.
Definition at line 75 of file touch.c.
Referenced by touch_enable(), touch_get_event(), touch_init(), touch_is_touched(), and touch_priv_process_samples().
struct touch_calibration_matrix touch_matrix [static] |
Calibration matrix for the driver.
Definition at line 83 of file touch.c.
Referenced by touch_get_calibration_matrix(), touch_priv_process_samples(), and touch_set_calibration_matrix().
uint16_t touch_raw_x [static] |
Temporary raw sample value for X surface.
Definition at line 78 of file touch.c.
Referenced by touch_priv_adc_handler(), touch_priv_port_handler(), and touch_priv_process_samples().
uint16_t touch_raw_y [static] |
Temporary raw sample value for Y surface.
Definition at line 80 of file touch.c.
Referenced by touch_priv_adc_handler(), touch_priv_port_handler(), and touch_priv_process_samples().
enum touch_states touch_state [static] |
Current driver state.
Definition at line 73 of file touch.c.
Referenced by touch_enable(), touch_init(), touch_priv_adc_handler(), touch_priv_port_handler(), and touch_priv_process_samples().
1.6.3