Microchip® Advanced Software Framework

thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/main.c File Reference
#include "compiler.h"
#include "board.h"
#include "power_clocks_lib.h"
#include "gpio.h"
#include "tc.h"
#include "intc.h"
#include "touch_api_at32uc3l.h"

Macros

Example Timer configuration settings.

Includes for Clock and Timer.

Includes for Touch Library.

#define EXAMPLE_TC   (&AVR32_TC0)
 timer number. More...
 
#define EXAMPLE_TC_IRQ_GROUP   (AVR32_TC0_IRQ_GROUP)
 timer irq group. More...
 
#define EXAMPLE_TC_IRQ   (AVR32_TC0_IRQ0)
 timer irq. More...
 
#define EXAMPLE_TC_CHANNEL   (0u)
 timer channel. More...
 
#define EXAMPLE_RC_VALUE   (6000u)
 set RC value for 1ms tick. More...
 
Example Clock configuration settings.

Note: The QDebug protocol USART clock settings are available in qdebug/Serial.h. When modifying the EXAMPLE_CPUCLK_HZ clock, care must be taken to modify the TARGET_PBA_FREQ_HZ and TARGET_CPU_FREQ_HZ defines in the Serial.h file for the QDebug protocol to work correctly.

#define EXAMPLE_TARGET_DFLL_FREQ_HZ   (96000000)
 DFLL target frequency, in Hz. More...
 
#define EXAMPLE_TARGET_MCUCLK_FREQ_HZ   (48000000)
 MCU clock target frequency, in Hz. More...
 
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ   (48000000)
 PBA clock target frequency, in Hz. More...
 
#define EXAMPLE_TARGET_PBBCLK_FREQ_HZ   (48000000)
 PBA clock target frequency, in Hz. More...
 

Functions

static touch_ret_t config_qt_grp_a_touch_sensors (void)
 configure keys, rotors and sliders. More...
 
static unsigned long init_clock (void)
 Initialize clock. More...
 
static void init_system (void)
 Initialize host app, pins, watchdog, clock etc. More...
 
static void init_timer (void)
 Configure timer to fire ISR regularly. More...
 
int main (void)
 Example application entry function. More...
 
static void tc_irq (void)
 Timer compare ISR. More...
 
static void touch_qta_measure_complete_callback (touch_measure_data_t *p_measure_data)
 timer ISR More...
 

Variables

volatile uint16_t current_time_ms_touch = 0u
 Current time, set by timer ISR. More...
 
static touch_general_config_t general_config
 General configuration options common to QMatrix, QTouch A/B and Autonomous Touch provided as input to Touch library. More...
 
uint16_t measurement_period_ms = 25u
 Touch Measurement period in milliseconds. More...
 
touch_measure_data_tp_qta_measure_data = NULL
 QTouch Group A measure data structure pointer. More...
 
static touch_qt_config_t qta_config
 QTouch Group A Configuration structure provided as input to Touch Library. More...
 
static uint8_t qta_data_blk [PRIV_QTA_DATA_BLK_SIZE]
 QTouch Group A Data block provided as input to Touch library. More...
 
volatile uint8_t qta_measurement_done_touch = 0u
 Flag set by touch_qta_measure_complete_callback() function when a fresh Touch status is available. More...
 
volatile uint8_t time_to_measure_touch = 0u
 Flag set by timer ISR when it's time to measure touch. More...
 
touch_config_t touch_config
 Touch Library input configuration structure. More...
 
Parameters to pcl_configure_clocks().
static scif_gclk_opt_t gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, false }
 
static pcl_freq_param_t pcl_dfll_freq_param
 

#define EXAMPLE_RC_VALUE   (6000u)

set RC value for 1ms tick.

Referenced by init_timer().

#define EXAMPLE_TARGET_DFLL_FREQ_HZ   (96000000)

DFLL target frequency, in Hz.

#define EXAMPLE_TARGET_MCUCLK_FREQ_HZ   (48000000)

MCU clock target frequency, in Hz.

#define EXAMPLE_TARGET_PBACLK_FREQ_HZ   (48000000)

PBA clock target frequency, in Hz.

#define EXAMPLE_TARGET_PBBCLK_FREQ_HZ   (48000000)

PBA clock target frequency, in Hz.

#define EXAMPLE_TC   (&AVR32_TC0)

timer number.

Referenced by init_timer(), and tc_irq().

#define EXAMPLE_TC_CHANNEL   (0u)

timer channel.

Referenced by init_timer(), and tc_irq().

#define EXAMPLE_TC_IRQ   (AVR32_TC0_IRQ0)

timer irq.

Referenced by main().

#define EXAMPLE_TC_IRQ_GROUP   (AVR32_TC0_IRQ_GROUP)

timer irq group.

touch_ret_t config_qt_grp_a_touch_sensors ( 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 HYST_6_25, NO_AKS_GROUP, RES_1_BIT, RES_8_BIT, SENSOR_TYPE_KEY, SENSOR_TYPE_ROTOR, SENSOR_TYPE_SLIDER, TOUCH_QT_GRP_A, touch_qt_sensor_config(), and TOUCH_SUCCESS.

Referenced by main().

static unsigned long init_clock ( void  )
static

Initialize clock.

Initialize Clock.

References pcl_configure_clocks(), and pcl_dfll_freq_param.

Referenced by init_system().

void init_system ( void  )
static

Initialize host app, pins, watchdog, clock etc.

Initialize host clock, pins, watchdog, etc.

References init_clock().

Referenced by main().

void init_timer ( void  )
static
static void tc_irq ( void  )
static
void touch_qta_measure_complete_callback ( touch_measure_data_t p_measure_data)
static

timer ISR

QTouch Group A measure complete callback function.

QTouch Group A measure complete callback function example prototype.

This function is called by the library when the touch measurement process for QTouch Group A sensors is completed.

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

References qta_measurement_done_touch, and UNUSED.

Referenced by main().

volatile uint16_t current_time_ms_touch = 0u

Current time, set by timer ISR.

scif_gclk_opt_t gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, false }
static
touch_general_config_t general_config
static
Initial value:
= {
}
#define TOUCH_SPREAD_SPECTRUM_MAX_DEV
Touch Maximum Deviation.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qm/touch_config_at32uc3l.h:1291
#define TOUCH_CSBRES
Touch Resistive Drive Enable for CSB lines.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qm/touch_config_at32uc3l.h:1313
#define TOUCH_SYNC_PIN_OPTION
Touch Sync Pin option.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qm/touch_config_at32uc3l.h:1275
#define TOUCH_CSARES
Touch Resistive Drive Enable for CSA lines.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qm/touch_config_at32uc3l.h:1302

General configuration options common to QMatrix, QTouch A/B and Autonomous Touch provided as input to Touch library.

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

uint16_t measurement_period_ms = 25u

Touch Measurement period in milliseconds.

This variable determines how often a new touch measurement must be done. Default value: Every 25 milliseconds.

touch_measure_data_t* p_qta_measure_data = NULL

QTouch Group A measure data structure pointer.

pcl_freq_param_t pcl_dfll_freq_param
static
Initial value:
= {
.main_clk_src = PCL_MC_DFLL0,
.pextra_params = &gc_dfllif_ref_opt
}
#define EXAMPLE_TARGET_PBBCLK_FREQ_HZ
PBA clock target frequency, in Hz.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/main.c:112
Definition: power_clocks_lib.h:106
static scif_gclk_opt_t gc_dfllif_ref_opt
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/main.c:170
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ
PBA clock target frequency, in Hz.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/main.c:111
#define EXAMPLE_TARGET_MCUCLK_FREQ_HZ
MCU clock target frequency, in Hz.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/main.c:110
#define EXAMPLE_TARGET_DFLL_FREQ_HZ
DFLL target frequency, in Hz.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/main.c:109

Referenced by init_clock().

touch_qt_config_t qta_config
static

QTouch Group A Configuration structure provided as input to Touch Library.

Note: Use the touch_config_at32uc3l.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 qta_data_blk[PRIV_QTA_DATA_BLK_SIZE]
static

QTouch Group A Data block provided as input to Touch library.

volatile uint8_t qta_measurement_done_touch = 0u

Flag set by touch_qta_measure_complete_callback() function when a fresh Touch status is available.

Referenced by main(), and touch_qta_measure_complete_callback().

volatile uint8_t time_to_measure_touch = 0u

Flag set by timer ISR when it's time to measure touch.

touch_config_t touch_config
Initial value:
= {
NULL,
NULL,
NULL,
}
#define NULL
Definition: lwip-1.4.1/src/include/lwip/def.h:47
static touch_general_config_t general_config
General configuration options common to QMatrix, QTouch A/B and Autonomous Touch provided as input to...
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/main.c:241
static touch_qt_config_t qta_config
QTouch Group A Configuration structure provided as input to Touch Library.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/main.c:194

Touch Library input configuration structure.