Microchip® Advanced Software Framework

uc3l-ek-touch-demo.c File Reference

This file contains the AT32UC3L-EK demonstration application that interfaces with QTouchStudio and controls the LEDs with the touch sensors.

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

#include "board.h"
#include "conf_clock.h"
#include "tc.h"
#include "intc.h"
#include "gpio.h"
#include "delay.h"
#include "power_clocks_lib.h"
#include "touch_api_at32uc3l.h"
#include "qdebug.h"
#include "demo.h"

Macros

#define DEMO_INIT_NB_AUTOMATIC_CHANGES   5
 Number of automatic LEDs intensity changes done at the beginning of the demo. More...
 
#define EXAMPLE_DFLL_COARSE_FDFLL96   (150u)
 
#define EXAMPLE_DFLL_FINE_FDFLL96   (65u)
 
#define EXAMPLE_MEASUREMENT_PERIOD_MS   (25u) /* The timing information for timer to fire periodically to measure touch. */
 
#define EXAMPLE_RC_VALUE   (6000u) /* configure timer for 1ms tick. */
 
#define EXAMPLE_TC   (&AVR32_TC0)
 
#define EXAMPLE_TC_CHANNEL   (0u)
 
#define EXAMPLE_TC_IRQ   (AVR32_TC0_IRQ0)
 
#define EXAMPLE_TC_IRQ_GROUP   (AVR32_TC0_IRQ_GROUP)
 

Functions

static touch_ret_t config_uc3lek_touch_sensors (void)
 
static unsigned long init_clock (unsigned long cpuclk_hz)
 
static void init_system (void)
 
static void init_timer (void)
 
int main (void)
 
static void tc_irq (void)
 
static void touch_qm_measure_complete_callback (touch_measure_data_t *p_measure_data)
 

Variables

volatile uint16_t current_time_ms_touch = 0u
 
static touch_general_config_t general_config
 
uint16_t measurement_period_ms = EXAMPLE_MEASUREMENT_PERIOD_MS
 Touch Measurement period in milliseconds. More...
 
touch_measure_data_tp_qm_measure_data = NULL
 Pointer to the measured data. More...
 
const uint8_t qm_burst_length [QM_NUM_CHANNELS]
 
static touch_qm_config_t qm_config
 
static uint8_t qm_data_blk [PRIV_QM_DATA_BLK_SIZE]
 
volatile uint8_t qm_measurement_done_touch = 0u
 
volatile uint8_t time_to_measure_touch = 0u
 
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 DEMO_INIT_NB_AUTOMATIC_CHANGES   5

Number of automatic LEDs intensity changes done at the beginning of the demo.

Referenced by main().

#define EXAMPLE_DFLL_COARSE_FDFLL96   (150u)
#define EXAMPLE_DFLL_FINE_FDFLL96   (65u)
#define EXAMPLE_MEASUREMENT_PERIOD_MS   (25u) /* The timing information for timer to fire periodically to measure touch. */
#define EXAMPLE_RC_VALUE   (6000u) /* configure timer for 1ms tick. */

Referenced by init_timer().

#define EXAMPLE_TC   (&AVR32_TC0)

Referenced by init_timer(), and tc_irq().

#define EXAMPLE_TC_CHANNEL   (0u)

Referenced by init_timer(), and tc_irq().

#define EXAMPLE_TC_IRQ   (AVR32_TC0_IRQ0)

Referenced by main().

#define EXAMPLE_TC_IRQ_GROUP   (AVR32_TC0_IRQ_GROUP)

static touch_ret_t config_uc3lek_touch_sensors ( void  )
static
static unsigned long init_clock ( unsigned long  cpuclk_hz)
static
static void init_system ( void  )
static

References EXAMPLE_CPUCLK_HZ, and init_clock().

Referenced by main().

static void tc_irq ( void  )
static
static void touch_qm_measure_complete_callback ( touch_measure_data_t p_measure_data)
static

References qm_measurement_done_touch.

Referenced by main().

volatile uint16_t current_time_ms_touch = 0u
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_qt/touch_config_at32uc3l.h:1291
#define TOUCH_CSARES
Touch Resistive Drive Enable for CSA lines.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/touch_config_at32uc3l.h:1302
#define TOUCH_CSBRES
Touch Resistive Drive Enable for CSB lines.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/touch_config_at32uc3l.h:1313
#define TOUCH_SYNC_PIN_OPTION
Touch Sync Pin option.
Definition: thirdparty/qtouch/devspecific/uc3/uc3l0/examples/example_qt/touch_config_at32uc3l.h:1275
uint16_t measurement_period_ms = EXAMPLE_MEASUREMENT_PERIOD_MS

Touch Measurement period in milliseconds.

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

Touch Measurement period in milliseconds.

Needs to be global since it is required for the QDebug module.

Touch Measurement period in milliseconds.

touch_measure_data_t* p_qm_measure_data = NULL

Pointer to the measured data.

Needs to be global since it is required for the QDebug module.

pcl_freq_param_t pcl_dfll_freq_param
static
Initial value:
= {
.main_clk_src = PCL_MC_DFLL0,
.pextra_params = &gc_dfllif_ref_opt
}
Definition: power_clocks_lib.h:106
#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
static scif_gclk_opt_t gc_dfllif_ref_opt
Definition: uc3l-ek-touch-demo.c:207

Referenced by init_clock().

const uint8_t qm_burst_length[QM_NUM_CHANNELS]
Initial value:
=
{
128,
128,
128,
128,
128,
128,
128,
128,
128,
1,
128,
128
}
touch_qm_config_t qm_config
static
uint8_t qm_data_blk[PRIV_QM_DATA_BLK_SIZE]
static
volatile uint8_t qm_measurement_done_touch = 0u
volatile uint8_t time_to_measure_touch = 0u
touch_config_t touch_config
Initial value:
=
{
NULL,
NULL,
NULL,
}
#define NULL
Definition: lwip-1.4.0/src/include/lwip/def.h:47
static touch_general_config_t general_config
Definition: uc3l-ek-touch-demo.c:353
static touch_qm_config_t qm_config
Definition: uc3l-ek-touch-demo.c:275

Touch Library input configuration structure.