AVR477QTouch buttons handling implementation.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include "touch_api.h"
#include "Avr477QTouch.h"
#include "memorymap.h"
#include <asf.h>
#include "avr/io.h"
#include <avr/interrupt.h>
Data Structures | |
struct | _Button_t |
Macros | |
#define | DEFAULT_BURST_LENGTH 20u |
configure the individual channel burst length (Based on tuning) More... | |
#define | FILL_OUT_X_LINE_INFO(port_num, x_bit) |
Info stored for each x line. More... | |
#define | FILL_OUT_Y_LINE_INFO(bit) { bit, (TOUCH_DATA_T)(1u << bit) } |
Info stored for each y line. More... | |
#define | FILL_OUT_YA_LINE_INFO(bit) { bit, (uint8_t)(1u << bit) } |
Info stored for each ya line. More... | |
#define | FILL_OUT_YB_LINE_INFO(bit) { bit, (uint8_t)(1u << bit) } |
Info stored for each yb line. More... | |
#define | LED_KEY_BURST_LENGTH_1 32u |
#define | LED_KEY_BURST_LENGTH_2 32u |
#define | QT_MEASUREMENT_PERIOD_MSEC 15u |
#define | ROTOR_BURST_LENGTH_10 25u |
#define | ROTOR_BURST_LENGTH_11 32u |
#define | ROTOR_BURST_LENGTH_8 40u |
#define | ROTOR_BURST_LENGTH_9 36u |
#define | ZERO_BURST_LENGTH 0u |
Typedefs | |
typedef struct _Button_t | Button_t |
Functions | |
void | appButtonsInd (BSP_TouchEvent_t event, uint8_t button, uint8_t data) |
Buttons handler. More... | |
void | BSP_InitQTouch (BSP_TouchEventHandler_t handler) |
Initialize QTouch. More... | |
static void | burst_len_config (void) |
static void | buzzer_init (void) |
Buzzer initialization. More... | |
static void | config_sensors (void) |
Configure the sensors, assign the channel number, aks_group, hysteresis. More... | |
static void | init_system (void) |
initialise host app, pins, watchdog, etc More... | |
static void | init_timer_isr (void) |
configure timer ISR to fire regularly More... | |
ISR (TIMER0_COMPA_vect) | |
static void | led0_toggle (void) |
led0 Toggle More... | |
static void | led1_toggle (void) |
Led1 Toggle. More... | |
static void | qt_avr477_filter_cb (void) |
This function is called every time the qt measuremement is done. 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 | touch_interrupt_call_back (void) |
uint8_t | Touch_measurement (uint8_t *button_event, uint8_t *button_state) |
Touch task handler. More... | |
Variables | |
uint8_t | altFunc |
static volatile uint16_t | burst_flag = 0u |
volatile uint16_t | current_time_ms_touch = 0u |
static uint16_t | filter [QT_NUM_CHANNELS][8] |
uint32_t | key_touch |
uint8_t | qt_burst_lengths [QT_NUM_CHANNELS] |
uint8_t | qt_button |
qt_touch_lib_config_data_t | qt_config_data |
uint8_t | qt_event |
uint16_t | qt_measurement_period_msec = QT_MEASUREMENT_PERIOD_MSEC |
uint32_t | rotor_down |
uint32_t | rotor_up |
static volatile uint16_t | status_flag = 0u |
static volatile uint8_t | time_to_measure_touch = 0u |
uint32_t | timer_int |
timer 0 compare ISR More... | |
uint8_t | touchlink_flag = false |
x_line_info_t | x_line_info [NUM_X_LINES] |
y_line_info_t | ya_line_info [NUM_Y_LINES] |
y_line_info_t | yb_line_info [NUM_Y_LINES] |
#define DEFAULT_BURST_LENGTH 20u |
configure the individual channel burst length (Based on tuning)
Referenced by burst_len_config().
#define FILL_OUT_X_LINE_INFO | ( | port_num, | |
x_bit | |||
) |
Info stored for each x line.
For each X line, enter the port and pin it is on. For instance, if X3 is on PB1, the 4th entry would be FILL_OUT_X_LINE_INFO( 1,1 ), and PORT_X_1 is B
#define FILL_OUT_Y_LINE_INFO | ( | bit | ) | { bit, (TOUCH_DATA_T)(1u << bit) } |
Info stored for each y line.
For each Y line, enter the pin it is on. For instance, if Y2 is on PA5 and PF5, the 3th entry would be FILL_OUT_Y_LINE_INFO( 5 ) NOTE: 1. The PORTs for YA and YB on which Y lines are going to be needs to be defined as PORT_YA and PORT_YB.
Example: PORT_YA=A and PORT_YB=F in the case above.
#define FILL_OUT_YA_LINE_INFO | ( | bit | ) | { bit, (uint8_t)(1u << bit) } |
Info stored for each ya line.
For each YA line, enter the pin it is on. For instance, if Y2A is on PA5 , the 3th entry would be FILL_OUT_YA_LINE_INFO( 5 ) NOTE: 1. The PORTs for YA and YB on which Y lines are going to be needs to be defined as PORT_YA and PORT_YB.
Example: PORT_YA=A in the case above.
#define FILL_OUT_YB_LINE_INFO | ( | bit | ) | { bit, (uint8_t)(1u << bit) } |
Info stored for each yb line.
For each YB line, enter the pin it is on. For instance, if Y2B is on PF3, the 3th entry would be FILL_OUT_YB_LINE_INFO( 3 ) NOTE: 1. The PORTs for YA and YB on which Y lines are going to be needs to be defined as PORT_YA and PORT_YB.
Example: PORT_YB=F in the case above.
#define LED_KEY_BURST_LENGTH_1 32u |
Referenced by burst_len_config().
#define LED_KEY_BURST_LENGTH_2 32u |
Referenced by burst_len_config().
#define QT_MEASUREMENT_PERIOD_MSEC 15u |
#define ROTOR_BURST_LENGTH_10 25u |
Referenced by burst_len_config().
#define ROTOR_BURST_LENGTH_11 32u |
Referenced by burst_len_config().
#define ROTOR_BURST_LENGTH_8 40u |
Referenced by burst_len_config().
#define ROTOR_BURST_LENGTH_9 36u |
Referenced by burst_len_config().
#define ZERO_BURST_LENGTH 0u |
Referenced by burst_len_config().
void appButtonsInd | ( | BSP_TouchEvent_t | event, |
uint8_t | button, | ||
uint8_t | data | ||
) |
void BSP_InitQTouch | ( | BSP_TouchEventHandler_t | handler | ) |
Initialize QTouch.
References burst_len_config(), buzzer_init(), config_sensors(), cpu_irq_enable, init_system(), init_timer_isr(), qt_avr477_filter_cb(), qt_filter_callback, qt_init_sensing, qt_reset_sensing(), and qt_set_parameters().
Referenced by main().
|
static |
|
static |
Buzzer initialization.
Referenced by BSP_InitQTouch().
|
static |
Configure the sensors, assign the channel number, aks_group, hysteresis.
References AKS_GROUP_1, CHANNEL_0, CHANNEL_1, CHANNEL_11, CHANNEL_12, CHANNEL_16, CHANNEL_17, CHANNEL_18, CHANNEL_19, CHANNEL_2, CHANNEL_3, CHANNEL_8, HYST_25, HYST_6_25, qt_enable_key(), qt_enable_rotor(), and RES_8_BIT.
Referenced by BSP_InitQTouch().
|
static |
initialise host app, pins, watchdog, etc
Referenced by BSP_InitQTouch().
|
static |
configure timer ISR to fire regularly
References qt_measurement_period_msec, tc_enable(), and TICKS_PER_MS.
Referenced by BSP_InitQTouch().
ISR | ( | TIMER0_COMPA_vect | ) |
References timer_int, and touch_interrupt_call_back().
|
inlinestatic |
led0 Toggle
Referenced by Touch_measurement().
|
inlinestatic |
Led1 Toggle.
Referenced by Touch_measurement().
|
static |
This function is called every time the qt measuremement is done.
This is the pointer to callback function called before processing the signal
References tag_qt_touch_lib_measure_data_t::channel_signals, filter, qt_measure_data, and QT_NUM_CHANNELS.
Referenced by BSP_InitQTouch().
|
static |
This will fill the default threshold values in the configuration data structure.But User can change the values of these parameters .
This is used to initialize the configuration data for processing.
References DEF_QT_DI, DEF_QT_DRIFT_HOLD_TIME, DEF_QT_MAX_ON_DURATION, DEF_QT_NEG_DRIFT_RATE, DEF_QT_POS_DRIFT_RATE, 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, tag_qt_touch_lib_config_data_t::qt_recal_threshold, and RECAL_100.
Referenced by BSP_InitQTouch().
void touch_interrupt_call_back | ( | void | ) |
References current_time_ms_touch, qt_measurement_period_msec, and time_to_measure_touch.
Referenced by ISR().
uint8_t Touch_measurement | ( | uint8_t * | button_event, |
uint8_t * | button_state | ||
) |
Touch task handler.
References tag_memory_map_t::body, burst_flag, BUTTON_NO_EVENT, BUTTON_PRESSED_EVENT, BUTTON_RELEASED_EVENT, tag_qt_touch_lib_measure_data_t::channel_signals, current_time_ms_touch, INVALID_KEY, KEY_ROT_CCW, KEY_ROT_CW, KEY_SW09, KEY_SW10, KEY_SW11, KEY_SW12, KEY_SW13, KEY_SW14, KEY_SW15, KEY_SW16, KEY_SW17, key_touch, led0_toggle(), led1_toggle(), memory_map, qt_measure_data, qt_measure_sensors(), tag_qt_touch_lib_measure_data_t::qt_touch_status, QTLIB_BURST_AGAIN, rotor_down, rotor_up, tag_qt_touch_status_t::sensor_states, tag_memory_map_body_t::sensor_status, status_flag, time_to_measure_touch, and tag_memory_map_body_t::wheel_position.
Referenced by app_task(), and main().
uint8_t altFunc |
|
static |
Referenced by Touch_measurement().
volatile uint16_t current_time_ms_touch = 0u |
Referenced by touch_interrupt_call_back(), and Touch_measurement().
|
static |
Referenced by qt_avr477_filter_cb().
uint32_t key_touch |
Referenced by Touch_measurement().
uint8_t qt_burst_lengths[QT_NUM_CHANNELS] |
Referenced by burst_len_config().
uint8_t qt_button |
Referenced by appButtonsInd().
qt_touch_lib_config_data_t qt_config_data |
uint8_t qt_event |
Referenced by appButtonsInd().
uint32_t rotor_down |
Referenced by Touch_measurement().
uint32_t rotor_up |
Referenced by Touch_measurement().
|
static |
Referenced by Touch_measurement().
|
static |
Referenced by touch_interrupt_call_back(), and Touch_measurement().
uint32_t timer_int |
timer 0 compare ISR
Referenced by ISR().
uint8_t touchlink_flag = false |
x_line_info_t x_line_info |
y_line_info_t ya_line_info |
y_line_info_t yb_line_info |