Microchip® Advanced Software Framework

main_xm128a1.c File Reference

QTouch Example for QT600-ATXMEGA128A1-QT16 board.

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

#include <avr/io.h>
#include <avr/interrupt.h>
#include "touch_api.h"
#include "QDebug.h"
#include "QDebugTransport.h"
#include "sysclk.h"
#include "pmic.h"
#include "tc.h"

Macros

#define __delay_cycles(n)   __builtin_avr_delay_cycles(n)
 
#define __enable_interrupt()   sei()
 
#define GET_ROTOR_SLIDER_POSITION(ROTOR_SLIDER_NUMBER)   qt_measure_data.qt_touch_status.rotor_slider_values[ROTOR_SLIDER_NUMBER]
 
#define GET_SENSOR_STATE(SENSOR_NUMBER)   qt_measure_data.qt_touch_status.sensor_states[(SENSOR_NUMBER/8)] & (1 << (SENSOR_NUMBER % 8))
 
TIMER_PERIOD conmputation
#define TIMER_PERIOD   TICKS_PER_MS * qt_measurement_period_msec
 
The timing information for timer to fire periodically to measure touch
#define TIMER_COUNTER_L   TCC0.CNTL
 
#define TIMER_COUNTER_H   TCC0.CNTH
 

Functions

static void example_cca_interrupt_callback (void)
 
static void init_system (void)
 
static void init_timer_isr (void)
 Configure timer ISR to fire regularly. More...
 
int main (void)
 code main entry point More...
 
int16_t qt_get_sensor_delta (uint8_t sensor)
 
static void qt_set_parameters (void)
 qt_set_parameters function More...
 

Variables

volatile uint16_t current_time_ms_touch = 0u
 Current time, set by timer ISR. More...
 
unsigned int gMsTimeout
 
qt_touch_lib_measure_data_tpqt_measure_data = &qt_measure_data
 
qt_touch_lib_config_data_t qt_config_data
 
qt_touch_lib_measure_data_t qt_measure_data
 
uint16_t qt_measurement_period_msec = 25u
 Touch Measurement period in milliseconds. More...
 
static volatile uint8_t time_to_measure_touch = 0u
 Flag set by timer ISR when it's time to measure touch. More...
 
uint16_t timestamp1_hword
 Time stamp information. More...
 
uint16_t timestamp1_lword
 
uint16_t timestamp2_hword
 
uint16_t timestamp2_lword
 
uint16_t timestamp3_hword
 
uint16_t timestamp3_lword
 

#define __delay_cycles (   n)    __builtin_avr_delay_cycles(n)
#define __enable_interrupt ( )    sei()

Referenced by main().

#define GET_ROTOR_SLIDER_POSITION (   ROTOR_SLIDER_NUMBER)    qt_measure_data.qt_touch_status.rotor_slider_values[ROTOR_SLIDER_NUMBER]
#define GET_SENSOR_STATE (   SENSOR_NUMBER)    qt_measure_data.qt_touch_status.sensor_states[(SENSOR_NUMBER/8)] & (1 << (SENSOR_NUMBER % 8))
#define TIMER_COUNTER_H   TCC0.CNTH

Referenced by main().

#define TIMER_COUNTER_L   TCC0.CNTL

Referenced by main().

#define TIMER_PERIOD   TICKS_PER_MS * qt_measurement_period_msec

Referenced by init_timer_isr().

static void example_cca_interrupt_callback ( void  )
static
static void init_system ( void  )
static
static void init_timer_isr ( void  )
static

Configure timer ISR to fire regularly.

References PMIC_LVL_LOW, tc_enable(), tc_set_cca_interrupt_level(), tc_write_clock_source(), tc_write_period(), and TIMER_PERIOD.

Referenced by main().

int16_t qt_get_sensor_delta ( uint8_t  sensor)

Referenced by Transmit_Delta().

static void qt_set_parameters ( void  )
static

qt_set_parameters function

This will fill the default threshold values in the configuration data structure.But User can change the values of these parameters .

Note
initialize configuration data for processing

References tag_qt_touch_lib_config_data_t::qt_di, tag_qt_touch_lib_config_data_t::qt_drift_hold_time, tag_qt_touch_lib_config_data_t::qt_max_on_duration, tag_qt_touch_lib_config_data_t::qt_neg_drift_rate, tag_qt_touch_lib_config_data_t::qt_pos_drift_rate, tag_qt_touch_lib_config_data_t::qt_pos_recal_delay, and tag_qt_touch_lib_config_data_t::qt_recal_threshold.

Referenced by main().

volatile uint16_t current_time_ms_touch = 0u

Current time, set by timer ISR.

Referenced by example_cca_interrupt_callback(), and main().

unsigned int gMsTimeout
volatile uint8_t time_to_measure_touch = 0u
static

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

Referenced by example_cca_interrupt_callback(), and main().

uint16_t timestamp1_hword

Time stamp information.

Referenced by main(), and Transmit_Time_Stamps().

uint16_t timestamp1_lword

Referenced by main(), and Transmit_Time_Stamps().

uint16_t timestamp2_hword

Referenced by main(), and Transmit_Time_Stamps().

uint16_t timestamp2_lword

Referenced by main(), and Transmit_Time_Stamps().

uint16_t timestamp3_hword

Referenced by main(), and Transmit_Time_Stamps().

uint16_t timestamp3_lword

Referenced by main(), and Transmit_Time_Stamps().