Microchip® Advanced Software Framework

touch_api_sam4l.h File Reference

This file contains the SAM4L QTouch Libary API interface for QMatrix, QTouch and Autonomous Touch method using the Capacitive Touch (CATB) module.

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

#include <exceptions.h>
#include <compiler.h>
#include <status_codes.h>
#include <parts.h>
#include "touch_config_sam4l.h"

Data Structures

struct  tag_sensor_t
 Sensor structure for storing sensor related information. More...
 
struct  tag_touch_at_config_t
 Autonomous Touch configuration input. More...
 
struct  tag_touch_at_pin_t
 Autonomous Touch pin configuration type. More...
 
struct  tag_touch_at_reg_t
 Autonomous Touch register configuration type. More...
 
struct  tag_touch_at_status_t
 Autonomous QTouch status type. More...
 
struct  tag_touch_config_t
 Touch Input Configuration type. More...
 
struct  tag_touch_filter_data_t
 Touch Filter Callback data type. More...
 
struct  tag_touch_global_param_t
 Global sensor configuration info. More...
 
struct  tag_touch_info_t
 Touch library information type. More...
 
struct  tag_touch_measure_data_t
 Touch Measured data type. More...
 
struct  tag_touch_qt_config_t
 QTouch configuration input. More...
 
struct  tag_touch_qt_dma_t
 QTouch dma type. More...
 
struct  tag_touch_qt_param_t
 QTouch sensor configuration type. More...
 
struct  tag_touch_qt_pin_t
 QTouch pin configuration type. More...
 
struct  tag_touch_qt_reg_t
 QTouch register configuration type. More...
 
struct  tag_touch_qt_time_t
 QTouch Library Timing info. More...
 

Macros

#define GET_QT_ROTOR_SLIDER_POSITION(ROTOR_SLIDER_NUMBER)   p_qt_measure_data->p_rotor_slider_values[ROTOR_SLIDER_NUMBER]
 
#define GET_QT_SENSOR_STATE(SENSOR_NUMBER)   p_qt_measure_data->p_sensor_states[(SENSOR_NUMBER/8)] & (1 << (SENSOR_NUMBER % 8))
 
#define PRIV_QT_DATA_BLK_SIZE
 QTouch Data block size. More...
 
#define PRIV_QT_PAD_BYTE_SIZE   (36u)
 Size of QTouch Pad bytes. More...
 
#define PRIV_QT_RS_TABLE_INIT   touch_qt_rs_table_init
 Initialize rotor slider table. More...
 
#define PRIV_QT_SIZE_CHANNEL   (25u)
 Size of QTouch Channel. More...
 
#define PRIV_QT_SIZE_RS   (13u)
 Size of QTouch Rotor Slider. More...
 
#define PRIV_QT_SIZE_SENSOR   (8u)
 Size of QTouch Sensor. More...
 
#define QT_NUM_CHANNELS   (QT_NUM_SENSOR_PINS_SELECTED)
 QTouch number of channels. More...
 
QTouch Library Acquisition Status bitfields.
#define TOUCH_NO_ACTIVITY   (0x0000u)
 No Touch activity. More...
 
#define TOUCH_IN_DETECT   (0x0001u)
 Atleast one Touch channel is in detect. More...
 
#define TOUCH_STATUS_CHANGE   (0x0002u)
 Change in Touch status of atleast one Touch channel. More...
 
#define TOUCH_ROTOR_SLIDER_POS_CHANGE   (0x0004u)
 Change in Rotor or Slider position of atleast one rotor or slider. More...
 
#define TOUCH_CHANNEL_REF_CHANGE   (0x0008u)
 Change in Reference value of atleast one Touch channel. More...
 
#define TOUCH_BURST_AGAIN   (0x0100u)
 Indicates that reburst is required to resolve Filtering or Calibration state. More...
 
#define TOUCH_RESOLVE_CAL   (0x0200u)
 Indicates that reburst is needed to resolve Calibration. More...
 
#define TOUCH_RESOLVE_FILTERIN   (0x0400u)
 Indicates that reburst is needed to resolve Filtering. More...
 
#define TOUCH_RESOLVE_DI   (0x0800u)
 Indicates that reburst is needed to resolve Detect Integration. More...
 
#define TOUCH_RESOLVE_POS_RECAL   (0x1000u)
 Indicates that reburst is needed to resolve Recalibration. More...
 

Typedefs

typedef enum tag_aks_group_t aks_group_t
 Which AKS group, if any, a sensor is in. More...
 
typedef enum tag_at_status_change_t at_status_change_t
 Autonomous Touch status change enum. More...
 
typedef uint8_t channel_t
 Sensor start and end channel type of a Sensor. Channel number starts with value 0. More...
 
typedef enum tag_hysteresis_t hysteresis_t
 A sensor detection hysteresis value. More...
 
typedef enum
tag_qt_discharge_pin_options_t 
qt_discharge_pin_options_t
 QTouch Pin options available. More...
 
typedef enum
tag_qt_sensor_pin_options_t 
qt_sensor_pin_options_t
 QTouch Pin options available. 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 uint8_t sensor_id_t
 Sensor number type. More...
 
typedef struct tag_sensor_t sensor_t
 Sensor structure for storing sensor related information. More...
 
typedef enum tag_sensor_type_t sensor_type_t
 Sensor types available. More...
 
typedef uint8_t threshold_t
 An unsigned 8-bit number setting a sensor detection threshold. More...
 
typedef enum tag_touch_acq_mode_t touch_acq_mode_t
 Touch library acquisition mode. More...
 
typedef uint16_t touch_acq_status_t
 Status of Touch measurement. More...
 
typedef struct
tag_touch_at_config_t 
touch_at_config_t
 Autonomous Touch configuration input. More...
 
typedef struct tag_touch_at_pin_t touch_at_pin_t
 Autonomous Touch pin configuration type. More...
 
typedef struct tag_touch_at_reg_t touch_at_reg_t
 Autonomous Touch register configuration type. More...
 
typedef struct
tag_touch_at_status_t 
touch_at_status
 Autonomous QTouch status type. More...
 
typedef uint8_t touch_bl_t
 QMatrix individual sensor burst length type. More...
 
typedef struct tag_touch_config_t touch_config_t
 Touch Input Configuration type. More...
 
typedef int16_t touch_delta_t
 Touch sensor delta value type. More...
 
typedef struct
tag_touch_filter_data_t 
touch_filter_data_t
 Touch Filter Callback data type. More...
 
typedef struct
tag_touch_global_param_t 
touch_global_param_t
 Global sensor configuration info. More...
 
typedef struct tag_touch_info_t touch_info_t
 Touch library information type. More...
 
typedef enum tag_touch_lib_state_t touch_lib_state_t
 Touch library state. More...
 
typedef struct
tag_touch_measure_data_t 
touch_measure_data_t
 Touch Measured data type. More...
 
typedef struct
tag_touch_qt_config_t 
touch_qt_config_t
 QTouch configuration input. More...
 
typedef struct tag_touch_qt_dma_t touch_qt_dma_t
 QTouch dma type. More...
 
typedef struct tag_touch_qt_param_t touch_qt_param_t
 QTouch sensor configuration type. More...
 
typedef struct tag_touch_qt_pin_t touch_qt_pin_t
 QTouch pin configuration type. More...
 
typedef struct tag_touch_qt_reg_t touch_qt_reg_t
 QTouch register configuration type. More...
 
typedef struct tag_touch_qt_time_t touch_qt_time_t
 QTouch Library Timing info. More...
 
typedef enum tag_touch_ret_t touch_ret_t
 Touch Library error codes. More...
 
typedef uint16_t touch_time_t
 Current time type. 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,
  MAX_AKS_GROUP
}
 Which AKS group, if any, a sensor is in. More...
 
enum  tag_at_status_change_t {
  OUT_OF_TOUCH,
  IN_TOUCH
}
 Autonomous Touch status change enum. 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_qt_discharge_pin_options_t {
  DIS_PA02,
  DIS_PA12,
  DIS_PA23,
  DIS_PA31,
  DIS_PB03,
  DIS_PB12,
  DIS_PC05,
  DIS_PC14,
  DIS_PC23
}
 QTouch Pin options available. More...
 
enum  tag_qt_sensor_pin_options_t {
  SP_PA04,
  SP_PA27,
  SP_PB13,
  SP_PA05,
  SP_PA28,
  SP_PB14,
  SP_PA06,
  SP_PA29,
  SP_PB15,
  SP_PA07,
  SP_PA30,
  SP_PC00,
  SP_PA08,
  SP_PC01,
  SP_PA09,
  SP_PC02,
  SP_PA10,
  SP_PC03,
  SP_PA11,
  SP_PC04,
  SP_PA13,
  SP_PC06,
  SP_PA14,
  SP_PC07,
  SP_PA15,
  SP_PC08,
  SP_PA16,
  SP_PC09,
  SP_PA17,
  SP_PC10,
  SP_PA18,
  SP_PC11,
  SP_PA19,
  SP_PC12,
  SP_PA20,
  SP_PC13,
  SP_PA21,
  SP_PC15,
  SP_PA22,
  SP_PC16,
  SP_PA24,
  SP_PC17,
  SP_PA25,
  SP_PC18,
  SP_PA26,
  SP_PC19,
  SP_PB00,
  SP_PC20,
  SP_PB01,
  SP_PC21,
  SP_PB02,
  SP_PC22,
  SP_PB04,
  SP_PC24,
  SP_PB05,
  SP_PC25,
  SP_PB06,
  SP_PC26,
  SP_PB07,
  SP_PC27,
  SP_PB08,
  SP_PC28,
  SP_PB09,
  SP_PC29,
  SP_PB10,
  SP_PC30,
  SP_PB11,
  SP_PC31
}
 QTouch Pin options available. 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...
 
enum  tag_sensor_type_t {
  SENSOR_TYPE_UNASSIGNED,
  SENSOR_TYPE_KEY,
  SENSOR_TYPE_ROTOR,
  SENSOR_TYPE_SLIDER,
  MAX_SENSOR_TYPE
}
 Sensor types available. More...
 
enum  tag_touch_acq_mode_t {
  RAW_ACQ_MODE,
  NORMAL_ACQ_MODE
}
 Touch library acquisition mode. More...
 
enum  tag_touch_lib_state_t {
  TOUCH_STATE_NULL,
  TOUCH_STATE_INIT,
  TOUCH_STATE_READY,
  TOUCH_STATE_CALIBRATE,
  TOUCH_STATE_BUSY
}
 Touch library state. More...
 
enum  tag_touch_ret_t {
  TOUCH_SUCCESS,
  TOUCH_ACQ_INCOMPLETE,
  TOUCH_INVALID_INPUT_PARAM,
  TOUCH_INVALID_LIB_STATE,
  TOUCH_INVALID_QT_CONFIG_PARAM,
  TOUCH_INVALID_RECAL_THRESHOLD,
  TOUCH_INVALID_CHANNEL_NUM,
  TOUCH_INVALID_SENSOR_TYPE,
  TOUCH_INVALID_SENSOR_ID,
  TOUCH_INVALID_DMA_PARAM,
  TOUCH_INVALID_RS_NUM,
  TOUCH_CATB_CLOCK_ERROR
}
 Touch Library error codes. More...
 

Functions

QTouch 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 QTouch Library. More...
 
void touch_sensors_deinit (void)
 This API is used to deinitialize capacitive touch acquisition on QTouch Sensors. More...
 
void touch_sensors_update_time (void)
 This API is used to update Timing info for QTouch Library. Typical usage of this API is inside a periodic timer ISR. More...
 
touch_ret_t touch_autonomous_sensor_enable (void)
 This API is used to enable Autonomous QTouch Sensor that can be used to Wakeup the CPU from Deep-Sleep modes. More...
 
void touch_autonomous_sensor_disable (void)
 This API is used to disable Autonomous QTouch Sensor. More...
 
Autonomous QTouch API.
touch_ret_t touch_at_sensor_enable (touch_config_t *p_touch_config)
 This API is used to initialize the Touch Library with Autonomous Touch pin and register configuration provided by the user. More...
 
touch_ret_t touch_at_sensor_disable (void)
 Stop the Autonomous Touch sensor from doing Touch measurement. More...
 
touch_ret_t touch_at_get_libinfo (touch_info_t *p_touch_info)
 This API can be used to read back Autonomous Touch configuration and status information in addition to the Touch Library version. More...
 
QTouch Library internal use functions.
void touch_qt_rs_table_init (void)
 This is an extern function of the Touch Library. This function is NOT to be used by the user. More...
 

Variables

touch_measure_data_tp_qt_measure_data
 QTouch measured data pointer. More...
 
touch_qt_time_t touch_qt_time
 QTouch Library Timing info. More...
 

QTouch API.

#define touch_qt_sensors_init(y)   touch_qt_sensors_init_with_rs_table( (y), PRIV_QT_RS_TABLE_INIT );
 touch_ret_t touch_qt_sensors_init( touch_config_t *p_touch_config); More...
 
touch_ret_t touch_qt_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 QTouch pin, register and sensor configuration provided by the user. More...
 
touch_ret_t touch_qt_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)
 This API can be used to configure a sensor of type key, rotor or slider. More...
 
touch_ret_t touch_qt_sensors_calibrate (void)
 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_qt_sensors_start_acquisition (touch_time_t current_time_ms, touch_qt_dma_t qt_dma_ch, touch_acq_mode_t qt_acq_mode, void(*measure_complete_callback)(void))
 This API can be used to start a QTouch measurement. More...
 
touch_ret_t touch_qt_get_libinfo (touch_info_t *p_touch_info)
 This API can be used to get the Touch Library configuration information for QTouch acquisition method. More...
 
touch_ret_t touch_qt_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...
 
void touch_event_dispatcher (void)
 Touch Library Event Dispatcher. More...
 
void touch_qt_deinit (void)
 This API can be used to deinitialize the touch library. Once this API is called, capacitive touch acquisition is stopped and the CATB hardware module is disabled. Before calling this API, use touch_qt_get_libinfo(&touch_info) and ensure that the library state is TOUCH_STATE_READY. if (touch_info.tlib_state == TOUCH_STATE_READY) { touch_sensors_deinit();}. More...