#include "compiler.h"
#include "board.h"
#include "power_clocks_lib.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_64ch_touch_keys_rotors_sliders (void) |
Example configuration for touch 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... | |
void | qm_filter_callback (touch_filter_data_t *p_filter_data) |
Example signal filtering function. More... | |
static void | tc_irq (void) |
Timer compare ISR. More... | |
static void | touch_qm_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 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_t * | p_qm_measure_data = NULL |
QMatrix measured data pointer. More... | |
uint8_t | qm_burst_length [QM_NUM_CHANNELS] |
QMatrix burst length. More... | |
static touch_qm_config_t | qm_config |
QMatrix Configuration structure provided as input to Touch Library. More... | |
static uint8_t | qm_data_blk [PRIV_QM_DATA_BLK_SIZE] |
QMatrix Data block provided as input to Touch library. More... | |
static uint16_t | qm_filter [QM_NUM_CHANNELS][4] |
Filter for channel signals. More... | |
volatile uint8_t | qm_measurement_done_touch = 0u |
Flag set by touch_qm_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.
Referenced by main().
#define EXAMPLE_TARGET_MCUCLK_FREQ_HZ (48000000) |
MCU clock target frequency, in Hz.
Referenced by main().
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ (48000000) |
PBA clock target frequency, in Hz.
Referenced by at45dbx_resources_init(), and main().
#define EXAMPLE_TARGET_PBBCLK_FREQ_HZ (48000000) |
PBA clock target frequency, in Hz.
#define EXAMPLE_TC (&AVR32_TC0) |
timer number.
Referenced by init_timer(), main(), and tc_irq().
#define EXAMPLE_TC_CHANNEL (0u) |
timer channel.
Referenced by init_timer(), tc_init(), 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.
|
static |
Example configuration for touch keys, rotors and sliders.
TOUCH_SUCCESS | Configuration setting successful. |
TOUCH_INVALID_xx | Invalid input configuration setting. |
References AKS_GROUP_1, HYST_6_25, i, RES_1_BIT, RES_8_BIT, SENSOR_TYPE_KEY, SENSOR_TYPE_ROTOR, SENSOR_TYPE_SLIDER, touch_qm_sensor_config(), and TOUCH_SUCCESS.
Referenced by main().
|
static |
Initialize clock.
Initialize Clock.
References pcl_configure_clocks(), pcl_dfll_freq_param, QM_GCLK_CAT_DIV, scif_gc_enable(), scif_gc_setup(), and SCIF_GCCTRL_DFLL0.
Referenced by init_system().
|
static |
Initialize host app, pins, watchdog, clock etc.
Initialize host clock, pins, watchdog, etc.
References init_clock().
Referenced by main().
|
static |
Configure timer to fire ISR regularly.
Configure timer ISR to fire regularly.
References tc_waveform_opt_t::channel, tc_interrupt_t::etrgs, EXAMPLE_RC_VALUE, EXAMPLE_TC, EXAMPLE_TC_CHANNEL, TC_CLOCK_SOURCE_TC3, tc_configure_interrupts(), TC_EVT_EFFECT_NOOP, tc_init_waveform(), TC_SEL_NO_EDGE, tc_start(), TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER, and tc_write_rc().
Referenced by main().
int main | ( | void | ) |
Example application entry function.
References tag_touch_measure_data_t::acq_status, config_64ch_touch_keys_rotors_sliders(), current_time_ms_touch, Disable_global_interrupt, tag_touch_qm_dma_t::dma_ch1, tag_touch_qm_dma_t::dma_ch2, Enable_global_interrupt, EXAMPLE_TC_IRQ, init_system(), init_timer(), INTC_init_interrupts(), INTC_register_interrupt(), NORMAL_ACQ_MODE, QDebug_Init(), QDebug_ProcessCommands(), QDebug_SendData(), qm_dma, QM_DMA_CHANNEL_0, QM_DMA_CHANNEL_1, qm_measurement_done_touch, tc_irq(), time_to_measure_touch, TOUCH_ACQ_INCOMPLETE, touch_event_dispatcher(), touch_qm_measure_complete_callback(), touch_qm_sensors_calibrate(), touch_qm_sensors_init, touch_qm_sensors_start_acquisition(), and TOUCH_SUCCESS.
void qm_filter_callback | ( | touch_filter_data_t * | p_filter_data | ) |
Example signal filtering function.
p_filter_data | Base address of the touch_filter_data_t instance. |
Mean Filter function.
p_filter_data | Base address of the touch_filter_data_t instance. |
References i, tag_touch_filter_data_t::num_channel_signals, tag_touch_filter_data_t::p_channel_signals, and qm_filter.
|
static |
Timer compare ISR.
References current_time_ms_touch, EXAMPLE_TC, EXAMPLE_TC_CHANNEL, measurement_period_ms, tc_read_sr(), and time_to_measure_touch.
Referenced by main().
|
static |
Timer ISR.
QMatrix measure complete callback function.
QMatrix measure complete callback function example prototype.
This function is called by the library when the touch measurement process for QMatrix Sensors is completed.
p_measure_data | Base address of touch_measure_data_t instance. |
References qm_measurement_done_touch.
Referenced by main().
volatile uint16_t current_time_ms_touch = 0u |
|
static |
Referenced by clockfrequencies_configure(), and main().
|
static |
General configuration options common to QMatrix, QTouch 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.
Referenced by ISR(), tc_irq(), and Transmit_Global_Config().
touch_measure_data_t* p_qm_measure_data = NULL |
QMatrix measured data pointer.
|
static |
Referenced by clockfrequencies_configure(), init_clock(), and main().
uint8_t qm_burst_length[QM_NUM_CHANNELS] |
QMatrix burst length.
Specify the number of QMatrix burst pulses for each channel. In order to disable bursting on a individual channel, a value of 1u has to be specified.
CAUTION: QMatrix Burst length setting recommendation. The following are the three possible Scenario's of Burst length usage when using the UC3L CAT module.
Scenario 1: The burst length of all channels has the same count value. Additionally, any or all of the (X, Y) pairs can have a count value of 1 (when a channel is to be disabled, the count value is set as 1).
Scenario 2: For a given X Line, the count value of all enabled Y Lines MUST be of the same value. Additionally, for this X Line, any or all of these (X, Y) pairs can have a value of 1.
Example, when X0, X1, X2 and Y0, Y1, Y2 lines are used in a design, then, X0Y0, X0Y1 and X0Y2 can have count values (48, 48, 48) or (48, 48, 1) or (1, 1, 48) etc respectively, 48 is an example value here. X1Y0, X1Y1 and X1Y2 can have count values (64, 64, 64) or (64, 64, 1) or (1, 1, 64) etc respectively, 64 is an example value here. X2Y0, X2Y1 and X2Y2 can have count values (32, 32, 32) or (32, 32, 1) or (1, 1, 32) etc respectively, 32 is an example value here.
Scenario 3: It is recommended to have the burst length settings as given in Scenario 1 or Scenario 2. However, in a case wherein it is required to have different count values on different channels, 1k ohm resistive drive MUST be used on all the enabled Y lines by setting the corresponding bits in the CSARES register.
|
static |
QMatrix 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.
|
static |
QMatrix Data block provided as input to Touch library.
|
static |
Filter for channel signals.
Referenced by qm_filter_callback().
volatile uint8_t qm_measurement_done_touch = 0u |
Flag set by touch_qm_measure_complete_callback() function when a fresh Touch status is available.
Referenced by main(), process_buttons(), and touch_qm_measure_complete_callback().
volatile uint8_t time_to_measure_touch = 0u |
Flag set by timer ISR when it's time to measure touch.
Referenced by ISR(), main(), tc_irq(), and touch_handler().
touch_config_t touch_config |
Touch Library input configuration structure.