Based on the application design, the user needs to select the right library variant and the configuration to be used along with the variant. This section illustrates the steps required to select the right QMatrix acquisition method library variant and configuration for your application.
For your design, you would need the following information to select the correct library variant
Device to be used for the design (only AT32UC3C0512 supported)
The number of touch sensing channels needed by the application – Then identify the Maximum number of channels required for the design that are supported by the library.
Number of X lines to be used in the design
The port on which your design permits to have the X lines
The X lines can be spread on a single port.
Number of Y lines to be used in the design
The port-pins ports on which your design permits to have the Y lines
Do you need support for Rotors and/or Sliders in your design
If yes, how many rotors/sliders would be needed?
Based on a) above, identify the maximum number of rotors sliders that the library supports
Which compiler platform you intend to use to integrate the libraries – IAR or AVR-GCC
After selecting the right library variant, following steps are to be performed
Define the constants and symbol names required
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. These values are derived from the parameters defined in step 2 for your application
The constant/symbol names are as listed in the table below
The constant/symbol definitions can be placed in any of the following:
In the user’s ‘C’ file prior to include touch_api.h in the file
Defined user’s project options.
Modify the defines in a touch_config.h
Symbol / Constant name |
Range of values |
Comments |
---|---|---|
_QMATRIX_ |
Symbol defined to indicate QMatrix acquisition method is required |
Define this symbol to indicate QMatrix acquisition method is required |
QT_NUM_CHANNELS |
The number of channels the library supports.( Possible values:4,8,16,24,32,64). |
Value should be same as the number of channels that the library supports |
NUM_X_LINES |
The number of X lines the library supports.( Possible values:4,8) |
Value should be same as the number of X lines that the library supports. Refer to library selection guide |
NUM_Y_LINES |
The number of Y lines the library supports.( Possible values:1,2,3,4,8) |
Value should be same as the number of Y lines that the library supports. Refer to library selection guide |
_ROTOR_SLIDER_ |
Symbol defined if Rotor and/or slider is required |
Needs to be added in case user needs to configure ROTOR/SLIDER Needs to be removed for ALL KEYS configuration |
QT_MAX_NUM_ROTORS_SLIDERS |
Maximum number of rotors/sliders the library supports( possible values:0,2,3,4,8) |
Subject to support for rotors/sliders in the library selected. |
QT_DELAY_CYCLES |
Possible values :1,2,3,4,5,10,25,50 |
|
PORT_X_1 |
First IO port for configuring the X lines.Any IO port available with the device. |
Drive electrode for touch sensing using QMatrix acquisition |
PORT_YA |
Any IO port available with the device. |
Receive electrode for touch sensing using QMatrix acquisition |
PORT_YB |
Analog Comparator port available for the device. |
Receive electrode for touch sensing using QMatrix acquisition |
PORT_SMP |
Any IO port available with the device. |
Port of the Sampling pin for touch sensing using QMatrix acquisition |
SMP_PIN |
Any IO port available with the device. |
Sampling pin for touch sensing using QMatrix acquisition |
SHARED_YAYB |
Possible Values 0 or 1. |
Value should be 0 if Ya and Yb are not on same port else 1 if they are on same port. |
Once you have selected the right library variant and configuration parameters for the application, follow the steps outlined below to integrate the library variant in your application.
Fill in the arrays x_line_info_t
x_line_info[NUM_X_LINES]
, y_line_info_t
ya_line_info[NUM_Y_LINES]
and y_line_info_t
yb_line_info[NUM_Y_LINES]
as given in main.c file.
Filling Arrays in the main.c file
According to the pin availability for the touch sensing, initialize the arrays in the main.c file as below:
x_line_info_t x_line_info[NUM_X_LINES] = { FILL_OUT_X_LINE_INFO( 1,0u ), FILL_OUT_X_LINE_INFO( 1,2u ), FILL_OUT_X_LINE_INFO( 1,7u ), FILL_OUT_X_LINE_INFO( 1,15u ), };
First argument of FILL_OUT_X_LINE_INFO should always be 1 as X port is only on one port. Second arguments denotes the pins on that particular port.
y_line_info_t ya_line_info[NUM_Y_LINES] = { FILL_OUT_YA_LINE_INFO( 0u ), FILL_OUT_YA_LINE_INFO( 5u ), }; y_line_info_t yb_line_info[NUM_Y_LINES] = { FILL_OUT_YB_LINE_INFO( 7u ), FILL_OUT_YB_LINE_INFO( 22u ), };
Yb lines are one of the inputs of the Analog Comparators.
Copy the library variant that was selected in step 1 to your project’s working directory or update your project to point to the library selected.
Include the “touch_api.h” header file and assembler source file from the QTouch library in your application. The touch_api.h can be found in the release package at C:\Program Files\Atmel\Atmel_QTouch_Libraries_5.x\Generic_QTouch_Libraries\include. The assembler files mentioned below could be found at the location C:\Program Files\Atmel\Atmel_QTouch_Libraries_5.x\Generic_QTouch_Libraries\32bit_AVR\UC3\QMatrix\common_files
qm_asm_uc3c_gcc.x in case of GCC compiler
qm_asm_uc3c_iar.s82 in case of IAR compiler.
Initialize/create and use the touch api’s in your application
In your application, create, initialize and configure the sensors.
The APIs of interest are qt_enable_key/rotor/slider()
configure the global configuration parameters valid for all the sensors in the library
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
General application notes
The clock, host application and other peripherals needed by the host application needs to be initialized.
The QMatrix acquisition method libraries for 32 Bit devices internally use TIMER0 with channel0 for their operation.
Ensure that there are no conflicts between the resources used by the touch library and the host application