Sensorian  1.0
C API Reference Guide Library
CAP1203.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2015 Sensorian
3  * *
4  * This file is part of Sensorian. *
5  * *
6  * Sensorian is free software: you can redistribute it and/or modify it *
7  * under the terms of the GNU Lesser General Public License as published *
8  * by the Free Software Foundation, either version 3 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * Sensorian is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with Sensorian. *
18  * If not, see <http://www.gnu.org/licenses/>. *
19  ****************************************************************************/
20 
28 #ifndef __CAP1203_H__
29 #define __CAP1203_H__
30 
31 #include "i2c.h"
32 
36 #define CAP1203ADDR 0x28 //0x28 - not shifted
37 
38 /*****************************Registers**************************/
39 #define MAIN_CTRL_REG 0x00
40 #define GEN_STATUS 0x02
41 #define SENSOR_INPUTS 0x03
42 #define NOISE_FLAG 0x0A
43 #define SENS1DELTACOUNT 0x10
44 #define SENS2DELTACOUNT 0x11
45 #define SENS3DELTACOUNT 0x12
46 #define SENSITIVITY 0x1F
47 #define CONFIG1 0x20
48 #define SENSINPUTEN 0x21
49 #define SENSINCONF1 0x22
50 #define SENSINCONF2 0x23
51 #define AVERAGE_SAMP_CONF 0x24
52 #define CAL_ACTIV 0x26
53 #define INT_ENABLE 0x27
54 #define REPEAT_RATE 0x28
55 #define MULTITOUCH 0x2A
56 #define MULTIPATCONF 0x2B
57 #define MULTIPATTERN 0x2D
58 #define BASECOUNT 0x2E
59 #define RECALCONFIG 0x2F
60 #define S1THRESHOLD 0x30
61 #define S2THRESHOLD 0x31
62 #define S3THRESHOLD 0x32
63 #define SENSTHRESHOLD 0x38
64 
65 #define STANDBYCHAN 0x40
66 #define STANDBYCONF 0x41
67 #define STANDBY_SENS 0x42
68 #define STANDBY_THRE 0x43
69 #define CONFIG2 0x44
70 #define S1BASECOUNT 0x50
71 #define S2BASECOUNT 0x51
72 #define S3BASECOUNT 0x52
73 #define PWR_BUTTON 0x60
74 #define PWR_CONFIG 0x61
75 #define S1INPCAL 0xB1
76 #define S2INPCAL 0xB2
77 #define S3INPCAL 0xB3
78 #define S1CALLSB 0xB9
79 
80 #define PRODUCT_ID 0xFD
81 #define MAN_ID 0xFE
82 #define REV 0xFF
83 
84 /************************MAIN CTRL REG********************************/
85 #define STBY 0x20
86 #define SLEEP 0x08
87 #define INT 0x01
88 /************************GEN_STATUS REG*******************************/
89 #define BC_OUT 0x40
90 #define ACAL_FAIL 0x20
91 #define PWR 0x10
92 #define MULT 0x04
93 #define MTP 0x02
94 #define TOUCH 0x01
95 
96 /************************SENSINPUTEN REG*******************************/
97 #define CS3 0x04
98 #define CS2 0x02
99 #define CS1 0x01
100 
101 /************************SENSINCONF1 REG*******************************/
102 
103 #define DUR560MS
104 #define DUR840MS
105 #define DUR1120MS
106 #define DUR1400MS
107 #define DUR1680MS
108 #define DUR2240MS
109 #define DUR2800MS
110 #define DUR3360MS
111 #define DUR3920MS
112 #define DUR4480MS
113 #define DUR5600MS
114 #define DUR6720MS
115 
116 
117 #define REP_35MS
118 #define REP_35MS
119 #define REP_35MS
120 #define REP_35MS
121 #define REP_35MS
122 #define REP_35MS
123 #define REP_35MS
124 #define REP_35MS
125 #define REP_35MS
126 #define REP_35MS
127 #define REP_35MS
128 #define REP_35MS
129 
130 #define M_PRESS35MS
131 #define M_PRESS70MS
132 #define M_PRESS105MS
133 #define M_PRESS140MS
134 #define M_PRESS175MS
135 #define M_PRESS210MS
136 #define M_PRESS2455MS
137 #define M_PRESS280MS
138 #define M_PRESS315MS
139 #define M_PRESS350MS
140 #define M_PRESS385MS
141 #define M_PRESS420MS
142 #define M_PRESS455MS
143 #define M_PRESS490MS
144 #define M_PRESS560MS
145 
146 /*********************Sensitivity Control Register***************************/
147 
148 //Delta sense controls the sensitivity of a touch detection for sensor inputs enabled in the Active state
149 #define MOST_SENSITIVE 0x00
150 #define DEFAULT 0x20
151 #define LEAST_SENSITIVE 0x70
152 
153 /*********************Configuration Register**********************************/
154 #define TIMEOUT 0x80
155 #define DIS_DIG_NOISE 0x20
156 #define DIS_ANA_NOISE 0x10
157 #define MAX_DUR_EN 0x08
158 
159 
160 /**********************Averaging and Sampling Configuration Register**********/
161 
162 #define AVG 0x30 //default value 0b01100000 8 samples
163 #define SAMP_TIME 0x80 //0b00001000 1.28 ms
164 #define CYCLE_TIME 0x01
165 
166 /************************Multiple Touch Configuration**************************/
167 #define MULTBLK_EN 0x80
168 
169 
170 /************************Multiple Touch Pattern Configuration**************************/
171 
172 #define MTP_EN 0x80
173 #define MTP_TH1 0x08
174 #define MTP_TH0 0x04
175 #define COMP_PTRN 0x02
176 #define MTP_ALERT 0x01
177 
178 /************************Multiple Touch Pattern Register**************************/
179 
180 #define CS3_PTRN 0x04
181 #define CS2_PTRN 0x02
182 #define CS1_PTRN 0x01
183 
184 /***********************Power Button Configuration****************************/
185 #define PWR_EN 0x40
186 #define TIME280ms 0x00
187 #define TIME560ms 0x01
188 #define TIME1120ms 0x02
189 #define TIME2240ms 0x03
190 
194 typedef enum{
198 ONE=0x00,
202 TWO=0x01,
207 
211 typedef enum{
215 B1=0x01,
219 B2 = 0x02,
224 
225 
229 typedef enum{
238 
239 void CAP1203_Initialize(void);
240 unsigned char CAP1203_ActiveMode(void);
241 unsigned char CAP1203_StandbyMode(void);
242 unsigned char CAP1203_DeepSleep(void);
243 unsigned char CAP1203_ResumeFromDeepSleep(void);
244 
245 unsigned char CAP1203_ReadPressedButton(void);
247 void CAP1203_SetSensitivity(sensitivity_type sensitivity);
248 unsigned char CAP1203_CheckSensorStatus(void);
249 unsigned char CAP1203_ClearInterrupt(void);
250 unsigned int CAP1203_ReadID(void);
251 
252 void CAP1203_ConfigureMultiTouch(touch_type number,unsigned char chan);
253 unsigned char CAP1203_MultitouchEvent(void);
254 
256 unsigned char CAP1203_ReadPowerButton(void);
257 
258 unsigned char CAP1203_GetStatusReg(void);
259 void CAP1203_Write(unsigned char reg, unsigned char data);
260 unsigned char CAP1203_Read(unsigned char reg);
261 
262 #endif
unsigned char CAP1203_MultitouchEvent(void)
Return true if a multitouch event was detected.
Definition: CAP1203.c:114
void CAP1203_Write(unsigned char reg, unsigned char data)
Write data value to register address.
Definition: CAP1203.c:257
unsigned char CAP1203_StandbyMode(void)
Configures the controller in standby mode.
Definition: CAP1203.c:64
Definition: CAP1203.h:202
button_type
Definition: CAP1203.h:211
Definition: CAP1203.h:219
Definition: CAP1203.h:223
Definition: CAP1203.h:233
unsigned char CAP1203_ReadPressedButton(void)
Return id indicating which button was pressed.
Definition: CAP1203.c:159
unsigned char CAP1203_ReadPowerButton(void)
Read the status of the power button.
Definition: CAP1203.c:141
void CAP1203_Initialize(void)
Basic configuration for the capacitive touch controller. Configures the sensor inactive mode and acti...
Definition: CAP1203.c:41
Definition: CAP1203.h:237
void CAP1203_SetSensitivity(sensitivity_type sensitivity)
Sets the sensitivity of each channel.
Definition: CAP1203.c:212
sensitivity_type
Definition: CAP1203.h:229
unsigned char CAP1203_CheckSensorStatus(void)
Checks the sensor status.
Definition: CAP1203.c:221
void CAP1203_EnableInterrupt(button_type pin)
Enable interrupt, the ALERT pin goes high once an interrupt occurs.
Definition: CAP1203.c:201
Definition: CAP1203.h:206
touch_type
Definition: CAP1203.h:194
unsigned char CAP1203_Read(unsigned char reg)
Reads data from register reg address.
Definition: CAP1203.c:267
Definition: CAP1203.h:198
void CAP1203_SetPowerButton(button_type button)
Configures the button as a power button.
Definition: CAP1203.c:130
void CAP1203_ConfigureMultiTouch(touch_type number, unsigned char chan)
Enables the multi-touch capability of the controller.
Definition: CAP1203.c:103
Definition: CAP1203.h:215
unsigned char CAP1203_ResumeFromDeepSleep(void)
Takes the controller out of deep sleep mode.
Definition: CAP1203.c:89
unsigned char CAP1203_ActiveMode(void)
Configures the controller in active mode.
Definition: CAP1203.c:52
unsigned char CAP1203_GetStatusReg(void)
Reads the status register.
Definition: CAP1203.c:190
unsigned char CAP1203_ClearInterrupt(void)
Clears any impending interrupts.
Definition: CAP1203.c:232
unsigned int CAP1203_ReadID(void)
Returns product chip and manufacturing ID.
Definition: CAP1203.c:243
unsigned char CAP1203_DeepSleep(void)
Configures the controller in deep sleep mode.
Definition: CAP1203.c:77