Microchip® Advanced Software Framework

touch_api_SAMD.h File Reference

This file contains the SAMD QTouch Library API for Capacitive Touch acquisition using the PTC module.

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

#include "compiler.h"
#include "touch_config_samd.h"

Data Structures

struct  tag_sensor_t
 
struct  tag_touch_config_t
 
struct  tag_touch_filter_data_t
 
struct  tag_touch_global_param_t
 
struct  tag_touch_info_t
 
struct  tag_touch_measure_data_t
 
struct  tag_touch_mutlcap_acq_param_t
 Mutual capacitance sensor acquisition parameter type. More...
 
struct  tag_touch_mutlcap_config_t
 
struct  tag_touch_mutlcap_param_t
 
struct  tag_touch_selfcap_acq_param_t
 Self capacitance sensor acquisition parameter type. More...
 
struct  tag_touch_selfcap_config_t
 
struct  tag_touch_selfcap_param_t
 
struct  tag_touch_time_t
 

Functions

Touch Helper API.
touch_ret_t touch_sensors_init (void)
 This API is used to initialize and configure the Touch Library. More...
 
touch_ret_t touch_sensors_measure (void)
 This API is used to perform a Single Capacitance measurement using the Touch Library. More...
 
void touch_sensors_update_time (void)
 This API is used to update Timing info for Touch Library. Typical usage of this API is inside a periodic timer ISR. More...
 
Touch Library internal use functions.
void touch_mutlcap_rs_table_init (void)
 This is an extern function of the Touch Library. This function is NOT to be used by the user. More...
 
void touch_selfcap_rs_table_init (void)
 

Touch Library Acquisition Status bitfields.

#define TOUCH_NO_ACTIVITY   (0x0000u) /* !< No Touch activity. */
 
#define TOUCH_IN_DETECT
 
#define TOUCH_STATUS_CHANGE
 
#define TOUCH_ROTOR_SLIDER_POS_CHANGE
 
#define TOUCH_CHANNEL_REF_CHANGE
 
#define TOUCH_BURST_AGAIN
 
#define TOUCH_RESOLVE_CAL
 
#define TOUCH_RESOLVE_FILTERIN
 
#define TOUCH_RESOLVE_DI
 
#define TOUCH_RESOLVE_POS_RECAL
 
#define GET_SELFCAP_SENSOR_STATE(SENSOR_NUMBER)
 
#define GET_MUTLCAP_SENSOR_STATE(SENSOR_NUMBER)
 
#define GET_SELFCAP_ROTOR_SLIDER_POSITION(ROTOR_SLIDER_NUMBER)
 
#define GET_MUTLCAP_ROTOR_SLIDER_POSITION(ROTOR_SLIDER_NUMBER)
 
#define X(n)   (uint16_t)(1u << n)
 Calculate X line bit position. More...
 
#define Y(n)   (uint16_t)(1u << n)
 Calculate Y line bit position. More...
 
#define TOUCH_MAX_POS_HYST   (7u)
 Max position hysteresis allowed. More...
 
enum  tag_gain_t {
  GAIN_1,
  GAIN_2,
  GAIN_4,
  GAIN_8,
  GAIN_16,
  GAIN_32
}
 
enum  tag_filter_level_t {
  FILTER_LEVEL_1,
  FILTER_LEVEL_2,
  FILTER_LEVEL_4,
  FILTER_LEVEL_8,
  FILTER_LEVEL_16,
  FILTER_LEVEL_32,
  FILTER_LEVEL_64
}
 
enum  tag_auto_os_t {
  AUTO_OS_DISABLE,
  AUTO_OS_2,
  AUTO_OS_4,
  AUTO_OS_8,
  AUTO_OS_16,
  AUTO_OS_32,
  AUTO_OS_64,
  AUTO_OS_128
}
 
enum  tag_touch_ret_t {
  TOUCH_SUCCESS,
  TOUCH_ACQ_INCOMPLETE,
  TOUCH_INVALID_INPUT_PARAM,
  TOUCH_INVALID_LIB_STATE,
  TOUCH_INVALID_SELFCAP_CONFIG_PARAM,
  TOUCH_INVALID_MUTLCAP_CONFIG_PARAM,
  TOUCH_INVALID_RECAL_THRESHOLD,
  TOUCH_INVALID_CHANNEL_NUM,
  TOUCH_INVALID_SENSOR_TYPE,
  TOUCH_INVALID_SENSOR_ID,
  TOUCH_INVALID_RS_NUM
}
 
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,
  CHANNEL_32,
  CHANNEL_33,
  CHANNEL_34,
  CHANNEL_35,
  CHANNEL_36,
  CHANNEL_37,
  CHANNEL_38,
  CHANNEL_39,
  CHANNEL_40,
  CHANNEL_41,
  CHANNEL_42,
  CHANNEL_43,
  CHANNEL_44,
  CHANNEL_45,
  CHANNEL_46,
  CHANNEL_47,
  CHANNEL_48,
  CHANNEL_49,
  CHANNEL_50,
  CHANNEL_51,
  CHANNEL_52,
  CHANNEL_53,
  CHANNEL_54,
  CHANNEL_55,
  CHANNEL_56,
  CHANNEL_57,
  CHANNEL_58,
  CHANNEL_59,
  CHANNEL_60,
  CHANNEL_61,
  CHANNEL_62,
  CHANNEL_63,
  CHANNEL_64,
  CHANNEL_65,
  CHANNEL_66,
  CHANNEL_67,
  CHANNEL_68,
  CHANNEL_69,
  CHANNEL_70,
  CHANNEL_71,
  CHANNEL_72,
  CHANNEL_73,
  CHANNEL_74,
  CHANNEL_75,
  CHANNEL_76,
  CHANNEL_77,
  CHANNEL_78,
  CHANNEL_79,
  CHANNEL_80,
  CHANNEL_81,
  CHANNEL_82,
  CHANNEL_83,
  CHANNEL_84,
  CHANNEL_85,
  CHANNEL_86,
  CHANNEL_87,
  CHANNEL_88,
  CHANNEL_89,
  CHANNEL_90,
  CHANNEL_91,
  CHANNEL_92,
  CHANNEL_93,
  CHANNEL_94,
  CHANNEL_95,
  CHANNEL_96,
  CHANNEL_97,
  CHANNEL_98,
  CHANNEL_99,
  CHANNEL_100,
  CHANNEL_101,
  CHANNEL_102,
  CHANNEL_103,
  CHANNEL_104,
  CHANNEL_105,
  CHANNEL_106,
  CHANNEL_107,
  CHANNEL_108,
  CHANNEL_109,
  CHANNEL_110,
  CHANNEL_111,
  CHANNEL_112,
  CHANNEL_113,
  CHANNEL_114,
  CHANNEL_115,
  CHANNEL_116,
  CHANNEL_117,
  CHANNEL_118,
  CHANNEL_119,
  CHANNEL_120,
  CHANNEL_121,
  CHANNEL_122,
  CHANNEL_123,
  CHANNEL_124,
  CHANNEL_125,
  CHANNEL_126,
  CHANNEL_127,
  CHANNEL_128,
  CHANNEL_129,
  CHANNEL_130,
  CHANNEL_131,
  CHANNEL_132,
  CHANNEL_133,
  CHANNEL_134,
  CHANNEL_135,
  CHANNEL_136,
  CHANNEL_137,
  CHANNEL_138,
  CHANNEL_139,
  CHANNEL_140,
  CHANNEL_141,
  CHANNEL_142,
  CHANNEL_143,
  CHANNEL_144,
  CHANNEL_145,
  CHANNEL_146,
  CHANNEL_147,
  CHANNEL_148,
  CHANNEL_149,
  CHANNEL_150,
  CHANNEL_151,
  CHANNEL_152,
  CHANNEL_153,
  CHANNEL_154,
  CHANNEL_155,
  CHANNEL_156,
  CHANNEL_157,
  CHANNEL_158,
  CHANNEL_159,
  CHANNEL_160,
  CHANNEL_161,
  CHANNEL_162,
  CHANNEL_163,
  CHANNEL_164,
  CHANNEL_165,
  CHANNEL_166,
  CHANNEL_167,
  CHANNEL_168,
  CHANNEL_169,
  CHANNEL_170,
  CHANNEL_171,
  CHANNEL_172,
  CHANNEL_173,
  CHANNEL_174,
  CHANNEL_175,
  CHANNEL_176,
  CHANNEL_177,
  CHANNEL_178,
  CHANNEL_179,
  CHANNEL_180,
  CHANNEL_181,
  CHANNEL_182,
  CHANNEL_183,
  CHANNEL_184,
  CHANNEL_185,
  CHANNEL_186,
  CHANNEL_187,
  CHANNEL_188,
  CHANNEL_189,
  CHANNEL_190,
  CHANNEL_191,
  CHANNEL_192,
  CHANNEL_193,
  CHANNEL_194,
  CHANNEL_195,
  CHANNEL_196,
  CHANNEL_197,
  CHANNEL_198,
  CHANNEL_199,
  CHANNEL_200,
  CHANNEL_201,
  CHANNEL_202,
  CHANNEL_203,
  CHANNEL_204,
  CHANNEL_205,
  CHANNEL_206,
  CHANNEL_207,
  CHANNEL_208,
  CHANNEL_209,
  CHANNEL_210,
  CHANNEL_211,
  CHANNEL_212,
  CHANNEL_213,
  CHANNEL_214,
  CHANNEL_215,
  CHANNEL_216,
  CHANNEL_217,
  CHANNEL_218,
  CHANNEL_219,
  CHANNEL_220,
  CHANNEL_221,
  CHANNEL_222,
  CHANNEL_223,
  CHANNEL_224,
  CHANNEL_225,
  CHANNEL_226,
  CHANNEL_227,
  CHANNEL_228,
  CHANNEL_229,
  CHANNEL_230,
  CHANNEL_231,
  CHANNEL_232,
  CHANNEL_233,
  CHANNEL_234,
  CHANNEL_235,
  CHANNEL_236,
  CHANNEL_237,
  CHANNEL_238,
  CHANNEL_239,
  CHANNEL_240,
  CHANNEL_241,
  CHANNEL_242,
  CHANNEL_243,
  CHANNEL_244,
  CHANNEL_245,
  CHANNEL_246,
  CHANNEL_247,
  CHANNEL_248,
  CHANNEL_249,
  CHANNEL_250,
  CHANNEL_251,
  CHANNEL_252,
  CHANNEL_253,
  CHANNEL_254,
  CHANNEL_255
}
 
enum  tag_touch_lib_state_t {
  TOUCH_STATE_NULL,
  TOUCH_STATE_INIT,
  TOUCH_STATE_READY,
  TOUCH_STATE_CALIBRATE,
  TOUCH_STATE_BUSY
}
 
enum  tag_sensor_type_t {
  SENSOR_TYPE_UNASSIGNED,
  SENSOR_TYPE_KEY,
  SENSOR_TYPE_ROTOR,
  SENSOR_TYPE_SLIDER,
  MAX_SENSOR_TYPE
}
 
enum  tag_touch_acq_mode_t {
  RAW_ACQ_MODE,
  NORMAL_ACQ_MODE
}
 
enum  tag_auto_tune_type_t {
  AUTO_TUNE_NONE,
  AUTO_TUNE_PRSC,
  AUTO_TUNE_RSEL
}
 
enum  tag_freq_mode_sel_t {
  FREQ_MODE_NONE,
  FREQ_MODE_HOP,
  FREQ_MODE_SPREAD,
  FREQ_MODE_SPREAD_MEDIAN
}
 PTC frequency mode setting. More...
 
enum  tag_prsc_div_sel_t {
  PRSC_DIV_SEL_1,
  PRSC_DIV_SEL_2,
  PRSC_DIV_SEL_4,
  PRSC_DIV_SEL_8
}
 PTC clock prescale setting. More...
 
enum  tag_rsel_val_t {
  RSEL_VAL_0,
  RSEL_VAL_20,
  RSEL_VAL_50,
  RSEL_VAL_100
}
 PTC series resistor setting. More...
 
enum  tag_freq_hop_sel_t {
  FREQ_HOP_SEL_1,
  FREQ_HOP_SEL_2,
  FREQ_HOP_SEL_3,
  FREQ_HOP_SEL_4,
  FREQ_HOP_SEL_5,
  FREQ_HOP_SEL_6,
  FREQ_HOP_SEL_7,
  FREQ_HOP_SEL_8,
  FREQ_HOP_SEL_9,
  FREQ_HOP_SEL_10,
  FREQ_HOP_SEL_11,
  FREQ_HOP_SEL_12,
  FREQ_HOP_SEL_13,
  FREQ_HOP_SEL_14,
  FREQ_HOP_SEL_15,
  FREQ_HOP_SEL_16
}
 PTC acquisition frequency delay setting. More...
 
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,
  MAX_AKS_GROUP
}
 Which AKS group, if any, a sensor is in. More...
 
enum  tag_hysteresis_t {
  HYST_50,
  HYST_25,
  HYST_12_5,
  HYST_6_25,
  MAX_HYST
}
 A sensor detection hysteresis value. More...
 
enum  tag_recal_threshold_t {
  RECAL_100,
  RECAL_50,
  RECAL_25,
  RECAL_12_5,
  RECAL_6_25,
  MAX_RECAL
}
 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,
  MAX_RES
}
 For rotors and sliders, the resolution of the reported angle or position. More...
 
typedef uint8_t threshold_t
 
typedef uint8_t sensor_id_t
 
typedef uint16_t touch_current_time_t
 
typedef int16_t touch_delta_t
 
typedef uint16_t touch_acq_status_t
 
typedef enum tag_gain_t gain_t
 
typedef enum tag_filter_level_t filter_level_t
 
typedef enum tag_auto_os_t auto_os_t
 
typedef enum tag_touch_ret_t touch_ret_t
 
typedef enum tag_channel_t channel_t
 
typedef enum tag_touch_lib_state_t touch_lib_state_t
 
typedef enum tag_sensor_type_t sensor_type_t
 
typedef enum tag_touch_acq_mode_t touch_acq_mode_t
 
typedef enum tag_auto_tune_type_t auto_tune_type_t
 
typedef enum tag_freq_mode_sel_t freq_mode_sel_t
 PTC frequency mode setting. More...
 
typedef enum tag_prsc_div_sel_t prsc_div_sel_t
 PTC clock prescale setting. More...
 
typedef enum tag_rsel_val_t rsel_val_t
 PTC series resistor setting. More...
 
typedef enum tag_freq_hop_sel_t freq_hop_sel_t
 PTC acquisition frequency delay setting. More...
 
typedef enum tag_aks_group_t aks_group_t
 Which AKS group, if any, a sensor is in. More...
 
typedef enum tag_hysteresis_t hysteresis_t
 A sensor detection hysteresis value. 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_touch_time_t touch_time_t
 
typedef struct tag_sensor_t sensor_t
 
typedef struct
tag_touch_global_param_t 
touch_global_param_t
 
typedef struct
tag_touch_filter_data_t 
touch_filter_data_t
 
typedef struct
tag_touch_measure_data_t 
touch_measure_data_t
 
typedef struct
tag_touch_selfcap_param_t 
touch_selfcap_param_t
 
typedef struct
tag_touch_mutlcap_param_t 
touch_mutlcap_param_t
 
typedef struct
tag_touch_mutlcap_acq_param_t 
touch_mutlcap_acq_param_t
 Mutual capacitance sensor acquisition parameter type. More...
 
typedef struct
tag_touch_selfcap_acq_param_t 
touch_selfcap_acq_param_t
 Self capacitance sensor acquisition parameter type. More...
 
typedef struct
tag_touch_selfcap_config_t 
touch_selfcap_config_t
 
typedef struct
tag_touch_mutlcap_config_t 
touch_mutlcap_config_t
 
typedef struct tag_touch_config_t touch_config_t
 
typedef struct tag_touch_info_t touch_info_t
 
touch_time_t touch_time
 
touch_measure_data_tp_selfcap_measure_data
 Self Cap sensors measured data pointer. More...
 
touch_measure_data_tp_mutlcap_measure_data
 Mutual Cap sensors measured data pointer. More...
 

Touch API.

#define touch_mutlcap_sensors_init(y)
 touch_ret_t touch_mutlcap_sensors_init( touch_config_t *p_touch_config); More...
 
#define touch_selfcap_sensors_init(y)
 touch_ret_t touch_selfcap_sensors_init( touch_config_t *p_touch_config); More...
 
touch_ret_t touch_mutlcap_sensors_init_with_rs_table (touch_config_t *p_touch_config, void(*rs_table_init)(void))
 This API is used to initialize the Touch Library with Mutual cap method pin, register and sensor configuration provided by the user. More...
 
touch_ret_t touch_selfcap_sensors_init_with_rs_table (touch_config_t *p_touch_config, void(*rs_table_init)(void))
 This API is used to initialize the Touch Library with Self cap method pin, register and sensor configuration provided by the user. More...
 
touch_ret_t touch_mutlcap_sensor_config (sensor_type_t sensor_type, 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, sensor_id_t *p_sensor_id)
 This API can be used to configure a sensor of type key, rotor or slider. More...
 
touch_ret_t touch_selfcap_sensor_config (sensor_type_t sensor_type, 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, sensor_id_t *p_sensor_id)
 
touch_ret_t touch_mutlcap_sensors_calibrate (auto_tune_type_t)
 This API is used to calibrate the sensors for the first time before starting a Touch measurement. This API can also be used to force calibration of sensors when any of the Touch sensor parameters are changed during runtime. More...
 
touch_ret_t touch_selfcap_sensors_calibrate (auto_tune_type_t)
 
touch_ret_t touch_selfcap_sensors_measure (touch_current_time_t current_time_ms, touch_acq_mode_t selfcap_acq_mode, void(*measure_complete_callback)(void))
 This API can be used to start a Touch measurement. More...
 
touch_ret_t touch_mutlcap_sensors_measure (touch_current_time_t current_time_ms, touch_acq_mode_t mutlcap_acq_mode, void(*measure_complete_callback)(void))
 
touch_ret_t touch_mutlcap_sensor_get_delta (sensor_id_t sensor_id, touch_delta_t *p_delta)
 This API can be used retrieve the delta value corresponding to a given sensor. More...
 
touch_ret_t touch_selfcap_sensor_get_delta (sensor_id_t sensor_id, touch_delta_t *p_delta)
 
touch_ret_t touch_mutlcap_sensor_update_config (sensor_id_t sensor_id, touch_mutlcap_param_t *p_touch_sensor_param)
 This API can be used to set the sensor configuration parameters. More...
 
touch_ret_t touch_selfcap_sensor_update_config (sensor_id_t sensor_id, touch_selfcap_param_t *p_touch_sensor_param)
 
touch_ret_t touch_mutlcap_sensor_get_config (sensor_id_t sensor_id, touch_mutlcap_param_t *p_touch_sensor_param)
 This API can be used to read back the sensor configuration parameters. More...
 
touch_ret_t touch_selfcap_sensor_get_config (sensor_id_t sensor_id, touch_selfcap_param_t *p_touch_sensor_param)
 
touch_ret_t touch_mutlcap_sensor_update_acq_config (touch_mutlcap_acq_param_t *p_touch_mutlcap_acq_param)
 This API can be used to set the sensor configuration parameters. More...
 
touch_ret_t touch_selfcap_sensor_update_acq_config (touch_selfcap_acq_param_t *p_touch_selfcap_acq_param)
 
touch_ret_t touch_mutlcap_sensor_get_acq_config (touch_mutlcap_acq_param_t *p_touch_mutlcap_acq_param)
 This API can be used to read back the sensor configuration parameters. More...
 
touch_ret_t touch_selfcap_sensor_get_acq_config (touch_selfcap_acq_param_t *p_touch_selfcap_acq_param)
 
touch_ret_t touch_mutlcap_update_global_param (touch_global_param_t *p_global_param)
 This API can be used to update the global parameter. More...
 
touch_ret_t touch_selfcap_update_global_param (touch_global_param_t *p_global_param)
 
touch_ret_t touch_mutlcap_get_global_param (touch_global_param_t *p_global_param)
 This API can be used to read back the global parameter. More...
 
touch_ret_t touch_selfcap_get_global_param (touch_global_param_t *p_global_param)
 
touch_ret_t touch_mutlcap_sensor_disable (sensor_id_t sensor_id)
 This API can be used to disable any sensor. More...
 
touch_ret_t touch_selfcap_sensor_disable (sensor_id_t sensor_id)
 
touch_ret_t touch_mutlcap_sensor_reenable (sensor_id_t sensor_id)
 This API can be used to reenable a disabled sensor. More...
 
touch_ret_t touch_selfcap_sensor_reenable (sensor_id_t sensor_id)
 
touch_ret_t touch_mutlcap_get_libinfo (touch_info_t *p_touch_info)
 This API can be used to get the Touch Library configuration. More...
 
touch_ret_t touch_selfcap_get_libinfo (touch_info_t *p_touch_info)