Microchip® Advanced Software Framework

avr477QTouch.c File Reference

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 
)
Value:
{JOIN(burst_qm_, \
port_num), \
(TOUCH_DATA_T)(1u << x_bit), \
BURST_MASK_X_PORT_ ## port_num }
#define JOIN(x, y)
Error Checking For the User Configuration Options ends here.
Definition: touch_api.h:344
#define TOUCH_DATA_T
This part of the code below is used for library selection.
Definition: touch_api.h:631

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().

typedef struct _Button_t Button_t

void appButtonsInd ( BSP_TouchEvent_t  event,
uint8_t  button,
uint8_t  data 
)

Buttons handler.

Parameters
[in]event- event
[in]button- index
[in]data- data (AKA hold time)

References qt_button, and qt_event.

Referenced by main().

static void buzzer_init ( void  )
static

Buzzer initialization.

Referenced by BSP_InitQTouch().

void config_sensors ( void  )
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 void init_system ( void  )
static

initialise host app, pins, watchdog, etc

Referenced by BSP_InitQTouch().

static void init_timer_isr ( void  )
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  )
static void led0_toggle ( void  )
inlinestatic

led0 Toggle

Referenced by Touch_measurement().

static void led1_toggle ( void  )
inlinestatic

Led1 Toggle.

Referenced by Touch_measurement().

static void qt_avr477_filter_cb ( void  )
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 void qt_set_parameters ( void  )
static
void touch_interrupt_call_back ( void  )

uint8_t altFunc
volatile uint16_t burst_flag = 0u
static

Referenced by Touch_measurement().

volatile uint16_t current_time_ms_touch = 0u
uint16_t filter[QT_NUM_CHANNELS][8]
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().

uint8_t qt_event

Referenced by appButtonsInd().

uint32_t rotor_down

Referenced by Touch_measurement().

uint32_t rotor_up

Referenced by Touch_measurement().

volatile uint16_t status_flag = 0u
static

Referenced by Touch_measurement().

volatile uint8_t time_to_measure_touch = 0u
static
uint32_t timer_int

timer 0 compare ISR

Referenced by ISR().

uint8_t touchlink_flag = false
x_line_info_t x_line_info
Initial value:
= {
}
#define FILL_OUT_X_LINE_INFO(port_num, x_bit)
Info stored for each x line.
Definition: avr477QTouch.c:147
y_line_info_t ya_line_info
Initial value:
= {
}
#define FILL_OUT_YA_LINE_INFO(bit)
Info stored for each ya line.
Definition: avr477QTouch.c:177
y_line_info_t yb_line_info
Initial value:
= {
}
#define FILL_OUT_YB_LINE_INFO(bit)
Info stored for each yb line.
Definition: avr477QTouch.c:190