Microchip® Advanced Software Framework

touch.c File Reference

This file contains the SAMD QTouch library initialization, sensor configuration and measurement routines.

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

#include <asf.h>
#include "touch_api_SAMD.h"

Macros

#define DEF_MUTLCAP_CAL_SEQ1_COUNT   8
 Includes for Touch Library. More...
 
#define DEF_MUTLCAP_CAL_SEQ2_COUNT   4
 
#define DEF_MUTLCAP_CC_CAL_CLK_PRESCALE   PRSC_DIV_SEL_8
 
#define DEF_MUTLCAP_CC_CAL_SENSE_RESISTOR   RSEL_VAL_100
 
#define DEF_MUTLCAP_QUICK_REBURST_ENABLE   1u
 
#define PTC_APBC_BITMASK   (1u << 19u)
 

Functions

void touch_configure_ptc_clock (void)
 Initialize and enable PTC clock. More...
 
void touch_mutlcap_measure_complete_callback (void)
 Mutual Cap measure complete callback function example prototype. More...
 
static touch_ret_t touch_sensors_config (void)
 configure keys, rotors and sliders. More...
 
touch_ret_t touch_sensors_init (void)
 Example application entry function. More...
 
touch_ret_t touch_sensors_measure (void)
 This API is used to perform a Single Capacitance measurement using the Touch Library. More...
 

Variables

static touch_mutlcap_config_t mutlcap_config
 Mutual Cap Configuration structure provided as input to Touch Library. More...
 
static uint8_t mutlcap_data_blk [PRIV_MUTLCAP_DATA_BLK_SIZE]
 Mutual Cap Data block provided as input to Touch library. More...
 
freq_hop_sel_t mutlcap_freq_hops [3u] = {DEF_MUTLCAP_HOP_FREQS}
 
gain_t mutlcap_gain_per_node [DEF_MUTLCAP_NUM_CHANNELS] = {DEF_MUTLCAP_GAIN_PER_NODE}
 
uint16_t mutlcap_xy_nodes [DEF_MUTLCAP_NUM_CHANNELS *2] = {DEF_MUTLCAP_NODES}
 Mutual Cap Sensor Pins Info. More...
 
touch_measure_data_tp_mutlcap_measure_data = NULL
 Mutual Cap sensors measured data pointer. More...
 
touch_measure_data_tp_selfcap_measure_data = NULL
 Self Cap sensors measured data pointer. More...
 
touch_config_t touch_config
 Touch Library input configuration structure. More...
 
touch_time_t touch_time
 

#define DEF_MUTLCAP_CAL_SEQ1_COUNT   8

Includes for Touch Library.

#define DEF_MUTLCAP_CAL_SEQ2_COUNT   4
#define DEF_MUTLCAP_CC_CAL_CLK_PRESCALE   PRSC_DIV_SEL_8
#define DEF_MUTLCAP_CC_CAL_SENSE_RESISTOR   RSEL_VAL_100
#define DEF_MUTLCAP_QUICK_REBURST_ENABLE   1u
#define PTC_APBC_BITMASK   (1u << 19u)

void touch_mutlcap_measure_complete_callback ( void  )

Mutual Cap measure complete callback function example prototype.

Mutual Cap measure complete callback function.

This function is called by the library when the touch measurement process for Mutual Cap sensors is completed.

Parameters
p_measure_dataBase address of touch_measure_data_t instance.
Note
A touch_mutlcap_measure_complete_callback() call signifies that fresh values of touch status, rotor/slider position, measured signals, references and Sensor data is available. The Mutual Cap measured data can be accessed using the p_measure_data pointer.

References tag_touch_measure_data_t::acq_status, tag_touch_measure_data_t::measurement_done_touch, TOUCH_BURST_AGAIN, TOUCH_CHANNEL_REF_CHANGE, TOUCH_ROTOR_SLIDER_POS_CHANGE, and TOUCH_STATUS_CHANGE.

Referenced by touch_sensors_measure().

touch_ret_t touch_sensors_config ( void  )
static

configure keys, rotors and sliders.

Example configuration for touch keys, rotors and sliders.

Return values
TOUCH_SUCCESSConfiguration setting successful.
TOUCH_INVALID_xxInvalid input configuration setting.

References CHANNEL_0, CHANNEL_1, CHANNEL_2, CHANNEL_5, CHANNEL_6, CHANNEL_9, HYST_6_25, NO_AKS_GROUP, RES_8_BIT, SENSOR_TYPE_KEY, SENSOR_TYPE_ROTOR, SENSOR_TYPE_SLIDER, touch_mutlcap_sensor_config(), and TOUCH_SUCCESS.

Referenced by touch_sensors_init().

touch_mutlcap_config_t mutlcap_config
static

Mutual Cap Configuration structure provided as input to Touch Library.

Note: Use the touch.h configuration header file to fill in the elements of this structure. DO NOT modify any of the input values directly in this structure.

uint8_t mutlcap_data_blk[PRIV_MUTLCAP_DATA_BLK_SIZE]
static

Mutual Cap Data block provided as input to Touch library.

freq_hop_sel_t mutlcap_freq_hops[3u] = {DEF_MUTLCAP_HOP_FREQS}
uint16_t mutlcap_xy_nodes[DEF_MUTLCAP_NUM_CHANNELS *2] = {DEF_MUTLCAP_NODES}

Mutual Cap Sensor Pins Info.

touch_config_t touch_config
Initial value:
= {
NULL,
}
static touch_mutlcap_config_t mutlcap_config
Mutual Cap Configuration structure provided as input to Touch Library.
Definition: touch.c:129
#define DEF_TOUCH_PTC_ISR_LVL
PTC Module clock configuration.
Definition: touch_config_samd.h:78

Touch Library input configuration structure.