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 API interface for
  6.  *         AVR 8-bit, AVR 32-bit and Atmel ARM QMatrix and QTouch method
  7.  *         Capacitive Touch acquisition.
  8.  *
  9.  * - Compiler:           IAR EWAVR/EWAVR32 and GNU GCC for AVR/AVR32
  10.  *                       IAR Workbench and GNU GCC for Atmel ARM.
  11.  * - Supported devices:  Atmel AVR 8-bit, AVR 32-bit, Atmel ARM.
  12.  * - Userguide:          QTouch Library User Guide - doc8207.pdf.
  13.  * - Support email:      touch@atmel.com
  14.  *
  15.  * \author               Atmel Corporation: http://www.atmel.com \n
  16.  *                       Support and FAQ: http://support.atmel.no/
  17.  *
  18.  ******************************************************************************/
  19.  
  20. /* Copyright (c) 2010 Atmel Corporation. All rights reserved.
  21.  *
  22.  * Redistribution and use in source and binary forms, with or without
  23.  * modification, are permitted provided that the following conditions are met:
  24.  *
  25.  * 1. Redistributions of source code must retain the above copyright notice, this
  26.  * list of conditions and the following disclaimer.
  27.  *
  28.  * 2. Redistributions in binary form must reproduce the above copyright notice,
  29.  * this list of conditions and the following disclaimer in the documentation
  30.  * and/or other materials provided with the distribution.
  31.  *
  32.  * 3. The name of Atmel may not be used to endorse or promote products derived
  33.  * from this software without specific prior written permission.
  34.  *
  35.  * 4. This software may only be redistributed and used in connection with an Atmel
  36.  * AVR product.
  37.  *
  38.  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  39.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  40.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  41.  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  42.  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  43.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  44.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  45.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  46.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  47.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  48.  *
  49.  */
  50.  
  51. #ifndef TOUCH_API_H
  52. #define TOUCH_API_H
  53.  
  54. #include "../../touch.h"
  55.  
  56. /*----------------------------------------------------------------------------
  57.                             nested include files
  58. ----------------------------------------------------------------------------*/
  59. #if defined (__GNUC__) || defined (__ICCARM__) ||defined (__CC_ARM)
  60. #include <stdint.h>
  61. #endif
  62.  
  63. #if !defined (__CC_ARM)
  64. #include <stdbool.h>
  65. #endif
  66. #include <stdlib.h>
  67. #ifndef MAKE_BUILD
  68. # ifdef _QMATRIX_
  69. #  if !(defined(__AVR32__) || defined(__ICCAVR32__))
  70. #   include "qm_asm_avr.h"
  71. #  else
  72. #   include "touch_qm_config32.h"
  73. #  endif
  74. # elif defined _QTOUCH_
  75. #  if !(defined(__AVR32__) || defined(__ICCAVR32__))
  76. #   include "qt_asm_avr.h"
  77. #  endif
  78. # else
  79. #  error /* please provide any one of the acquisition methods */
  80. # endif
  81. #endif
  82.  
  83. #ifdef __ICCAVR__
  84. #include <intrinsics.h>
  85. #endif /* (__ICCAVR__) */
  86.  
  87. /*----------------------------------------------------------------------------
  88.                         Note: choice of library version
  89. -----------------------------------------------------------------------------*/
  90. /**
  91.   * QTouch libraries are supplied built with a range of charge times.
  92.   * Charge time is the duration in which charge is transferred from the AVR onto
  93.   * the measurement capacitor. Shorter charge times result in faster measurements,
  94.   * but may be too fast to completely transfer charge onto the measurement
  95.   * capacitor.
  96.   *
  97.   * The range of charge times lets the user choose a suitable version for the clock
  98.   * rate their chip is running at.
  99.   *
  100.   * To make capacitive measurements, a charge time on the order of 0.25us to 2.5us
  101.   * is typically required. The following table shows the charge times corresponding
  102.   * to a range of clock speeds.
  103.   *
  104.   * Clock speed (MHz) Cycle time (us) Suitable charge times
  105.   * ----------------- --------------- ---------------------
  106.   *       1              1            1~2 cycles (1us to 2us)
  107.   *       2              0.5          1~5 cycles (0.5us to 2.5us)
  108.   *       4              0.25         1~10 cycles (0.25us to 2.5us)
  109.   *       8              0.125        2~10 cycles (0.25us to 1.25us)
  110.   *       10             0.1          3~25 cycles (0.3us to 2.5us)
  111.   *       16             0.0625       4~25 cycles (0.25us to 1.5625s)
  112.   *       20             0.05         5~50 cycles (0.25us to 2.5us)
  113.   */
  114.  
  115. /**
  116.   * Error Checking For the User Configuration Options Starts here.
  117.   */
  118. #ifdef _QMATRIX_
  119.  
  120. /**
  121.   * Info stored for each x line.
  122.   *
  123.   * For each X line, enter the port and pin it is on.
  124.   * For instance, if X3 is on PB1, the 4th entry would be
  125.   * FILL_OUT_X_LINE_INFO( 1,1 ), and PORT_X_1 is B
  126.   */
  127. #define FILL_OUT_X_LINE_INFO( port_num,x_bit ) {JOIN(burst_qm_, port_num) ,(TOUCH_DATA_T)( 1u << x_bit ), BURST_MASK_X_PORT_ ## port_num  }
  128.  
  129. /**
  130.   * Info stored for each y line.
  131.   *
  132.   * For each Y line, enter the pin it is on.
  133.   * For instance, if Y2 is on PA5 and PF5, the 3th entry would be
  134.   *    FILL_OUT_Y_LINE_INFO( 5 )
  135.   * NOTE: 1. The PORTs for YA and YB on which Y lines are going to
  136.   *          be needs to be defined as PORT_YA and PORT_YB.
  137.   *
  138.   * Example: PORT_YA=A and PORT_YB=F in the case above.
  139.   */
  140. #if !(defined(__AVR32__) || defined(__ICCAVR32__))
  141. //#define FILL_OUT_Y_LINE_INFO( bit ) { bit, (TOUCH_DATA_T)(1u<<bit) }
  142. #define FILL_OUT_YA_LINE_INFO( bit ) { bit, (TOUCH_DATA_T)(1u<<bit) }
  143. #define FILL_OUT_YB_LINE_INFO( bit ) { bit, (TOUCH_DATA_T)(1u<<bit) }
  144. #else
  145. #define FILL_OUT_YA_LINE_INFO( bit ) { bit, (TOUCH_DATA_T)(1u<<bit) }
  146. #define FILL_OUT_YB_LINE_INFO( bit ) { bit, (TOUCH_DATA_T)(1u<<bit) }
  147. #endif
  148.  
  149. /**
  150.   * Info stored for each ya line.
  151.   *
  152.   * For each YA line, enter the pin it is on.
  153.   * For instance, if Y2A is on PA5 , the 3th entry would be
  154.   *    FILL_OUT_YA_LINE_INFO( 5 )
  155.   * NOTE: 1. The PORTs for YA and YB on which Y lines are going to
  156.   *          be needs to be defined as PORT_YA and PORT_YB.
  157.   *
  158.   * Example: PORT_YA=A in the case above.
  159.   */
  160. //FWRAP: #define FILL_OUT_YA_LINE_INFO( bit ) { bit, (uint8_t)(1u<<bit) }
  161.  
  162. /**
  163.   * Info stored for each yb line.
  164.   *
  165.   * For each YB line, enter the pin it is on.
  166.   * For instance, if Y2B is on PF3, the 3th entry would be
  167.   *    FILL_OUT_YB_LINE_INFO( 3 )
  168.   * NOTE: 1. The PORTs for YA and YB on which Y lines are going to
  169.   *          be needs to be defined as PORT_YA and PORT_YB.
  170.   *
  171.   * Example: PORT_YB=F in the case above.
  172.   */
  173. //FWRAP: #define FILL_OUT_YB_LINE_INFO( bit ) { bit, (uint8_t)(1u<<bit) }
  174.  
  175.  
  176. #ifndef MAKE_BUILD
  177. //! Check necessary definitions.
  178. #if (NUM_X_PORTS==1)
  179. #if !defined(PORT_X_1) || !defined(PORT_YA) || !defined(PORT_YB) || !defined(QT_DELAY_CYCLES) || !defined(PORT_SMP) || !defined(SMP_BIT)
  180. #error Need to define PORT_X_1, PORT_YA,PORT_YB,PORT_SMP,SMP_BIT and QT_DELAY_CYCLES before including the header file.
  181. #endif
  182. #elif(NUM_X_PORTS==2)
  183. #if !defined(PORT_X_1)||!defined(PORT_X_2) || !defined(PORT_YA) || !defined(PORT_YB) || !defined(QT_DELAY_CYCLES) || !defined(PORT_SMP) || !defined(SMP_BIT)
  184. #error Need to define PORT_X_1,PORT_X_2, PORT_YA,PORT_YB,PORT_SMP,SMP_BIT and QT_DELAY_CYCLES before including the header file.
  185. #endif
  186. #elif(NUM_X_PORTS==3)
  187. #if !defined(PORT_X_1)||!defined(PORT_X_2) ||!defined(PORT_X_3)|| !defined(PORT_YA) || !defined(PORT_YB) || !defined(QT_DELAY_CYCLES) || !defined(PORT_SMP) || !defined(SMP_BIT)
  188. #error Need to define PORT_X_1,PORT_X_2,PORT_X_3, PORT_YA,PORT_YB,PORT_SMP,SMP_BIT and QT_DELAY_CYCLES before including the header file.
  189. #endif
  190. #endif
  191. #ifdef _ROTOR_SLIDER_
  192. #if (QT_NUM_CHANNELS == 4u)
  193. #if !(QT_MAX_NUM_ROTORS_SLIDERS == 1u)
  194. #error QT_MAX_NUM_ROTORS_SLIDERS should be define as 1
  195. #endif
  196. #elif (QT_NUM_CHANNELS == 8u)
  197. #if !(QT_MAX_NUM_ROTORS_SLIDERS == 2u)
  198. #error QT_MAX_NUM_ROTORS_SLIDERS should be define as 2
  199. #endif
  200. #elif (QT_NUM_CHANNELS == 16u)
  201. #if !((QT_MAX_NUM_ROTORS_SLIDERS == 2u) || (QT_MAX_NUM_ROTORS_SLIDERS == 4u))
  202. #error QT_MAX_NUM_ROTORS_SLIDERS should be define as 2 or 4 based on library selected
  203. #endif
  204. #elif (QT_NUM_CHANNELS == 24u)
  205. #if !((QT_MAX_NUM_ROTORS_SLIDERS == 3u))
  206. #error QT_MAX_NUM_ROTORS_SLIDERS should be define as 3
  207. #endif
  208. #elif (QT_NUM_CHANNELS == 32u)
  209. #if !(QT_MAX_NUM_ROTORS_SLIDERS == 4u)
  210. #error QT_MAX_NUM_ROTORS_SLIDERS should be define as 4 based on library selected
  211. #endif
  212. #elif (QT_NUM_CHANNELS == 64u)
  213. #if !((QT_MAX_NUM_ROTORS_SLIDERS == 4u) || (QT_MAX_NUM_ROTORS_SLIDERS == 8u))
  214. #error QT_MAX_NUM_ROTORS_SLIDERS should be define as 4 or 8 based on library selected
  215. #endif
  216. #endif
  217. #else
  218. #if !(QT_MAX_NUM_ROTORS_SLIDERS == 0u)
  219. #error QT_MAX_NUM_ROTORS_SLIDERS should be define as 0 Or _ROTOR_SLIDER_ Macro Needs to be define
  220. #endif
  221. #endif
  222.  
  223. #endif //! MAKE_BUILD.
  224. #endif //! _QMATRIX_
  225. /**
  226.   * Error Checking For the User Configuration Options ends here.
  227.   */
  228.  
  229. /**
  230.   * WARNING! Do not edit below this line.
  231.   */
  232.  
  233. /*----------------------------------------------------------------------------
  234.                                     macros
  235. ----------------------------------------------------------------------------*/
  236. /**
  237.   * Utility macro for expanding port registers.
  238.   */
  239. #define JOIN( x, y ) x ## y
  240. #define JOIN1( A, B, C ) A ## B ## C
  241.  
  242. /**
  243.   * Macro to build register writes for controlling ports. The intermediate
  244.   * JOIN macro is required for correct expansion of the args.
  245.   */
  246. #define REG( REGISTER, SIDE ) JOIN( REGISTER, SIDE )
  247. #define CONCAT( A, B, C ) JOIN1( A, B, C )
  248.  
  249. /**
  250.   * The number of bytes required to report the maximum possible number of
  251.   * sensors.
  252.   */
  253. #define QT_NUM_SENSOR_STATE_BYTES ( ( QT_NUM_CHANNELS + 7u ) / 8u )
  254.  
  255. /**
  256.   * Status flags used with debug
  257.   */
  258. //! indicating no activity.
  259. #define QTLIB_NO_ACTIVITY             (uint16_t) 0x0000
  260. //! indicating that at least one sensor is in detect.
  261. #define QTLIB_IN_DETECT               (uint16_t) 0x0001
  262. //! indicating that at least one sensor haschanged ON/OFF state since last call to measure_sensors.
  263. #define QTLIB_STATUS_CHANGE           (uint16_t) 0x0002
  264. //! indicating that at least one rotor slider has changed position since last call to measure_sensors.
  265. #define QTLIB_ROTOR_SLIDER_POS_CHANGE (uint16_t) 0x0004
  266. //! indicating that at least one reference value has changed since last call to measure_sensors.
  267. #define QTLIB_CHANNEL_REF_CHANGE      (uint16_t) 0x0008
  268. //! indicating that reburst is needed to resolve in FILTERIN or FILTEROUT or RECALIBRATE state.
  269. #define QTLIB_BURST_AGAIN             (uint16_t) 0x0100
  270. //! indicating that reburst is needed to resolve in CALIBRATION.
  271. #define QTLIB_RESOLVE_CAL             (uint16_t) 0x0200
  272. //! indicating that reburst is needed to resolve in FILTERING.
  273. #define QTLIB_RESOLVE_FILTERIN        (uint16_t) 0x0400
  274. //! indicating that reburst is needed to resolve in RECAL.
  275. #define QTLIB_RESOLVE_DI              (uint16_t) 0x0800
  276. //! indicating that reburst is needed to resolve in RECAL.
  277. #define QTLIB_RESOLVE_POS_RECAL       (uint16_t) 0x1000
  278.  
  279. /*----------------------------------------------------------------------------
  280.                                 type definitions
  281. ----------------------------------------------------------------------------*/
  282. #if defined (__ICCAVR__) || defined (__ICCAVR32__)
  283. //! An signed 8-bit value.
  284. typedef signed char int8_t;
  285. //! An unsigned 8-bit value.
  286. typedef unsigned char uint8_t;
  287. //! An unsigned 16-bit value.
  288. typedef unsigned short uint16_t;
  289. //! A signed 16-bit value.
  290. typedef short int16_t;
  291. //! An unsigned 32-bit value.
  292. typedef unsigned long uint32_t;
  293. #endif
  294.  
  295. /**
  296.   * This part of the code below is used for library selection. This code will not be documented.
  297.   */
  298. #ifdef _QTOUCH_
  299.  
  300.  
  301. #ifdef QTOUCH_STUDIO_MASKS
  302. #define CALCULATE_MASKS  NULL
  303. #else
  304. #define CALCULATE_MASKS  calc_masks
  305. #endif
  306.  
  307. #if defined (__AVR32__) || defined (__ICCAVR32__) || defined (_TOUCH_ARM_)
  308.  
  309. #if (QT_NUM_CHANNELS <= 8u && QT_NUM_CHANNELS != 0u)
  310. #define TOUCH_DATA_T uint8_t
  311. #elif (QT_NUM_CHANNELS > 8u && QT_NUM_CHANNELS <= 16u)
  312. #define TOUCH_DATA_T uint16_t
  313. #elif (QT_NUM_CHANNELS > 16u && QT_NUM_CHANNELS <= 32u)
  314. #define TOUCH_DATA_T uint32_t
  315. #else
  316. #error 'The number of channels specified is not supported.'
  317. #endif
  318. #else
  319. #define TOUCH_DATA_T uint8_t
  320. #endif
  321.  
  322. #ifndef MAKE_BUILD
  323. #if !(defined(__AVR32__) || defined(__ICCAVR32__)) || defined(_TOUCH_ARM_)
  324. #if (QT_NUM_CHANNELS == 16u)
  325. #ifndef _STATIC_PORT_PIN_CONF_
  326. #define _STATIC_PORT_PIN_CONF_
  327. #define QTOUCH_SNS_PORT_COUNT 2u
  328. #endif
  329. #else
  330. #ifdef INTRABURST_1
  331. #ifndef _STATIC_PORT_PIN_CONF_
  332. #define _STATIC_PORT_PIN_CONF_
  333. #define QTOUCH_SNS_PORT_COUNT 1u
  334. #endif
  335. #endif
  336. #ifndef SNS1
  337. #define SNS1 SNS
  338. #endif
  339. #ifndef SNSK1
  340. #define SNSK1 SNSK
  341. #endif
  342. #endif
  343. #else
  344. #ifdef INTRABURST_1
  345. #ifndef _STATIC_PORT_PIN_CONF_
  346. #define _STATIC_PORT_PIN_CONF_
  347. #define QTOUCH_SNS_PORT_COUNT 1u
  348. #endif
  349. #define SNS1 SNS
  350. #define SNSK1 SNSK
  351. #endif
  352. #endif
  353. #ifdef _ROTOR_SLIDER_
  354. #if !defined(QT_MAX_NUM_ROTORS_SLIDERS)
  355. #if (QT_NUM_CHANNELS == 4)
  356. #define QT_MAX_NUM_ROTORS_SLIDERS 1
  357. #elif (QT_NUM_CHANNELS == 8)
  358. #define QT_MAX_NUM_ROTORS_SLIDERS 2
  359. #elif (QT_NUM_CHANNELS == 12)
  360. #define QT_MAX_NUM_ROTORS_SLIDERS 3
  361. #elif (QT_NUM_CHANNELS == 16)
  362. #define QT_MAX_NUM_ROTORS_SLIDERS 4
  363. #elif (QT_NUM_CHANNELS == 32)
  364. #define QT_MAX_NUM_ROTORS_SLIDERS 8
  365. #endif
  366. #endif
  367. #else
  368. #define QT_MAX_NUM_ROTORS_SLIDERS 0
  369. #endif
  370. #endif
  371.  
  372. #if !(defined(__AVR32__) || defined(__ICCAVR32__) || defined(_TOUCH_ARM_))
  373. //! Macros for string concatenation.
  374. //#define JOIN3( a, b, c, d, e ) burst_ ## a ## _ ## b ## _ ## c ## d ## _ ## e
  375. #define JOIN4( a, b, c, d, e , f ) burst_ ## a ## _ ## b ## _ ## c ## d ## _ ## e ##_ ## f
  376. //#define BURST_JOIN( static_flag, num_ports, intra1, intra2, pow_opt ) JOIN3( static_flag, num_ports, intra1, intra2, pow_opt )
  377. #define BURST_JOIN( static_flag, num_ports, intra1, intra2, pow_opt, qtouch_pin_conf ) JOIN4( static_flag, num_ports, intra1, intra2, pow_opt, qtouch_pin_conf )
  378.  
  379. //! Build pointer to correct burst function.
  380. #define BURST_FUNC_NAME     BURST_JOIN( _STATIC_PORT_PIN_CONF_, QTOUCH_SNS_PORT_COUNT, INTRABURST_1, INTRABURST_2, _POWER_OPTIMIZATION_, QTOUCH_PIN_CONF )
  381. //#define BURST_FUNC_NAME               BURST_JOIN( _STATIC_PORT_PIN_CONF_, QTOUCH_SNS_PORT_COUNT, INTRABURST_1, INTRABURST_2, _POWER_OPTIMIZATION_ )
  382.  
  383.  
  384. //! Burst function prototype. The code itself is stored in the touch library.
  385. extern void BURST_FUNC_NAME (TOUCH_DATA_T mask_index);
  386.  
  387. //! Function pointer used for bursting.
  388. extern void (*burst_proc) (TOUCH_DATA_T mask_index);
  389.  
  390. #else
  391. #ifndef _STATIC_PORT_PIN_CONF_
  392.  
  393. /**
  394.   * Select SNS and SNSK port. Choosing the same port for both will
  395.   * configure intra-port bursting. Options are B,C, and D.
  396.   */
  397. #define QT_SNS_PORT  SNS
  398. #define QT_SNSK_PORT SNSK
  399.  
  400. //! Check necessary definitions.
  401. #if !defined(QT_SNS_PORT) || !defined(QT_SNSK_PORT) || !defined(QT_DELAY_CYCLES)
  402. #error Need to define QT_SNS_PORT, QT_SNSK_PORT, and QT_DELAY_CYCLES before including this header file.
  403. #endif
  404.  
  405. //! Macros for string concatenation.
  406. #define JOIN3( a, b, c ) burst_ ## a ## _ ## b ## c
  407. #define BURST_JOIN( cycles, snsk, sns ) JOIN3( cycles, snsk, sns )
  408.  
  409. //! Build pointer to correct burst function.
  410. #define BURST_FUNC_NAME     BURST_JOIN( QT_DELAY_CYCLES, QT_SNSK_PORT , QT_SNS_PORT)
  411.  
  412. #else
  413.  
  414. //! static port pin configurability declarations.
  415. #if (QTOUCH_SNS_PORT_COUNT > 0u)
  416. //! first SNS - SNSK port pin pairing.
  417. #define QT_SNS1_PORT SNS1
  418. #define QT_SNSK1_PORT SNSK1
  419.  
  420. #if !defined(QT_SNS1_PORT) || !defined(QT_SNSK1_PORT) || !defined(QT_DELAY_CYCLES) || !defined(QT_NUM_CHANNELS) || \
  421.                 !defined(QT_MAX_NUM_ROTORS_SLIDERS)
  422. #error Need to define QT_SNS1_PORT, QT_SNSK1_PORT, QT_DELAY_CYCLES, QT_NUM_CHANNELS and QT_MAX_NUM_ROTORS_SLIDERS before including this header file.
  423. #endif
  424. #endif
  425.  
  426. #if (QTOUCH_SNS_PORT_COUNT > 1u) && !defined(_TOUCH_ARM_)
  427. #error 'Maximum of only 1 SNS-SNSK port pairings are supported by the UC3 libraries.'
  428. #elif (QTOUCH_SNS_PORT_COUNT == 0u)
  429. #error 'Invalid QTOUCH_SNS_PORT_COUNT value.'
  430. #endif /*  QTOUCH_SNS_PORT_COUNT   */
  431.  
  432. #if (QTOUCH_SNS_PORT_COUNT > 1u)
  433. //! second SNS - SNSK port pin pairing.
  434. #define QT_SNS2_PORT SNS2
  435. #define QT_SNSK2_PORT SNSK2
  436.  
  437. #if !defined(QT_SNS2_PORT) || !defined(QT_SNSK2_PORT) || !defined(QT_DELAY_CYCLES) || !defined(QT_NUM_CHANNELS) || \
  438.                 !defined(QT_MAX_NUM_ROTORS_SLIDERS)
  439. #error Need to define QT_SNS2_PORT, QT_SNSK2_PORT, QT_DELAY_CYCLES, QT_NUM_CHANNELS and QT_MAX_NUM_ROTORS_SLIDERS  before including this header file.
  440. #endif
  441. #endif
  442.  
  443. #if (QTOUCH_SNS_PORT_COUNT == 1u)
  444.  
  445. //! Macros for string concatenation.
  446. #define JOIN3( a, b, c, d, z ) burst_ ## a ## _ ## b ## c
  447. #define BURST_JOIN( cycles, snsk1, sns1, ch, rs ) JOIN3( cycles, snsk1, sns1, ch, rs )
  448.  
  449. //! Build pointer to correct burst function.
  450. #define BURST_FUNC_NAME     BURST_JOIN( QT_DELAY_CYCLES, QT_SNSK1_PORT , QT_SNS1_PORT, QT_NUM_CHANNELS, \
  451.                 QT_MAX_NUM_ROTORS_SLIDERS)
  452.  
  453. #elif (QTOUCH_SNS_PORT_COUNT == 2u)
  454. #if defined(_TOUCH_ARM_)
  455. //! Macros for string concatenation.
  456. #define JOIN3( a, b, c, e, f, d, z ) burst_ ## a ## _ ## b ## c ## _ ## e ## f
  457. #define BURST_JOIN( cycles, snsk1, sns1, snsk2, sns2, ch, rs ) JOIN3( cycles, snsk1, sns1, snsk2, sns2, ch, rs )
  458.  
  459. //! Build pointer to correct burst function.
  460. #define BURST_FUNC_NAME     BURST_JOIN( QT_DELAY_CYCLES, QT_SNSK1_PORT , QT_SNS1_PORT, QT_SNSK2_PORT , QT_SNS2_PORT, QT_NUM_CHANNELS, \
  461.                 QT_MAX_NUM_ROTORS_SLIDERS)
  462. #endif
  463. #else
  464. #error 'Invalid QTOUCH_SNS_PORT_COUNT value.'
  465. #endif
  466.  
  467. #endif
  468.  
  469. //! Burst function prototype. The code itself is stored in the touch library.
  470. extern void BURST_FUNC_NAME (TOUCH_DATA_T mask_index);
  471.  
  472. //! Function pointer used for bursting.
  473. extern void (*burst_proc) (TOUCH_DATA_T mask_index);
  474. #endif
  475.  
  476. #endif
  477.  
  478. /**
  479.   * QMATRIX Start.
  480.   */
  481. #ifdef _QMATRIX_
  482.  
  483. // #ifdef __AVR32__
  484. #if defined (__AVR32__) || defined (__ICCAVR32__)
  485. #define TOUCH_DATA_T uint32_t
  486. #else
  487. #define TOUCH_DATA_T uint8_t
  488. #endif
  489.  
  490. //! Macros for string concatenation.
  491. #define BURST_JOIN(A,B) JOIN(A,B)
  492. #if (NUM_X_PORTS ==1)
  493. #define BURST_FUNC_1 BURST_JOIN(burst_qm_,PORT_NUM_1)
  494. extern void BURST_FUNC_1 (uint8_t channel, TOUCH_DATA_T x_mask);
  495. #elif (NUM_X_PORTS ==2)
  496. #define BURST_FUNC_1 BURST_JOIN(burst_qm_,PORT_NUM_1)
  497. extern void BURST_FUNC_1 (uint8_t channel, TOUCH_DATA_T x_mask);
  498. #define BURST_FUNC_2 BURST_JOIN(burst_qm_,PORT_NUM_2)
  499. extern void BURST_FUNC_2 (uint8_t channel, TOUCH_DATA_T x_mask);
  500. #elif (NUM_X_PORTS ==3)
  501. #define BURST_FUNC_1 BURST_JOIN(burst_qm_,PORT_NUM_1)
  502. extern void BURST_FUNC_1 (uint8_t channel, TOUCH_DATA_T x_mask);
  503. #define BURST_FUNC_2 BURST_JOIN(burst_qm_,PORT_NUM_2)
  504. extern void BURST_FUNC_2 (uint8_t channel, TOUCH_DATA_T x_mask);
  505. #define BURST_FUNC_3 BURST_JOIN(burst_qm_,PORT_NUM_3)
  506. extern void BURST_FUNC_3 (uint8_t channel, TOUCH_DATA_T x_mask);
  507. #endif
  508.  
  509. //! Function pointer used for bursting.
  510. extern void (*burst_proc_qm) (uint8_t channel, TOUCH_DATA_T drive_mask);
  511.  
  512. //! pointer to function to be called for a channel.
  513. typedef void (*PF_CHANNEL) (uint8_t channel);
  514.  
  515. //! pointer to function returning void.
  516. typedef void (*PFV) (uint8_t channel, TOUCH_DATA_T line_mask);
  517.  
  518. //! info stored for each x line.
  519. typedef struct tag_x_line_info_t
  520. {
  521.   //! ptr to function to burst on this line.
  522.   PFV p_burst_function;
  523.  
  524.   //! bit mask for driving/clamping this x line.
  525.   TOUCH_DATA_T mask;
  526.  
  527.   //! index into array of burst masks.
  528.   TOUCH_DATA_T burst_mask_array_index;
  529.  
  530. }
  531. x_line_info_t;
  532.  
  533. //! info stored for each y line.
  534. typedef struct tag_y_line_info_t
  535. {
  536.   //! which bit this y line is on.
  537.   TOUCH_DATA_T bit;
  538.   //! mask for y line.
  539.   TOUCH_DATA_T mask;
  540.  
  541. }
  542. y_line_info_t;
  543.  
  544. //! enumeration of recognised burst masks.
  545. typedef enum tag_burst_mask_t
  546. {
  547.   BURST_MASK_YA,        //! mask for ya lines.
  548.   BURST_MASK_YB,        //! mask for yb lines.
  549.   BURST_MASK_X_PORT_1,      //! mask for x lines on port1.
  550.   BURST_MASK_X_PORT_2,      //! mask for x lines on port2.
  551.   BURST_MASK_X_PORT_3,      //! mask for x lines on port3.
  552.   NUM_BURST_MASKS       //! Total number of masks.
  553. }
  554. burst_mask_t;
  555. /**
  556.   * The burst length on each QMatrix channel.
  557.   *
  558.   * Units: pulses
  559.   * Default value: 64 pulses
  560.   */
  561. extern uint8_t qt_burst_lengths[QT_NUM_CHANNELS];
  562.  
  563. #endif /* _QMATRIX_ */
  564. /**
  565.   * QMATRIX End
  566.   */
  567.  
  568. //! An unsigned 8-bit number setting a sensor detection threshold.
  569. typedef uint8_t threshold_t;
  570.  
  571. //! Options for the sensor types available.
  572. typedef enum tag_sensor_type_t
  573. {
  574.   SENSOR_TYPE_UNASSIGNED,
  575.   SENSOR_TYPE_KEY,
  576.   SENSOR_TYPE_ROTOR,
  577.   SENSOR_TYPE_SLIDER
  578. }
  579. sensor_type_t;
  580.  
  581. /**
  582.   * Which AKS group, if any, a sensor is in.
  583.   *
  584.   *  NO_AKS_GROUP = sensor is not in an AKS group, and cannot be suppressed.
  585.   *  AKS_GROUP_x  = sensor is in AKS group x.
  586.   */
  587. typedef enum tag_aks_group_t
  588. {
  589.   NO_AKS_GROUP,
  590.   AKS_GROUP_1,
  591.   AKS_GROUP_2,
  592.   AKS_GROUP_3,
  593.   AKS_GROUP_4,
  594.   AKS_GROUP_5,
  595.   AKS_GROUP_6,
  596.   AKS_GROUP_7
  597. }
  598. aks_group_t;
  599.  
  600. //! The channel(s) in a sensor.
  601. typedef enum tag_channel_t
  602. {
  603. #if (QT_NUM_CHANNELS > 0u)
  604.   CHANNEL_0,
  605.   CHANNEL_1,
  606.   CHANNEL_2,
  607.   CHANNEL_3
  608. #endif
  609. #if (QT_NUM_CHANNELS > 4u)
  610.     , CHANNEL_4,
  611.   CHANNEL_5,
  612.   CHANNEL_6,
  613.   CHANNEL_7
  614. #endif
  615. #if (QT_NUM_CHANNELS > 8u)
  616.     , CHANNEL_8,
  617.   CHANNEL_9,
  618.   CHANNEL_10,
  619.   CHANNEL_11
  620. #endif
  621. #if (QT_NUM_CHANNELS > 12u)
  622.     , CHANNEL_12,
  623.   CHANNEL_13,
  624.   CHANNEL_14,
  625.   CHANNEL_15
  626. #endif
  627. #if (QT_NUM_CHANNELS > 16u)
  628.     , CHANNEL_16,
  629.   CHANNEL_17,
  630.   CHANNEL_18,
  631.   CHANNEL_19,
  632.   CHANNEL_20,
  633.   CHANNEL_21,
  634.   CHANNEL_22,
  635.   CHANNEL_23
  636. #endif
  637. #if (QT_NUM_CHANNELS > 24u)
  638.     , CHANNEL_24,
  639.   CHANNEL_25,
  640.   CHANNEL_26,
  641.   CHANNEL_27,
  642.   CHANNEL_28,
  643.   CHANNEL_29,
  644.   CHANNEL_30,
  645.   CHANNEL_31
  646. #endif
  647. #if (QT_NUM_CHANNELS > 32u)
  648.     , CHANNEL_32,
  649.   CHANNEL_33,
  650.   CHANNEL_34,
  651.   CHANNEL_35,
  652.   CHANNEL_36,
  653.   CHANNEL_37,
  654.   CHANNEL_38,
  655.   CHANNEL_39,
  656.   CHANNEL_40,
  657.   CHANNEL_41,
  658.   CHANNEL_42,
  659.   CHANNEL_43,
  660.   CHANNEL_44,
  661.   CHANNEL_45,
  662.   CHANNEL_46,
  663.   CHANNEL_47,
  664.   CHANNEL_48,
  665.   CHANNEL_49,
  666.   CHANNEL_50,
  667.   CHANNEL_51,
  668.   CHANNEL_52,
  669.   CHANNEL_53,
  670.   CHANNEL_54,
  671.   CHANNEL_55
  672. #endif
  673. #if (QT_NUM_CHANNELS > 56u)
  674.     , CHANNEL_56,
  675.   CHANNEL_57,
  676.   CHANNEL_58,
  677.   CHANNEL_59,
  678.   CHANNEL_60,
  679.   CHANNEL_61,
  680.   CHANNEL_62,
  681.   CHANNEL_63
  682. #endif
  683. }
  684. channel_t;
  685.  
  686. /**
  687.   * A sensor detection hysteresis value.  This is expressed as a percentage of
  688.   *  the sensor detection threshold.
  689.   *
  690.   *  HYST_x = hysteresis value is x% of detection threshold value (rounded down).
  691.   *  NB: a minimum value of 2 is used.
  692.   *
  693.   *  Example: if detection threshold = 20, then:
  694.   *     HYST_50   = 10 (50% of 20)
  695.   *     HYST_25   = 5  (25% of 20)
  696.   *     HYST_12_5 = 2  (12.5% of 20)
  697.   *     HYST_6_25 = 2  (6.25% of 20 = 1, but value is hardlimited to 2)
  698.   */
  699. typedef enum tag_hysteresis_t
  700. {
  701.   HYST_50,
  702.   HYST_25,
  703.   HYST_12_5,
  704.   HYST_6_25
  705. }
  706. hysteresis_t;
  707.  
  708. /**
  709.   * For rotors and sliders, the resolution of the reported angle or position.
  710.   *
  711.   *  RES_x_BIT = rotor/slider reports x-bit values.
  712.   *
  713.   *  Example: if slider resolution is RES_7_BIT, then reported positions are in
  714.   *  the range 0..127.
  715.   */
  716. typedef enum tag_resolution_t
  717. {
  718.   RES_1_BIT,
  719.   RES_2_BIT,
  720.   RES_3_BIT,
  721.   RES_4_BIT,
  722.   RES_5_BIT,
  723.   RES_6_BIT,
  724.   RES_7_BIT,
  725.   RES_8_BIT
  726. }
  727. resolution_t;
  728.  
  729. /**
  730.   * A sensor recalibration threshold.  This is expressed as a percentage of the
  731.   *  sensor detection threshold.
  732.   *
  733.   *  RECAL_x = recalibration threshold is x% of detection threshold value
  734.   *           (rounded down).
  735.   *  NB:   a minimum value of 4 is used.
  736.   *
  737.   *  Example: if detection threshold = 40, then:
  738.   *     RECAL_100  = 40 (100% of 40)
  739.   *     RECAL_50   = 20 (50% of 40)
  740.   *     RECAL_25   = 10 (25% of 40)
  741.   *     RECAL_12_5 = 5  (12.5% of 40)
  742.   *  RECAL_6_25 = 4  (6.25% of 40 = 2, but value is hardlimited to 4)
  743.   */
  744. typedef enum tag_recal_threshold_t
  745. {
  746.   RECAL_100,
  747.   RECAL_50,
  748.   RECAL_25,
  749.   RECAL_12_5,
  750.   RECAL_6_25
  751. }
  752. recal_threshold_t;
  753.  
  754. //! The state of the library sensors.
  755. typedef struct tag_qt_touch_status_t
  756. {
  757.     /**
  758.       * The state (on/off) of the library sensors.
  759.       *  Bit 'n' = state of sensor 'n'.
  760.       *  Bit 0 = sensor_states[0] bit 0
  761.       *  Bit 1 = sensor_states[0] bit 1
  762.       *  ...
  763.       *  Bit 7 = sensor_states[0] bit 7
  764.       *  Bit 8 = sensor_states[1] bit 0
  765.       *  Bit 9 = sensor_states[1] bit 1
  766.       *  ... etc
  767.       *  0 = not in detect, 1 = in detect.
  768.       */
  769.   uint8_t sensor_states[QT_NUM_SENSOR_STATE_BYTES];
  770.     /**
  771.       * Rotor angles or slider positions.
  772.       *  These values are valid when sensor_states shows that the corresponding
  773.       *  rotor or slider sensor is in detect.
  774.       */
  775.   uint8_t rotor_slider_values[QT_MAX_NUM_ROTORS_SLIDERS];
  776. }
  777. qt_touch_status_t;
  778.  
  779.  
  780. //! post processing configuration data that is received from the debug interface.
  781. typedef struct tag_qt_touch_lib_config_data_t
  782. {
  783.   //! Sensor recalibration threshold.
  784.   recal_threshold_t qt_recal_threshold;
  785.   //! Sensor detect integration (DI) limit.
  786.   uint8_t qt_di;
  787.   //! Sensor drift hold time.
  788.   uint8_t qt_drift_hold_time;
  789.   //! Sensor maximum on duration.
  790.   uint8_t qt_max_on_duration;
  791.   //! Sensor negative drift rate.
  792.   uint8_t qt_neg_drift_rate;
  793.   //! Sensor positive drift rate.
  794.   uint8_t qt_pos_drift_rate;
  795.   //! Positive recalibration delay.
  796.   uint8_t qt_pos_recal_delay;
  797. }
  798. qt_touch_lib_config_data_t;
  799.  
  800. //! measured touch data that is sent for the debugging and fine tunning.
  801. typedef struct tag_qt_touch_lib_measure_data_t
  802. {
  803.   //! measured signal on each channel.
  804.   uint16_t channel_signals[QT_NUM_CHANNELS];
  805.   //! reference signal for each channel.
  806.   uint16_t channel_references[QT_NUM_CHANNELS];
  807.   //! state of sensors.
  808.   qt_touch_status_t qt_touch_status;
  809. }
  810. qt_touch_lib_measure_data_t;
  811.  
  812. //! This will be used to get the library information from the library.
  813. typedef struct qt_lib_sig_info_t
  814. {
  815.   uint16_t lib_sig_lword;
  816.   uint16_t lib_sig_hword;
  817.   uint16_t library_version;
  818. }
  819. qt_lib_siginfo_t;
  820.  
  821. typedef struct tag_sensor_t
  822. {
  823.   //! sensor state (calibrating, on, ...).
  824.   uint8_t state;
  825.  
  826.   //! general purpose ctr: used for calibration, drifting, etc.
  827.   uint8_t general_counter;
  828.  
  829.   //! DI ctr.
  830.   uint8_t ndil_counter;
  831.  
  832.   //! sensor detection threshold.
  833.   uint8_t threshold;
  834.  
  835.     /**
  836.       * sensor type, AKS group, positive recal flag, and hysteresis value
  837.       * bits 7..6: sensor type: 00: key
  838.       *                         01: rotor
  839.       *                         10: slider
  840.       *                         11: reserved
  841.       * bits 5..3: AKS group (0..7): 0 = no AKS group
  842.       * bit 2    : positive recal flag
  843.       * bits 1..0: hysteresis
  844.       */
  845.   uint8_t type_aks_pos_hyst;
  846.  
  847.     /**
  848.       * sensor from and to channels
  849.       * keys: from channel = to channel
  850.       * rotors/sliders run between the from and to channels
  851.       * NB: only need to_channel for keys in rotors/sliders build
  852.       */
  853.   uint8_t from_channel;
  854.  
  855. #ifdef _ROTOR_SLIDER_
  856.   uint8_t to_channel;
  857.  
  858.   //! index into array of rotor/slider values.
  859.   uint8_t index;
  860. #endif              /* _ROTOR_SLIDER_ */
  861.  
  862. }
  863. sensor_t;
  864.  
  865. /*----------------------------------------------------------------------------
  866.                                 extern variables
  867. ----------------------------------------------------------------------------*/
  868. /**
  869.   * This configuration data structure parameters if needs to be changed will be
  870.   * changed in the qt_set_parameters function
  871.   */
  872. extern qt_touch_lib_config_data_t qt_config_data;
  873. //! measurement data.
  874. extern qt_touch_lib_measure_data_t qt_measure_data;
  875. //! Get sensor delta values.
  876. extern int16_t qt_get_sensor_delta (uint8_t sensor);
  877. //! variable holding the status flags.
  878. extern uint16_t lib_status_flags;
  879. //! the library sensors.
  880. extern sensor_t sensors[QT_NUM_CHANNELS];
  881. //! timer period in msec.
  882. extern uint16_t qt_measurement_period_msec;
  883.  
  884. /*----------------------------------------------------------------------------
  885.                                 api
  886. ----------------------------------------------------------------------------*/
  887. /*! \brief  This function is called after the library has made capacitive measurements,
  888.  * but before it has processed them. The user can use this hook to apply filter
  889.  * functions to the measured signal values.
  890.  *
  891.  */
  892. extern void (*qt_filter_callback) (void);
  893.  
  894. /*! \brief Get the library signature.
  895.  *
  896.  * \param  qt_lib_siginfo_t: lib_sig_ptr=Pointer to the library signature structure
  897.  */
  898. extern void qt_get_library_sig (qt_lib_siginfo_t * lib_sig_ptr);
  899.  
  900. /*! \brief enable a key sensor.
  901.  *
  902.  * \param channel: which touch channel the key sensor uses
  903.  * \param aks_group: which AKS group (if any) the sensor is in
  904.  * \param detect_threshold: the sensor detection threshold
  905.  * \param detect_hysteresis: the sensor detection hysteresis value
  906.  *
  907.  * \note The sensor number corresponding to the key depends on the order in
  908.  *  which sensors are enabled. The first sensor enabled is sensor 0, the
  909.  *  second is sensor 1, and so on.
  910.  *
  911.  *  The current state of the key (on or off) can be checked in
  912.  *  qt_touch_status.sensor_states.
  913.  */
  914. extern void qt_enable_key (channel_t channel,
  915.                aks_group_t aks_group,
  916.                threshold_t detect_threshold,
  917.                hysteresis_t detect_hysteresis);
  918.  
  919. /*! \brief initialise touch sensing.
  920.  *
  921.  * \note  Any sensors required must be enabled (using qt_enable_xxx()) before
  922.  *  calling this function.
  923.  *
  924.  * This function calculates internal library variables and configures
  925.  * the touch channels, and must be called before qt_measure_sensors().
  926.  */
  927. #if defined( _QTOUCH_ )
  928.  
  929. #define qt_init_sensing( ) qt_init_sensing_with_burst( BURST_FUNC_NAME ,CALCULATE_MASKS)
  930. extern void
  931. qt_init_sensing_with_burst (void (*burst_function) (TOUCH_DATA_T mask_index),
  932.                 void (*calculate_masks) (void));
  933. extern void calc_masks (void);
  934. #elif defined( _QMATRIX_ )
  935.  
  936. #define qt_init_sensing( ) qt_init_sensing_with_burst(  )
  937. extern void qt_init_sensing_with_burst ();
  938.  
  939. #endif
  940.  
  941. /*! \brief measure touch sensors.
  942.  *
  943.  * \param  current_time_ms: the current time, in ms
  944.  * \return uint16_t: outputs the library status bits.
  945.  * \note This function performs a capacitive measurement on all enabled
  946.  * sensors. The measured signals for each sensor are then processed to
  947.  * check for user touches, releases, changes in rotor angle, changes in
  948.  * slider position, etc.
  949.  *
  950.  * The current state of all enabled sensors is reported in the
  951.  * qt_touch_status struct.
  952.  *
  953.  * Before calling this function, one or more sensors must have been
  954.  * enabled (using qt_enable_xxx()), and qt_init_sensing() must
  955.  * have been called.
  956.  */
  957. extern uint16_t qt_measure_sensors (uint16_t current_time_ms);
  958.  
  959. /*! \brief calibrate touch sensing.
  960.  *
  961.  * \note  This function forces a calibration of all enabled sensors.
  962.  * This may be useful if, for instance, it is desired to globally
  963.  * recalibrate all sensors on a change in application operating mode.
  964.  */
  965. extern void qt_calibrate_sensing (void);
  966.  
  967. /*! \brief reset touch sensing.
  968.  *
  969.  * \note  This function disables all enabled sensors, and returns all library
  970.  * variables (e.g., qt_di) to their default values.
  971.  *
  972.  * This may be useful if it is desired to dynamically reconfigure
  973.  * sensing. After calling this function, any required sensors must be
  974.  * re-enabled, and qt_init_sensing() must be called before
  975.  * qt_measure_channels() is called again.
  976.  */
  977. extern void qt_reset_sensing (void);
  978.  
  979. /*! \brief get the current delta on the specified sensor.
  980.  *
  981.  * \param  sensor: sensor number for which to get the delta.
  982.  * \return int16_t: returns the delta on the specified sensor.
  983.  * \note  This function is supplied as a functional replacement for the
  984.  * sensor_deltas[] array provided in earlier library versions.
  985.  */
  986. extern int16_t qt_get_sensor_delta (uint8_t sensor);
  987.  
  988. #ifdef _ROTOR_SLIDER_
  989.  
  990. /*! \brief enable a rotor sensor.
  991.  *
  992.  * \param  from_channel: the first channel in the rotor sensor
  993.  * \param  to_channel: the last channel in the rotor sensor
  994.  * \param  aks_group: which AKS group (if any) the sensor is in
  995.  * \param  detect_threshold: the sensor detection threshold
  996.  * \param  detect_hysteresis: the sensor detection hysteresis value
  997.  * \param  angle_resolution: the resolution of the reported angle value
  998.  * \param  angle_hysteresis: the hysteresis of the reported angle value
  999.  * \note   The sensor number corresponding to the rotor depends on the order in
  1000.  * which sensors are enabled. The first sensor enabled is sensor 0, the
  1001.  * second is sensor 1, and so on.
  1002.  *
  1003.  * The current state of the rotor (on or off) can be checked in
  1004.  * qt_touch_status.sensor_states.
  1005.  *
  1006.  * The rotor value is in qt_touch_status.rotor_slider_values[]. Which
  1007.  * array element is used depends on the order in which sensors are
  1008.  * enabled. The first rotor or slider enabled will use
  1009.  * and so on.
  1010.  *
  1011.  * The reported rotor value is valid when the rotor is on.
  1012.  */
  1013. extern void qt_enable_rotor (channel_t from_channel,
  1014.                  channel_t to_channel,
  1015.                  aks_group_t aks_group,
  1016.                  threshold_t detect_threshold,
  1017.                  hysteresis_t detect_hysteresis,
  1018.                  resolution_t angle_resolution,
  1019.                  uint8_t angle_hysteresis);
  1020.  
  1021. /*! \brief enable a slider sensor.
  1022.  *
  1023.  * \param  from_channel: the first channel in the slider sensor
  1024.  * \param  to_channel: the last channel in the slider sensor
  1025.  * \param  aks_group: which AKS group (if any) the sensor is in
  1026.  * \param  detect_threshold: the sensor detection threshold
  1027.  * \param  detect_hysteresis: the sensor detection hysteresis value
  1028.  * \param  position_resolution: the resolution of the reported position value
  1029.  * \param  position_hysteresis: the hysteresis of the reported position value
  1030.  * \note The sensor number corresponding to the slider depends on the order in
  1031.  * which sensors are enabled. The first sensor enabled is sensor 0, the
  1032.  * second is sensor 1, and so on.
  1033.  *
  1034.  * The current state of the slider (on or off) can be checked in
  1035.  * qt_touch_status.sensor_states.
  1036.  *
  1037.  * The slider value is in qt_touch_status.rotor_slider_values[]. Which
  1038.  * array element is used depends on the order in which sensors are
  1039.  * enabled. The first rotor or slider enabled will use
  1040.  * rotor_slider_values[0], the second will use rotor_slider_values[1],
  1041.  * and so on.
  1042.  *
  1043.  * The reported slider value is valid when the rotor is on.
  1044.  */
  1045. extern void qt_enable_slider (channel_t from_channel,
  1046.                   channel_t to_channel,
  1047.                   aks_group_t aks_group,
  1048.                   threshold_t detect_threshold,
  1049.                   hysteresis_t detect_hysteresis,
  1050.                   resolution_t position_resolution,
  1051.                   uint8_t position_hysteresis);
  1052.  
  1053. #endif
  1054.  
  1055. #endif /* TOUCH_API_H */
  1056.