From 64a5072bd11f22da77524bd5e69f54a61958674c Mon Sep 17 00:00:00 2001 From: joeycastillo Date: Wed, 16 Oct 2024 19:26:18 -0400 Subject: [PATCH] add vectorscope touch badge hack --- boards/vectorscope_touch/board.mk | 5 + boards/vectorscope_touch/pins.h | 48 ++ examples/vectorscope_tapedeck/Makefile | 22 + examples/vectorscope_tapedeck/app.c | 208 +++++++++ .../qtouch/atmel_start_pins.h | 35 ++ .../vectorscope_tapedeck/qtouch/hal_atomic.c | 66 +++ .../vectorscope_tapedeck/qtouch/hal_atomic.h | 120 +++++ .../qtouch/include/compiler.h | 64 +++ .../qtouch/include/err_codes.h | 73 +++ .../qtouch/include/hpl_calendar.h | 321 +++++++++++++ .../qtouch/include/hpl_irq.h | 116 +++++ .../qtouch/include/hri_l21.h | 39 ++ .../qtouch/include/parts.h | 41 ++ .../include/qtm_acq_saml21_0x0026_api.h | 338 ++++++++++++++ .../include/qtm_acq_saml22_0x0028_api.h | 380 +++++++++++++++ .../include/qtm_common_components_api.h | 211 +++++++++ .../include/qtm_surface_cs_0x0021_api.h | 150 ++++++ .../qtouch/include/qtm_touch_key_0x0002_api.h | 196 ++++++++ .../qtouch/include/touch_api_ptc.h | 67 +++ .../qtouch/include/utils.h | 368 +++++++++++++++ .../qtouch/include/utils_list.h | 164 +++++++ .../qtouch/lib/gcc/libqtm_acq_saml21_0x0026.a | Bin 0 -> 9914 bytes .../lib/gcc/libqtm_surface_cs_cm0p_0x0021.a | Bin 0 -> 4454 bytes .../lib/gcc/libqtm_touch_key_cm0p_0x0002.a | Bin 0 -> 4180 bytes .../qtouch/lib/iar/qtm_acq_saml21_0x0026.a | Bin 0 -> 16492 bytes .../lib/iar/qtm_surface_cs_cm0p_0x0021.a | Bin 0 -> 7380 bytes .../lib/iar/qtm_touch_key_cm0p_0x0002.a | Bin 0 -> 6652 bytes .../vectorscope_tapedeck/qtouch/license.h | 22 + examples/vectorscope_tapedeck/qtouch/touch.c | 437 ++++++++++++++++++ examples/vectorscope_tapedeck/qtouch/touch.h | 367 +++++++++++++++ .../qtouch/utils_assert.c | 46 ++ .../qtouch/utils_assert.h | 93 ++++ .../vectorscope_tapedeck/qtouch/utils_list.c | 136 ++++++ .../vectorscope_tapedeck/qtouch/utils_list.h | 164 +++++++ 34 files changed, 4297 insertions(+) create mode 100644 boards/vectorscope_touch/board.mk create mode 100644 boards/vectorscope_touch/pins.h create mode 100644 examples/vectorscope_tapedeck/Makefile create mode 100644 examples/vectorscope_tapedeck/app.c create mode 100644 examples/vectorscope_tapedeck/qtouch/atmel_start_pins.h create mode 100644 examples/vectorscope_tapedeck/qtouch/hal_atomic.c create mode 100644 examples/vectorscope_tapedeck/qtouch/hal_atomic.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/compiler.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/err_codes.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/hpl_calendar.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/hpl_irq.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/hri_l21.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/parts.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/qtm_acq_saml21_0x0026_api.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/qtm_acq_saml22_0x0028_api.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/qtm_common_components_api.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/qtm_surface_cs_0x0021_api.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/qtm_touch_key_0x0002_api.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/touch_api_ptc.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/utils.h create mode 100644 examples/vectorscope_tapedeck/qtouch/include/utils_list.h create mode 100644 examples/vectorscope_tapedeck/qtouch/lib/gcc/libqtm_acq_saml21_0x0026.a create mode 100644 examples/vectorscope_tapedeck/qtouch/lib/gcc/libqtm_surface_cs_cm0p_0x0021.a create mode 100644 examples/vectorscope_tapedeck/qtouch/lib/gcc/libqtm_touch_key_cm0p_0x0002.a create mode 100644 examples/vectorscope_tapedeck/qtouch/lib/iar/qtm_acq_saml21_0x0026.a create mode 100644 examples/vectorscope_tapedeck/qtouch/lib/iar/qtm_surface_cs_cm0p_0x0021.a create mode 100644 examples/vectorscope_tapedeck/qtouch/lib/iar/qtm_touch_key_cm0p_0x0002.a create mode 100644 examples/vectorscope_tapedeck/qtouch/license.h create mode 100644 examples/vectorscope_tapedeck/qtouch/touch.c create mode 100644 examples/vectorscope_tapedeck/qtouch/touch.h create mode 100644 examples/vectorscope_tapedeck/qtouch/utils_assert.c create mode 100644 examples/vectorscope_tapedeck/qtouch/utils_assert.h create mode 100644 examples/vectorscope_tapedeck/qtouch/utils_list.c create mode 100644 examples/vectorscope_tapedeck/qtouch/utils_list.h diff --git a/boards/vectorscope_touch/board.mk b/boards/vectorscope_touch/board.mk new file mode 100644 index 0000000..8ed6d88 --- /dev/null +++ b/boards/vectorscope_touch/board.mk @@ -0,0 +1,5 @@ +CHIP = saml21 +LDSCRIPT = saml21j18 + +DEFINES += \ + -D__SAML21G18B__ \ diff --git a/boards/vectorscope_touch/pins.h b/boards/vectorscope_touch/pins.h new file mode 100644 index 0000000..5fed129 --- /dev/null +++ b/boards/vectorscope_touch/pins.h @@ -0,0 +1,48 @@ +#pragma once + +#include "hal_gpio.h" +#include "spi.h" +#include "i2c.h" +#include "uart.h" + +// Analog pins +HAL_GPIO_PIN(YOUT, A, 2) +HAL_GPIO_PIN(XOUT, A, 5) + +// Buttons +HAL_GPIO_PIN(STOP_LIVE, A, 1) +HAL_GPIO_PIN(PLAY_PAUSE, B, 2) +HAL_GPIO_PIN(RECORD, A, 27) +HAL_GPIO_PIN(SLOWER, A, 0) +HAL_GPIO_PIN(FASTER, B, 3) + +// LEDs +HAL_GPIO_PIN(LED_BLUE, A, 12) +HAL_GPIO_PIN(LED_YELLOW, A, 13) +HAL_GPIO_PIN(LED_GREEN, A, 14) +HAL_GPIO_PIN(LED_RED, A, 15) + +// Touch matrix +HAL_GPIO_PIN(X0, A, 16) +HAL_GPIO_PIN(X1, A, 17) +HAL_GPIO_PIN(X2, A, 18) +HAL_GPIO_PIN(X3, A, 19) +HAL_GPIO_PIN(X4, A, 20) +HAL_GPIO_PIN(X5, A, 21) +HAL_GPIO_PIN(X6, A, 22) +HAL_GPIO_PIN(X7, A, 23) +HAL_GPIO_PIN(Y0, A, 3) +HAL_GPIO_PIN(Y1, A, 6) +HAL_GPIO_PIN(Y2, A, 8) +HAL_GPIO_PIN(Y3, A, 9) +HAL_GPIO_PIN(Y4, A, 10) +HAL_GPIO_PIN(Y5, A, 11) +HAL_GPIO_PIN(Y6, B, 10) +HAL_GPIO_PIN(Y7, B, 11) + +// UART +HAL_GPIO_PIN(TX, B, 22) +HAL_GPIO_PIN(RX, A, 23) +#define UART_SERCOM 5 +#define UART_SERCOM_TXPO UART_TXPO_2 +#define UART_SERCOM_RXPO UART_RXPO_3 diff --git a/examples/vectorscope_tapedeck/Makefile b/examples/vectorscope_tapedeck/Makefile new file mode 100644 index 0000000..04aa2d4 --- /dev/null +++ b/examples/vectorscope_tapedeck/Makefile @@ -0,0 +1,22 @@ +# Keep this first line. +GOSSAMER_PATH = ../.. + +# If your firmware targets a specific board, specify it here, +# or omit it and provide it on the command line (make BOARD=foo). +BOARD=vectorscope_touch + +# Leave this line here. +include $(GOSSAMER_PATH)/make.mk + +SRCS += \ + ./app.c \ + ./qtouch/touch.c \ + ./qtouch/hal_atomic.c \ + ./qtouch/utils_list.c \ + +LIBS += ./qtouch/lib/gcc/libqtm_acq_saml21_0x0026.a \ + ./qtouch/lib/gcc/libqtm_surface_cs_cm0p_0x0021.a \ + ./qtouch/lib/gcc/libqtm_touch_key_cm0p_0x0002.a + +# Finally, leave this line at the bottom of the file. +include $(GOSSAMER_PATH)/rules.mk diff --git a/examples/vectorscope_tapedeck/app.c b/examples/vectorscope_tapedeck/app.c new file mode 100644 index 0000000..2496066 --- /dev/null +++ b/examples/vectorscope_tapedeck/app.c @@ -0,0 +1,208 @@ +#include "app.h" +#include "tc.h" +#include "dac.h" +#include "dma.h" +#include "eic.h" +#include "delay.h" +#include "qtouch/touch.h" +#include +#include + +void eic_callback(uint8_t channel); +void reset_to_bootloader(void); + +extern volatile uint8_t measurement_done_touch; + +// needed for arc4random to work +int getentropy(void *buffer, size_t length); +int getentropy(void *buffer, size_t length) { + (void)buffer; + (void)length; + return 0; +} + +// x and y values are a union of two 16-bit values +typedef union { + struct { + uint16_t x; + uint16_t y; + } position; + uint32_t data; +} touch_val_t; + +touch_val_t live_touch_value; + +void app_init(void) { + // set up 4 MHz clock for touch controller + GCLK->GENCTRL[1].reg = GCLK_GENCTRL_DIV(2) | + GCLK_GENCTRL_SRC_OSC16M | + GCLK_GENCTRL_RUNSTDBY | + GCLK_GENCTRL_GENEN; +} + +void app_setup(void) { + // configure EIC + eic_init(); + eic_enable(); + + // Configure buttons as EIC inputs with pullups + HAL_GPIO_STOP_LIVE_in(); + HAL_GPIO_STOP_LIVE_pullup(); + HAL_GPIO_STOP_LIVE_pmuxen(HAL_GPIO_PMUX_EIC); + eic_configure_pin(HAL_GPIO_STOP_LIVE_pin(), INTERRUPT_TRIGGER_FALLING); + eic_enable_interrupt(HAL_GPIO_STOP_LIVE_pin()); + + HAL_GPIO_PLAY_PAUSE_in(); + HAL_GPIO_PLAY_PAUSE_pullup(); + HAL_GPIO_PLAY_PAUSE_pmuxen(HAL_GPIO_PMUX_EIC); + eic_configure_pin(HAL_GPIO_PLAY_PAUSE_pin(), INTERRUPT_TRIGGER_FALLING); + eic_enable_interrupt(HAL_GPIO_PLAY_PAUSE_pin()); + + HAL_GPIO_RECORD_in(); + HAL_GPIO_RECORD_pullup(); + HAL_GPIO_RECORD_pmuxen(HAL_GPIO_PMUX_EIC); + eic_configure_pin(HAL_GPIO_RECORD_pin(), INTERRUPT_TRIGGER_FALLING); + eic_enable_interrupt(HAL_GPIO_RECORD_pin()); + + HAL_GPIO_FASTER_in(); + HAL_GPIO_FASTER_pullup(); + HAL_GPIO_FASTER_pmuxen(HAL_GPIO_PMUX_EIC); + eic_configure_pin(HAL_GPIO_FASTER_pin(), INTERRUPT_TRIGGER_FALLING); + eic_enable_interrupt(HAL_GPIO_FASTER_pin()); + + HAL_GPIO_SLOWER_in(); + HAL_GPIO_SLOWER_pullup(); + HAL_GPIO_SLOWER_pmuxen(HAL_GPIO_PMUX_EIC); + eic_configure_pin(HAL_GPIO_SLOWER_pin(), INTERRUPT_TRIGGER_FALLING); + eic_enable_interrupt(HAL_GPIO_SLOWER_pin()); + + eic_configure_callback(eic_callback); + + // configure DACs + HAL_GPIO_XOUT_pmuxen(HAL_GPIO_PMUX_DAC); + HAL_GPIO_YOUT_pmuxen(HAL_GPIO_PMUX_DAC); + dac_init(); + dac_enable(DAC_CHANNEL_BOTH); + live_touch_value.position.x = 2048; + live_touch_value.position.y = 2048; + + // Configure LEDs + HAL_GPIO_LED_BLUE_out(); + HAL_GPIO_LED_GREEN_out(); + HAL_GPIO_LED_YELLOW_out(); + HAL_GPIO_LED_RED_out(); + + // Configure touch pads + HAL_GPIO_X0_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_X0_out(); + HAL_GPIO_X1_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_X1_out(); + HAL_GPIO_X2_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_X2_out(); + HAL_GPIO_X3_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_X3_out(); + HAL_GPIO_X4_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_X4_out(); + HAL_GPIO_X5_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_X5_out(); + HAL_GPIO_X6_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_X6_out(); + HAL_GPIO_X7_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_X7_out(); + HAL_GPIO_Y0_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_Y0_in(); + HAL_GPIO_Y1_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_Y1_in(); + HAL_GPIO_Y2_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_Y2_in(); + HAL_GPIO_Y3_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_Y3_in(); + HAL_GPIO_Y4_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_Y4_in(); + HAL_GPIO_Y5_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_Y5_in(); + HAL_GPIO_Y6_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_Y6_in(); + HAL_GPIO_Y7_pmuxen(HAL_GPIO_PMUX_PTC); + HAL_GPIO_Y7_in(); + + // enable PTC clock + GCLK->PCHCTRL[PTC_GCLK_ID].reg = GCLK_PCHCTRL_GEN_GCLK1_Val | (1 << GCLK_PCHCTRL_CHEN_Pos); + MCLK->APBDMASK.bit.PTC_ = 1; + + // set up the TC4 interrupt handler to call touch_timer_handler + tc_init(4, GENERIC_CLOCK_0, TC_PRESCALER_DIV1024); // 8 MHz / 1024 = 7182 + tc_set_wavegen(4, TC_WAVE_WAVEGEN_MFRQ); // Match frequency mode, overflow at CC0 + tc_count16_set_cc(4, 0, 156); // 7182 / 156 roughly equals 50 Hz or once every 20 ms + TC4->COUNT16.INTENSET.reg = TC_INTENSET_OVF; // enable overflow interrupt + NVIC_EnableIRQ(TC4_IRQn); + tc_enable(4); + + // Configure qtouch library + touch_init(); +} + +double i = 0; + +bool app_loop(void) { + touch_process(); + if (measurement_done_touch == 1) { + measurement_done_touch = 0; + } + + uint8_t status = get_surface_status(); + if (status & 1) { + // if there is a touch, the DAC outputs a voltage proportional to the touch position + live_touch_value.position.x = (255 - get_surface_position(VER_POS)) << 4; + live_touch_value.position.y = (get_surface_position(HOR_POS)) << 4; + } else { + // otherwise, the DAC outputs a random voltage on both channels + live_touch_value.position.x = arc4random() % 4096; + live_touch_value.position.y = arc4random() % 4096; + } + + // plot the live position on each loop, UNLESS the play/pause button is being held down. + // this will freeze the vectorscope's dot at the current position. + if (HAL_GPIO_PLAY_PAUSE_read()) { + dac_set_analog_value(0, live_touch_value.position.x); + dac_set_analog_value(1, live_touch_value.position.y); + } + + return false; +} + +void irq_handler_tc4(void); +void irq_handler_tc4(void) { + touch_timer_handler(); + HAL_GPIO_LED_BLUE_toggle(); + TC4->COUNT16.INTFLAG.reg = TC_INTFLAG_OVF; +} + +void eic_callback(uint8_t channel) { + switch (channel) { + case 1: // stop/live + break; + case 2: // play/pause + break; + case 15: // record + // if both STOP and PLAY are also held down, reset to bootloader + if (!HAL_GPIO_STOP_LIVE_read() && !HAL_GPIO_PLAY_PAUSE_read()) { + reset_to_bootloader(); + } + break; + case 3: // faster + // if both STOP and PLAY are also held down, just reset + if (!HAL_GPIO_STOP_LIVE_read() && !HAL_GPIO_PLAY_PAUSE_read()) { + NVIC_SystemReset(); + } + break; + case 0: // slower + break; + } +} + +void reset_to_bootloader(void) { + volatile uint32_t *dbl_tap_ptr = ((volatile uint32_t *)(HSRAM_ADDR + HSRAM_SIZE - 4)); + *dbl_tap_ptr = 0xf01669ef; // from the UF2 bootloaer: uf2.h line 255 + NVIC_SystemReset(); +} diff --git a/examples/vectorscope_tapedeck/qtouch/atmel_start_pins.h b/examples/vectorscope_tapedeck/qtouch/atmel_start_pins.h new file mode 100644 index 0000000..9d967b4 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/atmel_start_pins.h @@ -0,0 +1,35 @@ +/* + * Code generated from Atmel Start. + * + * This file will be overwritten when reconfiguring your Atmel Start project. + * Please copy examples or other code you want to keep to a separate file + * to avoid losing it when reconfiguring. + */ +#ifndef ATMEL_START_PINS_H_INCLUDED +#define ATMEL_START_PINS_H_INCLUDED + +#include + +// SAML22 has 9 pin functions + +#define GPIO_PIN_FUNCTION_A 0 +#define GPIO_PIN_FUNCTION_B 1 +#define GPIO_PIN_FUNCTION_C 2 +#define GPIO_PIN_FUNCTION_D 3 +#define GPIO_PIN_FUNCTION_E 4 +#define GPIO_PIN_FUNCTION_F 5 +#define GPIO_PIN_FUNCTION_G 6 +#define GPIO_PIN_FUNCTION_H 7 +#define GPIO_PIN_FUNCTION_I 8 + +#define PA02 GPIO(GPIO_PORTA, 2) +#define PA03 GPIO(GPIO_PORTA, 3) +#define PA10 GPIO(GPIO_PORTA, 10) +#define PA11 GPIO(GPIO_PORTA, 11) +#define PA27 GPIO(GPIO_PORTA, 27) +#define PA30 GPIO(GPIO_PORTA, 30) +#define PB08 GPIO(GPIO_PORTB, 8) +#define PB22 GPIO(GPIO_PORTB, 22) +#define PB23 GPIO(GPIO_PORTB, 23) + +#endif // ATMEL_START_PINS_H_INCLUDED diff --git a/examples/vectorscope_tapedeck/qtouch/hal_atomic.c b/examples/vectorscope_tapedeck/qtouch/hal_atomic.c new file mode 100644 index 0000000..f56418e --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/hal_atomic.c @@ -0,0 +1,66 @@ +/** + * \file + * + * \brief Critical sections related functionality implementation. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#include "hal_atomic.h" + +/** + * \brief Driver version + */ +#define DRIVER_VERSION 0x00000001u + +/** + * \brief Disable interrupts, enter critical section + */ +void atomic_enter_critical(hal_atomic_t volatile *atomic) +{ + *atomic = __get_PRIMASK(); + __disable_irq(); + __DMB(); +} + +/** + * \brief Exit atomic section + */ +void atomic_leave_critical(hal_atomic_t volatile *atomic) +{ + __DMB(); + __set_PRIMASK(*atomic); +} + +/** + * \brief Retrieve the current driver version + */ +uint32_t atomic_get_version(void) +{ + return DRIVER_VERSION; +} diff --git a/examples/vectorscope_tapedeck/qtouch/hal_atomic.h b/examples/vectorscope_tapedeck/qtouch/hal_atomic.h new file mode 100644 index 0000000..442b5b1 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/hal_atomic.h @@ -0,0 +1,120 @@ +/** + * \file + * + * \brief Critical sections related functionality declaration. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#ifndef _HAL_ATOMIC_H_INCLUDED +#define _HAL_ATOMIC_H_INCLUDED + +#include "include/compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \addtogroup doc_driver_hal_helper_atomic + * + *@{ + */ + +/** + * \brief Type for the register holding global interrupt enable flag + */ +typedef uint32_t hal_atomic_t; + +/** + * \brief Helper macro for entering critical sections + * + * This macro is recommended to be used instead of a direct call + * hal_enterCritical() function to enter critical + * sections. No semicolon is required after the macro. + * + * \section atomic_usage Usage Example + * \code + * CRITICAL_SECTION_ENTER() + * Critical code + * CRITICAL_SECTION_LEAVE() + * \endcode + */ +#define CRITICAL_SECTION_ENTER() \ + { \ + volatile hal_atomic_t __atomic; \ + atomic_enter_critical(&__atomic); + +/** + * \brief Helper macro for leaving critical sections + * + * This macro is recommended to be used instead of a direct call + * hal_leaveCritical() function to leave critical + * sections. No semicolon is required after the macro. + */ +#define CRITICAL_SECTION_LEAVE() \ + atomic_leave_critical(&__atomic); \ + } + +/** + * \brief Disable interrupts, enter critical section + * + * Disables global interrupts. Supports nested critical sections, + * so that global interrupts are only re-enabled + * upon leaving the outermost nested critical section. + * + * \param[out] atomic The pointer to a variable to store the value of global + * interrupt enable flag + */ +void atomic_enter_critical(hal_atomic_t volatile *atomic); + +/** + * \brief Exit atomic section + * + * Enables global interrupts. Supports nested critical sections, + * so that global interrupts are only re-enabled + * upon leaving the outermost nested critical section. + * + * \param[in] atomic The pointer to a variable, which stores the latest stored + * value of the global interrupt enable flag + */ +void atomic_leave_critical(hal_atomic_t volatile *atomic); + +/** + * \brief Retrieve the current driver version + * + * \return Current driver version. + */ +uint32_t atomic_get_version(void); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _HAL_ATOMIC_H_INCLUDED */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/compiler.h b/examples/vectorscope_tapedeck/qtouch/include/compiler.h new file mode 100644 index 0000000..f35db3d --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/compiler.h @@ -0,0 +1,64 @@ +/** + * \file + * + * \brief Header + * + * Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ +/* + * Support and FAQ: visit Microchip Support + */ + +/****************************************************************************** + * compiler.h + * + * Created: 05.05.2014 + * Author: N. Fomin + ******************************************************************************/ + +#ifndef _COMPILER_H +#define _COMPILER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#ifndef _UNIT_TEST_ +#include "parts.h" +#endif +#include "err_codes.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _COMPILER_H */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/err_codes.h b/examples/vectorscope_tapedeck/qtouch/include/err_codes.h new file mode 100644 index 0000000..a7aff01 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/err_codes.h @@ -0,0 +1,73 @@ +/** + * \file + * + * \brief Error code definitions. + * + * This file defines various status codes returned by functions, + * indicating success or failure as well as what kind of failure. + * + * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#ifndef ERROR_CODES_H_INCLUDED +#define ERROR_CODES_H_INCLUDED + +#define ERR_NONE 0 +#define ERR_INVALID_DATA -1 +#define ERR_NO_CHANGE -2 +#define ERR_ABORTED -3 +#define ERR_BUSY -4 +#define ERR_SUSPEND -5 +#define ERR_IO -6 +#define ERR_REQ_FLUSHED -7 +#define ERR_TIMEOUT -8 +#define ERR_BAD_DATA -9 +#define ERR_NOT_FOUND -10 +#define ERR_UNSUPPORTED_DEV -11 +#define ERR_NO_MEMORY -12 +#define ERR_INVALID_ARG -13 +#define ERR_BAD_ADDRESS -14 +#define ERR_BAD_FORMAT -15 +#define ERR_BAD_FRQ -16 +#define ERR_DENIED -17 +#define ERR_ALREADY_INITIALIZED -18 +#define ERR_OVERFLOW -19 +#define ERR_NOT_INITIALIZED -20 +#define ERR_SAMPLERATE_UNAVAILABLE -21 +#define ERR_RESOLUTION_UNAVAILABLE -22 +#define ERR_BAUDRATE_UNAVAILABLE -23 +#define ERR_PACKET_COLLISION -24 +#define ERR_PROTOCOL -25 +#define ERR_PIN_MUX_INVALID -26 +#define ERR_UNSUPPORTED_OP -27 +#define ERR_NO_RESOURCE -28 +#define ERR_NOT_READY -29 +#define ERR_FAILURE -30 +#define ERR_WRONG_LENGTH -31 + +#endif diff --git a/examples/vectorscope_tapedeck/qtouch/include/hpl_calendar.h b/examples/vectorscope_tapedeck/qtouch/include/hpl_calendar.h new file mode 100644 index 0000000..3c65d26 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/hpl_calendar.h @@ -0,0 +1,321 @@ +/** + * \file + * + * \brief Generic CALENDAR functionality declaration. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ +#ifndef _HPL_CALENDER_H_INCLUDED +#define _HPL_CALENDER_H_INCLUDED + +#include "compiler.h" +#include "../utils_list.h" +#include "hpl_irq.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Calendar structure + * + * The Calendar structure forward declaration. + */ +struct calendar_dev; + +/** + * \brief Available mask options for alarms. + * + * Available mask options for alarms. + */ +enum calendar_alarm_option { + /** Alarm disabled. */ + CALENDAR_ALARM_MATCH_DISABLED = 0, + /** Alarm match on second. */ + CALENDAR_ALARM_MATCH_SEC, + /** Alarm match on second and minute. */ + CALENDAR_ALARM_MATCH_MIN, + /** Alarm match on second, minute, and hour. */ + CALENDAR_ALARM_MATCH_HOUR, + /** Alarm match on second, minute, hour, and day. */ + CALENDAR_ALARM_MATCH_DAY, + /** Alarm match on second, minute, hour, day, and month. */ + CALENDAR_ALARM_MATCH_MONTH, + /** Alarm match on second, minute, hour, day, month and year. */ + CALENDAR_ALARM_MATCH_YEAR +}; + +/** + * \brief Available mode for alarms. + */ +enum calendar_alarm_mode { ONESHOT = 1, REPEAT }; +/** + * \brief Prototype of callback on alarm match + */ +typedef void (*calendar_drv_cb_alarm_t)(struct calendar_dev *const dev); + +/** + * \brief Prototype of callback on tamper detect + */ +typedef void (*tamper_drv_cb_t)(struct calendar_dev *const dev); + +/** + * \brief Structure of Calendar instance + */ +struct calendar_dev { + /** Pointer to the hardware base */ + void *hw; + /** Alarm match callback */ + calendar_drv_cb_alarm_t callback; + /** Tamper callback */ + tamper_drv_cb_t callback_tamper; + /** IRQ struct */ + struct _irq_descriptor irq; +}; +/** + * \brief Time struct for calendar + */ +struct calendar_time { + /*range from 0 to 59*/ + uint8_t sec; + /*range from 0 to 59*/ + uint8_t min; + /*range from 0 to 23*/ + uint8_t hour; +}; + +/** + * \brief Time struct for calendar + */ +struct calendar_date { + /*range from 1 to 28/29/30/31*/ + uint8_t day; + /*range from 1 to 12*/ + uint8_t month; + /*absolute year>= 1970(such as 2000)*/ + uint16_t year; +}; + +/** \brief Calendar driver struct + * + */ +struct calendar_descriptor { + struct calendar_dev device; + struct list_descriptor alarms; + /*base date/time = base_year/1/1/0/0/0(year/month/day/hour/min/sec)*/ + uint32_t base_year; + uint8_t flags; +}; + +/** \brief Date&Time struct for calendar + */ +struct calendar_date_time { + struct calendar_time time; + struct calendar_date date; +}; + +/** \brief struct for alarm time + */ +struct _calendar_alarm { + struct calendar_date_time datetime; + uint32_t timestamp; + enum calendar_alarm_option option; + enum calendar_alarm_mode mode; +}; + +/** \enum for tamper detection mode + */ +enum tamper_detection_mode { TAMPER_MODE_OFF = 0U, TAMPER_MODE_WAKE, TAMPER_MODE_CAPTURE, TAMPER_MODE_ACTL }; + +/** \enum for tamper detection mode + */ +enum tamper_id { TAMPID0 = 0U, TAMPID1, TAMPID2, TAMPID3, TAMPID4 }; +/** + * \brief Initialize Calendar instance + * + * \param[in] dev The pointer to calendar device struct + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _calendar_init(struct calendar_dev *const dev); + +/** + * \brief Deinitialize Calendar instance + * + * \param[in] dev The pointer to calendar device struct + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _calendar_deinit(struct calendar_dev *const dev); + +/** + * \brief Enable Calendar instance + * + * \param[in] dev The pointer to calendar device struct + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _calendar_enable(struct calendar_dev *const dev); + +/** + * \brief Disable Calendar instance + * + * \param[in] dev The pointer to calendar device struct + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _calendar_disable(struct calendar_dev *const dev); +/** + * \brief Set time for calendar + * + * \param[in] dev The pointer to calendar device struct + * \param[in] p_calendar_time Pointer to the time configuration + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _calendar_set_time(struct calendar_dev *const dev, struct calendar_time *const p_calendar_time); + +/** + * \brief Set date for calendar + * + * \param[in] dev The pointer to calendar device struct + * \param[in] p_calendar_date Pointer to the date configuration + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _calendar_set_date(struct calendar_dev *const dev, struct calendar_date *const p_calendar_date); + +/** + * \brief Get the time for calendar HAL instance and hardware + * Retrieve the time from calendar instance. + * + * \param[in] dev The pointer to calendar device struct + * \param[in] date_time Pointer to value that will be filled with current time + * + * \return Return current counter value + */ +uint32_t _calendar_get_date_time(struct calendar_dev *const dev, struct calendar_date_time *const date_time); + +/** + * \brief Set compare value for calendar + * + * \param[in] dev The pointer to calendar device struct + * \param[in] alarm Pointer to the configuration + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _calendar_set_alarm(struct calendar_dev *const dev, struct _calendar_alarm *const alarm); + +/** + * \brief Register callback for calendar alarm + * + * \param[in] dev The pointer to calendar device struct + * \param[in] callback The pointer to callback function + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _calendar_register_callback(struct calendar_dev *const dev, calendar_drv_cb_alarm_t callback); + +/** + * \brief Set calendar IRQ + * + * \param[in] dev The pointer to calendar device struct + */ +void _calendar_set_irq(struct calendar_dev *const dev); + +/** + * \brief Register callback for tamper detection + * + * \param[in] dev The pointer to calendar device struct + * \param[in] callback The pointer to callback function + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _tamper_register_callback(struct calendar_dev *const dev, tamper_drv_cb_t callback_tamper); + +/** + * \brief Find tamper is detected on specified pin + * + * \param[in] dev The pointer to calendar device struct + * \param[in] enum Tamper ID number + * + * \return true on detection success and false on failure. + */ +bool _is_tamper_detected(struct calendar_dev *const dev, enum tamper_id tamper_id_pin); + +/** + * \brief brief Clear the Tamper ID flag + * + * \param[in] dev The pointer to calendar device struct + * \param[in] enum Tamper ID number + * + * \return ERR_NONE + */ +int32_t _tamper_clear_tampid_flag(struct calendar_dev *const dev, enum tamper_id tamper_id_pin); + +/** + * \brief Enable Debounce Asynchronous Feature + * + * \param[in] dev The pointer to calendar device struct + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _tamper_enable_debounce_asynchronous(struct calendar_dev *const dev); + +/** + * \brief Disable Tamper Debounce Asynchronous Feature + * + * \param[in] dev The pointer to calendar device struct + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _tamper_disable_debounce_asynchronous(struct calendar_dev *const dev); + +/** + * \brief Enable Tamper Debounce Majority Feature + * + * \param[in] dev The pointer to calendar device struct + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _tamper_enable_debounce_majority(struct calendar_dev *const dev); + +/** + * \brief Enable Tamper Debounce Majority Feature + * + * \param[in] dev The pointer to calendar device struct + * + * \return ERR_NONE on success, or an error code on failure. + */ +int32_t _tamper_disable_debounce_majority(struct calendar_dev *const dev); + +#ifdef __cplusplus +} +#endif + +#endif /* _HPL_RTC_H_INCLUDED */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/hpl_irq.h b/examples/vectorscope_tapedeck/qtouch/include/hpl_irq.h new file mode 100644 index 0000000..5ea7c2a --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/hpl_irq.h @@ -0,0 +1,116 @@ +/** + * \file + * + * \brief IRQ related functionality declaration. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#ifndef _HPL_IRQ_H_INCLUDED +#define _HPL_IRQ_H_INCLUDED + +/** + * \addtogroup HPL IRQ + * + * \section hpl_irq_rev Revision History + * - v1.0.0 Initial Release + * + *@{ + */ + +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief IRQ descriptor + */ +struct _irq_descriptor { + void (*handler)(void *parameter); + void *parameter; +}; + +/** + * \name HPL functions + */ +//@{ +/** + * \brief Retrieve current IRQ number + * + * \return The current IRQ number + */ +uint8_t _irq_get_current(void); + +/** + * \brief Disable the given IRQ + * + * \param[in] n The number of IRQ to disable + */ +void _irq_disable(uint8_t n); + +/** + * \brief Set the given IRQ + * + * \param[in] n The number of IRQ to set + */ +void _irq_set(uint8_t n); + +/** + * \brief Clear the given IRQ + * + * \param[in] n The number of IRQ to clear + */ +void _irq_clear(uint8_t n); + +/** + * \brief Enable the given IRQ + * + * \param[in] n The number of IRQ to enable + */ +void _irq_enable(uint8_t n); + +/** + * \brief Register IRQ handler + * + * \param[in] number The number registered IRQ + * \param[in] irq The pointer to irq handler to register + * + * \return The status of IRQ handler registering + * \retval -1 Passed parameters were invalid + * \retval 0 The registering is completed successfully + */ +void _irq_register(const uint8_t number, struct _irq_descriptor *const irq); +//@} + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif /* _HPL_IRQ_H_INCLUDED */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/hri_l21.h b/examples/vectorscope_tapedeck/qtouch/include/hri_l21.h new file mode 100644 index 0000000..abd694d --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/hri_l21.h @@ -0,0 +1,39 @@ +/** + * \file + * + * \brief SAM L22 HRI top-level header file + * + * Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#ifndef _HRI_L22_H_INCLUDED_ +#define _HRI_L22_H_INCLUDED_ + +#include + +#endif /* _HRI_L22_H_INCLUDED_ */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/parts.h b/examples/vectorscope_tapedeck/qtouch/include/parts.h new file mode 100644 index 0000000..faa22f7 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/parts.h @@ -0,0 +1,41 @@ +/** + * \file + * + * \brief Atmel part identification macros + * + * Copyright (c) 2015-2019 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#ifndef ATMEL_PARTS_H +#define ATMEL_PARTS_H + +#include "saml21.h" + +#include "hri_l21.h" + +#endif /* ATMEL_PARTS_H */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/qtm_acq_saml21_0x0026_api.h b/examples/vectorscope_tapedeck/qtouch/include/qtm_acq_saml21_0x0026_api.h new file mode 100644 index 0000000..b3baedf --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/qtm_acq_saml21_0x0026_api.h @@ -0,0 +1,338 @@ +/*============================================================================ +Filename : qtm_acq_saml21_0x0026_api.h +Project : QTouch Modular Library +Purpose : API for Acquisition module - SAML21/PTC +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +Copyright (C) 2019 Microchip Inc. All rights reserved. +------------------------------------------------------------------------------ +============================================================================*/ + +#ifndef TOUCH_API_L21_ACQ_H +#define TOUCH_API_L21_ACQ_H + +/* Include files */ + +#include "qtm_common_components_api.h" + +/* Calibration auto-tuning options */ +#define CAL_OPTION_MASK 0x03u + +#define CAL_AUTO_TUNE_NONE 0u +#define CAL_AUTO_TUNE_RSEL 1u +#define CAL_AUTO_TUNE_PRSC 2u + +/* Timing auto-cal target */ +#define CAL_CHRG_TIME_MASK 0x30u +#define CAL_CHRG_TIME_POS 4u + +#define CAL_CHRG_2TAU 0u +#define CAL_CHRG_3TAU 1u +#define CAL_CHRG_4TAU 2u +#define CAL_CHRG_5TAU 3u + +#define RSEL_MAX_OPTION RSEL_VAL_100 +#define PRSC_MAX_OPTION PRSC_DIV_SEL_32 + +/* X line bit position */ +#define X_NONE 0u +#define X(n) ((uint16_t)(1u << (n))) + +/* Y line bit position */ +#define Y(n) ((uint16_t)(1u << (n))) + +/* Extract Analog / Digital Gain */ +#define NODE_GAIN_ANA(m) (uint8_t)(((m)&0xF0u) >> 4u) +#define NODE_GAIN_DIG(m) (uint8_t)((m)&0x0Fu) + +/* Combine Analog / Digital Gain */ +#define NODE_GAIN(a, d) (uint8_t)(((a) << 4u) | (d)) + +/* Extract Resistor / Prescaler */ +#define NODE_RSEL(m) (uint8_t)(((m)&0xF0u) >> 4u) +#define NODE_PRSC(m) (uint8_t)((m)&0x0Fu) + +/* Combine Resistor / Prescaler */ +#define NODE_RSEL_PRSC(r, p) (uint8_t)(((r) << 4u) | (p)) + +typedef enum tag_filter_level_t { + FILTER_LEVEL_1, + FILTER_LEVEL_2, + FILTER_LEVEL_4, + FILTER_LEVEL_8, + FILTER_LEVEL_16, + FILTER_LEVEL_32, + FILTER_LEVEL_64 +} filter_level_t; + +/* Touch library GAIN setting */ +typedef enum tag_gain_t { GAIN_1, GAIN_2, GAIN_4, GAIN_8, GAIN_16 } gain_t; +/* PTC clock prescale setting. +* For Example: if Generic clock input to PTC = 4MHz, then: +* PRSC_DIV_SEL_4 sets PTC Clock to 1MHz +* PRSC_DIV_SEL_8 sets PTC Clock to 500KHz + +* +*/ +typedef enum tag_prsc_div_sel_t { PRSC_DIV_SEL_4, PRSC_DIV_SEL_8, PRSC_DIV_SEL_16, PRSC_DIV_SEL_32 } prsc_div_sel_t; + +/** + * PTC series resistor setting, only works in mutual capacitance mode + * RSEL_VAL_0 sets internal series resistor to 0ohms. + * RSEL_VAL_20 sets internal series resistor to 20Kohms. + * RSEL_VAL_50 sets internal series resistor to 50Kohms. + * RSEL_VAL_100 sets internal series resistor to 100Kohms. + */ +typedef enum tag_rsel_val_t { RSEL_VAL_0, RSEL_VAL_20, RSEL_VAL_50, RSEL_VAL_100 } rsel_val_t; + +/** +* PTC acquisition frequency delay setting. + +* inserts "n" PTC clock cycles between consecutive measurements +* e.g. FREQ_HOP_SEL_14 setting inserts 14 PTC clock cycles. +OR +* FREQ_SEL_SPREAD automatically sweeps through all 15 delay values during the series of measurements. +*/ +typedef enum tag_freq_config_sel_t { + FREQ_SEL_0, + FREQ_SEL_1, + FREQ_SEL_2, + FREQ_SEL_3, + FREQ_SEL_4, + FREQ_SEL_5, + FREQ_SEL_6, + FREQ_SEL_7, + FREQ_SEL_8, + FREQ_SEL_9, + FREQ_SEL_10, + FREQ_SEL_11, + FREQ_SEL_12, + FREQ_SEL_13, + FREQ_SEL_14, + FREQ_SEL_15, + FREQ_SEL_SPREAD +} freq_config_sel_t; + +/*---------------------------------------------------------------------------- + * Structure Declarations + *----------------------------------------------------------------------------*/ + +/* Acquisition module SAML21 Sequential */ +typedef struct { + uint16_t node_xmask; /* Selects the X Pins for this node */ + uint16_t node_ymask; /* Selects the Y Pins for this node */ + uint8_t node_rsel_prsc; /* Bits 7:4 = Resistor, Bits 3:0 Prescaler */ + uint8_t node_gain; /* Bits 7:4 = Analog gain, Bits 3:0 = Digital gain */ + uint8_t node_oversampling; /* Accumulator setting */ +} qtm_acq_saml21_node_config_t; + +/* Node run-time data - Defined in common api as it will be used with all acquisition modules */ + +/* Node group configuration */ +typedef struct { + uint16_t num_sensor_nodes; /* Number of sensor nodes */ + uint8_t acq_sensor_type; /* Self or mutual sensors */ + uint8_t calib_option_select; /* Hardware tuning: XX | TT 3/4/5 Tau | X | XX None/RSEL/PRSC/CSD */ + uint8_t freq_option_select; /* SDS or ASDV setting */ + uint8_t ptc_interrupt_priority; /* Runtime priority of PTC interrupt */ +} qtm_acq_node_group_config_t; + +/* Container structure for sensor group */ +typedef struct { + qtm_acq_node_group_config_t(*qtm_acq_node_group_config); + qtm_acq_saml21_node_config_t(*qtm_acq_node_config); + qtm_acq_node_data_t(*qtm_acq_node_data); +} qtm_acquisition_control_t; + +typedef struct { + qtm_acquisition_control_t *qtm_acq_control; + uint16_t auto_scan_node_number; + uint8_t auto_scan_node_threshold; + uint8_t auto_scan_trigger; +} qtm_auto_scan_config_t; + +#define DRIVEN_SHIELD_DUMMY_ACQ 3u + +typedef void (*qtm_drivenshield_callback_t)(uint8_t csd, uint8_t sds, uint8_t prescaler, uint8_t volatile *ptr, + uint8_t value); + +typedef struct qtm_drivenshield_config_tag { + uint8_t flags; +} qtm_drivenshield_config_t; + +/*============================================================================ +touch_ret_t qtm_drivenshield_setup(qtm_drivenshield_config_t* config); +------------------------------------------------------------------------------ +Purpose: Setup the softshield with settings from the user +Input : qtm_drivenshield_config_t setup in touch.c and touch.h +Output : touch_ret_t +Notes : Called by application to load the softshield operating parameters +============================================================================*/ +touch_ret_t qtm_drivenshield_setup(qtm_drivenshield_config_t *config); + +/*============================================================================ +touch_ret_t qtm_drivenshield_register_start_callback(qtm_drivenshield_callback_t callback); +------------------------------------------------------------------------------ +Purpose: register the Softshield Start callback with the touch library +Input : pointer to the applicaion function to start the event system +Output : touch_ret_t +Notes : the library initialises this with a null, if this remains the + library will function as normal, if this is not null then the + application will start the event system and call this callback before + start of touch measurement +============================================================================*/ +touch_ret_t qtm_drivenshield_register_start_callback(qtm_drivenshield_callback_t callback); + +/*============================================================================ +touch_ret_t qtm_drivenshield_deregister_start_callback(void); +------------------------------------------------------------------------------ +Purpose: de-registers the Softshield start callback with the touch library +Input : void +Output : touch_ret_t +Notes : when this function is called driven shield functionality will stop +============================================================================*/ +touch_ret_t qtm_drivenshield_deregister_start_callback(void); + +/*---------------------------------------------------------------------------- + * prototypes + *----------------------------------------------------------------------------*/ + +/* Library prototypes */ +/*============================================================================ +touch_ret_t qtm_acquisition_process(void) +------------------------------------------------------------------------------ +Purpose: Signal capture and processing +Input : (Measured signals, config) +Output : touch_ret_t +Notes : Called by application after 'touch_measure_complete_callback' +============================================================================*/ +touch_ret_t qtm_acquisition_process(void); + +/*============================================================================ +touch_ret_t qtm_ptc_init_acquisition_module(qtm_acquisition_control_t* qtm_acq_control_ptr); +------------------------------------------------------------------------------ +Purpose: Initialize the PTC & Assign pins +Input : pointer to acquisition set +Output : touch_ret_t: TOUCH_SUCCESS or INVALID_PARAM +Notes : ptc_init_acquisition module must be called ONLY once with a pointer to each config set +============================================================================*/ +touch_ret_t qtm_ptc_init_acquisition_module(qtm_acquisition_control_t *qtm_acq_control_ptr); + +/*============================================================================ +touch_ret_t qtm_ptc_qtlib_assign_signal_memory(uint16_t* qtm_signal_raw_data_ptr); +------------------------------------------------------------------------------ +Purpose: Assign raw signals pointer to array defined in application code +Input : pointer to raw data array +Output : touch_ret_t: TOUCH_SUCCESS +Notes : none +============================================================================*/ +touch_ret_t qtm_ptc_qtlib_assign_signal_memory(uint16_t *qtm_signal_raw_data_ptr); + +/* Scan configuration */ +/*============================================================================ +touch_ret_t qtm_enable_sensor_node(qtm_acquisition_control_t* qtm_acq_control_ptr, uint16_t qtm_which_node_number); +------------------------------------------------------------------------------ +Purpose: Enables a sensor node for measurement +Input : Node configurations pointer, node (channel) number +Output : touch_ret_t: +Notes : +============================================================================*/ +touch_ret_t qtm_enable_sensor_node(qtm_acquisition_control_t *qtm_acq_control_ptr, uint16_t qtm_which_node_number); + +/*============================================================================ +touch_ret_t qtm_calibrate_sensor_node(ptc_seq_acq_settings* qtm_acq_control_l_ptr, uint16_t which_node_number) +------------------------------------------------------------------------------ +Purpose: Marks a sensor node for calibration +Input : Node configurations pointer, node (channel) number +Output : touch_ret_t: +Notes : +============================================================================*/ +touch_ret_t qtm_calibrate_sensor_node(qtm_acquisition_control_t *qtm_acq_control_ptr, uint16_t qtm_which_node_number); + +/* Measurement start - sequence or windowcomp */ + +/*============================================================================ +touch_ret_t qtm_ptc_start_measurement_seq(qtm_acquisition_control_t* qtm_acq_control_pointer, void +(*measure_complete_callback) (void)); +------------------------------------------------------------------------------ +Purpose: Loads touch configurations for first channel and start, +Input : Node configurations pointer, measure complete callback pointer +Output : touch_ret_t: +Notes : +============================================================================*/ +touch_ret_t qtm_ptc_start_measurement_seq(qtm_acquisition_control_t *qtm_acq_control_pointer, + void (*measure_complete_callback)(void)); + +/*============================================================================ +touch_ret_t qtm_autoscan_sensor_node(qtm_auto_scan_config_t* qtm_auto_scan_config_ptr, void +(*auto_scan_callback)(void)); +------------------------------------------------------------------------------ +Purpose: Configures the PTC for sleep mode measurement of a single node, with window comparator wake +Input : Acquisition set, channel number, threshold, scan trigger +Output : touch_ret_t +Notes : none +============================================================================*/ +touch_ret_t qtm_autoscan_sensor_node(qtm_auto_scan_config_t *qtm_auto_scan_config_ptr, + void (*auto_scan_callback)(void)); + +/*============================================================================ +touch_ret_t qtm_autoscan_node_cancel(void) +------------------------------------------------------------------------------ +Purpose: Cancel auto-scan config +Input : None +Output : touch_ret_t +Notes : none +============================================================================*/ +touch_ret_t qtm_autoscan_node_cancel(void); + +/*============================================================================ +void qtm_ptc_de_init(void) +------------------------------------------------------------------------------ +Purpose: Clear PTC Pin registers, set TOUCH_STATE_NULL +Input : none +Output : none +Notes : none +============================================================================*/ +void qtm_ptc_de_init(void); + +/*============================================================================ +uint16_t qtm_saml21_acq_module_get_id(void); +------------------------------------------------------------------------------ +Purpose: Returns the module ID +Input : none +Output : Module ID +Notes : none +============================================================================*/ +uint16_t qtm_saml21_acq_module_get_id(void); + +/*============================================================================ +uint8_t qtm_saml21_acq_module_get_version(void); +------------------------------------------------------------------------------ +Purpose: Returns the module Firmware version +Input : none +Output : Module ID - Upper nibble major / Lower nibble minor +Notes : none +============================================================================*/ +uint8_t qtm_saml21_acq_module_get_version(void); + +/*============================================================================ +void qtm_ptc_clear_interrupt(void) +------------------------------------------------------------------------------ +Purpose: Clears the eoc/wcomp interrupt bits +Input : none +Output : none +Notes : none +============================================================================*/ +void qtm_ptc_clear_interrupt(void); + +/*============================================================================ +void qtm_saml21_ptc_handler_eoc(void) +------------------------------------------------------------------------------ +Purpose: Captures the measurement, starts the next or End Of Sequence handler +Input : none +Output : none +Notes : none +============================================================================*/ +void qtm_saml21_ptc_handler_eoc(void); + +#endif /* TOUCH_API_L21_ACQ_H */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/qtm_acq_saml22_0x0028_api.h b/examples/vectorscope_tapedeck/qtouch/include/qtm_acq_saml22_0x0028_api.h new file mode 100644 index 0000000..ff0a6f2 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/qtm_acq_saml22_0x0028_api.h @@ -0,0 +1,380 @@ +/*============================================================================ +Filename : qtm_acq_saml22_api.h +Project : QTouch Modular Library +Purpose : API for Acquisition module - SAML22/PTC +------------------------------------------------------------------------------ +Copyright (C) 2019 Microchip. All rights reserved. +------------------------------------------------------------------------------ +============================================================================*/ +/* QTouch Modular Library Configuration */ +/* Header file for application project - Acquisition library API */ + +#ifndef TOUCH_API_L22_ACQ_H +#define TOUCH_API_L22_ACQ_H + +/* Include files */ +#include "qtm_common_components_api.h" + +/* Calibration auto-tuning options */ +#define CAL_OPTION_MASK 0x03u + +#define CAL_AUTO_TUNE_NONE 0u +#define CAL_AUTO_TUNE_RSEL 1u +#define CAL_AUTO_TUNE_PRSC 2u +#define CAL_AUTO_TUNE_CSD 3u + +/* Timing auto-cal target */ +#define CAL_CHRG_TIME_MASK 0x30u +#define CAL_CHRG_TIME_POS 4u + +#define CAL_CHRG_2TAU 0u +#define CAL_CHRG_3TAU 1u +#define CAL_CHRG_4TAU 2u +#define CAL_CHRG_5TAU 3u + +#define RSEL_MAX_OPTION RSEL_VAL_100 +#define PRSC_MAX_OPTION PRSC_DIV_SEL_32 + +/* X line bit position */ +#define X_NONE 0u +#define X(n) ((uint32_t)(1u << (n))) + +/* Y line bit position */ +#define Y(n) ((uint32_t)(((uint32_t)1u) << (n))) + +/* Extract Analog / Digital Gain */ +#define NODE_GAIN_ANA(m) (uint8_t)(((m)&0xF0u) >> 4u) +#define NODE_GAIN_DIG(m) (uint8_t)((m)&0x0Fu) + +/* Combine Analog / Digital Gain */ +#define NODE_GAIN(a, d) (uint8_t)(((a) << 4u) | (d)) + +/* Extract Resistor / Prescaler */ +#define NODE_RSEL(m) (uint8_t)(((m)&0xF0u) >> 4u) +#define NODE_PRSC(m) (uint8_t)((m)&0x0Fu) + +/* Combine Resistor / Prescaler */ +#define NODE_RSEL_PRSC(r, p) (uint8_t)(((r) << 4u) | (p)) + +typedef enum tag_filter_level_t { + FILTER_LEVEL_1, + FILTER_LEVEL_2, + FILTER_LEVEL_4, + FILTER_LEVEL_8, + FILTER_LEVEL_16, + FILTER_LEVEL_32, + FILTER_LEVEL_64 +} filter_level_t; + +/* Touch library GAIN setting */ +typedef enum tag_gain_t { GAIN_1, GAIN_2, GAIN_4, GAIN_8, GAIN_16 } gain_t; +/* PTC clock prescale setting. + * For Example: if Generic clock input to PTC = 4MHz, then: + * PRSC_DIV_SEL_4 sets PTC Clock to 1MHz + * PRSC_DIV_SEL_8 sets PTC Clock to 500KHz + * + */ +typedef enum tag_prsc_div_sel_t { PRSC_DIV_SEL_4, PRSC_DIV_SEL_8, PRSC_DIV_SEL_16, PRSC_DIV_SEL_32 } prsc_div_sel_t; + +/** +* PTC series resistor setting, only works in mutual capacitance mode +* RSEL_VAL_0 sets internal series resistor to 0ohms. +* RSEL_VAL_20 sets internal series resistor to 20Kohms. +* RSEL_VAL_50 sets internal series resistor to 50Kohms. +* RSEL_VAL_75 sets internal series resistor to 75Kohms. +* RSEL_VAL_100 sets internal series resistor to 100Kohms. +* RSEL_VAL_200 sets internal series resistor to 200Kohms. + +*/ +typedef enum tag_rsel_val_t { + RSEL_VAL_0, + RSEL_VAL_20, + RSEL_VAL_50, + RSEL_VAL_75, + RSEL_VAL_100, + RSEL_VAL_200 +} rsel_val_t; + +/** +* PTC acquisition frequency delay setting. + +* inserts "n" PTC clock cycles between consecutive measurements +* e.g. FREQ_HOP_SEL_14 setting inserts 14 PTC clock cycles. +OR +* FREQ_SEL_SPREAD automatically sweeps through all 15 delay values during the series of measurements. +*/ +typedef enum tag_freq_config_sel_t { + FREQ_SEL_0, + FREQ_SEL_1, + FREQ_SEL_2, + FREQ_SEL_3, + FREQ_SEL_4, + FREQ_SEL_5, + FREQ_SEL_6, + FREQ_SEL_7, + FREQ_SEL_8, + FREQ_SEL_9, + FREQ_SEL_10, + FREQ_SEL_11, + FREQ_SEL_12, + FREQ_SEL_13, + FREQ_SEL_14, + FREQ_SEL_15, + FREQ_SEL_SPREAD +} freq_config_sel_t; + +/*---------------------------------------------------------------------------- + * Structure Declarations + *----------------------------------------------------------------------------*/ + +/* Acquisition module SAML22 Sequential */ +typedef struct { + uint32_t node_xmask; /* Selects the X Pins for this node */ + uint32_t node_ymask; /* Selects the Y Pins for this node */ + uint8_t node_csd; /* Charge Share Delay */ + uint8_t node_rsel_prsc; /* Bits 7:4 = Resistor, Bits 3:0 Prescaler */ + uint8_t node_gain; /* Bits 7:4 = Analog gain, Bits 3:0 = Digital gain */ + uint8_t node_oversampling; /* Accumulator setting */ +} qtm_acq_saml22_node_config_t; + +/* Node run-time data - Defined in common api as it will be used with all acquisition modules */ + +/* Node group configuration */ +typedef struct { + uint16_t num_sensor_nodes; /* Number of sensor nodes */ + uint8_t acq_sensor_type; /* Self or mutual sensors */ + uint8_t calib_option_select; /* Hardware tuning: XX | TT 3/4/5 Tau | X | XX None/RSEL/PRSC/CSD */ + uint8_t freq_option_select; /* SDS or ASDV setting */ + uint8_t ptc_interrupt_priority; /* Runtime priority of PTC interrupt */ +} qtm_acq_node_group_config_t; + +/* Container structure for sensor group */ +typedef struct { + qtm_acq_node_group_config_t(*qtm_acq_node_group_config); + qtm_acq_saml22_node_config_t(*qtm_acq_node_config); + qtm_acq_node_data_t(*qtm_acq_node_data); +} qtm_acquisition_control_t; + +typedef struct { + qtm_acquisition_control_t *qtm_acq_control; + uint16_t auto_scan_node_number; + uint8_t auto_scan_node_threshold; + uint8_t auto_scan_trigger; +} qtm_auto_scan_config_t; + +#define DRIVEN_SHIELD_DUMMY_ACQ 3u + +typedef void (*qtm_drivenshield_callback_t)(uint8_t csd, uint8_t sds, uint8_t prescaler, uint32_t volatile *ptr, + uint32_t value); + +typedef struct qtm_drivenshield_config_tag { + uint8_t flags; +} qtm_drivenshield_config_t; + +/*============================================================================ +touch_ret_t qtm_drivenshield_setup(qtm_drivenshield_config_t* config); +------------------------------------------------------------------------------ +Purpose: Setup the drivenshield with settings from the user +Input : drivenshield_config_t setup in touch.c and touch.h +Output : touch_ret_t +Notes : Called by application to load the drivenshield operating parameters +============================================================================*/ +touch_ret_t qtm_drivenshield_setup(qtm_drivenshield_config_t *config); + +/*============================================================================ +touch_ret_t qtm_drivenshield_register_start_callback(qtm_drivenshield_callback_t callback); +------------------------------------------------------------------------------ +Purpose: Register the drivenshield Start callback with the touch library +Input : Pointer to the application function to start the event system +Output : touch_ret_t +Notes : The library initialises this with a null, if this remains the + library will function as normal, if this is not null then the + application will start the event system and call this callback before + start of touch measurement +============================================================================*/ +touch_ret_t qtm_drivenshield_register_start_callback(qtm_drivenshield_callback_t callback); + +/*============================================================================ +void qtm_drivenshield_register_complete_callback(qtm_drivenshield_callback_t callback); +------------------------------------------------------------------------------ +Purpose: register the drivenshield complete callback with the touch library +Input : pointer to the applicaion function to stop the drivenshield timer +Output : touch_ret_t +Notes : the library initialises this with a null, if this remains the the + library will function as normal, if this is not null then the + application will have some code to stop the drivenshield timer +============================================================================*/ +void qtm_drivenshield_register_complete_callback(qtm_drivenshield_callback_t callback); +/*============================================================================ +touch_ret_t qtm_drivenshield_deregister_start_callback(void); +------------------------------------------------------------------------------ +Purpose: De-register the drivenshield Start callback with the touch library +Input : None +Output : touch_ret_t +Notes : When this function is called driven shield functionality will stop +============================================================================*/ +touch_ret_t qtm_drivenshield_deregister_start_callback(void); + +/*---------------------------------------------------------------------------- + * prototypes + *----------------------------------------------------------------------------*/ + +/* Library prototypes */ +/*============================================================================ +touch_ret_t qtm_acquisition_process(void) +------------------------------------------------------------------------------ +Purpose: Signal capture and processing +Input : (Measured signals, config) +Output : touch_ret_t +Notes : Called by application after 'touch_measure_complete_callback' +============================================================================*/ +touch_ret_t qtm_acquisition_process(void); + +/*============================================================================ +touch_ret_t qtm_ptc_init_acquisition_module(qtm_acquisition_control_t* qtm_acq_control_ptr); +------------------------------------------------------------------------------ +Purpose: Initialize the PTC & Assign pins +Input : pointer to acquisition set +Output : touch_ret_t: TOUCH_SUCCESS or INVALID_PARAM +Notes : ptc_init_acquisition module must be called ONLY once with a pointer to each config set +============================================================================*/ +touch_ret_t qtm_ptc_init_acquisition_module(qtm_acquisition_control_t *qtm_acq_control_ptr); + +/*============================================================================ +touch_ret_t qtm_ptc_qtlib_assign_signal_memory(uint16_t* qtm_signal_raw_data_ptr); +------------------------------------------------------------------------------ +Purpose: Assign raw signals pointer to array defined in application code +Input : pointer to raw data array +Output : touch_ret_t: TOUCH_SUCCESS +Notes : none +============================================================================*/ +touch_ret_t qtm_ptc_qtlib_assign_signal_memory(uint16_t *qtm_signal_raw_data_ptr); + +/* Scan configuration */ +/*============================================================================ +touch_ret_t qtm_enable_sensor_node(qtm_acquisition_control_t* qtm_acq_control_ptr, uint16_t qtm_which_node_number); +------------------------------------------------------------------------------ +Purpose: Enables a sensor node for measurement +Input : Node configurations pointer, node (channel) number +Output : touch_ret_t: +Notes : +============================================================================*/ +touch_ret_t qtm_enable_sensor_node(qtm_acquisition_control_t *qtm_acq_control_ptr, uint16_t qtm_which_node_number); + +/*============================================================================ +touch_ret_t qtm_calibrate_sensor_node(ptc_seq_acq_settings* qtm_acq_control_l_ptr, uint16_t which_node_number) +------------------------------------------------------------------------------ +Purpose: Marks a sensor node for calibration +Input : Node configurations pointer, node (channel) number +Output : touch_ret_t: +Notes : +============================================================================*/ +touch_ret_t qtm_calibrate_sensor_node(qtm_acquisition_control_t *qtm_acq_control_ptr, uint16_t qtm_which_node_number); + +/* Measurement start - sequence or windowcomp */ + +/*============================================================================ +touch_ret_t qtm_ptc_start_measurement_seq(qtm_acquisition_control_t* qtm_acq_control_pointer, void +(*measure_complete_callback) (void)); +------------------------------------------------------------------------------ +Purpose: Loads touch configurations for first channel and start, +Input : Node configurations pointer, measure complete callback pointer +Output : touch_ret_t: +Notes : +============================================================================*/ +touch_ret_t qtm_ptc_start_measurement_seq(qtm_acquisition_control_t *qtm_acq_control_pointer, + void (*measure_complete_callback)(void)); + +/*============================================================================ +touch_ret_t qtm_autoscan_sensor_node(qtm_auto_scan_config_t* qtm_auto_scan_config_ptr, void +(*auto_scan_callback)(void)); +------------------------------------------------------------------------------ +Purpose: Configures the PTC for sleep mode measurement of a single node, with window comparator wake +Input : Acquisition set, channel number, threshold, scan trigger +Output : touch_ret_t +Notes : none +============================================================================*/ +touch_ret_t qtm_autoscan_sensor_node(qtm_auto_scan_config_t *qtm_auto_scan_config_ptr, + void (*auto_scan_callback)(void)); + +/*============================================================================ +touch_ret_t qtm_autoscan_node_cancel(void) +------------------------------------------------------------------------------ +Purpose: Cancel auto-scan config +Input : None +Output : touch_ret_t +Notes : none +============================================================================*/ +touch_ret_t qtm_autoscan_node_cancel(void); + +/*============================================================================ +void qtm_ptc_de_init(void) +------------------------------------------------------------------------------ +Purpose: Clear PTC Pin registers, set TOUCH_STATE_NULL +Input : none +Output : none +Notes : none +============================================================================*/ +void qtm_ptc_de_init(void); + +/*============================================================================ +uint16_t qtm_saml22_acq_module_get_id(void); +------------------------------------------------------------------------------ +Purpose: Returns the module ID +Input : none +Output : Module ID +Notes : none +============================================================================*/ +uint16_t qtm_saml22_acq_module_get_id(void); + +/*============================================================================ +uint8_t qtm_saml22_acq_module_get_version(void); +------------------------------------------------------------------------------ +Purpose: Returns the module Firmware version +Input : none +Output : Module ID - Upper nibble major / Lower nibble minor +Notes : none +============================================================================*/ +uint8_t qtm_saml22_acq_module_get_version(void); + +/*============================================================================ +void qtm_ptc_clear_interrupt(void) +------------------------------------------------------------------------------ +Purpose: Clears the eoc/wcomp interrupt bits +Input : none +Output : none +Notes : none +============================================================================*/ +void qtm_ptc_clear_interrupt(void); + +/*============================================================================ +void qtm_saml22_ptc_handler_eoc(void) +------------------------------------------------------------------------------ +Purpose: Captures the measurement, starts the next or End Of Sequence handler +Input : none +Output : none +Notes : none +============================================================================*/ +void qtm_saml22_ptc_handler_eoc(void); + +/*============================================================================ +void qtm_saml22_ptc_handler_wcomp(void) +------------------------------------------------------------------------------ +Purpose: Captures the measurement, calls the callback +Input : none +Output : none +Notes : none +============================================================================*/ +void qtm_saml22_ptc_handler_wcomp(void); + +/*============================================================================ +void qtm_ptc_clear_interrupt(void) +------------------------------------------------------------------------------ +Purpose: Clears the eoc/wcomp interrupt bits +Input : none +Output : none +Notes : none +============================================================================*/ +void qtm_ptc_clear_interrupt(void); + +#endif /* TOUCH_API_L22_ACQ_H */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/qtm_common_components_api.h b/examples/vectorscope_tapedeck/qtouch/include/qtm_common_components_api.h new file mode 100644 index 0000000..ed0b14e --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/qtm_common_components_api.h @@ -0,0 +1,211 @@ +/*============================================================================ +Filename : qtm_common_components_api.h +Project : QTouch Modular Library +Purpose : Stucts and definitions for use within modules +------------------------------------------------------------------------------ +Revision 1.0 - Released +Revision 1.1 - FMEA to BIST name change +Revision 1.2 - Maintain Backward Compatibility with FMEA to BIST name change +============================================================================*/ +/* + (c) 2020 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip 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 __QTM_API_COMMON_INC__ +#define __QTM_API_COMMON_INC__ + +#include +#include + +/* ---------------------------------------------------------------------------------------- */ +/* Version Information */ +/* ---------------------------------------------------------------------------------------- */ +#define COMMON_COMPONENTS_VERSION 0x12 + +/* ---------------------------------------------------------------------------------------- */ +/* Acquisition type */ +/* ---------------------------------------------------------------------------------------- */ +/* Acquisition set config */ +#define NODE_SELFCAP 0x80u +#define NODE_SELFCAP_SHIELD 0x81u +#define NODE_SELFCAP_SHIELD_2L 0x82u +#define NODE_MUTUAL 0x40u +#define NODE_MUTUAL_4P 0x41u +#define NODE_MUTUAL_8P 0x42u + +/* ---------------------------------------------------------------------------------------- */ +/* Touch Library functions return a touch_ret_t */ +/* ---------------------------------------------------------------------------------------- */ +typedef enum tag_touch_ret_t { + /* Successful completion of operation. */ + TOUCH_SUCCESS = 0u, + + /* Touch Library is busy with pending previous Touch measurement. */ + TOUCH_ACQ_INCOMPLETE = 1u, + + /* Invalid input parameter. */ + TOUCH_INVALID_INPUT_PARAM = 2u, + + /* Operation not allowed in the current state of the library module. */ + TOUCH_INVALID_LIB_STATE = 3u, + + /* Successful completion of FMEA.*/ + TOUCH_FMEA_SUCCESS = 4u, + + /* Error in FMEA Module. */ + TOUCH_FMEA_ERROR = 5u, + + /* MAGIC number used to Program Counter checking. */ + TOUCH_PC_FUNC_MAGIC_NO_1 = 6u, + + /* MAGIC number used to Program Counter checking. */ + TOUCH_PC_FUNC_MAGIC_NO_2 = 7u, + + /* Error in Logical Program Flow. */ + TOUCH_LOGICAL_PROGRAM_FLOW_ERROR = 8u, + + /* CRC on Touch Configuration failure. */ + TOUCH_LIB_CRC_FAIL = 9u, + + /* Double inverse failure. */ + TOUCH_LIB_DI_FAIL = 10u, + + /* Invalid Pointer argument */ + TOUCH_INVALID_POINTER = 11u, + + /* MAGIC number used to Program Counter checking. */ + TOUCH_PC_FUNC_MAGIC_NO_3 = 12u, + + /* Library Is Unsafe to Use */ + TOUCH_LIB_UNSAFE = 13u, + + /* Library Is Unable to Calibrate Node */ + TOUCH_LIB_NODE_CAL_ERROR = 14u, + + /* Successful completion of BIST.*/ + TOUCH_BIST_SUCCESS = 15u, + + /* Error in BIST Module. */ + TOUCH_BIST_ERROR = 16u, + +} touch_ret_t; + +/* ---------------------------------------------------------------------------------------- */ +/* Touch library state */ +/* ---------------------------------------------------------------------------------------- */ +typedef enum tag_touch_lib_state_t { + /* Null - Not initialized */ + TOUCH_STATE_NULL = 0u, + + /* Initialized, no measurements yet */ + TOUCH_STATE_INIT = 1u, + + /* Ready to take a measurement */ + TOUCH_STATE_READY = 2u, + + /* Calibration set for some nodes */ + TOUCH_STATE_CALIBRATE = 3u, + + /* Measurement sequence in progress */ + TOUCH_STATE_BUSY = 4u +} touch_lib_state_t; + +/* ---------------------------------------------------------------------------------------- */ +/* Acquisition node status byte */ +/* ---------------------------------------------------------------------------------------- */ +/* +Bit(s) +0 Node enabled for measurement (1) / Disabled (0) +1 Request hardware calibration (1) +4:2 Node state - 0 = Measure +1 = CC Calibration +2 = Prescaler calibration +3 = Series R calibration +4 = Charge Share Delay calibration +5 Reserved +6 TAU_CAL_DONE (1) - Flag for 3-stage hardware cal +7 CAL ERROR - Max comp cap +*/ + +#define NODE_STATUS_MASK 0x1Cu +#define NODE_STATUS_POS 0x02u + +#define NODE_ENABLED 0x01u +#define NODE_CAL_REQ 0x02u +#define CAL_STATE_SET 0x20u +#define TAU_CAL_DONE 0x40u +#define NODE_CAL_ERROR 0x80u + +/* Node state - 3 bits */ +#define NODE_MEASURE 0u +#define NODE_CC_CAL 1u +#define NODE_PRSC_CAL 2u +#define NODE_RSEL_CAL 3u +#define NODE_CSD_CAL 4u + +/* Any CAL bit */ +#define NODE_CAL_MASK 0x1Eu + +/* ---------------------------------------------------------------------------------------- */ +/* Acquisition Node run-time data */ +/* ---------------------------------------------------------------------------------------- */ +typedef struct { + uint8_t node_acq_status; + uint16_t node_acq_signals; + uint16_t node_comp_caps; +} qtm_acq_node_data_t; + +/* ---------------------------------------------------------------------------------------- */ +/* Key sensor status byte */ +/* ---------------------------------------------------------------------------------------- */ +#define QTM_KEY_STATE_DISABLE 0x00u +#define QTM_KEY_STATE_INIT 0x01u +#define QTM_KEY_STATE_CAL 0x02u +#define QTM_KEY_STATE_NO_DET 0x03u +#define QTM_KEY_STATE_FILT_IN 0x04u +#define QTM_KEY_STATE_DETECT 0x85u +#define QTM_KEY_STATE_FILT_OUT 0x86u +#define QTM_KEY_STATE_ANTI_TCH 0x07u +#define QTM_KEY_STATE_SUSPEND 0x08u +#define QTM_KEY_STATE_CAL_ERR 0x09u + +/* Note: Bit 7 indicates logical 'In Detect' (States 'Detect' and 'Filter Out') */ +#define KEY_TOUCHED_MASK 0x80u + +/* ---------------------------------------------------------------------------------------- */ +/* Key sensor run-time data */ +/* ---------------------------------------------------------------------------------------- */ +typedef struct { + uint8_t sensor_state; /* Disabled, Off, On, Filter, Cal... */ + uint8_t sensor_state_counter; /* State counter */ + qtm_acq_node_data_t *node_data_struct_ptr; /* Pointer to node data structure */ + uint16_t channel_reference; /* Reference signal */ +} qtm_touch_key_data_t; + +/* ---------------------------------------------------------------------------------------- */ +/* Scroller physical / layout types */ +/* ---------------------------------------------------------------------------------------- */ +#define SCROLLER_TYPE_SLIDER 0u +#define SCROLLER_TYPE_WHEEL 1u +#define SCROLLER_TYPE_WRAPAROUND 2u + +#endif /* __QTM_QPI_COMMON_*/ diff --git a/examples/vectorscope_tapedeck/qtouch/include/qtm_surface_cs_0x0021_api.h b/examples/vectorscope_tapedeck/qtouch/include/qtm_surface_cs_0x0021_api.h new file mode 100644 index 0000000..04c00c3 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/qtm_surface_cs_0x0021_api.h @@ -0,0 +1,150 @@ +/*============================================================================ +Filename : qtm_surface_1finger_touch_api.h +Project : QTouch Modular Library +Purpose : Structs and definitions for use within modules +------------------------------------------------------------------------------ +Copyright (C) 2019 Microchip. All rights reserved. +------------------------------------------------------------------------------ +============================================================================*/ + +#ifndef TOUCH_API_SURFACE_CS_H +#define TOUCH_API_SURFACE_CS_H + +/* Include files */ +#include +#include "qtm_common_components_api.h" + +/* Axis status bits */ +#define TOUCH_ACTIVE (uint8_t)((uint8_t)1u << 0u) /* Bit 0 */ +#define POSITION_CHANGE (uint8_t)((uint8_t)1u << 1u) /* Bit 1 */ +#define POSITION_H_INC (uint8_t)((uint8_t)1u << 2u) /* Bit 2 */ +#define POSITION_H_DEC (uint8_t)((uint8_t)1u << 3u) /* Bit 3 */ +#define POSITION_V_INC (uint8_t)((uint8_t)1u << 4u) /* Bit 4 */ +#define POSITION_V_DEC (uint8_t)((uint8_t)1u << 5u) /* Bit 5 */ +#define SURFACE_REBURST (uint8_t)((uint8_t)1u << 7u) /* Bit 7 */ + +/* Extract Resolution / Deadband */ +#define SCR_RESOLUTION(m) ((uint8_t)(((m)&0xF0u) >> 4u)) +#define SCR_DEADBAND(m) ((uint8_t)((m)&0x0Fu)) + +/* Combine Resolution / Deadband */ +#define SCR_RESOL_DEADBAND(r, p) ((uint8_t)(((r) << 4u) | (p))) + +/* Position filtering */ +#define POSITION_IIR_MASK 0x03u +#define POSITION_MEDIAN_ENABLE 0x10u +#define SCR_MEDIAN_IIR(r, p) ((uint8_t)(((r) << 4u) | (p))) + +/* scroller resolution setting */ +typedef enum tag_resolution_t { + RESOL_2_BIT = 2, + RESOL_3_BIT, + RESOL_4_BIT, + RESOL_5_BIT, + RESOL_6_BIT, + RESOL_7_BIT, + RESOL_8_BIT, + RESOL_9_BIT, + RESOL_10_BIT, + RESOL_11_BIT, + RESOL_12_BIT +} scr_resolution_t; + +/* scroller deadband percentage setting */ +typedef enum tag_deadband_t { + DB_NONE, + DB_1_PERCENT, + DB_2_PERCENT, + DB_3_PERCENT, + DB_4_PERCENT, + DB_5_PERCENT, + DB_6_PERCENT, + DB_7_PERCENT, + DB_8_PERCENT, + DB_9_PERCENT, + DB_10_PERCENT, + DB_11_PERCENT, + DB_12_PERCENT, + DB_13_PERCENT, + DB_14_PERCENT, + DB_15_PERCENT +} scr_deadband_t; + +/*---------------------------------------------------------------------------- + * Structure Declarations + *----------------------------------------------------------------------------*/ + +/* Surface CS Configuration */ +typedef struct { + uint16_t start_key_h; /* Start key of horizontal axis */ + uint8_t number_of_keys_h; /* Number of keys in horizontal axis */ + uint16_t start_key_v; /* Start key of vertical axis */ + uint8_t number_of_keys_v; /* Number of keys in vertical axis */ + uint8_t resol_deadband; /* Resolution 2 to 12 bits | Deadband 0% to 15% */ + uint8_t position_hysteresis; /* Distance threshold for initial move or direction change */ + uint8_t position_filter; /* Bits 1:0 = IIR (0% / 25% / 50% / 75%), Bit 4 = Enable Median Filter (3-point) */ + uint16_t contact_min_threshold; /* Contact threshold / Sum of 4 deltas */ + qtm_touch_key_data_t *qtm_touch_key_data; /* Pointer to touch key data */ +} qtm_surface_cs_config_t; + +/* Surface CS Data */ +typedef struct { + uint8_t qt_surface_status; + uint16_t h_position_abs; + uint16_t h_position; + uint16_t v_position_abs; + uint16_t v_position; + uint16_t contact_size; +} qtm_surface_contact_data_t; + +/* Container */ +typedef struct { + qtm_surface_contact_data_t *qtm_surface_contact_data; + qtm_surface_cs_config_t * qtm_surface_cs_config; +} qtm_surface_cs_control_t; + +/*---------------------------------------------------------------------------- + * prototypes + *----------------------------------------------------------------------------*/ + +/*============================================================================ +touch_ret_t qtm_init_surface_cs(qtm_surface_cs_control_t *qtm_surface_cs_control); +------------------------------------------------------------------------------ +Purpose: Initialize a scroller +Input : Pointer to scroller group control data +Output : TOUCH_SUCCESS +Notes : none +============================================================================*/ +touch_ret_t qtm_init_surface_cs(qtm_surface_cs_control_t *qtm_surface_cs_control); + +/*============================================================================ +touch_ret_t qtm_surface_cs_process(qtm_surface_cs_control_t *qtm_surface_cs_control); +------------------------------------------------------------------------------ +Purpose: Scroller position calculation and filtering +Input : Pointer to scroller group control data +Output : TOUCH_SUCCESS +Notes : none +============================================================================*/ +touch_ret_t qtm_surface_cs_process(qtm_surface_cs_control_t *qtm_surface_cs_control); + +/*============================================================================ +uint16_t qtm_get_scroller_module_id(void) +------------------------------------------------------------------------------ +Purpose: Returns the module ID +Input : none +Output : Module ID +Notes : none +============================================================================*/ +uint16_t qtm_get_surface_cs_module_id(void); + +/*============================================================================ +uint8_t qtm_get_scroller_module_ver(void) +------------------------------------------------------------------------------ +Purpose: Returns the module Firmware version +Input : none +Output : Module ID - Upper nibble major / Lower nibble minor +Notes : none +============================================================================*/ +uint8_t qtm_get_surface_cs_module_ver(void); + +#endif /* TOUCH_API_SCROLLER_H */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/qtm_touch_key_0x0002_api.h b/examples/vectorscope_tapedeck/qtouch/include/qtm_touch_key_0x0002_api.h new file mode 100644 index 0000000..010c4c8 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/qtm_touch_key_0x0002_api.h @@ -0,0 +1,196 @@ +/*============================================================================ +Filename : qtm_touch_key_api.h +Project : QTouch Modular Library +Purpose : Structs and definitions for use within modules +------------------------------------------------------------------------------ +Copyright (c) 2019 Microchip. All rights reserved. +------------------------------------------------------------------------------ +============================================================================*/ + +#ifndef TOUCH_API_KEYS_H +#define TOUCH_API_KEYS_H + +/* Include files */ +#include +#include "qtm_common_components_api.h" + +/* Keys status dlags */ +#define QTM_KEY_REBURST 0x80u +#define QTM_KEY_DETECT 0x01u + +/* QTLib Timebase */ +#define QTLIB_TIMEBASE 200u + +/*---------------------------------------------------------------------------- + * type definitions + *----------------------------------------------------------------------------*/ + +/* ! An unsigned 8-bit number setting a sensor detection threshold. */ +typedef uint8_t threshold_t; + +/* ! Sensor number type. */ +typedef uint16_t sensor_id_t; + +/* ! Current time type. */ +typedef uint16_t touch_current_time_t; + +/* ! Touch sensor delta value type. */ +typedef int16_t touch_delta_t; + +/* ! Status of Touch measurement. */ +typedef uint16_t touch_acq_status_t; + +typedef enum tag_hysteresis_t { HYST_50, HYST_25, HYST_12_5, HYST_6_25, MAX_HYST } QTM_hysteresis_t; + +typedef enum tag_aks_group_t { + NO_AKS_GROUP, + AKS_GROUP_1, + AKS_GROUP_2, + AKS_GROUP_3, + AKS_GROUP_4, + AKS_GROUP_5, + AKS_GROUP_6, + AKS_GROUP_7, + MAX_AKS_GROUP +} QTM_aks_group_t; + +typedef enum tag_recal_threshold_t { + RECAL_100, + RECAL_50, + RECAL_25, + RECAL_12_5, + RECAL_6_25, + MAX_RECAL +} recal_threshold_t; + +/* Reburst mode: +0 = none (application calls only) +1 = Unresolved - i.e. sensors in process of calibration / filter in / filter out and AKS groups +2 = All keys +*/ +typedef enum { REBURST_NONE, REBURST_UNRESOLVED, REBURST_ALL } reburst_mode_t; +/*---------------------------------------------------------------------------- + * Structure Declarations + *----------------------------------------------------------------------------*/ + +/* Key process module */ +/* Sensor group config */ +typedef struct { + uint16_t num_key_sensors; /* Number of sensors */ + uint8_t sensor_touch_di; /* Count in to Detect */ + uint8_t sensor_max_on_time; /* Max on duration x 200ms */ + uint8_t sensor_anti_touch_di; /* Count in to Anti-touch recal */ + uint8_t sensor_anti_touch_recal_thr; /* Anti-touch recal threshold % */ + uint8_t sensor_touch_drift_rate; /* One count per <200> ms */ + uint8_t sensor_anti_touch_drift_rate; /* One count per <200> ms */ + uint8_t sensor_drift_hold_time; /* Drift hold time */ + uint8_t sensor_reburst_mode; /* None / Unresolved / All */ +} qtm_touch_key_group_config_t; + +/* Sensor group data */ +typedef struct { + uint8_t qtm_keys_status; /* Status byte - bitfield: Bit 7 = REBURST_REQ, Bits 6:1 = Reserved, Bit 0 = Detect */ + uint16_t acq_group_timestamp; /* For tracking this group drift etc */ + uint8_t dht_count_in; /* Count of drift hold time */ + uint8_t tch_drift_count_in; /* Count of towards touch drift */ + uint8_t antitch_drift_count_in; /* Count of away from touch drift */ +} qtm_touch_key_group_data_t; + +/* Sensor keys config */ +typedef struct { + uint8_t channel_threshold; /* Touch detection threshold */ + uint8_t channel_hysteresis; /* Percentage of threshold reduction to exit detect state */ + uint8_t channel_aks_group; /* 0 = None, 1-255 = group number */ +} qtm_touch_key_config_t; + +/* ---------------------------------------------------------------------------------------- */ +/* Key sensor run-time data - api common */ +/* ---------------------------------------------------------------------------------------- */ + +/* Container */ +typedef struct { + qtm_touch_key_group_data_t(*qtm_touch_key_group_data); + qtm_touch_key_group_config_t(*qtm_touch_key_group_config); + qtm_touch_key_data_t(*qtm_touch_key_data); + qtm_touch_key_config_t(*qtm_touch_key_config); +} qtm_touch_key_control_t; + +/*---------------------------------------------------------------------------- + * prototypes + *----------------------------------------------------------------------------*/ + +/* Key Process Library Prototypes */ + +/*============================================================================ +touch_ret_t qtm_init_sensor_key(qtm_touch_key_control_t* qtm_lib_key_group_ptr, uint8_t which_sensor_key, +qtm_acq_node_data_t* acq_lib_node_ptr) +------------------------------------------------------------------------------ +Purpose: Initialize a touch key sensor +Input : Pointer to key group control data, key number, pointers to sensor node status and signal +Output : TOUCH_SUCCESS +Notes : none +============================================================================*/ +touch_ret_t qtm_init_sensor_key(qtm_touch_key_control_t *qtm_lib_key_group_ptr, uint8_t which_sensor_key, + qtm_acq_node_data_t *acq_lib_node_ptr); + +/*============================================================================ +touch_ret_t qtm_key_sensors_process(qtm_touch_key_control_t* qtm_lib_key_group_ptr) +------------------------------------------------------------------------------ +Purpose: Sensor key post-processing (touch detect state machine) +Input : Pointer to key group control data +Output : TOUCH_SUCCESS +Notes : none +============================================================================*/ +touch_ret_t qtm_key_sensors_process(qtm_touch_key_control_t *qtm_lib_key_group_ptr); + +/*============================================================================ +touch_ret_t qtm_key_suspend(uint16_t which_sensor_key, qtm_touch_key_control_t* qtm_lib_key_group_ptr) +------------------------------------------------------------------------------ +Purpose: Suspends acquisition measurements for the key +Input : Key number, Pointer to key group control data +Output : TOUCH_SUCCESS +Notes : none +============================================================================*/ +touch_ret_t qtm_key_suspend(uint16_t which_sensor_key, qtm_touch_key_control_t *qtm_lib_key_group_ptr); + +/*============================================================================ +touch_ret_t qtm_key_resume(uint16_t which_sensor_key, qtm_touch_key_control_t* qtm_lib_key_group_ptr) +------------------------------------------------------------------------------ +Purpose: Resumes acquisition measurements for the key +Input : Key number, Pointer to key group control data +Output : TOUCH_SUCCESS +Notes : none +============================================================================*/ +touch_ret_t qtm_key_resume(uint16_t which_sensor_key, qtm_touch_key_control_t *qtm_lib_key_group_ptr); + +/*============================================================================ +void update_qtlib_timer(uint16_t time_elapsed_since_update) +------------------------------------------------------------------------------ +Purpose: Updates local variable with time period +Input : Number of ms since last update +Output : none +Notes : none +============================================================================*/ +void qtm_update_qtlib_timer(uint16_t time_elapsed_since_update); + +/*============================================================================ +uint16_t qtm_get_touch_keys_module_id(void) +------------------------------------------------------------------------------ +Purpose: Returns the module ID +Input : none +Output : Module ID +Notes : none +============================================================================*/ +uint16_t qtm_get_touch_keys_module_id(void); + +/*============================================================================ +uint8_t qtm_get_touch_keys_module_ver(void) +------------------------------------------------------------------------------ +Purpose: Returns the module Firmware version +Input : none +Output : Module ID - Upper nibble major / Lower nibble minor +Notes : none +============================================================================*/ +uint8_t qtm_get_touch_keys_module_ver(void); + +#endif /* TOUCH_API_PTC_H */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/touch_api_ptc.h b/examples/vectorscope_tapedeck/qtouch/include/touch_api_ptc.h new file mode 100644 index 0000000..568a13e --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/touch_api_ptc.h @@ -0,0 +1,67 @@ + +/*============================================================================ +Filename : touch_api_ptc.h +Project : QTouch Modular Library +Purpose : Includes the Module API header files based on the configured modules, + prototypes for touch.c file and Application helper API functions + +This file is part of QTouch Modular Library Release 7.5 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) 2021 Microchip. All rights reserved. +------------------------------------------------------------------------------ +============================================================================*/ + +#ifndef TOUCH_API_PTC_H +#define TOUCH_API_PTC_H + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * include files + *----------------------------------------------------------------------------*/ + +#include "qtm_common_components_api.h" +#include "qtm_acq_saml21_0x0026_api.h" +#include "qtm_touch_key_0x0002_api.h" +#include "qtm_surface_cs_0x0021_api.h" + +/*---------------------------------------------------------------------------- + * prototypes + *----------------------------------------------------------------------------*/ +/* Application Helper API's */ +uint16_t get_sensor_node_signal(uint16_t sensor_node); +void update_sensor_node_signal(uint16_t sensor_node, uint16_t new_signal); +uint16_t get_sensor_node_reference(uint16_t sensor_node); +void update_sensor_node_reference(uint16_t sensor_node, uint16_t new_reference); +uint16_t get_sensor_cc_val(uint16_t sensor_node); +void update_sensor_cc_val(uint16_t sensor_node, uint16_t new_cc_value); +uint8_t get_sensor_state(uint16_t sensor_node); +void update_sensor_state(uint16_t sensor_node, uint8_t new_state); +void calibrate_node(uint16_t sensor_node); +uint8_t get_scroller_state(uint16_t sensor_node); +uint16_t get_scroller_position(uint16_t sensor_node); +#define HOR_POS 0u +#define VER_POS 1u +uint8_t get_surface_status(void); +uint8_t get_surface_position(uint8_t ver_or_hor); + +void touch_timer_handler(void); +void touch_init(void); +void touch_process(void); + +#ifdef __cplusplus +} +#endif + +#endif /* TOUCH_API_PTC_H */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/utils.h b/examples/vectorscope_tapedeck/qtouch/include/utils.h new file mode 100644 index 0000000..1cf2699 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/utils.h @@ -0,0 +1,368 @@ +/** + * \file + * + * \brief Different macros. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#ifndef UTILS_H_INCLUDED +#define UTILS_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \addtogroup doc_driver_hal_utils_macro + * + * @{ + */ + +/** + * \brief Retrieve pointer to parent structure + */ +#define CONTAINER_OF(ptr, type, field_name) ((type *)(((uint8_t *)ptr) - offsetof(type, field_name))) + +/** + * \brief Retrieve array size + */ +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + +/** + * \brief Emit the compiler pragma \a arg. + * + * \param[in] arg The pragma directive as it would appear after \e \#pragma + * (i.e. not stringified). + */ +#define COMPILER_PRAGMA(arg) _Pragma(#arg) + +/** + * \def COMPILER_PACK_SET(alignment) + * \brief Set maximum alignment for subsequent struct and union definitions to \a alignment. + */ +#define COMPILER_PACK_SET(alignment) COMPILER_PRAGMA(pack(alignment)) + +/** + * \def COMPILER_PACK_RESET() + * \brief Set default alignment for subsequent struct and union definitions. + */ +#define COMPILER_PACK_RESET() COMPILER_PRAGMA(pack()) + +/** + * \brief Set aligned boundary. + */ +#if defined __GNUC__ +#define COMPILER_ALIGNED(a) __attribute__((__aligned__(a))) +#elif defined __ICCARM__ +#define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a) +#elif defined __CC_ARM +#define COMPILER_ALIGNED(a) __attribute__((__aligned__(a))) +#endif + +/** + * \brief Flash located data macros + */ +#if defined __GNUC__ +#define PROGMEM_DECLARE(type, name) const type name +#define PROGMEM_T const +#define PROGMEM_READ_BYTE(x) *((uint8_t *)(x)) +#define PROGMEM_PTR_T const * +#define PROGMEM_STRING_T const uint8_t * +#elif defined __ICCARM__ +#define PROGMEM_DECLARE(type, name) const type name +#define PROGMEM_T const +#define PROGMEM_READ_BYTE(x) *((uint8_t *)(x)) +#define PROGMEM_PTR_T const * +#define PROGMEM_STRING_T const uint8_t * +#elif defined __CC_ARM +#define PROGMEM_DECLARE(type, name) const type name +#define PROGMEM_T const +#define PROGMEM_READ_BYTE(x) *((uint8_t *)(x)) +#define PROGMEM_PTR_T const * +#define PROGMEM_STRING_T const uint8_t * +#endif + +/** + * \brief Optimization + */ +#if defined __GNUC__ +#define OPTIMIZE_HIGH __attribute__((optimize(s))) +#elif defined __CC_ARM +#define OPTIMIZE_HIGH _Pragma("O3") +#elif defined __ICCARM__ +#define OPTIMIZE_HIGH _Pragma("optimize=high") +#endif + +/** + * \brief RAM located function attribute + */ +#if defined(__CC_ARM) /* Keil ?Vision 4 */ +#define RAMFUNC __attribute__((section(".ramfunc"))) +#elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ +#define RAMFUNC __ramfunc +#elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ +#define RAMFUNC __attribute__((section(".ramfunc"))) +#endif + +/** + * \brief No-init section. + * Place a data object or a function in a no-init section. + */ +#if defined(__CC_ARM) +#define NO_INIT(a) __attribute__((zero_init)) +#elif defined(__ICCARM__) +#define NO_INIT(a) __no_init +#elif defined(__GNUC__) +#define NO_INIT(a) __attribute__((section(".no_init"))) +#endif + +/** + * \brief Set user-defined section. + * Place a data object or a function in a user-defined section. + */ +#if defined(__CC_ARM) +#define COMPILER_SECTION(a) __attribute__((__section__(a))) +#elif defined(__ICCARM__) +#define COMPILER_SECTION(a) COMPILER_PRAGMA(location = a) +#elif defined(__GNUC__) +#define COMPILER_SECTION(a) __attribute__((__section__(a))) +#endif + +/** + * \brief Define WEAK attribute. + */ +#if defined(__CC_ARM) /* Keil ?Vision 4 */ +#define WEAK __attribute__((weak)) +#elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */ +#define WEAK __weak +#elif defined(__GNUC__) /* GCC CS3 2009q3-68 */ +#define WEAK __attribute__((weak)) +#endif + +/** + * \brief Pointer to function + */ +typedef void (*FUNC_PTR)(void); + +#define LE_BYTE0(a) ((uint8_t)(a)) +#define LE_BYTE1(a) ((uint8_t)((a) >> 8)) +#define LE_BYTE2(a) ((uint8_t)((a) >> 16)) +#define LE_BYTE3(a) ((uint8_t)((a) >> 24)) + +#define LE_2_U16(p) ((p)[0] + ((p)[1] << 8)) +#define LE_2_U32(p) ((p)[0] + ((p)[1] << 8) + ((p)[2] << 16) + ((p)[3] << 24)) + +/** \name Zero-Bit Counting + * + * Under GCC, __builtin_clz and __builtin_ctz behave like macros when + * applied to constant expressions (values known at compile time), so they are + * more optimized than the use of the corresponding assembly instructions and + * they can be used as constant expressions e.g. to initialize objects having + * static storage duration, and like the corresponding assembly instructions + * when applied to non-constant expressions (values unknown at compile time), so + * they are more optimized than an assembly periphrasis. Hence, clz and ctz + * ensure a possible and optimized behavior for both constant and non-constant + * expressions. + * + * @{ */ + +/** \brief Counts the leading zero bits of the given value considered as a 32-bit integer. + * + * \param[in] u Value of which to count the leading zero bits. + * + * \return The count of leading zero bits in \a u. + */ +#if (defined __GNUC__) || (defined __CC_ARM) +#define clz(u) __builtin_clz(u) +#else +#define clz(u) \ + ( \ + ((u) == 0) \ + ? 32 \ + : ((u) & (1ul << 31)) \ + ? 0 \ + : ((u) & (1ul << 30)) \ + ? 1 \ + : ((u) & (1ul << 29)) \ + ? 2 \ + : ((u) & (1ul << 28)) \ + ? 3 \ + : ((u) & (1ul << 27)) \ + ? 4 \ + : ((u) & (1ul << 26)) \ + ? 5 \ + : ((u) & (1ul << 25)) \ + ? 6 \ + : ((u) & (1ul << 24)) \ + ? 7 \ + : ((u) & (1ul << 23)) \ + ? 8 \ + : ((u) & (1ul << 22)) \ + ? 9 \ + : ((u) & (1ul << 21)) \ + ? 10 \ + : ((u) & (1ul << 20)) \ + ? 11 \ + : ((u) & (1ul << 19)) \ + ? 12 \ + : ((u) & (1ul << 18)) \ + ? 13 \ + : ((u) & (1ul << 17)) ? 14 \ + : ((u) & (1ul << 16)) ? 15 \ + : ((u) & (1ul << 15)) ? 16 \ + : ((u) & (1ul << 14)) ? 17 \ + : ((u) & (1ul << 13)) ? 18 \ + : ((u) & (1ul << 12)) ? 19 \ + : ((u) \ + & (1ul \ + << 11)) \ + ? 20 \ + : ((u) \ + & (1ul \ + << 10)) \ + ? 21 \ + : ((u) \ + & (1ul \ + << 9)) \ + ? 22 \ + : ((u) \ + & (1ul \ + << 8)) \ + ? 23 \ + : ((u) & (1ul << 7)) ? 24 \ + : ((u) & (1ul << 6)) ? 25 \ + : ((u) \ + & (1ul \ + << 5)) \ + ? 26 \ + : ((u) & (1ul << 4)) ? 27 \ + : ((u) & (1ul << 3)) ? 28 \ + : ((u) & (1ul << 2)) ? 29 \ + : ( \ + (u) & (1ul << 1)) \ + ? 30 \ + : 31) +#endif + +/** \brief Counts the trailing zero bits of the given value considered as a 32-bit integer. + * + * \param[in] u Value of which to count the trailing zero bits. + * + * \return The count of trailing zero bits in \a u. + */ +#if (defined __GNUC__) || (defined __CC_ARM) +#define ctz(u) __builtin_ctz(u) +#else +#define ctz(u) \ + ( \ + (u) & (1ul << 0) \ + ? 0 \ + : (u) & (1ul << 1) \ + ? 1 \ + : (u) & (1ul << 2) \ + ? 2 \ + : (u) & (1ul << 3) \ + ? 3 \ + : (u) & (1ul << 4) \ + ? 4 \ + : (u) & (1ul << 5) \ + ? 5 \ + : (u) & (1ul << 6) \ + ? 6 \ + : (u) & (1ul << 7) \ + ? 7 \ + : (u) & (1ul << 8) \ + ? 8 \ + : (u) & (1ul << 9) \ + ? 9 \ + : (u) & (1ul << 10) \ + ? 10 \ + : (u) & (1ul << 11) \ + ? 11 \ + : (u) & (1ul << 12) \ + ? 12 \ + : (u) & (1ul << 13) \ + ? 13 \ + : (u) & (1ul << 14) \ + ? 14 \ + : (u) & (1ul << 15) \ + ? 15 \ + : (u) & (1ul << 16) \ + ? 16 \ + : (u) & (1ul << 17) \ + ? 17 \ + : (u) & (1ul << 18) \ + ? 18 \ + : (u) & (1ul << 19) ? 19 \ + : (u) & (1ul << 20) ? 20 \ + : (u) & (1ul << 21) ? 21 \ + : (u) & (1ul << 22) ? 22 \ + : (u) & (1ul << 23) ? 23 \ + : (u) & (1ul << 24) ? 24 \ + : (u) & (1ul << 25) ? 25 \ + : (u) & (1ul << 26) ? 26 \ + : (u) & (1ul << 27) ? 27 \ + : (u) & (1ul << 28) ? 28 : (u) & (1ul << 29) ? 29 : (u) & (1ul << 30) ? 30 : (u) & (1ul << 31) ? 31 : 32) +#endif +/** @} */ + +/** + * \brief Counts the number of bits in a mask (no more than 32 bits) + * \param[in] mask Mask of which to count the bits. + */ +#define size_of_mask(mask) (32 - clz(mask) - ctz(mask)) + +/** + * \brief Retrieve the start position of bits mask (no more than 32 bits) + * \param[in] mask Mask of which to retrieve the start position. + */ +#define pos_of_mask(mask) ctz(mask) + +/** + * \brief Return division result of a/b and round up the result to the closest + * number divisible by "b" + */ +#define round_up(a, b) (((a)-1) / (b) + 1) + +/** + * \brief Get the minimum of x and y + */ +#define min(x, y) ((x) > (y) ? (y) : (x)) + +/** + * \brief Get the maximum of x and y + */ +#define max(x, y) ((x) > (y) ? (x) : (y)) + +/**@}*/ + +#ifdef __cplusplus +} +#endif +#endif /* UTILS_H_INCLUDED */ diff --git a/examples/vectorscope_tapedeck/qtouch/include/utils_list.h b/examples/vectorscope_tapedeck/qtouch/include/utils_list.h new file mode 100644 index 0000000..8dee700 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/include/utils_list.h @@ -0,0 +1,164 @@ +/** + * \file + * + * \brief List declaration. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#ifndef _UTILS_LIST_H_INCLUDED +#define _UTILS_LIST_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \addtogroup doc_driver_hal_utils_list + * + * @{ + */ + +#include "compiler.h" + +/** + * \brief List element type + */ +struct list_element { + struct list_element *next; +}; + +/** + * \brief List head type + */ +struct list_descriptor { + struct list_element *head; +}; + +/** + * \brief Reset list + * + * \param[in] list The pointer to a list descriptor + */ +static inline void list_reset(struct list_descriptor *const list) +{ + list->head = NULL; +} + +/** + * \brief Retrieve list head + * + * \param[in] list The pointer to a list descriptor + * + * \return A pointer to the head of the given list or NULL if the list is + * empty + */ +static inline void *list_get_head(const struct list_descriptor *const list) +{ + return (void *)list->head; +} + +/** + * \brief Retrieve next list head + * + * \param[in] list The pointer to a list element + * + * \return A pointer to the next list element or NULL if there is not next + * element + */ +static inline void *list_get_next_element(const void *const element) +{ + return element ? ((struct list_element *)element)->next : NULL; +} + +/** + * \brief Insert an element as list head + * + * \param[in] list The pointer to a list element + * \param[in] element An element to insert to the given list + */ +void list_insert_as_head(struct list_descriptor *const list, void *const element); + +/** + * \brief Insert an element after the given list element + * + * \param[in] after An element to insert after + * \param[in] element Element to insert to the given list + */ +void list_insert_after(void *const after, void *const element); + +/** + * \brief Insert an element at list end + * + * \param[in] after An element to insert after + * \param[in] element Element to insert to the given list + */ +void list_insert_at_end(struct list_descriptor *const list, void *const element); + +/** + * \brief Check whether an element belongs to a list + * + * \param[in] list The pointer to a list + * \param[in] element An element to check + * + * \return The result of checking + * \retval true If the given element is an element of the given list + * \retval false Otherwise + */ +bool is_list_element(const struct list_descriptor *const list, const void *const element); + +/** + * \brief Removes list head + * + * This function removes the list head and sets the next element after the list + * head as a new list head. + * + * \param[in] list The pointer to a list + * + * \return The pointer to the new list head of NULL if the list head is NULL + */ +void *list_remove_head(struct list_descriptor *const list); + +/** + * \brief Removes the list element + * + * \param[in] list The pointer to a list + * \param[in] element An element to remove + * + * \return The result of element removing + * \retval true The given element is removed from the given list + * \retval false The given element is not an element of the given list + */ +bool list_delete_element(struct list_descriptor *const list, const void *const element); + +/**@}*/ + +#ifdef __cplusplus +} +#endif +#endif /* _UTILS_LIST_H_INCLUDED */ diff --git a/examples/vectorscope_tapedeck/qtouch/lib/gcc/libqtm_acq_saml21_0x0026.a b/examples/vectorscope_tapedeck/qtouch/lib/gcc/libqtm_acq_saml21_0x0026.a new file mode 100644 index 0000000000000000000000000000000000000000..6077ebcd1d8d8b17c73635bac3406da7454150bf GIT binary patch literal 9914 zcmeHNeQZ-#mOt-3f8-0C!~qf~gcrXgggBTaE;J<+OkPV$43q++0RrPVj?42BV#juh z4KrI0MXLE&O-rbn#*oR;43V z&7Sj~pJP7?v;XWLyV@&m&OP`1&hLI--*+!f8$2Pew6SarUmUvDuIuh}tX=n*gXcSC zQ{i8pf3&M7=P*5x7RZ|I_&Wt zz8^T^dlkEfvije21d&Cp*xR3Ze;fav%h;J+sma9$`3`V?e|Cm2g)Yc<` zk%>{C>`nIZ$f$qV?FondhsNCW$1{p#M*^W(9->sepakrnaoOq{^9+yrP#p^gLhiA^ zh{B7l^bdzTk^3#4iAW&q^Uu$#ubzR`RIyrVu(2wQ^v7@7!1B)&KC;f#E=o1;Xe`_^+l9+9+muF zi8!&w6QL0HJ>;Z19&RsIZVa2UM!OV>7sh>Bx3VxWf2a(bN+amTc_}yA9#~VhCT~|< zAGET%Iy={`TgUS~kM-o1)==5=Pj1`7Fbpm*B{0wi3mU*L>*aj?BeH0NHP9j3pKsC) z?2euhZ>7M-q<2UEa3|OgH6Ze?yH^_|gCL3)xF`WXUAsGRrq7XPuK(Hs*?pE~=~U`s z)MOA2?$w0J`Z&C&`>1ncbDtMZ zezk6nap)gUrv5ec)t%o(4NsjjoHOl$%Ke+gMCygU_-1F{-S@9;$u$M;UNtl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F7@E!31kir+mg;J>X z+IPibf(N`X7K7v?LGG<_fjsAmW1x9){9_RH-7z;2!H&PO^rj1T{A{;-B9V}Pcmj_U zxRCyPfu8bkY0GC;@_2;)6a+fkP-wzPI9$qdAROsxP}3_hqXeUh>%lbb6>6X*PN4%M z`OsOJ!h>*qXe-3+MExu|Uc_`^{TfiA?{zh(d@o=|A)juUvgc9#C||AL8<-|{_3QUHH~{!B zAIL`Wr#Y$iUm8KdJWAms^$NzqayzhG9`mT&3XE#Ge}`$}Rr#DafV9`EL2bu%%qZmB zhJ4ho#7EycD&IX!7xL|S0N;Niu8?m}0UwQ@%GZu$g?!Qj_*xNE$akQCkNQ;Qb8Gm% zk9^c-HK^?!)bNcUUnhd7z0^M{-w!o>zrc>9?;bU%eDsY~SikegN9%+5==)RUyQ1Oy z94FnkjmKYT_}(sPFY&5;vl_mykuQsOHK_Hwso{GE`DkrY{pdzQ<@;L0_X$n{9_?yS z=WHD&5SpJ?Un6d(3PP!tt9~1*^KTn=5`E{XLB&0We1-k@`-1Uk%<<8D9MY6Kg8yHL zSIKfXQV(eO8nDx7-cfsbjB0zI*YKT0zGk$mL9O49HMq-&ds_veRB^9s%I&~%ooJ_W zg&dCB@u7xq51t8W?^J`z_qQ6p(Sml+y#wKh?-LDQ9QjlZ;zY9?<~6vJ55TR&HABOs z`Xvx&&vB4Y^Vj5Xw00=`4dMbyQvORE6nhYd|AMNi1vjZ~RmovUt-^@7eE2@L_o;#m m;-XMkH`4baUlu1B)$zL+sqHl0G^YyOp$E^XZx>{!eE$XP#swk( literal 0 HcmV?d00001 diff --git a/examples/vectorscope_tapedeck/qtouch/lib/gcc/libqtm_surface_cs_cm0p_0x0021.a b/examples/vectorscope_tapedeck/qtouch/lib/gcc/libqtm_surface_cs_cm0p_0x0021.a new file mode 100644 index 0000000000000000000000000000000000000000..b5535c60a725fc5451d3f8e8b426d9ccdda72454 GIT binary patch literal 4454 zcmcgvU2GHC6+U-nJpRcL5(kz^9MTE4yCK;)&L0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^t}V!wnZ*Nr|F zDkNwzW-JrX!s9H&z>!EIvKSGgN1}oLMk&z085{KX_U@LN`oHv5>9F5F8Is2RL22Ki zVd=osnBw&+Ug==*bLwoBcP4oADx;cV}2?{IcVO+jT+afg)c(g>QgDJ7HE?$)uO zd)hN01(nmjkk3CYb#%7(boCsEeQlVsTXB#1fY@=UL%W@a_YV&M&lrf2n7K`4Gugt5 zq?Xi?2JQ(H)P4u?-7BjCTlSR%V1X&~z@kJ;EWRRUtpNGW$kP~;*cjyTs{<3*id3Ev zix--5dmVfRfzu(f`JEdi=;}h=r?wH3$o{$k6K(odS7mKUA+lam1px@0YNr zF=sPczFy)Rus1^`{I0sWisq8aPApjXw>7M4!b>g8}`i=F}`WM+XnoTXyY9X_(Q%hzI+Z} zDCl-LVOsgds)bhxD;@-`OXmN7_b$F03>J^>Sq7Jr?lszX(H^(|3s^GBpP)T%Rxj-l zKSBE~_@2_f0*xJ^*{QI54Eu1f*iWdVurd<{2fg!yV+?;S98};a72ScSSW!^^i%_b4 zQB}SIYbI3w_*#_fKXp~spym5wbt#JRpY$`drg`cw(SL)`A0vmyKQ*OHV}bB6cDTdg zpl|F{SP5ZC|5vggkiJiR$)NaOvSzKG!i^;yE?I%ra zaVJ#}_Vk^kv=^He_ao%#`K*$P+l2xnHdjgUcl>9id2GT)Pi~5%yn05e^Ua}5#HNy( zUjPN#xCUe*DhPWuF3njR_kkuZji<)FfMcz{7&7#nR!Q}D9tB!||3ZIND5LYh;i|vu zIM(|6BPKqh7QKYS4&KJ5^(Wx_)`T+ZPr#<;w}@k{zx`MsdQPgO*5yMKXmMkRQ*)6PHU(2w~T^H)d}j<;eP-LL~1_( literal 0 HcmV?d00001 diff --git a/examples/vectorscope_tapedeck/qtouch/lib/gcc/libqtm_touch_key_cm0p_0x0002.a b/examples/vectorscope_tapedeck/qtouch/lib/gcc/libqtm_touch_key_cm0p_0x0002.a new file mode 100644 index 0000000000000000000000000000000000000000..0270b79936316d428fcdd4d5ec48e77a6698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w(fm#cMp_mbflb^wChL>S>oWenx145H|8@b-;+dDjWcAM$@Pz?5&=>h<*SkD%U?|dOFC8j^ z!;!75Pky8f!@-&&{hCbvsy#y#5(gE9ENa(6BT87kE3uidz8yKfA;Xu!-W*?xV>IE_ zbS%fWXY_jb#tPm5GdZ5koC)*4wt`;+ze1i7TNza>KXz*!nvBOI<1tqdo{vM2hJvGh z+y?%@Xv{x^cgazBK6~r@f4lVJ7}<j>nV^3BbS1b{Z2Zrz&k7l1#?Zrb< z99($64}fb3FY7KQaIIDs7ajmv?Nh!9^2*{bgO#SMeIw*;Guqsj!b)lGdm%4e{lfsi z8vYxEeLJ{UmTa6VJfM(UKAAK?jXTzT6~+}YF3XR_W%1OwSFvB{Zygq# zoe3(bac`rb5ZC(@+;59;ClIIBg85YaeO!b){S;gc24!*G%or(&xJb5}`DZ%TYVi-} zR#a7=Ax^bnGKOKq#;>jc#-G5txKt(bYL`9LTp6wb_xvCV*n6!O8ygd=C#!Lxza$FY KLzzmdzkdOAmyR3& literal 0 HcmV?d00001 diff --git a/examples/vectorscope_tapedeck/qtouch/lib/iar/qtm_acq_saml21_0x0026.a b/examples/vectorscope_tapedeck/qtouch/lib/iar/qtm_acq_saml21_0x0026.a new file mode 100644 index 0000000000000000000000000000000000000000..6aba1af0273336dd8f891299fd0974f0a026df51 GIT binary patch literal 16492 zcmeHNeRx#WnLqc=WM(n}5(sF35O2Z+l92BY41Ul_1_R+s4ANGJolKH3cW{y!W+pfh zs{^P_)LLY1mk-;eO1t)(M(NWJ(#6)g>TYX>;6ARj-O*a1U40g*k7cdv?C(AI-pQE| zY_i?{*9$lA{hjwczw@5=eBV2T*Lgx+>PmZ+l77`REU&GuYgoRbR#B?CO8dLKzMiA2 zYZ~+VuLeSKa(3%YkidfnY2-%f8|SoL}R z-R`bH-)+7gM(Lie9sRzrFX9XIQF0^{@VoB_gl_ls^|-^{h&vbwU1Apu1-iW9u$JB* z352^meeS+MH_G(%b)iU3Y$(DgHW1=^uITdke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gt z{EVHIHwyh+<;~#A#D9_>12Z|DF-)hXo%?onR_<1hF~V=nI|i|%cpYJJI{504X7g0$ zT9e1ZUjNTn#yl3n@xR4F#OLOP^PsE|q4Gat!LbS!j)8M62JlP%-XL*psJd`3w^7Ob z)tE{R+Kpx0Qm&k<&{T2NT#aB9>NG1kIGgaDLfjds@Vti8@p^ula{QOzkRwQmaW>f{ zFkyc%@GaO#oMk=AS9xy08P{W#=P`~#9I!NefzZJI;e)Y~O_)1a3Sox$=OLG6FqD#I z5W+B3vIr8Bk|mVCL9mrLk4jchwj3^0vJjTPkeFK*BepDM4tXWBJHCh^8z=vDu4uo- z^9UMP-$tb+=NXpu)Ob%rxJ%tJZ;QyuWz@XffwVf4ud5k5j*9E^jaoQF$&hLz)LC|9 zJ}QiDft`BTLcJ3<3=hL8#O!(t0$P-P0KX7LJ??#QY(d957U~-o*xe617c*EuUdU>^ zw_(S|SV%!MD0`e&R4mK+mCaw-b8xoK-6(3i2G~81HfC37XLbw6Jpnrp+80s~4TXM8 z*N7Nok;*F{BP*rF#y!}wFTL=buA>LamJiI;>S`6<4*j<~~ ztJy-lwODLny)1?qEr#cT(bYM1(Q_f*qzbR_o>~m=N!b0EIQT$?#}X8y#qhrPk$84E z4W`Qe7T*4g;W=UVW9E0O3Xh#_MvLLy^CR(&tMCe!2!?kr3eI?#;WK&{cAIk5qUXbq v%2X|_xRyB}vv^i=DmcUY4T}0)?t&eT$oGi-#jVDR!)`m;7+yUJBZl`cF0lgu literal 0 HcmV?d00001 diff --git a/examples/vectorscope_tapedeck/qtouch/license.h b/examples/vectorscope_tapedeck/qtouch/license.h new file mode 100644 index 0000000..21e7abb --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/license.h @@ -0,0 +1,22 @@ +/* + (c) 2020 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip 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. +*/ diff --git a/examples/vectorscope_tapedeck/qtouch/touch.c b/examples/vectorscope_tapedeck/qtouch/touch.c new file mode 100644 index 0000000..724f0d8 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/touch.c @@ -0,0 +1,437 @@ +/*============================================================================ +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 7.5 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) 2021 Microchip. All rights reserved. +------------------------------------------------------------------------------ +============================================================================*/ +#ifndef TOUCH_C +#define TOUCH_C + +#ifdef __XC32__ +#warning "The library is not tested for XC32 compiler, use ARM-GCC compiler instead" +#endif + +/*---------------------------------------------------------------------------- + * include files + *----------------------------------------------------------------------------*/ + +#include "touch.h" +#include "pins.h" + +#if DEF_TOUCH_DATA_STREAMER_ENABLE == 1 +#include "datastreamer.h" +#endif + +#if DEF_PTC_CAL_OPTION != CAL_AUTO_TUNE_NONE +#warning \ + "The autotune option is NOT enabled in START. Enable Autotune feature in START or Configure initial CSD values >= 20." +#endif + +#if DEF_TOUCH_DATA_STREAMER_ENABLE == 0u +#if DEF_PTC_CAL_OPTION != CAL_AUTO_TUNE_NONE +#warning \ + "Automatic charge time option is enabled without enabling datastreamer. So, automatic tuning of charge time option is disabled." +#define DEF_PTC_CAL_OPTION CAL_AUTO_TUNE_NONE +#endif +#endif + +/*---------------------------------------------------------------------------- + * prototypes + *----------------------------------------------------------------------------*/ + +/*! \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, DEF_PTC_INTERRUPT_PRIORITY}; + +/* Node status, signal, calibration values */ +qtm_acq_node_data_t ptc_qtlib_node_stat1[DEF_NUM_CHANNELS]; + +/* Node configurations */ +qtm_acq_saml21_node_config_t ptc_seq_node_cfg1[DEF_NUM_CHANNELS] = {NODE_0_PARAMS, + NODE_1_PARAMS, + NODE_2_PARAMS, + NODE_3_PARAMS, + NODE_4_PARAMS, + NODE_5_PARAMS, + NODE_6_PARAMS, + NODE_7_PARAMS, + NODE_8_PARAMS, + NODE_9_PARAMS, + NODE_10_PARAMS, + NODE_11_PARAMS, + NODE_12_PARAMS, + NODE_13_PARAMS, + NODE_14_PARAMS, + NODE_15_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, + KEY_3_PARAMS, + KEY_4_PARAMS, + KEY_5_PARAMS, + KEY_6_PARAMS, + KEY_7_PARAMS, + KEY_8_PARAMS, + KEY_9_PARAMS, + KEY_10_PARAMS, + KEY_11_PARAMS, + KEY_12_PARAMS, + KEY_13_PARAMS, + KEY_14_PARAMS, + KEY_15_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]}; + +/**********************************************************/ +/***************** Surface 1t Module ********************/ +/**********************************************************/ + +qtm_surface_cs_config_t qtm_surface_cs_config1 = { + /* Config: */ + SURFACE_CS_START_KEY_H, + SURFACE_CS_NUM_KEYS_H, + SURFACE_CS_START_KEY_V, + SURFACE_CS_NUM_KEYS_V, + SURFACE_CS_RESOL_DB, + SURFACE_CS_POS_HYST, + SURFACE_CS_FILT_CFG, + SURFACE_CS_MIN_CONTACT, + &qtlib_key_data_set1[0]}; + +/* Surface Data */ +qtm_surface_contact_data_t qtm_surface_cs_data1; + +/* Container */ +qtm_surface_cs_control_t qtm_surface_cs_control1 = {&qtm_surface_cs_data1, &qtm_surface_cs_config1}; + +/*============================================================================ +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]); + } + + touch_ret |= qtm_init_surface_cs(&qtm_surface_cs_control1); + + 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; + +#if DEF_TOUCH_DATA_STREAMER_ENABLE == 1 + datastreamer_output(); +#endif +} + +/*============================================================================ +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) +{ + /* Configure touch sensors with Application specific settings */ + touch_sensors_config(); + +#if DEF_TOUCH_DATA_STREAMER_ENABLE == 1 + datastreamer_init(); +#endif +} + +/*============================================================================ +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 (touch_ret == TOUCH_INVALID_INPUT_PARAM) { + qtm_error_callback(0); + } + /* 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); + } + touch_ret = qtm_surface_cs_process(&qtm_surface_cs_control1); + if (TOUCH_SUCCESS != touch_ret) { + qtm_error_callback(2); + } + } 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; + } + +#if DEF_TOUCH_DATA_STREAMER_ENABLE == 1 + datastreamer_output(); +#endif + } +} + +/*============================================================================ +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) +{ + /* 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]); +} + +uint8_t get_surface_status(void) +{ + return (qtm_surface_cs_control1.qtm_surface_contact_data->qt_surface_status); +} + +uint8_t get_surface_position(uint8_t ver_or_hor) +{ + uint8_t temp_pos = 0; + /* + * ver_or_hor, 0 = hor, 1 = ver + */ + if (ver_or_hor == VER_POS) { + temp_pos = qtm_surface_cs_control1.qtm_surface_contact_data->v_position; + } else { + temp_pos = qtm_surface_cs_control1.qtm_surface_contact_data->h_position; + } + return temp_pos; +} + +/*============================================================================ +void PTC_Handler_EOC(void) +------------------------------------------------------------------------------ +Purpose: Interrupt service handler for PTC EOC interrupt +Input : none +Output : none +Notes : none +============================================================================*/ +void irq_handler_ptc(void) +{ + // toggle yellow LED + HAL_GPIO_LED_GREEN_toggle(); + qtm_ptc_clear_interrupt(); + qtm_saml21_ptc_handler_eoc(); +} + +#endif /* TOUCH_C */ diff --git a/examples/vectorscope_tapedeck/qtouch/touch.h b/examples/vectorscope_tapedeck/qtouch/touch.h new file mode 100644 index 0000000..db578c4 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/touch.h @@ -0,0 +1,367 @@ +/*============================================================================ +Filename : touch.h +Project : QTouch Modular Library +Purpose : configuation macros for touch library + +This file is part of QTouch Modular Library Release 7.5 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) 2021 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_MUTUAL + +/* 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_PRSC + +/* 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 1 + +/* 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_SPREAD + +/*---------------------------------------------------------------------------- + * 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 (16) + +/* Defines mutual cap node parameter setting + * {X-line, Y-line, NODE_RSEL_PRSC(series resistor, prescaler), NODE_G(Analog Gain , Digital Gain), filter level} + */ +#define NODE_0_PARAMS \ + { \ + X(4) | X(5) | X(6) | X(7) | X(8) | X(9) | X(10) | X(11), Y(3), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_1_PARAMS \ + { \ + X(4) | X(5) | X(6) | X(7) | X(8) | X(9) | X(10) | X(11), Y(2), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_2_PARAMS \ + { \ + X(4) | X(5) | X(6) | X(7) | X(8) | X(9) | X(10) | X(11), Y(9), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_3_PARAMS \ + { \ + X(4) | X(5) | X(6) | X(7) | X(8) | X(9) | X(10) | X(11), Y(8), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_4_PARAMS \ + { \ + X(4) | X(5) | X(6) | X(7) | X(8) | X(9) | X(10) | X(11), Y(7), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_5_PARAMS \ + { \ + X(4) | X(5) | X(6) | X(7) | X(8) | X(9) | X(10) | X(11), Y(6), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_6_PARAMS \ + { \ + X(4) | X(5) | X(6) | X(7) | X(8) | X(9) | X(10) | X(11), Y(4), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_7_PARAMS \ + { \ + X(4) | X(5) | X(6) | X(7) | X(8) | X(9) | X(10) | X(11), Y(1), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_8_PARAMS \ + { \ + X(4), Y(3) | Y(2) | Y(1) | Y(4) | Y(6) | Y(7) | Y(8) | Y(9), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_9_PARAMS \ + { \ + X(5), Y(3) | Y(2) | Y(1) | Y(4) | Y(6) | Y(7) | Y(8) | Y(9), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_10_PARAMS \ + { \ + X(6), Y(3) | Y(2) | Y(1) | Y(4) | Y(6) | Y(7) | Y(8) | Y(9), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_11_PARAMS \ + { \ + X(7), Y(3) | Y(2) | Y(1) | Y(4) | Y(6) | Y(7) | Y(8) | Y(9), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_12_PARAMS \ + { \ + X(8), Y(3) | Y(2) | Y(1) | Y(4) | Y(6) | Y(7) | Y(8) | Y(9), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_13_PARAMS \ + { \ + X(9), Y(3) | Y(2) | Y(1) | Y(4) | Y(6) | Y(7) | Y(8) | Y(9), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_14_PARAMS \ + { \ + X(10), Y(3) | Y(2) | Y(1) | Y(4) | Y(6) | Y(7) | Y(8) | Y(9), NODE_RSEL_PRSC(RSEL_VAL_0, PRSC_DIV_SEL_4), \ + NODE_GAIN(GAIN_1, GAIN_1), FILTER_LEVEL_16 \ + } +#define NODE_15_PARAMS \ + { \ + X(11), Y(3) | Y(2) | Y(1) | Y(4) | Y(6) | Y(7) | Y(8) | Y(9), NODE_RSEL_PRSC(RSEL_VAL_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 (16) + +/* Defines Key Sensor setting + * {Sensor Threshold, Sensor Hysterisis, Sensor AKS} + */ +#define KEY_0_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_1_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_2_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_3_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_4_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_5_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_6_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_7_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_8_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_9_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_10_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_11_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_12_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_13_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_14_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } +#define KEY_15_PARAMS \ + { \ + 20, HYST_25, AKS_GROUP_1 \ + } + +/* 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 + +/**********************************************************/ +/***************** Surface Parameters ****************/ +/**********************************************************/ + +/* Config: */ +/* Horizontal Start Key <0-65534> + * Start key of horizontal axis + * Range: 0 to 65534 + */ +#define SURFACE_CS_START_KEY_H 8 +/* Horizontal Number of Channel <0-255> + * Number of Channels forming horizontal axis + * Range: 0 to 255 + */ +#define SURFACE_CS_NUM_KEYS_H 8 +/* Vertical Start Key <0-65534> + * Start key of vertical axis + * Range: 0 to 65534 + */ +#define SURFACE_CS_START_KEY_V 0 +/* Vertical Number of Channel <0-255> + * Number of Channels forming vertical axis + * Range: 0 to 255 + */ +#define SURFACE_CS_NUM_KEYS_V 8 +/* Position Resolution and Deadband Percentage + * Full scale position resolution reported for the axis and the deadband Percentage + * RESOL_2_BIT - RESOL_12_BIT + * DB_NONE - DB_15_PERCENT + */ +#define SURFACE_CS_RESOL_DB SCR_RESOL_DEADBAND(RESOL_8_BIT, DB_1_PERCENT) +/* Median filter enable and IIR filter Config + * Median Filter <0-1> + * Enable or Disable Median Filter + * enable - 1 + * disable - 0 + * IIR filter <0-3> + * Configure IIR filter + * 0 - None + * 1 - 25% + * 2 - 50% + * 3 - 75% + */ +#define SURFACE_CS_FILT_CFG SCR_MEDIAN_IIR(1, 3) +/* Position Hystersis <0-255> + * The minimum travel distance to be reported after contact or direction change + * Applicable to Horizontal and Vertical directions + */ +#define SURFACE_CS_POS_HYST 3 +/* Minimum Contact <0-65534> + * The minimum contact size measurement for persistent contact tracking. + * Contact size is the sum of neighbouring keys' touch deltas forming the touch contact. + */ +#define SURFACE_CS_MIN_CONTACT 60 + +/**********************************************************/ +/***************** Communication - Data Streamer ******************/ +/**********************************************************/ + +#define DEF_TOUCH_DATA_STREAMER_ENABLE 0u + +/**********************************************************/ +/***************** Communication - Surface Utility ******************/ +/**********************************************************/ + +#ifdef __cplusplus +} +#endif // __cplusplus +#endif // TOUCH_C diff --git a/examples/vectorscope_tapedeck/qtouch/utils_assert.c b/examples/vectorscope_tapedeck/qtouch/utils_assert.c new file mode 100644 index 0000000..b376c97 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/utils_assert.c @@ -0,0 +1,46 @@ +/** + * \file + * + * \brief Asserts related functionality. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#include + +/** + * \brief Assert function + */ +void assert(const bool condition, const char *const file, const int line) +{ + if (!(condition)) { + __asm("BKPT #0"); + } + (void)file; + (void)line; +} diff --git a/examples/vectorscope_tapedeck/qtouch/utils_assert.h b/examples/vectorscope_tapedeck/qtouch/utils_assert.h new file mode 100644 index 0000000..a53412e --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/utils_assert.h @@ -0,0 +1,93 @@ +/** + * \file + * + * \brief Asserts related functionality. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#ifndef _ASSERT_H_INCLUDED +#define _ASSERT_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/compiler.h" + +#ifndef USE_SIMPLE_ASSERT +//# define USE_SIMPLE_ASSERT +#endif + +/** + * \brief Assert macro + * + * This macro is used to throw asserts. It can be mapped to different function + * based on debug level. + * + * \param[in] condition A condition to be checked; + * assert is thrown if the given condition is false + */ +#define ASSERT(condition) ASSERT_IMPL((condition), __FILE__, __LINE__) + +#ifdef DEBUG + +#ifdef USE_SIMPLE_ASSERT +#define ASSERT_IMPL(condition, file, line) \ + if (!(condition)) \ + __asm("BKPT #0"); +#else +#define ASSERT_IMPL(condition, file, line) assert((condition), file, line) +#endif + +#else /* DEBUG */ + +#ifdef USE_SIMPLE_ASSERT +#define ASSERT_IMPL(condition, file, line) ((void)0) +#else +#define ASSERT_IMPL(condition, file, line) ((void)0) +#endif + +#endif /* DEBUG */ + +/** + * \brief Assert function + * + * This function is used to throw asserts. + * + * \param[in] condition A condition to be checked; assert is thrown if the given + * condition is false + * \param[in] file File name + * \param[in] line Line number + */ +void assert(const bool condition, const char *const file, const int line); + +#ifdef __cplusplus +} +#endif +#endif /* _ASSERT_H_INCLUDED */ diff --git a/examples/vectorscope_tapedeck/qtouch/utils_list.c b/examples/vectorscope_tapedeck/qtouch/utils_list.c new file mode 100644 index 0000000..44d6879 --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/utils_list.c @@ -0,0 +1,136 @@ +/** + * \file + * + * \brief List functionality implementation. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#include "utils_list.h" +#include "utils_assert.h" + +/** + * \brief Check whether element belongs to list + */ +bool is_list_element(const struct list_descriptor *const list, const void *const element) +{ + struct list_element *it; + for (it = list->head; it; it = it->next) { + if (it == element) { + return true; + } + } + + return false; +} + +/** + * \brief Insert an element as list head + */ +void list_insert_as_head(struct list_descriptor *const list, void *const element) +{ + ASSERT(!is_list_element(list, element)); + + ((struct list_element *)element)->next = list->head; + list->head = (struct list_element *)element; +} + +/** + * \brief Insert an element after the given list element + */ +void list_insert_after(void *const after, void *const element) +{ + ((struct list_element *)element)->next = ((struct list_element *)after)->next; + ((struct list_element *)after)->next = (struct list_element *)element; +} + +/** + * \brief Insert an element at list end + */ +void list_insert_at_end(struct list_descriptor *const list, void *const element) +{ + struct list_element *it = list->head; + + ASSERT(!is_list_element(list, element)); + + if (!list->head) { + list->head = (struct list_element *)element; + ((struct list_element *)element)->next = NULL; + return; + } + + while (it->next) { + it = it->next; + } + it->next = (struct list_element *)element; + ((struct list_element *)element)->next = NULL; +} + +/** + * \brief Removes list head + */ +void *list_remove_head(struct list_descriptor *const list) +{ + if (list->head) { + struct list_element *tmp = list->head; + + list->head = list->head->next; + return (void *)tmp; + } + + return NULL; +} + +/** + * \brief Removes list element + */ +bool list_delete_element(struct list_descriptor *const list, const void *const element) +{ + if (!element) { + return false; + } + + if (list->head == element) { + list->head = list->head->next; + return true; + } else { + struct list_element *it = list->head; + + while (it && it->next != element) { + it = it->next; + } + if (it) { + it->next = ((struct list_element *)element)->next; + return true; + } + } + + return false; +} + +//@} diff --git a/examples/vectorscope_tapedeck/qtouch/utils_list.h b/examples/vectorscope_tapedeck/qtouch/utils_list.h new file mode 100644 index 0000000..77f8a0e --- /dev/null +++ b/examples/vectorscope_tapedeck/qtouch/utils_list.h @@ -0,0 +1,164 @@ +/** + * \file + * + * \brief List declaration. + * + * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries. + * + * \asf_license_start + * + * \page License + * + * Subject to your compliance with these terms, you may use Microchip + * 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. + * + * \asf_license_stop + * + */ + +#ifndef _UTILS_LIST_H_INCLUDED +#define _UTILS_LIST_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \addtogroup doc_driver_hal_utils_list + * + * @{ + */ + +#include "include/compiler.h" + +/** + * \brief List element type + */ +struct list_element { + struct list_element *next; +}; + +/** + * \brief List head type + */ +struct list_descriptor { + struct list_element *head; +}; + +/** + * \brief Reset list + * + * \param[in] list The pointer to a list descriptor + */ +static inline void list_reset(struct list_descriptor *const list) +{ + list->head = NULL; +} + +/** + * \brief Retrieve list head + * + * \param[in] list The pointer to a list descriptor + * + * \return A pointer to the head of the given list or NULL if the list is + * empty + */ +static inline void *list_get_head(const struct list_descriptor *const list) +{ + return (void *)list->head; +} + +/** + * \brief Retrieve next list head + * + * \param[in] list The pointer to a list element + * + * \return A pointer to the next list element or NULL if there is not next + * element + */ +static inline void *list_get_next_element(const void *const element) +{ + return element ? ((struct list_element *)element)->next : NULL; +} + +/** + * \brief Insert an element as list head + * + * \param[in] list The pointer to a list element + * \param[in] element An element to insert to the given list + */ +void list_insert_as_head(struct list_descriptor *const list, void *const element); + +/** + * \brief Insert an element after the given list element + * + * \param[in] after An element to insert after + * \param[in] element Element to insert to the given list + */ +void list_insert_after(void *const after, void *const element); + +/** + * \brief Insert an element at list end + * + * \param[in] after An element to insert after + * \param[in] element Element to insert to the given list + */ +void list_insert_at_end(struct list_descriptor *const list, void *const element); + +/** + * \brief Check whether an element belongs to a list + * + * \param[in] list The pointer to a list + * \param[in] element An element to check + * + * \return The result of checking + * \retval true If the given element is an element of the given list + * \retval false Otherwise + */ +bool is_list_element(const struct list_descriptor *const list, const void *const element); + +/** + * \brief Removes list head + * + * This function removes the list head and sets the next element after the list + * head as a new list head. + * + * \param[in] list The pointer to a list + * + * \return The pointer to the new list head of NULL if the list head is NULL + */ +void *list_remove_head(struct list_descriptor *const list); + +/** + * \brief Removes the list element + * + * \param[in] list The pointer to a list + * \param[in] element An element to remove + * + * \return The result of element removing + * \retval true The given element is removed from the given list + * \retval false The given element is not an element of the given list + */ +bool list_delete_element(struct list_descriptor *const list, const void *const element); + +/**@}*/ + +#ifdef __cplusplus +} +#endif +#endif /* _UTILS_LIST_H_INCLUDED */