MEGA-1284P Xplained Example Application

touch_qt_config.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 *   $FILE:  touch_config.h
00003 *   Atmel Corporation:  http://www.atmel.com \n
00004 *   Support email:  touch@atmel.com
00005 ******************************************************************************/
00006 
00007 /*  License
00008 *   Copyright (c) 2010, Atmel Corporation All rights reserved.
00009 *
00010 *   Redistribution and use in source and binary forms, with or without
00011 *   modification, are permitted provided that the following conditions are met:
00012 *
00013 *   1. Redistributions of source code must retain the above copyright notice,
00014 *   this list of conditions and the following disclaimer.
00015 *
00016 *   2. Redistributions in binary form must reproduce the above copyright notice,
00017 *   this list of conditions and the following disclaimer in the documentation
00018 *   and/or other materials provided with the distribution.
00019 *
00020 *   3. The name of ATMEL may not be used to endorse or promote products derived
00021 *   from this software without specific prior written permission.
00022 *
00023 *   THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00024 *   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00025 *   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
00026 *   SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00027 *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00028 *   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 *   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00030 *   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00031 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00032 *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 */
00034 
00035 #ifndef _TOUCH_CONFIG_H_
00036 #define _TOUCH_CONFIG_H_
00037 
00038 
00039 /* 
00040 * Number of Channels(dependent on the library used).Please refer to the user guide
00041 * more information on selecting the number of channels.
00042 *
00043 * Possible values: 4, 8, 12, 16.
00044 */
00045 #ifndef QT_NUM_CHANNELS
00046     #define QT_NUM_CHANNELS 16
00047 #endif
00048 
00049 /* 
00050 * Delay cycles that determine the capacitance charge pulse width. 
00051 *
00052 * Possible values: 1 to 255
00053 */
00054 #ifndef QT_DELAY_CYCLES
00055     #define QT_DELAY_CYCLES 1
00056 #endif
00057 
00058 /* 
00059 * Enabling the _ROTOR_SLIDER_ constant will link the library need for using rotors
00060 * and sliders.
00061 *
00062 * Possible values: comment/uncomment the define
00063 */
00064 #ifndef _ROTOR_SLIDER_
00065     //#define _ROTOR_SLIDER_
00066 #endif
00067 
00068 /*
00069 * Define the ports to be used for SNS1 and SNSK1 pins. SNS1 and SNSK1 port pins
00070 * can be available on the same port or on different ports
00071 *
00072 * Possible values: refer to the device data sheet and QTouch libraries user guide.
00073 */
00074 #ifndef SNS1
00075     #define SNS1            D
00076 #endif
00077 #ifndef SNSK1
00078     #define SNSK1           D
00079 #endif    
00080 
00081 /* 
00082 * If the same port is being used for SNS1 and SNSK1 then the _SNS1_SNSK1_SAME_PORT_ 
00083 * constant has to be enabled
00084 *
00085 * Possible values: comment/uncomment the define
00086 */
00087 #ifndef _SNS1_SNSK1_SAME_PORT_
00088     //#define _SNS1_SNSK1_SAME_PORT_
00089 #endif
00090 
00091 /*
00092 * Define the ports to be used for SNS2 and SNSK2 pins. SNS2 and SNSK2 port pins
00093 * can be available on the same port or on different ports
00094 *
00095 * Possible values: refer to the device data sheet and QTouch libraries user guide.
00096 */
00097 #ifndef SNS2
00098     #define SNS2            C
00099 #endif
00100 #ifndef SNSK2
00101     #define SNSK2           B
00102 #endif    
00103 
00104 /* 
00105 * If the same port is being used for SNS2 and SNSK2 then the _SNS2_SNSK2_SAME_PORT_ 
00106 * constant has to be enabled
00107 *
00108 * Possible values: comment/uncomment the define
00109 */
00110 #ifndef _SNS2_SNSK2_SAME_PORT_
00111     //#define _SNS2_SNSK2_SAME_PORT_
00112 #endif    
00113 
00114 /*
00115 * Enabling _POWER_OPTIMIZATION_ will lead to a 40% reduction in power consumed 
00116 * by the library, but by disabling spread spectrum feature. When power optimization 
00117 * is enabled the unused pins, within a port used for QTouch, may not be usable for 
00118 * interrupt driven applications. This option is available only for ATtiny and ATmega 
00119 * devices.
00120 *
00121 * Possible values: 0 or 1 (For ATtiny and ATmega devices)
00122 *                  0 (For ATxmega devices) 
00123 */
00124 
00125 #ifndef _POWER_OPTIMIZATION_
00126     #define _POWER_OPTIMIZATION_ 0
00127 #endif
00128 
00129 /*
00130 * Enabling _DEBUG_INTERFACE_ will add QDEBUG code to the existing projects. This 
00131 * will enable viewing the output of the QTouch functionality using the QTouch studio.
00132 *
00133 * Possible values: comment/uncomment the define
00134 */
00135 #ifndef _DEBUG_INTERFACE_
00136     //#define _DEBUG_INTERFACE_
00137 #endif
00138 
00139 /**************************************************************/
00140 /* Please do not change any part of the code below this line. */
00141 /**************************************************************/
00142 #if (QT_DELAY_CYCLES == 0)
00143 #error 'QT_DELAY_CYCLES can only have values in the range 1-255.'
00144 #endif
00145 
00146 #if !(defined(__AVR32__) || defined(__ICCAVR32__))
00147         #if ((QT_NUM_CHANNELS == 8) || (QT_NUM_CHANNELS == 4))
00148                 #ifdef _SNS1_SNSK1_SAME_PORT_
00149                         #define _STATIC_PORT_PIN_CONF_ 1
00150                         #define INTRABURST_1 1
00151                         #if (QT_NUM_CHANNELS == 4)
00152                                 #define QTOUCH_SNS_PORT_COUNT 1
00153                                 #define INTRABURST_2 0
00154                         #elif (QT_NUM_CHANNELS == 8)
00155                                 #define QTOUCH_SNS_PORT_COUNT 2
00156                                 #define INTRABURST_2 1
00157                         #endif
00158                 #else
00159                         #ifndef _STATIC_PORT_PIN_CONF_
00160                   #define _STATIC_PORT_PIN_CONF_ 0
00161             #else
00162                   #define _STATIC_PORT_PIN_CONF_ 1
00163             #endif
00164                         #define QTOUCH_SNS_PORT_COUNT 1
00165                         #define INTRABURST_1 0
00166                         #define INTRABURST_2 0
00167                 #endif
00168         #elif ((QT_NUM_CHANNELS == 16) || (QT_NUM_CHANNELS == 12))
00169                 #define _STATIC_PORT_PIN_CONF_ 1
00170                 #define QTOUCH_SNS_PORT_COUNT 2
00171 
00172                 #ifdef _SNS1_SNSK1_SAME_PORT_
00173                         #define INTRABURST_1 1
00174                 #else
00175                         #define INTRABURST_1 0
00176                 #endif
00177 
00178                 #ifdef _SNS2_SNSK2_SAME_PORT_
00179                         #define INTRABURST_2 1
00180                 #else
00181                         #define INTRABURST_2 0
00182                 #endif
00183 
00184                 #if ((INTRABURST_1== 1) && (INTRABURST_2== 1))
00185                         #error 'QT_NUM_CHANNELS value should be 8 in this case.'
00186                 #elif ((INTRABURST_1== 1) || (INTRABURST_2== 1))
00187                         #if (QT_NUM_CHANNELS == 16)
00188                                 #error 'QT_NUM_CHANNELS value should be 12 in this case.'
00189                         #endif
00190                 #elif ((INTRABURST_1== 0) && (INTRABURST_2== 0))
00191                         #if (QT_NUM_CHANNELS == 12)
00192                                 #error 'QT_NUM_CHANNELS value should be 16 in this case.'
00193                         #endif
00194                 #endif
00195         #elif (QT_NUM_CHANNELS == 32)
00196                 #define _STATIC_PORT_PIN_CONF_ 1
00197                 #define QTOUCH_SNS_PORT_COUNT 2
00198 
00199                 #ifdef _SNS1_SNSK1_SAME_PORT_
00200                         #define INTRABURST_1 1
00201                 #else
00202                         #define INTRABURST_1 0
00203                 #endif
00204 
00205                 #ifdef _SNS2_SNSK2_SAME_PORT_
00206                         #define INTRABURST_2 1
00207                 #else
00208                         #define INTRABURST_2 0
00209                 #endif
00210         #else
00211         #error 'QT_NUM_CHANNELS specified is not supported.'
00212         #endif
00213 #else
00214         #ifdef _SNS1_SNSK1_SAME_PORT_
00215                 #define _STATIC_PORT_PIN_CONF_ 1
00216                 #define QTOUCH_SNS_PORT_COUNT 1
00217                 #define INTRABURST_1 1
00218                 #define INTRABURST_2 0
00219         #else
00220                 #define _STATIC_PORT_PIN_CONF_ 0
00221                 #define QTOUCH_SNS_PORT_COUNT 1
00222                 #define INTRABURST_1 0
00223                 #define INTRABURST_2 0
00224         #endif
00225 #endif
00226 
00227 #if (defined(__IAR_SYSTEMS_ASM__) || defined(__ASSEMBLER__) || defined(__ICCAVR32__) || defined(__AVR32__))
00228     #if (defined(__IAR_SYSTEMS_ASM__) || defined(__ICCAVR32__))
00229         #if defined(__IAR_SYSTEMS_ASM__)
00230             #include <ioavr.h>
00231             #define p_1 r16
00232             #define p_2 r17
00233             #define p_3 r18
00234             #define p_4 r19
00235             #define p_5 r20
00236             #define r_v r16
00237             #define FILE_HEADER NAME qt_asm_iar
00238             #define FILE_FOOTER END
00239             #define FILE_SEGMENT RSEG CODE
00240             #define GLOBAL_FUNCTION PUBLIC
00241 
00242             #define GLOBAL_VAR EQU
00243         #elif defined(__ICCAVR32__) 
00244             #include <avr32/io.h>
00245             #define p_1 r12
00246             #define p_2 r11
00247             #define p_3 r10
00248             #define r_v r12
00249             #define _UC3A_
00250             #define _QTOUCH_
00251             //#define FILE_HEADER NAME qt_asm_iar
00252             //#define FILE_FOOTER END
00253             //#define FILE_SEGMENT RSEG CODE
00254             #define FILE_HEADER
00255             #define FILE_FOOTER
00256             #define FILE_SEGMENT
00257             #define GLOBAL_FUNCTION PUBLIC
00258         #endif
00259     #elif (defined(__ASSEMBLER__) || defined(__AVR32__))
00260         #if defined(__AVR32__)
00261             #include <avr32/io.h>
00262 
00263             #define p_1 r12
00264             #define p_2 r11
00265             #define p_3 r10
00266             #define r_v r12
00267 
00268             #define _QTOUCH_
00269             #define _UC3A_
00270             #define _STATIC_PORT_PIN_CONF_ 0
00271             #define QTOUCH_SNS_PORT_COUNT 1
00272             #define INTRABURST_1 0
00273             #define INTRABURST_2 0
00274         #else
00275             #define __SFR_OFFSET 0
00276             #include <avr/io.h>   
00277             #define p_1 r24
00278             #define p_2 r22
00279             #define p_3 r20
00280             #define p_4 r18
00281             #define p_5 r16
00282             #define r_v r24
00283             
00284             #define GLOBAL_VAR .EQU
00285         #endif
00286     
00287         #define FILE_HEADER
00288         #define FILE_FOOTER 
00289         #define FILE_SEGMENT 
00290         #define GLOBAL_FUNCTION .global
00291     #else    
00292         #error 'Assembler not supported.'
00293     #endif
00294     
00295     #define JOIN( x, y ) x ## y
00296     #define JOIN1( A, B, C ) A ## B ## C
00297     #define REG( REGISTER, SIDE ) JOIN( REGISTER, SIDE )
00298     #define CONCAT( A, B, C ) JOIN1( A, B, C )
00299     
00300     #define sreg_save r2
00301     
00302     #define _00011001_  nop
00303     #define _01101001_  brne _111_
00304     #define _01101011_  brne _222_
00305     #define _10001110_  rjmp . 
00306     #if (defined (__AVR32__) || defined (__ICCAVR32__))
00307         #define _10100011_      _111_: sub r9,1
00308         #define _10100111_      _222_: sub r9,1
00309         #define _11100011_      mov r9,((QT_DELAY_CYCLES - 1)/3)
00310     #else
00311         #define _10100011_      _111_: dec r19
00312         #define _10100111_      _222_: dec r19
00313         #define _11100011_      ldi r19,((QT_DELAY_CYCLES - 1)/3)
00314     #endif
00315 
00316 #else
00317     #ifndef _QTOUCH_
00318         #define _QTOUCH_
00319     #endif
00320 #endif
00321 
00322 #endif /*_TOUCH_CONFIG_H_*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines