SAM4S-Xplained QTouch and LED demonstration.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include "conf_example.h"
Macros | |
#define | DEFAULT_LED_FREQ 4 |
Set default LED blink period to 250ms*3. More... | |
#define | GET_ROTOR_SLIDER_POSITION(ROTOR_SLIDER_NUMBER) |
#define | GET_SENSOR_STATE(SENSOR_NUMBER) |
#define | LED_BLINK_PERIOD 3 |
LED blink period. More... | |
#define | LED_FREQ_DIV 3 |
frequency divider for LED blinking More... | |
#define | QT_MAX_DATA 255 |
QTouch max data value. More... | |
#define | QTOUCH_LIB_COMPILER_MASK 0x01 |
QTouch library compiler type mask. More... | |
#define | QTOUCH_LIB_COMPILER_OFFSET 2 |
QTouch library compiler type offset: GCC / IAR. More... | |
#define | QTOUCH_LIB_KEY_ONLY_MASK 0x01 |
QTouch library supports keys only mask. More... | |
#define | QTOUCH_LIB_KEY_ONLY_OFFSET 10 |
QTouch library supports keys only offset. More... | |
#define | QTOUCH_LIB_MAX_CHANNEL_MASK 0x7F |
QTouch library maximum channels mask. More... | |
#define | QTOUCH_LIB_MAX_CHANNEL_OFFSET 3 |
QTouch library maximum channels offset. More... | |
#define | QTOUCH_LIB_ROTOR_NUM_MASK 0x1F |
QTouch library maximum rotors/sliders mask. More... | |
#define | QTOUCH_LIB_ROTOR_NUM_OFFSET 11 |
QTouch library maximum rotors/sliders offset. More... | |
#define | QTOUCH_LIB_TPYE_MASK 0x01 |
QTouch library type: QTouch / QMatrix. More... | |
Functions | |
static void | config_sensors (void) |
Configure the sensors. More... | |
static void | configure_tc (uint32_t freq) |
Configure Timer Counter 0 to generate an interrupt with the specific frequency. More... | |
static void | init_system (void) |
initialize pins, watchdog, etc. More... | |
static void | init_timer_isr (void) |
Configure timer ISR to fire regularly. More... | |
int | main (void) |
getting-started Application entry point. More... | |
static void | qt_set_parameters (void) |
This will fill the default threshold values in the configuration data structure.But User can change the values of these parameters. More... | |
void | SysTick_Handler (void) |
Handler for System Tick interrupt. More... | |
void | TC0_Handler (void) |
Interrupt handler for TC0 interrupt. More... | |
Variables | |
static volatile uint16_t | current_time_ms_touch = 0u |
Current time, set by timer ISR. More... | |
static volatile uint32_t | led_blink_period = 0 |
LED blink period. More... | |
uint16_t | qt_measurement_period_msec = 25u |
Timer period in msec. More... | |
uint32_t | qt_shift_data = 0 |
Shift data gotten from the QTouch. More... | |
static volatile uint8_t | time_to_measure_touch = 0u |
Flag set by timer ISR when it's time to measure touch. More... | |
#define DEFAULT_LED_FREQ 4 |
Set default LED blink period to 250ms*3.
Referenced by init_system().
#define GET_ROTOR_SLIDER_POSITION | ( | ROTOR_SLIDER_NUMBER | ) |
Referenced by main().
#define GET_SENSOR_STATE | ( | SENSOR_NUMBER | ) |
#define LED_BLINK_PERIOD 3 |
LED blink period.
Referenced by TC0_Handler().
#define LED_FREQ_DIV 3 |
frequency divider for LED blinking
Referenced by main().
#define QT_MAX_DATA 255 |
QTouch max data value.
Referenced by main().
#define QTOUCH_LIB_COMPILER_MASK 0x01 |
QTouch library compiler type mask.
#define QTOUCH_LIB_COMPILER_OFFSET 2 |
QTouch library compiler type offset: GCC / IAR.
#define QTOUCH_LIB_KEY_ONLY_MASK 0x01 |
QTouch library supports keys only mask.
#define QTOUCH_LIB_KEY_ONLY_OFFSET 10 |
QTouch library supports keys only offset.
#define QTOUCH_LIB_MAX_CHANNEL_MASK 0x7F |
QTouch library maximum channels mask.
#define QTOUCH_LIB_MAX_CHANNEL_OFFSET 3 |
QTouch library maximum channels offset.
#define QTOUCH_LIB_ROTOR_NUM_MASK 0x1F |
QTouch library maximum rotors/sliders mask.
#define QTOUCH_LIB_ROTOR_NUM_OFFSET 11 |
QTouch library maximum rotors/sliders offset.
#define QTOUCH_LIB_TPYE_MASK 0x01 |
QTouch library type: QTouch / QMatrix.
|
static |
|
static |
Configure Timer Counter 0 to generate an interrupt with the specific frequency.
freq | Timer counter frequency. |
Configure TC with the frequency and trigger on RC compare.
Start the counter.
References sysclk_get_cpu_hz(), tc_disable_interrupt(), tc_enable_interrupt(), tc_find_mck_divisor(), tc_init(), tc_start(), tc_stop(), and tc_write_rc().
Referenced by init_system(), and main().
|
static |
initialize pins, watchdog, etc.
References configure_tc(), DEFAULT_LED_FREQ, gpio_configure_pin, pmc_enable_periph_clk(), sysclk_init(), and wdt_disable().
Referenced by main().
|
static |
Configure timer ISR to fire regularly.
References qt_measurement_period_msec, and sysclk_get_cpu_hz().
Referenced by main().
int main | ( | void | ) |
getting-started Application entry point.
References config_sensors(), configure_tc(), current_time_ms_touch, GET_ROTOR_SLIDER_POSITION, init_system(), init_timer_isr(), LED_FREQ_DIV, qt_filter_callback, qt_init_sensing, QT_MAX_DATA, qt_measure_sensors(), qt_reset_sensing(), qt_set_parameters(), qt_shift_data, QTLIB_BURST_AGAIN, and time_to_measure_touch.
|
static |
This will fill the default threshold values in the configuration data structure.But User can change the values of these parameters.
References DEF_QT_DI, DEF_QT_DRIFT_HOLD_TIME, DEF_QT_MAX_ON_DURATION, DEF_QT_NEG_DRIFT_RATE, DEF_QT_POS_DRIFT_RATE, DEF_QT_POS_RECAL_DELAY, DEF_QT_RECAL_THRESHOLD, qt_config_data, 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().
void SysTick_Handler | ( | void | ) |
Handler for System Tick interrupt.
Process System Tick Event
References current_time_ms_touch, qt_measurement_period_msec, and time_to_measure_touch.
void TC0_Handler | ( | void | ) |
Interrupt handler for TC0 interrupt.
Toggles the state of LEDs.
Toggle LED state.
References gpio_toggle_pin, LED_BLINK_PERIOD, led_blink_period, and tc_get_status().
|
static |
Current time, set by timer ISR.
|
static |
LED blink period.
Referenced by TC0_Handler().
uint32_t qt_shift_data = 0 |
Shift data gotten from the QTouch.
Referenced by main().
|
static |
Flag set by timer ISR when it's time to measure touch.