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/
Author
Microchip Technology Inc: http://www.microchip.com
#include "parts.h"
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include "touch_qt_config.h"

Data Structures

struct  qt_lib_sig_info_t
 This will be used to get the library information from the library. More...
 
struct  tag_qt_touch_lib_config_data_t
 post processing configuration data that is received from the debug interface. More...
 
struct  tag_qt_touch_lib_measure_data_t
 measured touch data that is sent for the debugging and fine tunning. More...
 
struct  tag_qt_touch_status_t
 The state of the library sensors. More...
 
struct  tag_sensor_t
 

Macros

#define BURST_FUNC_NAME   BURST_JOIN( _STATIC_PORT_PIN_CONF_, QTOUCH_SNS_PORT_COUNT, INTRABURST_1, INTRABURST_2, _POWER_OPTIMIZATION_, QTOUCH_PIN_CONF )
 Build pointer to correct burst function. More...
 
#define BURST_JOIN(static_flag, num_ports, intra1, intra2, pow_opt, qtouch_pin_conf)   JOIN4( static_flag, num_ports, intra1, intra2, pow_opt, qtouch_pin_conf )
 
#define CALCULATE_MASKS   calc_masks
 This part of the code below is used for library selection. More...
 
#define CONCAT(A, B, C)   JOIN1( A, B, C )
 
#define DEF_QT_DI   4u
 Initialization values for the Qtouch library parameters. More...
 
#define DEF_QT_DRIFT_HOLD_TIME   20 /* 4s */
 Sensor drift hold time. More...
 
#define DEF_QT_MAX_ON_DURATION   0 /* disabled */
 Sensor maximum on duration. More...
 
#define DEF_QT_NEG_DRIFT_RATE   20 /* 4s per LSB */
 Sensor negative drift rate. More...
 
#define DEF_QT_POS_DRIFT_RATE   5 /* 1s per LSB */
 Sensor positive drift rate. More...
 
#define DEF_QT_POS_RECAL_DELAY   3u
 Positive recalibration delay. More...
 
#define DEF_QT_RECAL_THRESHOLD   RECAL_50 /* recal threshold = 50% of detect */
 Sensor recalibration threshold. More...
 
#define JOIN(x, y)   x ## y
 WARNING! Do not edit below this line. More...
 
#define JOIN1(A, B, C)   A ## B ## C
 
#define JOIN4(a, b, c, d, e, f)   burst_ ## a ## _ ## b ## _ ## c ## d ## _ ## e ##_ ## f
 Macros for string concatenation. More...
 
#define qt_init_sensing()   qt_init_sensing_with_burst( BURST_FUNC_NAME ,CALCULATE_MASKS)
 initialise touch sensing. More...
 
#define QT_MAX_NUM_ROTORS_SLIDERS   0
 
#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
 indicating that reburst is needed to resolve in FILTERIN or FILTEROUT or RECALIBRATE state. More...
 
#define QTLIB_CHANNEL_REF_CHANGE   (uint16_t) 0x0008
 indicating that at least one reference value has changed since last call to measure_sensors. More...
 
#define QTLIB_IN_DETECT   (uint16_t) 0x0001
 indicating that at least one sensor is in detect. More...
 
#define QTLIB_NO_ACTIVITY   (uint16_t) 0x0000
 Status flags used with debug. More...
 
#define QTLIB_RESOLVE_CAL   (uint16_t) 0x0200
 indicating that reburst is needed to resolve in CALIBRATION. More...
 
#define QTLIB_RESOLVE_DI   (uint16_t) 0x0800
 indicating that reburst is needed to resolve in RECAL. More...
 
#define QTLIB_RESOLVE_FILTERIN   (uint16_t) 0x0400
 indicating that reburst is needed to resolve in FILTERING. More...
 
#define QTLIB_RESOLVE_POS_RECAL   (uint16_t) 0x1000
 indicating that reburst is needed to resolve in RECAL. More...
 
#define QTLIB_ROTOR_SLIDER_POS_CHANGE   (uint16_t) 0x0004
 indicating that at least one rotor slider has changed position since last call to measure_sensors. More...
 
#define QTLIB_STATUS_CHANGE   (uint16_t) 0x0002
 indicating that at least one sensor haschanged ON/OFF state since last call to measure_sensors. More...
 
#define REG(REGISTER, SIDE)   JOIN( REGISTER, SIDE )
 Macro to build register writes for controlling ports. More...
 
#define SNS1   SNS
 
#define SNSK1   SNSK
 
#define TICKS_PER_MS   500u
 QTouch libraries are supplied built with a range of charge times. More...
 
#define TOUCH_DATA_T   uint8_t
 

Typedefs

typedef enum tag_aks_group_t aks_group_t
 Which AKS group, if any, a sensor is in. More...
 
typedef enum tag_channel_t channel_t
 The channel(s) in a sensor. More...
 
typedef enum tag_hysteresis_t hysteresis_t
 A sensor detection hysteresis value. More...
 
typedef struct qt_lib_sig_info_t qt_lib_siginfo_t
 This will be used to get the library information from the library. More...
 
typedef struct
tag_qt_touch_lib_config_data_t 
qt_touch_lib_config_data_t
 post processing configuration data that is received from the debug interface. More...
 
typedef struct
tag_qt_touch_lib_measure_data_t 
qt_touch_lib_measure_data_t
 measured touch data that is sent for the debugging and fine tunning. More...
 
typedef struct
tag_qt_touch_status_t 
qt_touch_status_t
 The state of the library sensors. More...
 
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
 Options for the sensor types available. More...
 
typedef uint8_t threshold_t
 QMATRIX Start. More...
 

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_channel_t
 The channel(s) in a sensor. More...
 
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 = 0,
  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
}
 Options for the sensor types available. More...
 

Functions

void BURST_FUNC_NAME (TOUCH_DATA_T mask_index)
 Burst function prototype. The code itself is stored in the touch library. More...
 
void calc_masks (void)
 
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_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 (void(*burst_function)(TOUCH_DATA_T mask_index), void(*calculate_masks)(void))
 
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 )(TOUCH_DATA_T mask_index)
 Function pointer used for bursting. More...
 
uint16_t lib_status_flags
 variable holding the status flags. 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
 measurement data. More...
 
uint16_t qt_measurement_period_msec
 timer period in msec. More...
 
sensor_t sensors [QT_NUM_CHANNELS]
 the library sensors. More...