Atmel Software Framework

xmega/applications/xmega_a3bu_xplained_demo/qtouch/touch_api.h File Reference
#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_ )
 
#define BURST_JOIN(static_flag, num_ports, intra1, intra2, pow_opt)   JOIN3( static_flag, num_ports, intra1, intra2, pow_opt )
 
#define CALCULATE_MASKS   NULL
 
#define CONCAT(A, B, C)   JOIN1( A, B, C )
 
#define DEF_QT_DI   4
 
#define DEF_QT_DRIFT_HOLD_TIME   20 /* 4s */
 
#define DEF_QT_MAX_ON_DURATION   0 /* disabled */
 
#define DEF_QT_NEG_DRIFT_RATE   20 /* 4s per LSB */
 
#define DEF_QT_POS_DRIFT_RATE   5 /* 1s per LSB */
 
#define DEF_QT_POS_RECAL_DELAY   3
 
#define DEF_QT_RECAL_THRESHOLD   RECAL_50 /* recal threshold = 50% of detect */
 
#define JOIN(x, y)   x ## y
 
#define JOIN1(A, B, C)   A ## B ## C
 
#define JOIN3(a, b, c, d, e)   burst_ ## a ## _ ## b ## _ ## c ## d ## _ ## e
 
#define qt_init_sensing()   qt_init_sensing_with_burst( BURST_FUNC_NAME ,CALCULATE_MASKS)
 
#define QT_MAX_NUM_ROTORS_SLIDERS   0
 
#define QT_NUM_SENSOR_STATE_BYTES   ( ( QT_NUM_CHANNELS + 7u ) / 8u )
 
#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
 
#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 )
 
#define TICKS_PER_MS   500u
 
#define TOUCH_DATA_T   uint8_t
 

Typedefs

typedef enum tag_aks_group_t aks_group_t
 
typedef enum tag_channel_t channel_t
 
typedef enum tag_hysteresis_t hysteresis_t
 
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
 
typedef enum tag_resolution_t resolution_t
 
typedef struct tag_sensor_t sensor_t
 
typedef enum tag_sensor_type_t sensor_type_t
 
typedef uint8_t threshold_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,
  NO_AKS_GROUP,
  AKS_GROUP_1,
  AKS_GROUP_2,
  AKS_GROUP_3,
  AKS_GROUP_4,
  AKS_GROUP_5,
  AKS_GROUP_6,
  AKS_GROUP_7
}
 
enum  tag_channel_t {
  CHANNEL_0,
  CHANNEL_1,
  CHANNEL_2,
  CHANNEL_3,
  CHANNEL_0,
  CHANNEL_1,
  CHANNEL_2,
  CHANNEL_3
}
 
enum  tag_hysteresis_t {
  HYST_50,
  HYST_25,
  HYST_12_5,
  HYST_6_25,
  HYST_50,
  HYST_25,
  HYST_12_5,
  HYST_6_25
}
 
enum  tag_recal_threshold_t {
  RECAL_100 = 0,
  RECAL_50,
  RECAL_25,
  RECAL_12_5,
  RECAL_6_25,
  RECAL_100,
  RECAL_50,
  RECAL_25,
  RECAL_12_5,
  RECAL_6_25
}
 
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,
  RES_1_BIT,
  RES_2_BIT,
  RES_3_BIT,
  RES_4_BIT,
  RES_5_BIT,
  RES_6_BIT,
  RES_7_BIT,
  RES_8_BIT
}
 
enum  tag_sensor_type_t {
  SENSOR_TYPE_UNASSIGNED,
  SENSOR_TYPE_KEY,
  SENSOR_TYPE_ROTOR,
  SENSOR_TYPE_SLIDER,
  SENSOR_TYPE_UNASSIGNED,
  SENSOR_TYPE_KEY,
  SENSOR_TYPE_ROTOR,
  SENSOR_TYPE_SLIDER
}
 

Functions

void BURST_FUNC_NAME (TOUCH_DATA_T mask_index)
 
void calc_masks (void)
 
bool check_touch_key_pressed (void)
 Checks whether the QTouch key is pressed. More...
 
void qt_calibrate_sensing (void)
 
void qt_enable_key (channel_t channel, aks_group_t aks_group, threshold_t detect_threshold, hysteresis_t detect_hysteresis)
 
void qt_get_library_sig (qt_lib_siginfo_t *lib_sig_ptr)
 
int16_t qt_get_sensor_delta (uint8_t sensor)
 
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)
 
void qt_reset_sensing (void)
 
void touch_init (void)
 Configure QTouch library and measurement setup. More...
 

Variables

void(* burst_proc )(TOUCH_DATA_T mask_index)
 
uint16_t lib_status_flags
 
qt_touch_lib_config_data_t qt_config_data
 
void(* qt_filter_callback )(void)
 
qt_touch_lib_measure_data_t qt_measure_data
 
uint16_t qt_measurement_period_msec
 Timer period in msec. More...
 
sensor_t sensors [4]
 

#define BURST_JOIN (   static_flag,
  num_ports,
  intra1,
  intra2,
  pow_opt 
)    JOIN3( static_flag, num_ports, intra1, intra2, pow_opt )
#define CALCULATE_MASKS   NULL
#define CONCAT (   A,
  B,
 
)    JOIN1( A, B, C )
#define DEF_QT_DI   4
#define DEF_QT_DRIFT_HOLD_TIME   20 /* 4s */
#define DEF_QT_MAX_ON_DURATION   0 /* disabled */
#define DEF_QT_NEG_DRIFT_RATE   20 /* 4s per LSB */
#define DEF_QT_POS_DRIFT_RATE   5 /* 1s per LSB */
#define DEF_QT_POS_RECAL_DELAY   3
#define DEF_QT_RECAL_THRESHOLD   RECAL_50 /* recal threshold = 50% of detect */
#define JOIN (   x,
 
)    x ## y
#define JOIN1 (   A,
  B,
 
)    A ## B ## C
#define JOIN3 (   a,
  b,
  c,
  d,
 
)    burst_ ## a ## _ ## b ## _ ## c ## d ## _ ## e
#define qt_init_sensing ( )    qt_init_sensing_with_burst( BURST_FUNC_NAME ,CALCULATE_MASKS)
#define QT_MAX_NUM_ROTORS_SLIDERS   0
#define QT_NUM_SENSOR_STATE_BYTES   ( ( QT_NUM_CHANNELS + 7u ) / 8u )
#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
#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 )
#define TICKS_PER_MS   500u
#define TOUCH_DATA_T   uint8_t

typedef enum tag_channel_t channel_t
typedef struct tag_sensor_t sensor_t
typedef uint8_t threshold_t

Enumerator
NO_AKS_GROUP 
AKS_GROUP_1 
AKS_GROUP_2 
AKS_GROUP_3 
AKS_GROUP_4 
AKS_GROUP_5 
AKS_GROUP_6 
AKS_GROUP_7 
NO_AKS_GROUP 
AKS_GROUP_1 
AKS_GROUP_2 
AKS_GROUP_3 
AKS_GROUP_4 
AKS_GROUP_5 
AKS_GROUP_6 
AKS_GROUP_7 
Enumerator
CHANNEL_0 
CHANNEL_1 
CHANNEL_2 
CHANNEL_3 
CHANNEL_0 
CHANNEL_1 
CHANNEL_2 
CHANNEL_3 
Enumerator
HYST_50 
HYST_25 
HYST_12_5 
HYST_6_25 
HYST_50 
HYST_25 
HYST_12_5 
HYST_6_25 
Enumerator
RECAL_100 
RECAL_50 
RECAL_25 
RECAL_12_5 
RECAL_6_25 
RECAL_100 
RECAL_50 
RECAL_25 
RECAL_12_5 
RECAL_6_25 
Enumerator
RES_1_BIT 
RES_2_BIT 
RES_3_BIT 
RES_4_BIT 
RES_5_BIT 
RES_6_BIT 
RES_7_BIT 
RES_8_BIT 
RES_1_BIT 
RES_2_BIT 
RES_3_BIT 
RES_4_BIT 
RES_5_BIT 
RES_6_BIT 
RES_7_BIT 
RES_8_BIT 
Enumerator
SENSOR_TYPE_UNASSIGNED 
SENSOR_TYPE_KEY 
SENSOR_TYPE_ROTOR 
SENSOR_TYPE_SLIDER 
SENSOR_TYPE_UNASSIGNED 
SENSOR_TYPE_KEY 
SENSOR_TYPE_ROTOR 
SENSOR_TYPE_SLIDER 

void BURST_FUNC_NAME ( TOUCH_DATA_T  mask_index)
void calc_masks ( void  )
bool check_touch_key_pressed ( void  )
void qt_calibrate_sensing ( void  )
void qt_enable_key ( channel_t  channel,
aks_group_t  aks_group,
threshold_t  detect_threshold,
hysteresis_t  detect_hysteresis 
)
void qt_get_library_sig ( qt_lib_siginfo_t lib_sig_ptr)
int16_t qt_get_sensor_delta ( uint8_t  sensor)
void qt_init_sensing_with_burst ( void(*)(TOUCH_DATA_T mask_index)  burst_function,
void(*)(void)  calculate_masks 
)
uint16_t qt_measure_sensors ( uint16_t  current_time_ms)
void qt_reset_sensing ( void  )
void touch_init ( void  )

Configure QTouch library and measurement setup.

Configures touch library and measurement setup.

Configure QTouch library and measurement setup.

Precondition
Interrupts must be enabled in order to trigger regular measurements The touch configuration requires a fixed CPU speed to work properly in this case we need 2 MHz.

References config_sensor(), init_timer_isr(), QDebug_Init(), qt_filter_callback, qt_init_sensing, qt_set_parameters(), SNS_array, SNSK_array, touch_config_sensor(), touch_init_timer_isr(), and touch_set_parameters().

Referenced by main().

void(* burst_proc)(TOUCH_DATA_T mask_index)
uint16_t lib_status_flags
void(* qt_filter_callback)(void)
qt_touch_lib_measure_data_t qt_measure_data
sensor_t sensors[4]