From 1ee86ed3abe798cef1fa827950be5235736095a9 Mon Sep 17 00:00:00 2001 From: kangmin Date: Sat, 24 Aug 2019 16:37:45 -0500 Subject: [PATCH] touch lib --- avr/libraries/Touch/library.properties | 2 +- avr/libraries/Touch/src/QTouch/port.h | 717 ------------------ avr/libraries/Touch/src/QTouch/touch.c | 382 ---------- avr/libraries/Touch/src/QTouch/touch.h | 189 ----- avr/libraries/Touch/src/TinyTouch.cpp | 82 +- avr/libraries/Touch/src/TinyTouch.h | 97 ++- ...me_t1616_0x0018.a => libqtm_acq_runtime.a} | Bin ..._t1616_0x0005.a => libqtm_binding_layer.a} | Bin ..._key_t1616_0x0002.a => libqtm_touch_key.a} | Bin .../Touch/src/attiny3217/libqtm_acq_runtime.a | Bin 0 -> 10084 bytes .../src/attiny3217/libqtm_binding_layer.a | Bin 0 -> 5112 bytes .../Touch/src/attiny3217/libqtm_touch_key.a | Bin 0 -> 6934 bytes avr/variants/tiny32/pins_arduino.h | 24 + 13 files changed, 185 insertions(+), 1308 deletions(-) delete mode 100644 avr/libraries/Touch/src/QTouch/port.h delete mode 100644 avr/libraries/Touch/src/QTouch/touch.c delete mode 100644 avr/libraries/Touch/src/QTouch/touch.h rename avr/libraries/Touch/src/attiny1616/{libqtm_acq_runtime_t1616_0x0018.a => libqtm_acq_runtime.a} (100%) rename avr/libraries/Touch/src/attiny1616/{libqtm_binding_layer_t1616_0x0005.a => libqtm_binding_layer.a} (100%) rename avr/libraries/Touch/src/attiny1616/{libqtm_touch_key_t1616_0x0002.a => libqtm_touch_key.a} (100%) create mode 100644 avr/libraries/Touch/src/attiny3217/libqtm_acq_runtime.a create mode 100644 avr/libraries/Touch/src/attiny3217/libqtm_binding_layer.a create mode 100644 avr/libraries/Touch/src/attiny3217/libqtm_touch_key.a diff --git a/avr/libraries/Touch/library.properties b/avr/libraries/Touch/library.properties index 99cba6a..24630ff 100644 --- a/avr/libraries/Touch/library.properties +++ b/avr/libraries/Touch/library.properties @@ -8,4 +8,4 @@ category=Sensors url=http://www.arduino.cc/en/Reference/SPI architectures=avr precompiled=true -ldflags=-lqtm_acq_runtime_t1616_0x0018 -lqtm_binding_layer_t1616_0x0005 -lqtm_touch_key_t1616_0x0002 \ No newline at end of file +ldflags=-lqtm_acq_runtime -lqtm_binding_layer -lqtm_touch_key \ No newline at end of file diff --git a/avr/libraries/Touch/src/QTouch/port.h b/avr/libraries/Touch/src/QTouch/port.h deleted file mode 100644 index beb0c28..0000000 --- a/avr/libraries/Touch/src/QTouch/port.h +++ /dev/null @@ -1,717 +0,0 @@ -/** - * \file - * - * \brief Port related support - * - (c) 2018 Microchip Technology Inc. and its subsidiaries. - - Subject to your compliance with these terms,you may use this software and - any derivatives exclusively with Microchip products.It is your responsibility - to comply with third party license terms applicable to your use of third party - software (including open source software) that may accompany Microchip software. - - THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER - EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED - WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A - PARTICULAR PURPOSE. - - IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, - INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND - WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS - BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE - FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN - ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, - THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. - * - */ - -#ifndef PORT_INCLUDED -#define PORT_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - - -enum port_pull_mode { - PORT_PULL_OFF, - PORT_PULL_UP, -}; - -enum port_dir { - PORT_DIR_IN, - PORT_DIR_OUT, - PORT_DIR_OFF, -}; - -/** - * \brief Set port pin pull mode - * - * Configure pin to pull up, down or disable pull mode, supported pull modes are defined by device used - * - * \param[in] pin The pin number within port - * \param[in] pull_mode Pin pull mode - */ -static inline void PORTA_set_pin_pull_mode(const uint8_t pin, const enum port_pull_mode pull_mode) -{ - volatile uint8_t *port_pin_ctrl = ((uint8_t *)&PORTA + 0x10 + pin); - - if (pull_mode == PORT_PULL_UP) { - *port_pin_ctrl |= PORT_PULLUPEN_bm; - } else if (pull_mode == PORT_PULL_OFF) { - *port_pin_ctrl &= ~PORT_PULLUPEN_bm; - } -} - -/** - * \brief Set port pin inverted mode - * - * Configure pin invert I/O or not - * - * \param[in] pin The pin number within port - * \param[in] inverted Pin inverted mode - */ -static inline void PORTA_pin_set_inverted(const uint8_t pin, const bool inverted) -{ - volatile uint8_t *port_pin_ctrl = ((uint8_t *)&PORTA + 0x10 + pin); - - if (inverted) { - *port_pin_ctrl |= PORT_INVEN_bm; - } else { - *port_pin_ctrl &= ~PORT_INVEN_bm; - } -} - -/** - * \brief Set port pin input/sense configuration - * - * Enable/disable digital input buffer and pin change interrupt, - * select pin interrupt edge/level sensing mode - * - * \param[in] pin pin number within port - * \param[in] isc PORT_ISC_INTDISABLE_gc = Interrupt disabled but input buffer enabled - * PORT_ISC_BOTHEDGES_gc = Sense Both Edges - * PORT_ISC_RISING_gc = Sense Rising Edge - * PORT_ISC_FALLING_gc = Sense Falling Edge - * PORT_ISC_INPUT_DISABLE_gc = Digital Input Buffer disabled - * PORT_ISC_LEVEL_gc = Sense low Level - * - */ -static inline void PORTA_pin_set_isc(const uint8_t pin, const PORT_ISC_t isc) -{ - volatile uint8_t *port_pin_ctrl = ((uint8_t *)&PORTA + 0x10 + pin); - - *port_pin_ctrl = (*port_pin_ctrl & ~PORT_ISC_gm) | isc; -} - -/** - * \brief Set port data direction - * - * Select if the pin data direction is input, output or disabled. - * If disabled state is not possible, this function throws an assert. - * - * \param[in] mask Bit mask where 1 means apply direction setting to the - * corresponding pin - * \param[in] dir PORT_DIR_IN = Data direction in - * PORT_DIR_OUT = Data direction out - * PORT_DIR_OFF = Disables the pin - * (low power state) - */ -static inline void PORTA_set_port_dir(const uint8_t mask, const enum port_dir dir) -{ - switch (dir) { - case PORT_DIR_IN: - VPORTA.DIR &= ~mask; - break; - case PORT_DIR_OUT: - VPORTA.DIR |= mask; - break; - case PORT_DIR_OFF: - /*/ should activate the pullup for power saving - but a bit costly to do it here */ - { - for (uint8_t i = 0; i < 8; i++) { - if (mask & 1 << i) { - *((uint8_t *)&PORTA + 0x10 + i) |= 1 << PORT_PULLUPEN_bp; - } - } - } - break; - default: - break; - } -} - -/** - * \brief Set port pin data direction - * - * Select if the pin data direction is input, output or disabled. - * If disabled state is not possible, this function throws an assert. - * - * \param[in] pin The pin number within port - * \param[in] dir PORT_DIR_IN = Data direction in - * PORT_DIR_OUT = Data direction out - * PORT_DIR_OFF = Disables the pin - * (low power state) - */ -static inline void PORTA_set_pin_dir(const uint8_t pin, const enum port_dir dir) -{ - switch (dir) { - case PORT_DIR_IN: - VPORTA.DIR &= ~(1 << pin); - break; - case PORT_DIR_OUT: - VPORTA.DIR |= (1 << pin); - break; - case PORT_DIR_OFF: - *((uint8_t *)&PORTA + 0x10 + pin) |= 1 << PORT_PULLUPEN_bp; - break; - default: - break; - } -} - -/** - * \brief Set port level - * - * Sets output level on the pins defined by the bit mask - * - * \param[in] mask Bit mask where 1 means apply port level to the corresponding - * pin - * \param[in] level true = Pin levels set to "high" state - * false = Pin levels set to "low" state - */ -static inline void PORTA_set_port_level(const uint8_t mask, const bool level) -{ - if (level == true) { - VPORTA.OUT |= mask; - } else { - VPORTA.OUT &= ~mask; - } -} - -/** - * \brief Set port level - * - * Sets output level on a pin - * - * \param[in] pin The pin number within port - * \param[in] level true = Pin level set to "high" state - * false = Pin level set to "low" state - */ -static inline void PORTA_set_pin_level(const uint8_t pin, const bool level) -{ - if (level == true) { - VPORTA.OUT |= (1 << pin); - } else { - VPORTA.OUT &= ~(1 << pin); - } -} - -/** - * \brief Toggle out level on pins - * - * Toggle the pin levels on pins defined by bit mask - * - * \param[in] mask Bit mask where 1 means toggle pin level to the corresponding - * pin - */ -static inline void PORTA_toggle_port_level(const uint8_t mask) -{ - PORTA.OUTTGL = mask; -} - -/** - * \brief Toggle output level on pin - * - * Toggle the pin levels on pins defined by bit mask - * - * \param[in] pin The pin number within port - */ -static inline void PORTA_toggle_pin_level(const uint8_t pin) -{ - VPORTA.IN |= 1 << pin; -} - -/** - * \brief Get input level on pins - * - * Read the input level on pins connected to a port - * - */ -static inline uint8_t PORTA_get_port_level() -{ - return VPORTA.IN; -} - -/** - * \brief Get level on pin - * - * Reads the level on pins connected to a port - */ -static inline bool PORTA_get_pin_level(const uint8_t pin) -{ - return VPORTA.IN & (1 << pin); -} - -/** - * \brief Write value to Port - * - * Write directly to the port OUT register - * - * \param[in] value Value to write to the port register - */ -static inline void PORTA_write_port(const uint8_t value) -{ - VPORTA.OUT = value; -} - -/** - * \brief Set port pin pull mode - * - * Configure pin to pull up, down or disable pull mode, supported pull modes are defined by device used - * - * \param[in] pin The pin number within port - * \param[in] pull_mode Pin pull mode - */ -static inline void PORTB_set_pin_pull_mode(const uint8_t pin, const enum port_pull_mode pull_mode) -{ - volatile uint8_t *port_pin_ctrl = ((uint8_t *)&PORTB + 0x10 + pin); - - if (pull_mode == PORT_PULL_UP) { - *port_pin_ctrl |= PORT_PULLUPEN_bm; - } else if (pull_mode == PORT_PULL_OFF) { - *port_pin_ctrl &= ~PORT_PULLUPEN_bm; - } -} - -/** - * \brief Set port pin inverted mode - * - * Configure pin invert I/O or not - * - * \param[in] pin The pin number within port - * \param[in] inverted Pin inverted mode - */ -static inline void PORTB_pin_set_inverted(const uint8_t pin, const bool inverted) -{ - volatile uint8_t *port_pin_ctrl = ((uint8_t *)&PORTB + 0x10 + pin); - - if (inverted) { - *port_pin_ctrl |= PORT_INVEN_bm; - } else { - *port_pin_ctrl &= ~PORT_INVEN_bm; - } -} - -/** - * \brief Set port pin input/sense configuration - * - * Enable/disable digital input buffer and pin change interrupt, - * select pin interrupt edge/level sensing mode - * - * \param[in] pin pin number within port - * \param[in] isc PORT_ISC_INTDISABLE_gc = Interrupt disabled but input buffer enabled - * PORT_ISC_BOTHEDGES_gc = Sense Both Edges - * PORT_ISC_RISING_gc = Sense Rising Edge - * PORT_ISC_FALLING_gc = Sense Falling Edge - * PORT_ISC_INPUT_DISABLE_gc = Digital Input Buffer disabled - * PORT_ISC_LEVEL_gc = Sense low Level - * - */ -static inline void PORTB_pin_set_isc(const uint8_t pin, const PORT_ISC_t isc) -{ - volatile uint8_t *port_pin_ctrl = ((uint8_t *)&PORTB + 0x10 + pin); - - *port_pin_ctrl = (*port_pin_ctrl & ~PORT_ISC_gm) | isc; -} - -/** - * \brief Set port data direction - * - * Select if the pin data direction is input, output or disabled. - * If disabled state is not possible, this function throws an assert. - * - * \param[in] mask Bit mask where 1 means apply direction setting to the - * corresponding pin - * \param[in] dir PORT_DIR_IN = Data direction in - * PORT_DIR_OUT = Data direction out - * PORT_DIR_OFF = Disables the pin - * (low power state) - */ -static inline void PORTB_set_port_dir(const uint8_t mask, const enum port_dir dir) -{ - switch (dir) { - case PORT_DIR_IN: - VPORTB.DIR &= ~mask; - break; - case PORT_DIR_OUT: - VPORTB.DIR |= mask; - break; - case PORT_DIR_OFF: - /*/ should activate the pullup for power saving - but a bit costly to do it here */ - { - for (uint8_t i = 0; i < 8; i++) { - if (mask & 1 << i) { - *((uint8_t *)&PORTB + 0x10 + i) |= 1 << PORT_PULLUPEN_bp; - } - } - } - break; - default: - break; - } -} - -/** - * \brief Set port pin data direction - * - * Select if the pin data direction is input, output or disabled. - * If disabled state is not possible, this function throws an assert. - * - * \param[in] pin The pin number within port - * \param[in] dir PORT_DIR_IN = Data direction in - * PORT_DIR_OUT = Data direction out - * PORT_DIR_OFF = Disables the pin - * (low power state) - */ -static inline void PORTB_set_pin_dir(const uint8_t pin, const enum port_dir dir) -{ - switch (dir) { - case PORT_DIR_IN: - VPORTB.DIR &= ~(1 << pin); - break; - case PORT_DIR_OUT: - VPORTB.DIR |= (1 << pin); - break; - case PORT_DIR_OFF: - *((uint8_t *)&PORTB + 0x10 + pin) |= 1 << PORT_PULLUPEN_bp; - break; - default: - break; - } -} - -/** - * \brief Set port level - * - * Sets output level on the pins defined by the bit mask - * - * \param[in] mask Bit mask where 1 means apply port level to the corresponding - * pin - * \param[in] level true = Pin levels set to "high" state - * false = Pin levels set to "low" state - */ -static inline void PORTB_set_port_level(const uint8_t mask, const bool level) -{ - if (level == true) { - VPORTB.OUT |= mask; - } else { - VPORTB.OUT &= ~mask; - } -} - -/** - * \brief Set port level - * - * Sets output level on a pin - * - * \param[in] pin The pin number within port - * \param[in] level true = Pin level set to "high" state - * false = Pin level set to "low" state - */ -static inline void PORTB_set_pin_level(const uint8_t pin, const bool level) -{ - if (level == true) { - VPORTB.OUT |= (1 << pin); - } else { - VPORTB.OUT &= ~(1 << pin); - } -} - -/** - * \brief Toggle out level on pins - * - * Toggle the pin levels on pins defined by bit mask - * - * \param[in] mask Bit mask where 1 means toggle pin level to the corresponding - * pin - */ -static inline void PORTB_toggle_port_level(const uint8_t mask) -{ - PORTB.OUTTGL = mask; -} - -/** - * \brief Toggle output level on pin - * - * Toggle the pin levels on pins defined by bit mask - * - * \param[in] pin The pin number within port - */ -static inline void PORTB_toggle_pin_level(const uint8_t pin) -{ - VPORTB.IN |= 1 << pin; -} - -/** - * \brief Get input level on pins - * - * Read the input level on pins connected to a port - * - */ -static inline uint8_t PORTB_get_port_level() -{ - return VPORTB.IN; -} - -/** - * \brief Get level on pin - * - * Reads the level on pins connected to a port - */ -static inline bool PORTB_get_pin_level(const uint8_t pin) -{ - return VPORTB.IN & (1 << pin); -} - -/** - * \brief Write value to Port - * - * Write directly to the port OUT register - * - * \param[in] value Value to write to the port register - */ -static inline void PORTB_write_port(const uint8_t value) -{ - VPORTB.OUT = value; -} - -/** - * \brief Set port pin pull mode - * - * Configure pin to pull up, down or disable pull mode, supported pull modes are defined by device used - * - * \param[in] pin The pin number within port - * \param[in] pull_mode Pin pull mode - */ -static inline void PORTC_set_pin_pull_mode(const uint8_t pin, const enum port_pull_mode pull_mode) -{ - volatile uint8_t *port_pin_ctrl = ((uint8_t *)&PORTC + 0x10 + pin); - - if (pull_mode == PORT_PULL_UP) { - *port_pin_ctrl |= PORT_PULLUPEN_bm; - } else if (pull_mode == PORT_PULL_OFF) { - *port_pin_ctrl &= ~PORT_PULLUPEN_bm; - } -} - -/** - * \brief Set port pin inverted mode - * - * Configure pin invert I/O or not - * - * \param[in] pin The pin number within port - * \param[in] inverted Pin inverted mode - */ -static inline void PORTC_pin_set_inverted(const uint8_t pin, const bool inverted) -{ - volatile uint8_t *port_pin_ctrl = ((uint8_t *)&PORTC + 0x10 + pin); - - if (inverted) { - *port_pin_ctrl |= PORT_INVEN_bm; - } else { - *port_pin_ctrl &= ~PORT_INVEN_bm; - } -} - -/** - * \brief Set port pin input/sense configuration - * - * Enable/disable digital input buffer and pin change interrupt, - * select pin interrupt edge/level sensing mode - * - * \param[in] pin pin number within port - * \param[in] isc PORT_ISC_INTDISABLE_gc = Interrupt disabled but input buffer enabled - * PORT_ISC_BOTHEDGES_gc = Sense Both Edges - * PORT_ISC_RISING_gc = Sense Rising Edge - * PORT_ISC_FALLING_gc = Sense Falling Edge - * PORT_ISC_INPUT_DISABLE_gc = Digital Input Buffer disabled - * PORT_ISC_LEVEL_gc = Sense low Level - * - */ -static inline void PORTC_pin_set_isc(const uint8_t pin, const PORT_ISC_t isc) -{ - volatile uint8_t *port_pin_ctrl = ((uint8_t *)&PORTC + 0x10 + pin); - - *port_pin_ctrl = (*port_pin_ctrl & ~PORT_ISC_gm) | isc; -} - -/** - * \brief Set port data direction - * - * Select if the pin data direction is input, output or disabled. - * If disabled state is not possible, this function throws an assert. - * - * \param[in] mask Bit mask where 1 means apply direction setting to the - * corresponding pin - * \param[in] dir PORT_DIR_IN = Data direction in - * PORT_DIR_OUT = Data direction out - * PORT_DIR_OFF = Disables the pin - * (low power state) - */ -static inline void PORTC_set_port_dir(const uint8_t mask, const enum port_dir dir) -{ - switch (dir) { - case PORT_DIR_IN: - VPORTC.DIR &= ~mask; - break; - case PORT_DIR_OUT: - VPORTC.DIR |= mask; - break; - case PORT_DIR_OFF: - /*/ should activate the pullup for power saving - but a bit costly to do it here */ - { - for (uint8_t i = 0; i < 8; i++) { - if (mask & 1 << i) { - *((uint8_t *)&PORTC + 0x10 + i) |= 1 << PORT_PULLUPEN_bp; - } - } - } - break; - default: - break; - } -} - -/** - * \brief Set port pin data direction - * - * Select if the pin data direction is input, output or disabled. - * If disabled state is not possible, this function throws an assert. - * - * \param[in] pin The pin number within port - * \param[in] dir PORT_DIR_IN = Data direction in - * PORT_DIR_OUT = Data direction out - * PORT_DIR_OFF = Disables the pin - * (low power state) - */ -static inline void PORTC_set_pin_dir(const uint8_t pin, const enum port_dir dir) -{ - switch (dir) { - case PORT_DIR_IN: - VPORTC.DIR &= ~(1 << pin); - break; - case PORT_DIR_OUT: - VPORTC.DIR |= (1 << pin); - break; - case PORT_DIR_OFF: - *((uint8_t *)&PORTC + 0x10 + pin) |= 1 << PORT_PULLUPEN_bp; - break; - default: - break; - } -} - -/** - * \brief Set port level - * - * Sets output level on the pins defined by the bit mask - * - * \param[in] mask Bit mask where 1 means apply port level to the corresponding - * pin - * \param[in] level true = Pin levels set to "high" state - * false = Pin levels set to "low" state - */ -static inline void PORTC_set_port_level(const uint8_t mask, const bool level) -{ - if (level == true) { - VPORTC.OUT |= mask; - } else { - VPORTC.OUT &= ~mask; - } -} - -/** - * \brief Set port level - * - * Sets output level on a pin - * - * \param[in] pin The pin number within port - * \param[in] level true = Pin level set to "high" state - * false = Pin level set to "low" state - */ -static inline void PORTC_set_pin_level(const uint8_t pin, const bool level) -{ - if (level == true) { - VPORTC.OUT |= (1 << pin); - } else { - VPORTC.OUT &= ~(1 << pin); - } -} - -/** - * \brief Toggle out level on pins - * - * Toggle the pin levels on pins defined by bit mask - * - * \param[in] mask Bit mask where 1 means toggle pin level to the corresponding - * pin - */ -static inline void PORTC_toggle_port_level(const uint8_t mask) -{ - PORTC.OUTTGL = mask; -} - -/** - * \brief Toggle output level on pin - * - * Toggle the pin levels on pins defined by bit mask - * - * \param[in] pin The pin number within port - */ -static inline void PORTC_toggle_pin_level(const uint8_t pin) -{ - VPORTC.IN |= 1 << pin; -} - -/** - * \brief Get input level on pins - * - * Read the input level on pins connected to a port - * - */ -static inline uint8_t PORTC_get_port_level() -{ - return VPORTC.IN; -} - -/** - * \brief Get level on pin - * - * Reads the level on pins connected to a port - */ -static inline bool PORTC_get_pin_level(const uint8_t pin) -{ - return VPORTC.IN & (1 << pin); -} - -/** - * \brief Write value to Port - * - * Write directly to the port OUT register - * - * \param[in] value Value to write to the port register - */ -static inline void PORTC_write_port(const uint8_t value) -{ - VPORTC.OUT = value; -} - -#ifdef __cplusplus -} -#endif - -#endif /* PORT_INCLUDED */ diff --git a/avr/libraries/Touch/src/QTouch/touch.c b/avr/libraries/Touch/src/QTouch/touch.c deleted file mode 100644 index 28102ce..0000000 --- a/avr/libraries/Touch/src/QTouch/touch.c +++ /dev/null @@ -1,382 +0,0 @@ -/*============================================================================ -Filename : touch.c -Project : QTouch Modular Library -Purpose : Provides Initialization, Processing and ISR handler of touch library, - Simple API functions to get/set the key touch parameters from/to the - touch library data structures - -This file is part of QTouch Modular Library Release 6.3 application. - -Important Note: Do not edit this file manually. - Use QTouch Configurator within Atmel Start to apply any - modifications to this file. - -Usage License: Refer license.h file for license information -Support: Visit http://www.microchip.com/support/hottopics.aspx - to create MySupport case. - ------------------------------------------------------------------------------- -Copyright (c) 2019 Microchip. All rights reserved. ------------------------------------------------------------------------------- -============================================================================*/ -#ifndef TOUCH_C -#define TOUCH_C -/*---------------------------------------------------------------------------- - * include files - *----------------------------------------------------------------------------*/ - -#include "touch.h" -#include "license.h" -#include "Arduino.h" - -#include "port.h" - -/*---------------------------------------------------------------------------- - * prototypes - *----------------------------------------------------------------------------*/ - -/*! \brief configure the ptc port pins to Input - */ -static void touch_ptc_pin_config(void); - -/*! \brief configure keys, wheels and sliders. - */ -static touch_ret_t touch_sensors_config(void); - -/*! \brief Touch measure complete callback function example prototype. - */ -static void qtm_measure_complete_callback(void); - -/*! \brief Touch Error callback function prototype. - */ -static void qtm_error_callback(uint8_t error); - -/*---------------------------------------------------------------------------- - * Global Variables - *----------------------------------------------------------------------------*/ -/* Flag to indicate time for touch measurement */ -volatile uint8_t time_to_measure_touch_flag = 0; - -/* postporcess request flag */ -volatile uint8_t touch_postprocess_request = 0; - -/* Measurement Done Touch Flag */ -volatile uint8_t measurement_done_touch = 0; - -/* Error Handling */ -uint8_t module_error_code = 0; - -/* Acquisition module internal data - Size to largest acquisition set */ -uint16_t touch_acq_signals_raw[DEF_NUM_CHANNELS]; - -/* Acquisition set 1 - General settings */ -qtm_acq_node_group_config_t ptc_qtlib_acq_gen1 - = {DEF_NUM_CHANNELS, DEF_SENSOR_TYPE, DEF_PTC_CAL_AUTO_TUNE, DEF_SEL_FREQ_INIT}; - -/* Node status, signal, calibration values */ -qtm_acq_node_data_t ptc_qtlib_node_stat1[DEF_NUM_CHANNELS]; - -/* Node configurations */ -qtm_acq_t161x_node_config_t ptc_seq_node_cfg1[DEF_NUM_CHANNELS] = {NODE_0_PARAMS, NODE_1_PARAMS, NODE_2_PARAMS}; - -/* Container */ -qtm_acquisition_control_t qtlib_acq_set1 = {&ptc_qtlib_acq_gen1, &ptc_seq_node_cfg1[0], &ptc_qtlib_node_stat1[0]}; - -/**********************************************************/ -/*********************** Keys Module **********************/ -/**********************************************************/ - -/* Keys set 1 - General settings */ -qtm_touch_key_group_config_t qtlib_key_grp_config_set1 = {DEF_NUM_SENSORS, - DEF_TOUCH_DET_INT, - DEF_MAX_ON_DURATION, - DEF_ANTI_TCH_DET_INT, - DEF_ANTI_TCH_RECAL_THRSHLD, - DEF_TCH_DRIFT_RATE, - DEF_ANTI_TCH_DRIFT_RATE, - DEF_DRIFT_HOLD_TIME, - DEF_REBURST_MODE}; - -qtm_touch_key_group_data_t qtlib_key_grp_data_set1; - -/* Key data */ -qtm_touch_key_data_t qtlib_key_data_set1[DEF_NUM_SENSORS]; - -/* Key Configurations */ -qtm_touch_key_config_t qtlib_key_configs_set1[DEF_NUM_SENSORS] = {KEY_0_PARAMS, KEY_1_PARAMS, KEY_2_PARAMS}; - -/* Container */ -qtm_touch_key_control_t qtlib_key_set1 - = {&qtlib_key_grp_data_set1, &qtlib_key_grp_config_set1, &qtlib_key_data_set1[0], &qtlib_key_configs_set1[0]}; - - -static void touch_ptc_pin_config(void) -{ - - PORTA_set_pin_pull_mode(4, PORT_PULL_OFF); - PORTA_pin_set_isc(4, PORT_ISC_INPUT_DISABLE_gc); - - PORTA_set_pin_pull_mode(5, PORT_PULL_OFF); - PORTA_pin_set_isc(5, PORT_ISC_INPUT_DISABLE_gc); - - PORTA_set_pin_pull_mode(6, PORT_PULL_OFF); - PORTA_pin_set_isc(6, PORT_ISC_INPUT_DISABLE_gc); -} - -/*============================================================================ -static touch_ret_t touch_sensors_config(void) ------------------------------------------------------------------------------- -Purpose: Initialization of touch key sensors -Input : none -Output : none -Notes : -============================================================================*/ -/* Touch sensors config - assign nodes to buttons / wheels / sliders / surfaces / water level / etc */ -static touch_ret_t touch_sensors_config(void) -{ - uint16_t sensor_nodes; - touch_ret_t touch_ret = TOUCH_SUCCESS; - - /* Init acquisition module */ - qtm_ptc_init_acquisition_module(&qtlib_acq_set1); - - /* Init pointers to DMA sequence memory */ - qtm_ptc_qtlib_assign_signal_memory(&touch_acq_signals_raw[0]); - - /* Initialize sensor nodes */ - - for (sensor_nodes = 0u; sensor_nodes < DEF_NUM_CHANNELS; sensor_nodes++) - - { - /* Enable each node for measurement and mark for calibration */ - qtm_enable_sensor_node(&qtlib_acq_set1, sensor_nodes); - qtm_calibrate_sensor_node(&qtlib_acq_set1, sensor_nodes); - } - - /* Enable sensor keys and assign nodes */ - for (sensor_nodes = 0u; sensor_nodes < DEF_NUM_CHANNELS; sensor_nodes++) { - qtm_init_sensor_key(&qtlib_key_set1, sensor_nodes, &ptc_qtlib_node_stat1[sensor_nodes]); - } - - return (touch_ret); -} - -/*============================================================================ -static void qtm_measure_complete_callback( void ) ------------------------------------------------------------------------------- -Purpose: this function is called after the completion of - measurement cycle. This function sets the post processing request - flag to trigger the post processing. -Input : none -Output : none -Notes : -============================================================================*/ -static void qtm_measure_complete_callback(void) -{ - touch_postprocess_request = 1u; -} /*============================================================================ - static void qtm_error_callback(uint8_t error) - ------------------------------------------------------------------------------ - Purpose: this function is used to report error in the modules. - Input : error code - Output : decoded module error code - Notes : - Derived Module_error_codes: - Acquisition module error =1 - post processing module1 error = 2 - post processing module2 error = 3 - ... and so on - ============================================================================*/ -static void qtm_error_callback(uint8_t error) -{ - module_error_code = error + 1u; - -} - -/*============================================================================ -void Timer_set_period(const uint8_t val) ------------------------------------------------------------------------------- -Purpose: This function sets the time interval on the RTC/Timer peripheral based - on the user configuration. -Input : Time interval -Output : none -Notes : -============================================================================*/ -void Timer_set_period(const uint8_t val) -{ - while (RTC.STATUS & RTC_PERBUSY_bm) /* wait for RTC synchronization */ - ; - RTC.PER = val; -} - -/*============================================================================ -void touch_init(void) ------------------------------------------------------------------------------- -Purpose: Initialization of touch library. PTC, timer, and - datastreamer modules are initialized in this function. -Input : none -Output : none -Notes : -============================================================================*/ -void touch_init(void) -{ - - /* Set match value for timer */ - Timer_set_period(32); - - /* configure the PTC pins for Input*/ - touch_ptc_pin_config(); - - /* Configure touch sensors with Application specific settings */ - touch_sensors_config(); - -} - -/*============================================================================ -void touch_process(void) ------------------------------------------------------------------------------- -Purpose: Main processing function of touch library. This function initiates the - acquisition, calls post processing after the acquistion complete and - sets the flag for next measurement based on the sensor status. -Input : none -Output : none -Notes : -============================================================================*/ -void touch_process(void) -{ - touch_ret_t touch_ret; - - /* check the time_to_measure_touch_flag flag for Touch Acquisition */ - if (time_to_measure_touch_flag == 1u) { - /* Do the acquisition */ - touch_ret = qtm_ptc_start_measurement_seq(&qtlib_acq_set1, qtm_measure_complete_callback); - - /* if the Acquistion request was successful then clear the request flag */ - if (TOUCH_SUCCESS == touch_ret) { - /* Clear the Measure request flag */ - time_to_measure_touch_flag = 0u; - } - } - - /* check the flag for node level post processing */ - if (touch_postprocess_request == 1u) { - /* Reset the flags for node_level_post_processing */ - touch_postprocess_request = 0u; - - /* Run Acquisition module level post processing*/ - touch_ret = qtm_acquisition_process(); - - /* Check the return value */ - if (TOUCH_SUCCESS == touch_ret) { - /* Returned with success: Start module level post processing */ - touch_ret = qtm_key_sensors_process(&qtlib_key_set1); - if (TOUCH_SUCCESS != touch_ret) { - qtm_error_callback(1); - } - } else { - /* Acq module Eror Detected: Issue an Acq module common error code 0x80 */ - qtm_error_callback(0); - } - - if ((0u != (qtlib_key_set1.qtm_touch_key_group_data->qtm_keys_status & 0x80u))) { - time_to_measure_touch_flag = 1u; - } else { - measurement_done_touch = 1u; - } - - } -} - -uint8_t interrupt_cnt; -/*============================================================================ -void touch_timer_handler(void) ------------------------------------------------------------------------------- -Purpose: This function updates the time elapsed to the touch key module to - synchronize the internal time counts used by the module. -Input : none -Output : none -Notes : -============================================================================*/ -void touch_timer_handler(void) -{ - interrupt_cnt++; - if (interrupt_cnt >= DEF_TOUCH_MEASUREMENT_PERIOD_MS) { - interrupt_cnt = 0; - /* Count complete - Measure touch sensors */ - time_to_measure_touch_flag = 1u; - qtm_update_qtlib_timer(DEF_TOUCH_MEASUREMENT_PERIOD_MS); - } -} - -uint16_t get_sensor_node_signal(uint16_t sensor_node) -{ - return (ptc_qtlib_node_stat1[sensor_node].node_acq_signals); -} - -void update_sensor_node_signal(uint16_t sensor_node, uint16_t new_signal) -{ - ptc_qtlib_node_stat1[sensor_node].node_acq_signals = new_signal; -} - -uint16_t get_sensor_node_reference(uint16_t sensor_node) -{ - return (qtlib_key_data_set1[sensor_node].channel_reference); -} - -void update_sensor_node_reference(uint16_t sensor_node, uint16_t new_reference) -{ - qtlib_key_data_set1[sensor_node].channel_reference = new_reference; -} - -uint16_t get_sensor_cc_val(uint16_t sensor_node) -{ - return (ptc_qtlib_node_stat1[sensor_node].node_comp_caps); -} - -void update_sensor_cc_val(uint16_t sensor_node, uint16_t new_cc_value) -{ - ptc_qtlib_node_stat1[sensor_node].node_comp_caps = new_cc_value; -} - -uint8_t get_sensor_state(uint16_t sensor_node) -{ - return (qtlib_key_set1.qtm_touch_key_data[sensor_node].sensor_state); -} - -void update_sensor_state(uint16_t sensor_node, uint8_t new_state) -{ - qtlib_key_set1.qtm_touch_key_data[sensor_node].sensor_state = new_state; -} - -void calibrate_node(uint16_t sensor_node) -{ - /* Calibrate Node */ - qtm_calibrate_sensor_node(&qtlib_acq_set1, sensor_node); - /* Initialize key */ - qtm_init_sensor_key(&qtlib_key_set1, sensor_node, &ptc_qtlib_node_stat1[sensor_node]); -} - -/*============================================================================ -ISR(ADC0_RESRDY_vect) ------------------------------------------------------------------------------- -Purpose: Interrupt handler for ADC / PTC EOC Interrupt -Input : none -Output : none -Notes : none -============================================================================*/ -ISR(ADC0_RESRDY_vect) -{ - qtm_t161x_ptc_handler_eoc(); -} - -ISR(RTC_CNT_vect) -{ - - /* Insert your RTC Compare interrupt handling code */ - touch_timer_handler(); - - /* Compare interrupt flag has to be cleared manually */ - RTC.INTFLAGS = RTC_CMP_bm; -} - -#endif /* TOUCH_C */ diff --git a/avr/libraries/Touch/src/QTouch/touch.h b/avr/libraries/Touch/src/QTouch/touch.h deleted file mode 100644 index eeeb4c6..0000000 --- a/avr/libraries/Touch/src/QTouch/touch.h +++ /dev/null @@ -1,189 +0,0 @@ -/*============================================================================ -Filename : touch.h -Project : QTouch Modular Library -Purpose : configuation macros for touch library - -This file is part of QTouch Modular Library Release 6.3 application. - -Important Note: Do not edit this file manually. - Use QTouch Configurator within Atmel Start to apply any - modifications to this file. - -Usage License: Refer license.h file for license information -Support: Visit http://www.microchip.com/support/hottopics.aspx - to create MySupport case. - ------------------------------------------------------------------------------- -Copyright (c) 2019 Microchip. All rights reserved. ------------------------------------------------------------------------------- -============================================================================*/ - -#ifndef TOUCH_H -#define TOUCH_H - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -/*---------------------------------------------------------------------------- - * include files - *----------------------------------------------------------------------------*/ - -#include "./include/touch_api_ptc.h" - -/**********************************************************/ -/******************* Acquisition controls *****************/ -/**********************************************************/ -/* Defines the Measurement Time in milli seconds. - * Range: 1 to 255. - * Default value: 20. - */ -#define DEF_TOUCH_MEASUREMENT_PERIOD_MS 20 - -/* Defines the Type of sensor - * Default value: NODE_MUTUAL. - */ -#define DEF_SENSOR_TYPE NODE_SELFCAP - -/* Set sensor calibration mode for charge share delay ,Prescaler or series resistor. - * Range: CAL_AUTO_TUNE_NONE / CAL_AUTO_TUNE_RSEL / CAL_AUTO_TUNE_PRSC / CAL_AUTO_TUNE_CSD - * Default value: CAL_AUTO_TUNE_NONE. - */ -#define DEF_PTC_CAL_OPTION CAL_AUTO_TUNE_NONE - -/* Defines the interrupt priority for the PTC. Set low priority to PTC interrupt for applications having interrupt time - * constraints. Range: 0 to 2 Default: 2 (Lowest Priority) - */ -#define DEF_PTC_INTERRUPT_PRIORITY None - -/* Calibration option to ensure full charge transfer */ -/* Bits 7:0 = XX | TT SELECT_TAU | X | CAL_OPTION */ -#define DEF_PTC_TAU_TARGET CAL_CHRG_5TAU -#define DEF_PTC_CAL_AUTO_TUNE (uint8_t)((DEF_PTC_TAU_TARGET << CAL_CHRG_TIME_POS) | DEF_PTC_CAL_OPTION) - -/* Set default bootup acquisition frequency. - * Range: FREQ_SEL_0 - FREQ_SEL_15 , FREQ_SEL_SPREAD - * Default value: FREQ_SEL_0. - */ -#define DEF_SEL_FREQ_INIT FREQ_SEL_0 - -/*---------------------------------------------------------------------------- - * defines - *----------------------------------------------------------------------------*/ - -/**********************************************************/ -/***************** Node Params ******************/ -/**********************************************************/ -/* Acquisition Set 1 */ -/* Defines the number of sensor nodes in the acquisition set - * Range: 1 to 65535. - * Default value: 1 - */ -#define DEF_NUM_CHANNELS (3) - -/* Defines self-cap node parameter setting - * {X-line, Y-line, Charge Share Delay, Prescaler, NODE_G(Analog Gain , Digital Gain), filter level} - */ -#define NODE_0_PARAMS \ - { \ - X_NONE, Y(0), 0, PRSC_DIV_SEL_4, NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ - } -#define NODE_1_PARAMS \ - { \ - X_NONE, Y(1), 0, PRSC_DIV_SEL_4, NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ - } -#define NODE_2_PARAMS \ - { \ - X_NONE, Y(2), 0, PRSC_DIV_SEL_4, NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ - } - -/**********************************************************/ -/***************** Key Params ******************/ -/**********************************************************/ -/* Defines the number of key sensors - * Range: 1 to 65535. - * Default value: 1 - */ -#define DEF_NUM_SENSORS (3) - -/* Defines Key Sensor setting - * {Sensor Threshold, Sensor Hysterisis, Sensor AKS} - */ -#define KEY_0_PARAMS \ - { \ - 20, HYST_25, NO_AKS_GROUP \ - } -#define KEY_1_PARAMS \ - { \ - 20, HYST_25, NO_AKS_GROUP \ - } -#define KEY_2_PARAMS \ - { \ - 20, HYST_25, NO_AKS_GROUP \ - } - -/* De-bounce counter for additional measurements to confirm touch detection - * Range: 0 to 255. - * Default value: 4. - */ -#define DEF_TOUCH_DET_INT 4 - -/* De-bounce counter for additional measurements to confirm away from touch signal - * to initiate Away from touch re-calibration. - * Range: 0 to 255. - * Default value: 5. - */ -#define DEF_ANTI_TCH_DET_INT 5 - -/* Threshold beyond with automatic sensor recalibration is initiated. - * Range: RECAL_100/ RECAL_50 / RECAL_25 / RECAL_12_5 / RECAL_6_25 / MAX_RECAL - * Default value: RECAL_100. - */ -#define DEF_ANTI_TCH_RECAL_THRSHLD RECAL_100 - -/* Rate at which sensor reference value is adjusted towards sensor signal value - * when signal value is greater than reference. - * Units: 200ms - * Range: 0-255 - * Default value: 20u = 4 seconds. - */ -#define DEF_TCH_DRIFT_RATE 20 - -/* Rate at which sensor reference value is adjusted towards sensor signal value - * when signal value is less than reference. - * Units: 200ms - * Range: 0-255 - * Default value: 5u = 1 second. - */ -#define DEF_ANTI_TCH_DRIFT_RATE 5 - -/* Time to restrict drift on all sensor when one or more sensors are activated. - * Units: 200ms - * Range: 0-255 - * Default value: 20u = 4 seconds. - */ -#define DEF_DRIFT_HOLD_TIME 20 - -/* Set mode for additional sensor measurements based on touch activity. - * Range: REBURST_NONE / REBURST_UNRESOLVED / REBURST_ALL - * Default value: REBURST_UNRESOLVED - */ -#define DEF_REBURST_MODE REBURST_UNRESOLVED - -/* Sensor maximum ON duration upon touch. - * Range: 0-255 - * Default value: 0 - */ -#define DEF_MAX_ON_DURATION 0 - -/**********************************************************/ -/***************** Communication - Data Streamer ******************/ -/**********************************************************/ -#define DEF_TOUCH_DATA_STREAMER_ENABLE 1u - -#define DATA_STREAMER_BOARD_TYPE USER_BOARD - -#ifdef __cplusplus -} -#endif // __cplusplus -#endif // TOUCH_C diff --git a/avr/libraries/Touch/src/TinyTouch.cpp b/avr/libraries/Touch/src/TinyTouch.cpp index 6b903a5..38c05f2 100644 --- a/avr/libraries/Touch/src/TinyTouch.cpp +++ b/avr/libraries/Touch/src/TinyTouch.cpp @@ -2,6 +2,38 @@ #include "TinyTouch.h" #include "Arduino.h" +volatile uint8_t TinyTouch::touch_postprocess_request = 0; +volatile uint8_t TinyTouch::time_to_measure_touch_flag = 0; + +uint8_t TinyTouch::interrupt_cnt = 0; + + +ISR(ADC0_RESRDY_vect) +{ + qtm_t161x_ptc_handler_eoc(); +} + +ISR(RTC_CNT_vect) +{ + + /* Insert your RTC Compare interrupt handling code */ + TinyTouch::touch_timer_handler(); + + /* Compare interrupt flag has to be cleared manually */ + RTC.INTFLAGS = RTC_CMP_bm; +} + +static void TinyTouch::touch_timer_handler(void) +{ + interrupt_cnt++; + if (interrupt_cnt >= DEF_TOUCH_MEASUREMENT_PERIOD_MS) { + interrupt_cnt = 0; + /* Count complete - Measure touch sensors */ + time_to_measure_touch_flag = 1u; + qtm_update_qtlib_timer(DEF_TOUCH_MEASUREMENT_PERIOD_MS); + } +} + TinyTouch::TinyTouch() { while (RTC.STATUS > 0) { /* Wait for all register to be synchronized */ @@ -37,8 +69,25 @@ void TinyTouch::begin() // default initializer } void TinyTouch::begin(uint8_t *pinList, uint16_t totalNumPins) { - + + uint16_t sensor_nodes; + touch_ret_t touch_ret = TOUCH_SUCCESS; + PORT_t* port; + uint8_t bit_pos; + volatile uint8_t* pin_ctrl_reg; // to do, init timer and pins + timer_set_period(32); + + for(sensor_nodes = 0; sensor_nodes < totalNumPins; sensor_nodes++) { + port = digitalPinToPortStruct(pinList[sensor_nodes]); + bit_pos = digitalPinToBitPosition(pinList[sensor_nodes]); + /* Calculate where pin control register is */ + pin_ctrl_reg = getPINnCTRLregister(port, bit_pos); + + *pin_ctrl_reg &= ~PORT_PULLUPEN_bm; + *pin_ctrl_reg = (*pin_ctrl_reg & ~PORT_ISC_gm) | PORT_ISC_INPUT_DISABLE_gc; + + } time_to_measure_touch_flag = 0; @@ -48,8 +97,7 @@ void TinyTouch::begin(uint8_t *pinList, uint16_t totalNumPins) { module_error_code = 0; - uint16_t sensor_nodes; - touch_ret_t touch_ret = TOUCH_SUCCESS; + ptc_qtlib_acq_gen1 = {totalNumPins, DEF_SENSOR_TYPE, DEF_PTC_CAL_AUTO_TUNE, DEF_SEL_FREQ_INIT}; @@ -59,13 +107,13 @@ void TinyTouch::begin(uint8_t *pinList, uint16_t totalNumPins) { touch_acq_signals_raw = new uint16_t[totalNumPins]; - for(int i = 0; i < totalNumPins; i++) { - ptc_seq_node_cfg1[i].node_xmask = X_NONE; - ptc_seq_node_cfg1[i].node_ymask = Y(digitalPinToTouchPin(pinList[i])); - ptc_seq_node_cfg1[i].node_csd = 0; - ptc_seq_node_cfg1[i].node_rsel_prsc = PRSC_DIV_SEL_4; - ptc_seq_node_cfg1[i].node_gain = NODE_GAIN(GAIN_1, GAIN_1); - ptc_seq_node_cfg1[i].node_oversampling = FILTER_LEVEL_16; + for(sensor_nodes = 0; sensor_nodes < totalNumPins; sensor_nodes++) { + ptc_seq_node_cfg1[sensor_nodes].node_xmask = X_NONE; + ptc_seq_node_cfg1[sensor_nodes].node_ymask = Y(digitalPinToTouchPin(pinList[sensor_nodes])); + ptc_seq_node_cfg1[sensor_nodes].node_csd = 0; + ptc_seq_node_cfg1[sensor_nodes].node_rsel_prsc = PRSC_DIV_SEL_4; + ptc_seq_node_cfg1[sensor_nodes].node_gain = NODE_GAIN(GAIN_1, GAIN_1); + ptc_seq_node_cfg1[sensor_nodes].node_oversampling = FILTER_LEVEL_16; } @@ -87,7 +135,7 @@ void TinyTouch::begin(uint8_t *pinList, uint16_t totalNumPins) { qtm_calibrate_sensor_node(&qtlib_acq_set1, sensor_nodes); } - qtlib_key_grp_config_set1 = {DEF_NUM_SENSORS, + qtlib_key_grp_config_set1 = {totalNumPins, DEF_TOUCH_DET_INT, DEF_MAX_ON_DURATION, DEF_ANTI_TCH_DET_INT, @@ -119,12 +167,19 @@ void TinyTouch::begin(uint8_t *pinList, uint16_t totalNumPins) { } +void TinyTouch::timer_set_period(const uint8_t val) +{ + while (RTC.STATUS & RTC_PERBUSY_bm) /* wait for RTC synchronization */ + ; + RTC.PER = val; +} + static void TinyTouch::qtm_measure_complete_callback(void) { touch_postprocess_request = 1u; } -static void TinyTouch::qtm_error_callback(uint8_t error) +void TinyTouch::qtm_error_callback(uint8_t error) { module_error_code = error + 1u; @@ -136,6 +191,7 @@ void TinyTouch::touchHandle() { /* check the time_to_measure_touch_flag flag for Touch Acquisition */ if (time_to_measure_touch_flag == 1u) { /* Do the acquisition */ + touch_ret = qtm_ptc_start_measurement_seq(&qtlib_acq_set1, TinyTouch::qtm_measure_complete_callback); /* if the Acquistion request was successful then clear the request flag */ @@ -186,5 +242,5 @@ void TinyTouch::end() { } uint16_t TinyTouch::getValue(uint8_t sensor_node) { - return get_sensor_node_signal(sensor_node); + return (ptc_qtlib_node_stat1[sensor_node].node_acq_signals); } diff --git a/avr/libraries/Touch/src/TinyTouch.h b/avr/libraries/Touch/src/TinyTouch.h index f27db81..7ec77c8 100644 --- a/avr/libraries/Touch/src/TinyTouch.h +++ b/avr/libraries/Touch/src/TinyTouch.h @@ -3,7 +3,87 @@ #include "pins_arduino.h" #include "Arduino.h" -#include "QTouch/touch.h" +#include "QTouch/include/touch_api_ptc.h" +#include "avr/interrupt.h" + +#define DEF_TOUCH_MEASUREMENT_PERIOD_MS 20 + +/* Defines the Type of sensor + * Default value: NODE_MUTUAL. + */ +#define DEF_SENSOR_TYPE NODE_SELFCAP + +/* Set sensor calibration mode for charge share delay ,Prescaler or series resistor. + * Range: CAL_AUTO_TUNE_NONE / CAL_AUTO_TUNE_RSEL / CAL_AUTO_TUNE_PRSC / CAL_AUTO_TUNE_CSD + * Default value: CAL_AUTO_TUNE_NONE. + */ +#define DEF_PTC_CAL_OPTION CAL_AUTO_TUNE_NONE + +/* Defines the interrupt priority for the PTC. Set low priority to PTC interrupt for applications having interrupt time + * constraints. Range: 0 to 2 Default: 2 (Lowest Priority) + */ +#define DEF_PTC_INTERRUPT_PRIORITY None + +/* Calibration option to ensure full charge transfer */ +/* Bits 7:0 = XX | TT SELECT_TAU | X | CAL_OPTION */ +#define DEF_PTC_TAU_TARGET CAL_CHRG_5TAU +#define DEF_PTC_CAL_AUTO_TUNE (uint8_t)((DEF_PTC_TAU_TARGET << CAL_CHRG_TIME_POS) | DEF_PTC_CAL_OPTION) + +/* Set default bootup acquisition frequency. + * Range: FREQ_SEL_0 - FREQ_SEL_15 , FREQ_SEL_SPREAD + * Default value: FREQ_SEL_0. + */ +#define DEF_SEL_FREQ_INIT FREQ_SEL_0 + +#define DEF_TOUCH_DET_INT 4 + +/* De-bounce counter for additional measurements to confirm away from touch signal + * to initiate Away from touch re-calibration. + * Range: 0 to 255. + * Default value: 5. + */ +#define DEF_ANTI_TCH_DET_INT 5 + +/* Threshold beyond with automatic sensor recalibration is initiated. + * Range: RECAL_100/ RECAL_50 / RECAL_25 / RECAL_12_5 / RECAL_6_25 / MAX_RECAL + * Default value: RECAL_100. + */ +#define DEF_ANTI_TCH_RECAL_THRSHLD RECAL_100 + +/* Rate at which sensor reference value is adjusted towards sensor signal value + * when signal value is greater than reference. + * Units: 200ms + * Range: 0-255 + * Default value: 20u = 4 seconds. + */ +#define DEF_TCH_DRIFT_RATE 20 + +/* Rate at which sensor reference value is adjusted towards sensor signal value + * when signal value is less than reference. + * Units: 200ms + * Range: 0-255 + * Default value: 5u = 1 second. + */ +#define DEF_ANTI_TCH_DRIFT_RATE 5 + +/* Time to restrict drift on all sensor when one or more sensors are activated. + * Units: 200ms + * Range: 0-255 + * Default value: 20u = 4 seconds. + */ +#define DEF_DRIFT_HOLD_TIME 20 + +/* Set mode for additional sensor measurements based on touch activity. + * Range: REBURST_NONE / REBURST_UNRESOLVED / REBURST_ALL + * Default value: REBURST_UNRESOLVED + */ +#define DEF_REBURST_MODE REBURST_UNRESOLVED + +/* Sensor maximum ON duration upon touch. + * Range: 0-255 + * Default value: 0 + */ +#define DEF_MAX_ON_DURATION 0 class TinyTouch{ private: @@ -26,15 +106,20 @@ class TinyTouch{ static volatile uint8_t touch_postprocess_request; /* Measurement Done Touch Flag */ - static volatile uint8_t measurement_done_touch; + volatile uint8_t measurement_done_touch; /* Error Handling */ - static uint8_t module_error_code; - - static void qtm_measure_complete_callback(void); - static void qtm_error_callback(uint8_t error); + uint8_t module_error_code; + static uint8_t interrupt_cnt; + void qtm_error_callback(uint8_t error); + void timer_set_period(const uint8_t val); + public: + + static void qtm_measure_complete_callback(void); + static void touch_timer_handler(); + TinyTouch(); ~TinyTouch(); diff --git a/avr/libraries/Touch/src/attiny1616/libqtm_acq_runtime_t1616_0x0018.a b/avr/libraries/Touch/src/attiny1616/libqtm_acq_runtime.a similarity index 100% rename from avr/libraries/Touch/src/attiny1616/libqtm_acq_runtime_t1616_0x0018.a rename to avr/libraries/Touch/src/attiny1616/libqtm_acq_runtime.a diff --git a/avr/libraries/Touch/src/attiny1616/libqtm_binding_layer_t1616_0x0005.a b/avr/libraries/Touch/src/attiny1616/libqtm_binding_layer.a similarity index 100% rename from avr/libraries/Touch/src/attiny1616/libqtm_binding_layer_t1616_0x0005.a rename to avr/libraries/Touch/src/attiny1616/libqtm_binding_layer.a diff --git a/avr/libraries/Touch/src/attiny1616/libqtm_touch_key_t1616_0x0002.a b/avr/libraries/Touch/src/attiny1616/libqtm_touch_key.a similarity index 100% rename from avr/libraries/Touch/src/attiny1616/libqtm_touch_key_t1616_0x0002.a rename to avr/libraries/Touch/src/attiny1616/libqtm_touch_key.a diff --git a/avr/libraries/Touch/src/attiny3217/libqtm_acq_runtime.a b/avr/libraries/Touch/src/attiny3217/libqtm_acq_runtime.a new file mode 100644 index 0000000000000000000000000000000000000000..d6e3f43a65deef134ef394720e4d37b44c5c9969 GIT binary patch literal 10084 zcmeHMdvH|Oc|TVx) zoYiF!ac25gXL_V>zwdnKJHPXt*LTjncg9kGq-FQA!aC3O$#=(s#q$>|Ua)A1$5U?= zIe$H#JACtHh2}yb#6%(TdjB`HH`<~5TlVg2>uig*g@SrZC>V`|+VumW$amU;yY$XL zR1ZfZBG)b)3AF?|J1u?0e?V{bNBw$7z~8wq66gp7qn+7W;b@EA7Ho@N*GxyKbzghH zs?GAf(e}2Ty1%otZC6m|kG~yY9ihlWS(DDFKN5Ae0N3_fr3ZGmwd~e`7|>hxMIvb2 zQU`+mo$Ucw1v^6#J&0mU-Qq`65r6c?692wvsI$cn2Xd-p3kagaq9xF7VMTq5d=H|d zE&6VMu(dr9(F38Do0J@A33Y_6GTH-&W8$#IB(M({6@3@Rysh=-W%~n>PRy04%UwLz zFQprD^X;VseRH9Ie}ogF@6w|S=KB_VLv@9Pb=h*e>dn@oufBfKqD3ChoeLH%v@M$p z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h6@GpZQXzJ?BELL#_iC05*U( zfYiELO@YbEbb zgrM*Ak22fY1ad*<+6hWI3eL4b8?KiaNcH6q2vL9caUuAD*9}<+OIUSKilS*IltiA zbITdCTe$H%?pIi-uen?UuEZmO>Vn9KU7lf zT5$!+23b&xdlTb=6??$*L5#KE1Ud0|W=vHevJA|MJ*?Bf4AM#9wSyCnW1#R3Kz8Dt zLgp$1k4y?Wg1i&2q6E)A=sfW_4hoO{IPp%Rpa(jY6kZw%C*E1yH6DbHcvgG{XMcYQ za^fu=W8W8`wvxijAm_weS8m^_h({dd-xbJCye8ni1)WL??=vWzcp@;6h4*F--jb;!co4IA zzt6$jj>XCKsglC`A_va|2-gSwv+fe$%-@Q!XC38VE5MWtb+*5CId*$s$3Cj0+T9Af z0w`4+3c}7Yy;(dykNq)r1F~Hwo@$G2EBU1yyb#(|WllRj>p9z{9aPz*>RguXsxsP* zHZJ4g80*wagnh7Mj8%zcB!s){n6T^;=A%q?3VGEoxoVSkCxCYpcKoKox#O5~e_|P3 Ohqn$v;3G#xh4()w8fPZ} literal 0 HcmV?d00001 diff --git a/avr/libraries/Touch/src/attiny3217/libqtm_binding_layer.a b/avr/libraries/Touch/src/attiny3217/libqtm_binding_layer.a new file mode 100644 index 0000000000000000000000000000000000000000..4792880859f0fa45636c88e71b2920fcb2b5cdf7 GIT binary patch literal 5112 zcmds4Z){uD6+iw%Nlcc1v@|IVF>GSpMr|i?Q-nrgOXP}Kt4heXCeLJ2R(jHFpwN$p5@+p}-A-A~$nenNNG=)*MeCj($#%UNip54pN5kRx z=!k00cZ`RcOGRq~i=WiB`G0gQi{#;3gtV2{m-4ut9MqkU`D*hqsSz)J-dB@K_ay<*8rH8u zE=G&h#jc+X_N;tV`n1%$daY|?&{wP#yqJ4e4wjCT`d0tyd#UTUgFh}^F144*Lbjh; zjI(YvnCGk1RAFQ0w=UFlj%BHwcWs5LRJ`l-Rm>)TZN0=jte4u#gG=j6SC{&tYhYl0 zd)y4}Sp8FV!}n3w^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TfRiP`;519C2VKW4MJ1TfP@T9Qm0A3J!f7rwXzXt3=rnX2=K_*WAt%9!t z9}7<78V@WMI`wn1(ANOx3Vjjq_d=f!EEjw!a0#+8#z%x+1FSOXs|DW!Y(}Pb1Her} zr*>O~z5}=g*@`trX}ig0zu+{Mli=j%b6~sBH$cB6^lyPNp}U~}OXvxhqb_j6e;mq2 z|C7MUX9{qT&`$%02)-76#)Fg1Bf!~0pATFpbQf@`;AB&YO#V0H*|mZvfNv2t`+z%z zz8knpaI)WP;)ezQ2zUgU`tSkpbHO`+-y$1rT@f6IKf7kq6Hz7`is7BeK|Gt>Eth zn*`qv+${JDz^x{IA2{`mYz_#%1{f8b{2vj#9r&f-#lVZm#+ext97~oZ^wYRUNG@4aO%$iU?SQePJS{4 zUjv>8PCl0civ^zmyhrfGz_}*A1f2ZXfpvnDpH(Kl5uAK(0yYbMC}JBD`WE13lfGZ* zWOLla|0Zm#(7R0hHk7FkhoKD@ycvDKw6nM&*o#1VZxVli)&Ox_*RJc}q%%kTW7XcW za-i3vW2M2o?$uuAz!%;!=AfH_!{e?hbCBxj>+WN!zR9=YUKYK-2luM(>(g*wCgLk` zA64RmvEF6sQ{P{P@!9z2Oz7h=#lUfs&)bfQ+UjaIzH|T5lnq1Lo0vW=jTLAB)ltet zCXORXOE%yjy4AQ27h(9{|z^s Ipw6KG1{B<08~^|S literal 0 HcmV?d00001 diff --git a/avr/variants/tiny32/pins_arduino.h b/avr/variants/tiny32/pins_arduino.h index 2fb5fff..d8d783f 100644 --- a/avr/variants/tiny32/pins_arduino.h +++ b/avr/variants/tiny32/pins_arduino.h @@ -276,6 +276,30 @@ const uint8_t PROGMEM analog_pin_to_channel[] = { 7 // 16 PA7 }; +const uint8_t PROGMEM touch_pin_to_channel[] = { + NOT_A_PIN, // 0 PB3 + NOT_A_PIN, // 1 PB2 + 4, // 2 PB1 + 5, // 3 PB0 + 13, // 4 PB4 + 12, // 5 PB5 + 6, // 6 PC0 + 7, // 7 PC1 + 8, // 8 PC2 + 9, // 9 PC3 + NOT_A_PIN, // 10 PA1 + NOT_A_PIN, // 11 PA2 + NOT_A_PIN, // 12 PA3 + 0, // 13 PA4 + 1, // 14 PA5 + 2, // 15 PA6 + 3, // 16 PA7 + NOT_A_PIN, // 17 PB6 + NOT_A_PIN, // 18 PB7 + 10, // 19 PC4 + 11 // 20 PC5 +}; + #define digitalPinToAnalogInput(p) ((p < NUM_TOTAL_PINS) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN ) #endif