Go to the documentation of this file.
38 #include "mikrosdk_version.h"
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
63 #define CAPTOUCH5_MAP_MIKROBUS( cfg, mikrobus ) \
64 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
73 #define CAPTOUCH5_RETVAL uint8_t
75 #define CAPTOUCH5_OK 0x00
76 #define CAPTOUCH5_INIT_ERROR 0xFF
79 #define CAPTOUCH5_I2C_SLAVE_ADDRESS 0x37
85 #define CAPTOUCH5_REG_SENSOR_EN 0x00
86 #define CAPTOUCH5_REG_FSS_EN 0x02
87 #define CAPTOUCH5_REG_SENSITIVITY0 0x08
88 #define CAPTOUCH5_REG_SENSITIVITY1 0x09
89 #define CAPTOUCH5_REG_SENSITIVITY2 0x0A
90 #define CAPTOUCH5_REG_SENSITIVITY3 0x0B
91 #define CAPTOUCH5_REG_BASE_THRESHOLD0 0x0C
92 #define CAPTOUCH5_REG_BASE_THRESHOLD1 0x0D
93 #define CAPTOUCH5_REG_FINGER_THRESHOLD2 0x0E
94 #define CAPTOUCH5_REG_FINGER_THRESHOLD3 0x0F
95 #define CAPTOUCH5_REG_FINGER_THRESHOLD4 0x10
96 #define CAPTOUCH5_REG_FINGER_THRESHOLD5 0x11
97 #define CAPTOUCH5_REG_FINGER_THRESHOLD6 0x12
98 #define CAPTOUCH5_REG_FINGER_THRESHOLD7 0x13
99 #define CAPTOUCH5_REG_FINGER_THRESHOLD8 0x14
100 #define CAPTOUCH5_REG_FINGER_THRESHOLD9 0x15
101 #define CAPTOUCH5_REG_FINGER_THRESHOLD10 0x16
102 #define CAPTOUCH5_REG_FINGER_THRESHOLD11 0x17
103 #define CAPTOUCH5_REG_FINGER_THRESHOLD12 0x18
104 #define CAPTOUCH5_REG_FINGER_THRESHOLD13 0x19
105 #define CAPTOUCH5_REG_FINGER_THRESHOLD14 0x1A
106 #define CAPTOUCH5_REG_FINGER_THRESHOLD15 0x1B
107 #define CAPTOUCH5_REG_SENSOR_DEBOUNCE 0x1C
108 #define CAPTOUCH5_REG_BUTTON_HYS 0x1D
109 #define CAPTOUCH5_REG_BUTTON_LBR 0x1F
110 #define CAPTOUCH5_REG_BUTTON_NNT 0x20
111 #define CAPTOUCH5_REG_BUTTON_NT 0x21
112 #define CAPTOUCH5_REG_PROX_EN 0x26
113 #define CAPTOUCH5_REG_PROX_CFG 0x27
114 #define CAPTOUCH5_REG_PROX_TOUCH_TH0 0x28
115 #define CAPTOUCH5_REG_PROX_TOUCH_TH1 0x2A
116 #define CAPTOUCH5_REG_PROX_RESOLUTION0 0x2E
117 #define CAPTOUCH5_REG_PROX_RESOLUTION1 0x2F
118 #define CAPTOUCH5_REG_PROX_HYS 0x30
119 #define CAPTOUCH5_REG_PROX_LBR 0x32
120 #define CAPTOUCH5_REG_PROX_NNT 0x33
121 #define CAPTOUCH5_REG_PROX_NT 0x34
122 #define CAPTOUCH5_REG_BUZZER_CFG 0x3E
123 #define CAPTOUCH5_REG_BUZZER_ON_TIME 0x3F
124 #define CAPTOUCH5_REG_SPO_CFG 0x4C
125 #define CAPTOUCH5_REG_DEVICE_CFG0 0x4D
126 #define CAPTOUCH5_REG_DEVICE_CFG1 0x4E
127 #define CAPTOUCH5_REG_DEVICE_CFG2 0x4F
128 #define CAPTOUCH5_REG_DEVICE_CFG3 0x50
129 #define CAPTOUCH5_REG_I2C_ADDR 0x51
130 #define CAPTOUCH5_REG_REFRESH_CTRL 0x52
131 #define CAPTOUCH5_REG_STATE_TIMEOUT 0x55
132 #define CAPTOUCH5_REG_SLIDER_CFG 0x5D
133 #define CAPTOUCH5_REG_SLIDER1_CFG 0x61
134 #define CAPTOUCH5_REG_SLIDER1_RESOLUTION 0x62
135 #define CAPTOUCH5_REG_SLIDER1_THRESHOLD 0x63
136 #define CAPTOUCH5_REG_SLIDER2_CFG 0x67
137 #define CAPTOUCH5_REG_SLIDER2_RESOLUTION 0x68
138 #define CAPTOUCH5_REG_SLIDER2_THRESHOLD 0x69
139 #define CAPTOUCH5_REG_SLIDER_LBR 0x71
140 #define CAPTOUCH5_REG_SLIDER_NNT 0x72
141 #define CAPTOUCH5_REG_SLIDER_NT 0x73
142 #define CAPTOUCH5_REG_SCRATCHPAD0 0x7A
143 #define CAPTOUCH5_REG_SCRATCHPAD1 0x7B
144 #define CAPTOUCH5_REG_CONFIG_CRC 0x7E
145 #define CAPTOUCH5_REG_SENSOR_ID 0x82
146 #define CAPTOUCH5_REG_CTRL_CMD 0x86
147 #define CAPTOUCH5_REG_CTRL_CMD_STATUS 0x88
148 #define CAPTOUCH5_REG_CTRL_CMD_ERR 0x89
149 #define CAPTOUCH5_REG_SYSTEM_STATUS 0x8A
150 #define CAPTOUCH5_REG_PREV_CTRL_CMD_CODE 0x8C
151 #define CAPTOUCH5_REG_FAMILY_ID 0x8F
152 #define CAPTOUCH5_REG_DEVICE_ID 0x90
153 #define CAPTOUCH5_REG_DEVICE_REV 0x92
154 #define CAPTOUCH5_REG_CALC_CRC 0x94
155 #define CAPTOUCH5_REG_TOTAL_WORKING_SNS 0x97
156 #define CAPTOUCH5_REG_SNS_CP_HIGH 0x98
157 #define CAPTOUCH5_REG_SNS_VDD_SHORT 0x9A
158 #define CAPTOUCH5_REG_SNS_GND_SHORT 0x9C
159 #define CAPTOUCH5_REG_CMOD_SHIELD_TEST 0xA0
160 #define CAPTOUCH5_REG_BUTTON_STAT 0xAA
161 #define CAPTOUCH5_REG_LATCHED_BUTTON_STAT 0xAC
162 #define CAPTOUCH5_REG_PROX_STAT 0xAE
163 #define CAPTOUCH5_REG_LATCHED_PROx_STAT 0xAF
164 #define CAPTOUCH5_REG_SLIDER1_POSITION 0xB0
165 #define CAPTOUCH5_REG_LIFTOFF_SLIDER1_POSITION 0xB1
166 #define CAPTOUCH5_REG_SLIDER2_POSITION 0xB2
167 #define CAPTOUCH5_REG_LIFTOFF_SLIDER2_POSITION 0xB3
168 #define CAPTOUCH5_REG_SYNC_COUNTER0 0xB9
169 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR0 0xBA
170 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR1 0xBC
171 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR2 0xBE
172 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR3 0xC0
173 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR4 0xC2
174 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR5 0xC4
175 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR6 0xC6
176 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR7 0xC8
177 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR8 0xCA
178 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR9 0xCC
179 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR10 0xCE
180 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR11 0xD0
181 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR12 0xD2
182 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR13 0xD4
183 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR14 0xD6
184 #define CAPTOUCH5_REG_DIFFERENCE_COUNT_SENSOR15 0xD8
185 #define CAPTOUCH5_REG_SYNC_COUNTER1 0xDB
186 #define CAPTOUCH5_REG_DEBUG_SENSOR_ID 0xDC
187 #define CAPTOUCH5_REG_DEBUG_CP 0xDD
188 #define CAPTOUCH5_REG_DIFFERENCE_COUNT0 0xDE
189 #define CAPTOUCH5_REG_DEBUG_BASELINE0 0xE0
190 #define CAPTOUCH5_REG_DEBUG_RAW_COUNT0 0xE2
191 #define CAPTOUCH5_REG_DEBUG_AVG_RAW_COUNT0 0xE4
192 #define CAPTOUCH5_REG_SYNC_COUNTER2 0xE7
199 #define CAPTOUCH5_BUTTON_PRESSED 1
200 #define CAPTOUCH5_BUTTON_NOT_PRESSED 0
207 #define CAPTOUCH5_CFG0_IIR_FILTER_ENABLED 1
208 #define CAPTOUCH5_CFG0_IIR_FILTER_DISABLED 1
209 #define CAPTOUCH5_CFG0_MED_FILTER_ENABLED 1
210 #define CAPTOUCH5_CFG0_MED_FILTER_DISABLED 1
217 #define CAPTOUCH5_CFG1_SYS_DIAGNOSTIC_ENABLED 1
218 #define CAPTOUCH5_CFG1_SYS_DIAGNOSTIC_DISABLED 1
225 #define CAPTOUCH5_CFG2_SHIELD_ENABLED 1
226 #define CAPTOUCH5_CFG2_SHIELD_DISABLED 0
227 #define CAPTOUCH5_CFG2_GUARD_SENS_ENABLED 1
228 #define CAPTOUCH5_CFG2_GUARD_SENS_DISABLED 0
229 #define CAPTOUCH5_CFG2_EMC_ENABLED 1
230 #define CAPTOUCH5_CFG2_EMC_DISABLED 0
231 #define CAPTOUCH5_CFG2_AUTOMATIC_THRESHOLD_ENABLED 1
232 #define CAPTOUCH5_CFG2_AUTOMATIC_THRESHOLD_DISABLED 0
233 #define CAPTOUCH5_CFG2_BUTTON_SLIDER_AUTO_RESET_DISABLED 0
234 #define CAPTOUCH5_CFG2_BUTTON_SLIDER_AUTO_RESET_ENABLED_5_SEC 1
235 #define CAPTOUCH5_CFG2_BUTTON_SLIDER_AUTO_RESET_ENABLED_20_SEC 2
236 #define CAPTOUCH5_CFG2_PROXIMIYU_AUTO_RESET_DISABLED 0
237 #define CAPTOUCH5_CFG2_PROXIMIYU_AUTO_RESET_ENABLED_5_SEC 1
238 #define CAPTOUCH5_CFG2_PROXIMIYU_AUTO_RESET_ENABLED_20_SEC 2
245 #define CAPTOUCH5_CFG3_POWER_SUPPLY_INTERNALLY 0
246 #define CAPTOUCH5_CFG3_POWER_SUPPLY_EXTERNALLY 1
253 #define CAPTOUCH5_SLIDER_SENS_0p1 0
254 #define CAPTOUCH5_SLIDER_SENS_0p2 1
255 #define CAPTOUCH5_SLIDER_SENS_0p3 2
256 #define CAPTOUCH5_SLIDER_SENS_0p4 3
263 #define CAPTOUCH5_BUTTON_SENS_ENABLED 0xFFFF
264 #define CAPTOUCH5_BUTTON_SENS_DISABLED 0x0000
271 #define CAPTOUCH5_DEVICE_ID 2566
272 #define CAPTOUCH5_FAMILY_ID 154
280 #define CAPTOUCH5_ERROR 1
281 #define CAPTOUCH5_NO_ERROR 0
578 #endif // _CAPTOUCH5_H_
uint8_t proximityAutoReset
Definition: captouch5.h:346
uint8_t button1
Definition: captouch5.h:327
T_CAPTOUCH5_CONFIG3 cfg3
Definition: captouch5.h:365
Definition: captouch5.h:334
uint8_t guardSens
Definition: captouch5.h:350
void captouch5_generic_read(captouch5_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t autoThreshold
Definition: captouch5.h:348
Definition: captouch5.h:355
void captouch5_default_cfg(captouch5_t *ctx, T_CAPTOUCH5_DEVICE_CONFIG *device_cfg)
Click Default Configuration function.
void captouch5_read_button_status(captouch5_t *ctx, T_CAPTOUCH5_BUTTONS *buttons)
Function read button status.
uint8_t i2c_address
Definition: captouch5.h:320
uint8_t buttonAutoReset
Definition: captouch5.h:347
Definition: captouch5.h:361
pin_name_t sda
Definition: captouch5.h:315
pin_name_t scl
Definition: captouch5.h:314
uint8_t powerSupply
Definition: captouch5.h:356
#define CAPTOUCH5_RETVAL
Definition: captouch5.h:73
uint8_t shieldSens
Definition: captouch5.h:351
void captouch5_write_byte(captouch5_t *ctx, uint8_t reg_addr, uint8_t data_buf)
Generic write 8bit data function.
uint32_t i2c_speed
Definition: captouch5.h:319
uint8_t emcSolution
Definition: captouch5.h:349
uint8_t medFilter
Definition: captouch5.h:336
T_CAPTOUCH5_CONFIG0 cfg0
Definition: captouch5.h:362
uint16_t captouch5_get_device_id(captouch5_t *ctx)
Function for geting device id.
void captouch5_config_sensors(captouch5_t *ctx, uint16_t sens_data)
Function for configuring sensor.
uint8_t slave_address
Definition: captouch5.h:303
void captouch5_write_two_bytes(captouch5_t *ctx, uint8_t reg_addr, uint16_t data_buf)
Generic write 16bit data function.
uint8_t button3
Definition: captouch5.h:329
void captouch5_cfg_setup(captouch5_cfg_t *cfg)
Config Object Initialization function.
uint8_t captouch5_read_byte(captouch5_t *ctx, uint8_t reg_addr)
Generic read 8bit data function.
Definition: captouch5.h:345
uint8_t button2
Definition: captouch5.h:328
void captouch5_software_reset(captouch5_t *ctx)
Function to reset device.
uint8_t captouch5_get_family_id(captouch5_t *ctx)
Function for geting family id.
uint16_t captouch5_read_two_bytes(captouch5_t *ctx, uint8_t reg_addr)
Generic read 16bit data function.
uint8_t captouch5_process(captouch5_t *ctx)
Function for checking error.
uint8_t button4
Definition: captouch5.h:330
uint8_t iirFilter
Definition: captouch5.h:335
i2c_master_t i2c
Definition: captouch5.h:299
uint16_t captouch5_read_slider_position(captouch5_t *ctx)
Function for reading slider position.
Definition: captouch5.h:340
CAPTOUCH5_RETVAL captouch5_init(captouch5_t *ctx, captouch5_cfg_t *cfg)
Initialization function.
Definition: captouch5.h:326
Click ctx object definition.
Definition: captouch5.h:295
Click configuration structure definition.
Definition: captouch5.h:311
uint8_t sysDiagnostic
Definition: captouch5.h:341
void captouch5_config_slider(captouch5_t *ctx, uint8_t slider_data)
Function for configuring slider.
void captouch5_generic_write(captouch5_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
T_CAPTOUCH5_CONFIG1 cfg1
Definition: captouch5.h:363
void captouch5_device_config(captouch5_t *ctx, T_CAPTOUCH5_DEVICE_CONFIG *device_cfg)
Function for configuring device.
T_CAPTOUCH5_CONFIG2 cfg2
Definition: captouch5.h:364