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_measure_data_tp_qm_measure_data = NULL
 
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
 
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

Referenced by main(), and tc_irq().

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_CSBRES
Definition: touch_config_at32uc3l.h:1132
#define TOUCH_SPREAD_SPECTRUM_MAX_DEV
Definition: touch_config_at32uc3l.h:1112
#define TOUCH_SYNC_PIN_OPTION
Definition: touch_config_at32uc3l.h:1097
#define TOUCH_CSARES
Definition: touch_config_at32uc3l.h:1122
uint16_t measurement_period_ms = EXAMPLE_MEASUREMENT_PERIOD_MS

Referenced by tc_irq(), and Transmit_Global_Config().

touch_measure_data_t* p_qm_measure_data = NULL
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_MCUCLK_FREQ_HZ
MCU clock target frequency (Hertz)
Definition: conf_clock.h:64
static scif_gclk_opt_t gc_dfllif_ref_opt
Definition: uc3l-ek-touch-demo.c:207
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ
PBA clock target frequency (Hertz)
Definition: conf_clock.h:65
#define EXAMPLE_TARGET_DFLL_FREQ_HZ
DFLL target frequency (Hertz)
Definition: conf_clock.h:63

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
}

Referenced by Set_QM_Burst_Lengths().

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

Referenced by main(), and tc_irq().

touch_config_t touch_config
Initial value:
=
{
NULL,
NULL,
NULL,
}
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