Microchip® Advanced Software Framework

touch_api.h File Reference

This file contains the QTouch Libary API interface for AVR 8-bit, AVR 32-bit and Atmel ARM QMatrix and QTouch method Capacitive Touch acquisition.

  • Compiler: IAR EWAVR/EWAVR32 and GNU GCC for AVR/AVR32 IAR Workbench and GNU GCC for Atmel ARM.
  • Supported devices: Atmel AVR 8-bit, AVR 32-bit, Atmel ARM.
  • Userguide: QTouch Library User Guide - doc8207.pdf.
  • Support: https://www.microchip.com/support/

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "touch_config.h"
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include "qm_asm_avr.h"

Data Structures

struct  qt_lib_sig_info_t
 
struct  tag_qt_touch_lib_config_data_t
 
struct  tag_qt_touch_lib_measure_data_t
 
struct  tag_qt_touch_status_t
 
struct  tag_sensor_t
 
struct  tag_x_line_info_t
 
struct  tag_y_line_info_t
 

Macros

#define BURST_FUNC_1   BURST_JOIN(burst_qm_, PORT_NUM_1)
 
#define BURST_FUNC_2   BURST_JOIN(burst_qm_, PORT_NUM_2)
 
#define BURST_JOIN(A, B)   JOIN(A, B)
 
#define CONCAT(A, B, C)   JOIN1( A, B, C )
 
#define FILL_OUT_X_LINE_INFO(port_num, x_bit)
 QTouch libraries are supplied built with a range of charge times. More...
 
#define FILL_OUT_Y_LINE_INFO(bit)   { bit, (TOUCH_DATA_T)(1u << bit) }
 Info stored for each y line. More...
 
#define FILL_OUT_YA_LINE_INFO(bit)   { bit, (uint8_t)(1u << bit) }
 Info stored for each ya line. More...
 
#define FILL_OUT_YB_LINE_INFO(bit)   { bit, (uint8_t)(1u << bit) }
 Info stored for each yb line. More...
 
#define JOIN(x, y)   x ## y
 Error Checking For the User Configuration Options ends here. More...
 
#define JOIN1(A, B, C)   A ## B ## C
 
#define qt_init_sensing()   qt_init_sensing_with_burst()
 initialise touch sensing. More...
 
#define QT_NUM_SENSOR_STATE_BYTES   ((QT_NUM_CHANNELS + 7u) / 8u)
 The number of bytes required to report the maximum possible number of sensors. More...
 
#define QTLIB_BURST_AGAIN   (uint16_t)0x0100
 
#define QTLIB_CHANNEL_REF_CHANGE   (uint16_t)0x0008
 
#define QTLIB_IN_DETECT   (uint16_t)0x0001
 
#define QTLIB_NO_ACTIVITY   (uint16_t)0x0000
 Status flags used with debug. More...
 
#define QTLIB_RESOLVE_CAL   (uint16_t)0x0200
 
#define QTLIB_RESOLVE_DI   (uint16_t)0x0800
 
#define QTLIB_RESOLVE_FILTERIN   (uint16_t)0x0400
 
#define QTLIB_RESOLVE_POS_RECAL   (uint16_t)0x1000
 
#define QTLIB_ROTOR_SLIDER_POS_CHANGE   (uint16_t)0x0004
 
#define QTLIB_STATUS_CHANGE   (uint16_t)0x0002
 
#define REG(REGISTER, SIDE)   JOIN( REGISTER, SIDE )
 Macro to build register writes for controlling ports. More...
 
#define TOUCH_DATA_T   uint8_t
 This part of the code below is used for library selection. More...
 

Typedefs

typedef enum tag_aks_group_t aks_group_t
 Which AKS group, if any, a sensor is in. More...
 
typedef enum tag_burst_mask_t burst_mask_t
 
typedef enum tag_channel_t channel_t
 
typedef enum tag_hysteresis_t hysteresis_t
 A sensor detection hysteresis value. More...
 
typedef void(* PF_CHANNEL )(uint8_t channel)
 
typedef void(* PFV )(uint8_t channel, TOUCH_DATA_T line_mask)
 
typedef struct qt_lib_sig_info_t qt_lib_siginfo_t
 
typedef struct
tag_qt_touch_lib_config_data_t 
qt_touch_lib_config_data_t
 
typedef struct
tag_qt_touch_lib_measure_data_t 
qt_touch_lib_measure_data_t
 
typedef struct
tag_qt_touch_status_t 
qt_touch_status_t
 
typedef enum tag_recal_threshold_t recal_threshold_t
 A sensor recalibration threshold. More...
 
typedef enum tag_resolution_t resolution_t
 For rotors and sliders, the resolution of the reported angle or position. More...
 
typedef struct tag_sensor_t sensor_t
 
typedef enum tag_sensor_type_t sensor_type_t
 
typedef uint8_t threshold_t
 QMATRIX End. More...
 
typedef struct tag_x_line_info_t x_line_info_t
 
typedef struct tag_y_line_info_t y_line_info_t
 

Enumerations

enum  tag_aks_group_t {
  NO_AKS_GROUP,
  AKS_GROUP_1,
  AKS_GROUP_2,
  AKS_GROUP_3,
  AKS_GROUP_4,
  AKS_GROUP_5,
  AKS_GROUP_6,
  AKS_GROUP_7
}
 Which AKS group, if any, a sensor is in. More...
 
enum  tag_burst_mask_t {
  BURST_MASK_YA,
  BURST_MASK_YB,
  BURST_MASK_X_PORT_1,
  BURST_MASK_X_PORT_2,
  BURST_MASK_X_PORT_3,
  NUM_BURST_MASKS
}
 
enum  tag_channel_t {
  CHANNEL_0,
  CHANNEL_1,
  CHANNEL_2,
  CHANNEL_3,
  CHANNEL_4,
  CHANNEL_5,
  CHANNEL_6,
  CHANNEL_7,
  CHANNEL_8,
  CHANNEL_9,
  CHANNEL_10,
  CHANNEL_11,
  CHANNEL_12,
  CHANNEL_13,
  CHANNEL_14,
  CHANNEL_15,
  CHANNEL_16,
  CHANNEL_17,
  CHANNEL_18,
  CHANNEL_19,
  CHANNEL_20,
  CHANNEL_21,
  CHANNEL_22,
  CHANNEL_23,
  CHANNEL_24,
  CHANNEL_25,
  CHANNEL_26,
  CHANNEL_27,
  CHANNEL_28,
  CHANNEL_29,
  CHANNEL_30,
  CHANNEL_31
}
 
enum  tag_hysteresis_t {
  HYST_50,
  HYST_25,
  HYST_12_5,
  HYST_6_25
}
 A sensor detection hysteresis value. More...
 
enum  tag_recal_threshold_t {
  RECAL_100,
  RECAL_50,
  RECAL_25,
  RECAL_12_5,
  RECAL_6_25
}
 A sensor recalibration threshold. More...
 
enum  tag_resolution_t {
  RES_1_BIT,
  RES_2_BIT,
  RES_3_BIT,
  RES_4_BIT,
  RES_5_BIT,
  RES_6_BIT,
  RES_7_BIT,
  RES_8_BIT
}
 For rotors and sliders, the resolution of the reported angle or position. More...
 
enum  tag_sensor_type_t {
  SENSOR_TYPE_UNASSIGNED,
  SENSOR_TYPE_KEY,
  SENSOR_TYPE_ROTOR,
  SENSOR_TYPE_SLIDER
}
 

Functions

void BURST_FUNC_1 (uint8_t channel, TOUCH_DATA_T x_mask)
 
void BURST_FUNC_2 (uint8_t channel, TOUCH_DATA_T x_mask)
 
void qt_calibrate_sensing (void)
 calibrate touch sensing. More...
 
void qt_enable_key (channel_t channel, aks_group_t aks_group, threshold_t detect_threshold, hysteresis_t detect_hysteresis)
 enable a key sensor. More...
 
void qt_enable_rotor (channel_t from_channel, channel_t to_channel, aks_group_t aks_group, threshold_t detect_threshold, hysteresis_t detect_hysteresis, resolution_t angle_resolution, uint8_t angle_hysteresis)
 enable a rotor sensor. More...
 
void qt_enable_slider (channel_t from_channel, channel_t to_channel, aks_group_t aks_group, threshold_t detect_threshold, hysteresis_t detect_hysteresis, resolution_t position_resolution, uint8_t position_hysteresis)
 enable a slider sensor. More...
 
void qt_get_library_sig (qt_lib_siginfo_t *lib_sig_ptr)
 Get the library signature. More...
 
int16_t qt_get_sensor_delta (uint8_t sensor)
 get the current delta on the specified sensor. More...
 
void qt_init_sensing_with_burst ()
 
uint16_t qt_measure_sensors (uint16_t current_time_ms)
 measure touch sensors. More...
 
void qt_reset_sensing (void)
 reset touch sensing. More...
 

Variables

void(* burst_proc_qm )(uint8_t channel, TOUCH_DATA_T drive_mask)
 
uint16_t lib_status_flags
 
uint8_t qt_burst_lengths [QT_NUM_CHANNELS]
 The burst length on each QMatrix channel. More...
 
qt_touch_lib_config_data_t qt_config_data
 This configuration data structure parameters if needs to be changed will be changed in the qt_set_parameters function. More...
 
void(* qt_filter_callback )(void)
 This function is called after the library has made capacitive measurements, but before it has processed them. The user can use this hook to apply filter functions to the measured signal values. More...
 
qt_touch_lib_measure_data_t qt_measure_data
 
uint16_t qt_measurement_period_msec
 
sensor_t sensors [QT_NUM_CHANNELS]