Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. /* This source file is part of the ATMEL QTouch Library Release 4.3.1 */
  2. /* This file is prepared for Doxygen automatic documentation generation. */
  3. /*! \file *********************************************************************
  4.  *
  5.  * \brief  This file contains the QTouch Libary configuration options for
  6.  *         AVR 8-bit QTouch method Capacitive Touch acquisition.
  7.  *
  8.  * - Compiler:           IAR EWAVR and GNU GCC for AVR.
  9.  * - Supported devices:  Atmel AVR 8-bit.
  10.  * - Userguide:          QTouch Library User Guide - doc8207.pdf.
  11.  * - Support email:      touch@atmel.com
  12.  *
  13.  * \author               Atmel Corporation: http://www.atmel.com \n
  14.  *                       Support and FAQ: http://support.atmel.no/
  15.  *
  16.  ******************************************************************************/
  17.  
  18. /* Copyright (c) 2010 Atmel Corporation. All rights reserved.
  19.  *
  20.  * Redistribution and use in source and binary forms, with or without
  21.  * modification, are permitted provided that the following conditions are met:
  22.  *
  23.  * 1. Redistributions of source code must retain the above copyright notice, this
  24.  * list of conditions and the following disclaimer.
  25.  *
  26.  * 2. Redistributions in binary form must reproduce the above copyright notice,
  27.  * this list of conditions and the following disclaimer in the documentation
  28.  * and/or other materials provided with the distribution.
  29.  *
  30.  * 3. The name of Atmel may not be used to endorse or promote products derived
  31.  * from this software without specific prior written permission.
  32.  *
  33.  * 4. This software may only be redistributed and used in connection with an Atmel
  34.  * AVR product.
  35.  *
  36.  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  37.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  38.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  39.  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  40.  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  41.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  44.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  45.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  46.  *
  47.  */
  48.  
  49. #ifndef _QT_ASM_AVR_H_
  50. #define _QT_ASM_AVR_H_
  51.  
  52. #include "../../touch.h"
  53.  
  54. /**
  55.   * Warning: Please do not change any part of the code below this line.
  56.   */
  57. #if (QT_DELAY_CYCLES == 0)
  58. #error 'QT_DELAY_CYCLES can only have values in the range 1-255.'
  59. #endif
  60.  
  61. #if !(defined(__AVR32__) || defined(__ICCAVR32__))
  62. #if ((QT_NUM_CHANNELS == 8) || (QT_NUM_CHANNELS == 4))
  63.  
  64. #ifdef QTOUCH_STUDIO_MASKS
  65. #define QTOUCH_PIN_CONF 1
  66. #define _STATIC_PORT_PIN_CONF_ 1
  67. #else
  68. #define QTOUCH_PIN_CONF 0
  69. #define _STATIC_PORT_PIN_CONF_ 0
  70. #endif
  71.  
  72. #ifdef _SNS1_SNSK1_SAME_PORT_
  73. #define _STATIC_PORT_PIN_CONF_ 1
  74. #define INTRABURST_1 1
  75.  
  76. #if (QT_NUM_CHANNELS == 4)
  77. #define QTOUCH_SNS_PORT_COUNT 1
  78. #define INTRABURST_2 0
  79. #elif (QT_NUM_CHANNELS == 8)
  80. #define QTOUCH_SNS_PORT_COUNT 2
  81. #define INTRABURST_2 1
  82. #endif
  83. #else
  84.  
  85. #define QTOUCH_SNS_PORT_COUNT 1
  86. #define INTRABURST_1 0
  87. #define INTRABURST_2 0
  88. #endif
  89. #elif ((QT_NUM_CHANNELS == 16) || (QT_NUM_CHANNELS == 12))
  90. #define _STATIC_PORT_PIN_CONF_ 1
  91. #define QTOUCH_SNS_PORT_COUNT 2
  92.  
  93. #ifdef QTOUCH_STUDIO_MASKS
  94. #define QTOUCH_PIN_CONF 1
  95. #else
  96. #define QTOUCH_PIN_CONF 0
  97. #endif
  98.  
  99. #ifdef _SNS1_SNSK1_SAME_PORT_
  100. #define INTRABURST_1 1
  101. #else
  102. #define INTRABURST_1 0
  103. #endif
  104.  
  105. #ifdef _SNS2_SNSK2_SAME_PORT_
  106. #define INTRABURST_2 1
  107. #else
  108. #define INTRABURST_2 0
  109. #endif
  110.  
  111. #if ((INTRABURST_1== 1) && (INTRABURST_2== 1))
  112. #error 'QT_NUM_CHANNELS value should be 8 in this case.'
  113. #elif ((INTRABURST_1== 1) || (INTRABURST_2== 1))
  114. #if (QT_NUM_CHANNELS == 16)
  115. #error 'QT_NUM_CHANNELS value should be 12 in this case.'
  116. #endif
  117. #elif ((INTRABURST_1== 0) && (INTRABURST_2== 0))
  118. #if (QT_NUM_CHANNELS == 12)
  119. #error 'QT_NUM_CHANNELS value should be 16 in this case.'
  120. #endif
  121. #endif
  122. #elif (QT_NUM_CHANNELS == 32)
  123. #define _STATIC_PORT_PIN_CONF_ 1
  124. #define QTOUCH_SNS_PORT_COUNT 2
  125. #define QTOUCH_PIN_CONF 0
  126. #ifdef _SNS1_SNSK1_SAME_PORT_
  127. #define INTRABURST_1 1
  128. #else
  129. #define INTRABURST_1 0
  130. #endif
  131.  
  132. #ifdef _SNS2_SNSK2_SAME_PORT_
  133. #define INTRABURST_2 1
  134. #else
  135. #define INTRABURST_2 0
  136. #endif
  137. #else
  138. #error 'QT_NUM_CHANNELS specified is not supported.'
  139. #endif
  140. #else
  141. #ifdef _SNS1_SNSK1_SAME_PORT_
  142. #define _STATIC_PORT_PIN_CONF_ 1
  143. #define QTOUCH_SNS_PORT_COUNT 1
  144. #define INTRABURST_1 1
  145. #define INTRABURST_2 0
  146. #else
  147. #define _STATIC_PORT_PIN_CONF_ 0
  148. #define QTOUCH_SNS_PORT_COUNT 1
  149. #define INTRABURST_1 0
  150. #define INTRABURST_2 0
  151. #endif
  152. #endif
  153.  
  154. #if (defined(__IAR_SYSTEMS_ASM__) || defined(__ASSEMBLER__) || defined(__ICCAVR32__) || defined(__AVR32__))
  155. #if (defined(__IAR_SYSTEMS_ASM__) || defined(__ICCAVR32__))
  156. #if defined(__IAR_SYSTEMS_ASM__)
  157. #include <ioavr.h>
  158. #define p_1 r16
  159. #define p_2 r17
  160. #define p_3 r18
  161. #define p_4 r19
  162. #define p_5 r20
  163. #define r_v r16
  164. #define FILE_HEADER NAME qt_asm_iar
  165. #define FILE_FOOTER END
  166. #define FILE_SEGMENT RSEG CODE
  167. #define GLOBAL_FUNCTION PUBLIC
  168.  
  169. #define GLOBAL_VAR EQU
  170. #elif defined(__ICCAVR32__)
  171. #include <avr32/io.h>
  172. #define p_1 r12
  173. #define p_2 r11
  174. #define p_3 r10
  175. #define r_v r12
  176. #define _UC3A_
  177.  
  178. #define _QTOUCH_
  179.         //#define FILE_HEADER NAME qt_asm_iar
  180.         //#define FILE_FOOTER END
  181.         //#define FILE_SEGMENT RSEG CODE
  182. #define FILE_HEADER
  183. #define FILE_FOOTER
  184. #define FILE_SEGMENT
  185. #define GLOBAL_FUNCTION PUBLIC
  186. #endif
  187. #elif (defined(__ASSEMBLER__) || defined(__AVR32__))
  188. #if defined(__AVR32__)
  189. #include <avr32/io.h>
  190.  
  191. #define p_1 r12
  192. #define p_2 r11
  193. #define p_3 r10
  194. #define r_v r12
  195.  
  196.  
  197. #define _QTOUCH_
  198. #define _UC3A_
  199. #define _STATIC_PORT_PIN_CONF_ 0
  200. #define QTOUCH_SNS_PORT_COUNT 1
  201. #define INTRABURST_1 0
  202. #define INTRABURST_2 0
  203. #else
  204. #define __SFR_OFFSET 0
  205. #include <avr/io.h>
  206. #define p_1 r24
  207. #define p_2 r22
  208. #define p_3 r20
  209. #define p_4 r18
  210. #define p_5 r16
  211. #define r_v r24
  212.  
  213. #define GLOBAL_VAR .EQU
  214. #endif
  215.  
  216. #define FILE_HEADER
  217. #define FILE_FOOTER
  218. #define FILE_SEGMENT
  219. #define GLOBAL_FUNCTION .global
  220. #else
  221. #error 'Assembler not supported.'
  222. #endif
  223.  
  224. #define JOIN( x, y ) x ## y
  225. #define JOIN1( A, B, C ) A ## B ## C
  226. #define REG( REGISTER, SIDE ) JOIN( REGISTER, SIDE )
  227. #define CONCAT( A, B, C ) JOIN1( A, B, C )
  228.  
  229. #define sreg_save r2
  230.  
  231. #define _00011001_  nop
  232. #define _01101001_  brne _111_
  233. #define _01101011_  brne _222_
  234. #define _10001110_  rjmp .
  235. #if (defined (__AVR32__) || defined (__ICCAVR32__))
  236. #define _10100011_  _111_: sub r9,1
  237. #define _10100111_  _222_: sub r9,1
  238. #define _11100011_  mov r9,((QT_DELAY_CYCLES - 1)/3)
  239. #else
  240. #define _10100011_  _111_: dec r19
  241. #define _10100111_  _222_: dec r19
  242. #define _11100011_  ldi r19,((QT_DELAY_CYCLES - 1)/3)
  243. #endif
  244.  
  245. #else
  246.  
  247. #ifndef _QTOUCH_
  248. #define _QTOUCH_
  249. #endif
  250. #endif
  251.  
  252. #endif /*_QT_ASM_AVR8_H_*/
  253.