Integrating QTouch acquisition method libraries in your application

The following steps illustrate how to add QTouch acquisition method support in your application.

  1. 1.

    QTouch acquisition method library variants are offered for IAR and AVR Studio/GCC tool chains. First step is to select the compiler tool chain to be used based on the code and data memory requirements.

    Use the library selection guide (C:\ Program Files\Atmel\Atmel_QTouch_Libraries_5.x\ Library_Selection_Guide.xls) to select the QTouch acquisition method library variant required for the device.

    1. 1.1.

      There are specific library variants distributed for each microcontroller. You would need the following parameters to identify the right library variant to be used in your application

      1. 1.1.1.

        The microcontroller to be used for the application.

      2. 1.1.2.

        The acquisition method to be used for the application.

      3. 1.1.3.

        The number of channels you need for the application.

      4. 1.1.4.

        Whether Rotor and/or Slider support required in the application.

      5. 1.1.5.

        The number of rotors and/or slider needed for the application.

    2. 1.2.

      There are specific variants of the library which is pre-built with a specific configuration set supported. Use the library selection guide (C:\ Program Files\Atmel\Atmel_QTouch_Libaries_5.x\Library_Selection_Guide.xls) to find the sample project using the QTouch acquisition method library variant.

  2. 2.

    Define the constants and symbol names required

    1. 2.1.

      The next step is to define certain constants and symbols required in the host application files where the touch API is going to be used.

    2. 2.2.

      The constant/symbol names are as listed in the table below.

    3. 2.3.

      The constant/symbol definitions can be placed in the touch_config.h file. The user may modify these defined values based on the requirements.

      Table 1. Constant and symbol name definitions required to use the QTouch acquisition method libraries

      Symbol / Constant name

      Range of values

      Comments

      _QTOUCH_

      This macro has to be defined in order to use QTouch libraries.

       

      SNS1 and SNSK1

      Refer to library selection guide.

      To be used if only single port pair is needed for the design.

      SNS1 – SNSK1

      and

      SNS2 – SNSK2

       Refer to library selection guide.

      To be used if two port pairs are needed for the design.

      _SNS1_SNSK1_SAME_PORT_

      Comment/uncomment define

      To be enabled if the same port is used for SNSK1 and SNS1 pins for QTouch. If SNSK1 and SNS1 pins are on different ports then this definition is not required.

      _SNS2_SNSK2_SAME_PORT_

      Comment/uncomment define

      To be enabled if the same port is used for SNSK2 and SNS2 pins for QTouch. If SNSK1 and SNS1 pins are on different ports then this definition is not required.

      QT_NUM_CHANNELS

      4, 8, 12, 16 for tinyAVR, megaAVR and XMEGA device libraries and 8, 16, 32 for UC3 device libraries.

       

      _ROTOR_SLIDER_

      Rotor / slider can be added to the design, if this macro is enabled.

      A library with rotor / slider functionality already available needs to be selected if this macro is to be enabled.

      QT_DELAY_CYCLES

      1 to 255

      _POWER_OPTIMIZATION_

      (Required only for ATtiny and ATmega libraries. ATxmega and UC3 libraries by default optimized for power without any limitations)

      0 or 1

      Used to reduce the power consumed by the library. When power optimization is enabled the unused pins, within a port used for QTouch, may not be usable for interrupt driven applications. Spread spectrum noise reduction is also disabled when power optimization is enabled.

      _TOUCH_ARM_

      To be defined when using ATSAM libraries

      For ATSAM libraries only.

      QTOUCH_STUDIO_MASKS

      This macro needs to be defined if QTouch Studio Pin Configurator Wizard.is used to generate the SNS and SNSK masks.

      _STATIC_PORT_PIN_CONF_

      This macro needs to be defined only in case of 4 and 8 channel libraries with interport configuration and pin configurability.

  3. 3.

    Using QTouch API’s in your application to add touch functionality

    1. 3.1.

      The clock, host application and other peripherals needed by the host application needs to be initialized.

    2. 3.2.

      In your application, create, initialize and configure the sensors.

      1. 3.2.1.

        The APIs of interest are qt_enable_key/rotor/slider().

    3. 3.3.

      The channel configuration parameters need to be set by calling the qt_set_parameters()

    4. 3.4.

      Once the sensors are configured, qt_init_sensing() has to be called to trigger the initialization of the sensors with the configuration defined in steps above.

    5. 3.5.

      Provide timing for the QTouch libraries to operate. i,e the QTouch libraries do not use any timer resources of the microcontroller. The Host application has to provide the required timing and also call the API’s at the appropriate intervals to perform touch sense detect operations.

      Note:

      The ATSAM example applications provided with the libraries illustrate the usage for the evaluation kits supported by the library. Refer to the main.c files for reference.

  4. 4.

    Adding the necessary source files

    The following files are to be added along with the touch library and user application before compilation:

    1. 4.1.

      ATtiny, ATmega devices - touch_api.h, qt_asm_avr.h, touch_config.h and qt_asm_tiny_mega.S.

    2. 4.2.

      ATxmega devices - touch_api.h, qt_asm_avr.h, touch_config.h and qt_asm_xmega.S.

    3. 4.3.

      UC3 devices – touch_api.h.

    4. 4.4.

      ATSAM devices - touch_api.h and touch_config.h.

  5. 5.

    General application notes

    1. 5.1.

      The clock, host application and other peripherals needed by the host application needs to be initialized.

    2. 5.2.

      Ensure that there are no conflicts between the resources used by the touch library and the host application.

    3. 5.3.

      Ensure that the stack size for your application is adjusted to factor in the stack depth required for the operation of the touch libraries.