42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
67#define TOUCHKEY4_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
77#define TOUCHKEY4_RETVAL uint8_t
79#define TOUCHKEY4_OK 0x00
80#define TOUCHKEY4_INIT_ERROR 0xFF
87#define TOUCHKEY4_MAIN_CONTROL_REG 0x00
88#define TOUCHKEY4_GEN_STATUS_REG 0x02
89#define TOUCHKEY4_SENS_IN_STATUS_REG 0x03
90#define TOUCHKEY4_NOISE_FLAG_REG 0x0A
91#define TOUCHKEY4_SENS_IN1_DELTA_CNT_REG 0x10
92#define TOUCHKEY4_SENS_IN2_DELTA_CNT_REG 0x11
93#define TOUCHKEY4_SENS_IN3_DELTA_CNT_REG 0x12
94#define TOUCHKEY4_SENSITIVITY_CON_REG 0x1F
95#define TOUCHKEY4_CONFIG_REG 0x20
96#define TOUCHKEY4_SENS_IN_EN_REG 0x21
97#define TOUCHKEY4_SENS_IN_CONFIG_REG 0x22
98#define TOUCHKEY4_SENS_IN_CONFIG2_REG 0x23
99#define TOUCHKEY4_AVRG_AND_SAMPL_CONFIG_REG 0x24
100#define TOUCHKEY4_CALIB_ACTIVATE_REG 0x26
101#define TOUCHKEY4_INTERR_EN_REG 0x27
102#define TOUCHKEY4_REPEAT_RATE_EN_REG 0x28
103#define TOUCHKEY4_SIGNAL_GUARD_EN_REG 0x29
104#define TOUCHKEY4_MULTIPLE_TOUCH_CONFIG_REG 0x2A
105#define TOUCHKEY4_MULTIPLE_TOUCH_PATTERN_CONFIG_REG 0x2B
106#define TOUCHKEY4_MULTIPLE_TOUCH_PATTERN_REG 0x2D
107#define TOUCHKEY4_BASE_CNT_LIMIT_REG 0x2E
108#define TOUCHKEY4_RECALIB_CONFIG_REG 0x2F
109#define TOUCHKEY4_SENS_IN1_THRESHOLD_REG 0x30
110#define TOUCHKEY4_SENS_IN2_THRESHOLD_REG 0x31
111#define TOUCHKEY4_SENS_IN3_THRESHOLD_REG 0x32
112#define TOUCHKEY4_SENS_IN_NOISE_THRESHOLD_REG 0x38
113#define TOUCHKEY4_STANDBY_CHANN_REG 0x40
114#define TOUCHKEY4_STANDBY_CONFIG_REG 0x41
115#define TOUCHKEY4_STANDBY_SENSITIVITY_REG 0x42
116#define TOUCHKEY4_STANDBY_THRESHOLD_REG 0x43
117#define TOUCHKEY4_CONFIG2_REG 0x44
118#define TOUCHKEY4_SENS_IN1_BASE_CNT_REG 0x50
119#define TOUCHKEY4_SENS_IN2_BASE_CNT_REG 0x51
120#define TOUCHKEY4_SENS_IN3_BASE_CNT_REG 0x52
121#define TOUCHKEY4_POWER_BUTTON_REG 0x60
122#define TOUCHKEY4_POWER_BUTTON_CONFIG_REG 0x61
123#define TOUCHKEY4_CALIB_SENSITIVITY_CONFIG_REG 0x80
124#define TOUCHKEY4_SENS_IN1_CALIB_REG 0xB1
125#define TOUCHKEY4_SENS_IN2_CALIB_REG 0xB2
126#define TOUCHKEY4_SENS_IN3_CALIB_REG 0xB3
127#define TOUCHKEY4_SENS_IN_CALIB_LSB1_REG 0xB9
128#define TOUCHKEY4_PRODUCT_ID_REG 0xFD
129#define TOUCHKEY4_MANUFACT_ID_REG 0xFE
130#define TOUCHKEY4_REVISION_REG 0xFF
137#define TOUCHKEY4_SENSITIVITY_MULTIPLIER_128X 0x00
138#define TOUCHKEY4_SENSITIVITY_MULTIPLIER_64X 0x10
139#define TOUCHKEY4_SENSITIVITY_MULTIPLIER_32X 0x20
140#define TOUCHKEY4_SENSITIVITY_MULTIPLIER_16X 0x30
141#define TOUCHKEY4_SENSITIVITY_MULTIPLIER_8X 0x40
142#define TOUCHKEY4_SENSITIVITY_MULTIPLIER_4X 0x50
143#define TOUCHKEY4_SENSITIVITY_MULTIPLIER_2X 0x60
144#define TOUCHKEY4_SENSITIVITY_MULTIPLIER_1X 0x70
145#define TOUCHKEY4_DATA_SCALING_FACTOR_1X 0x00
146#define TOUCHKEY4_DATA_SCALING_FACTOR_2X 0x01
147#define TOUCHKEY4_DATA_SCALING_FACTOR_4X 0x02
148#define TOUCHKEY4_DATA_SCALING_FACTOR_8X 0x03
149#define TOUCHKEY4_DATA_SCALING_FACTOR_16X 0x04
150#define TOUCHKEY4_DATA_SCALING_FACTOR_32X 0x05
151#define TOUCHKEY4_DATA_SCALING_FACTOR_64X 0x06
152#define TOUCHKEY4_DATA_SCALING_FACTOR_128X 0x07
153#define TOUCHKEY4_DATA_SCALING_FACTOR_256X 0x08
160#define TOUCHKEY4_TIMEOUT_DIS 0x00
161#define TOUCHKEY4_TIMEOUT_EN 0x80
162#define TOUCHKEY4_DIG_NOISE_THRESHOLD_EN 0x00
163#define TOUCHKEY4_DIG_NOISE_THRESHOLD_DIS 0x20
164#define TOUCHKEY4_AN_NOISE_FILTER_EN 0x00
165#define TOUCHKEY4_AN_NOISE_FILTER_DIS 0x10
166#define TOUCHKEY4_MAX_DUR_RECALIB_DIS 0x00
167#define TOUCHKEY4_MAX_DUR_RECALIB_EN 0x08
174#define TOUCHKEY4_AN_CALIB_NO_RETRY 0x00
175#define TOUCHKEY4_AN_CALIB_RETRY 0x40
176#define TOUCHKEY4_POWER_CONSUMPTION_REDUCE_EN 0x00
177#define TOUCHKEY4_POWER_CONSUMPTION_REDUCE_DIS 0x20
178#define TOUCHKEY4_BASE_CNT_OUT_LIMIT_INTERR_DIS 0x00
179#define TOUCHKEY4_BASE_CNT_OUT_LIMIT_INTERR_EN 0x10
180#define TOUCHKEY4_SHOW_LOW_FREQ_NOISE 0x00
181#define TOUCHKEY4_NOT_SHOW_LOW_FREQ_NOISE 0x08
182#define TOUCHKEY4_RF_NOISE_FILTER_EN 0x00
183#define TOUCHKEY4_RF_NOISE_FILTER_DIS 0x04
184#define TOUCHKEY4_AN_CALIB_FAIL_INTERR_DIS 0x00
185#define TOUCHKEY4_AN_CALIB_FAIL_INTERR_EN 0x02
186#define TOUCHKEY4_DETECT_RELEASE_EN 0x00
187#define TOUCHKEY4_DETECT_RELEASE_DIS 0x01
194#define TOUCHKEY4_560MILISEC_BEFORE_RECALIB 0x00
195#define TOUCHKEY4_840MILISEC_BEFORE_RECALIB 0x10
196#define TOUCHKEY4_1120MILISEC_BEFORE_RECALIB 0x20
197#define TOUCHKEY4_1400MILISEC_BEFORE_RECALIB 0x30
198#define TOUCHKEY4_1680MILISEC_BEFORE_RECALIB 0x40
199#define TOUCHKEY4_2240MILISEC_BEFORE_RECALIB 0x50
200#define TOUCHKEY4_2800MILISEC_BEFORE_RECALIB 0x60
201#define TOUCHKEY4_3360MILISEC_BEFORE_RECALIB 0x70
202#define TOUCHKEY4_3920MILISEC_BEFORE_RECALIB 0x80
203#define TOUCHKEY4_4480MILISEC_BEFORE_RECALIB 0x90
204#define TOUCHKEY4_5600MILISEC_BEFORE_RECALIB 0xA0
205#define TOUCHKEY4_6720MILISEC_BEFORE_RECALIB 0xB0
206#define TOUCHKEY4_7840MILISEC_BEFORE_RECALIB 0xC0
207#define TOUCHKEY4_8906MILISEC_BEFORE_RECALIB 0xD0
208#define TOUCHKEY4_10080MILISEC_BEFORE_RECALIB 0xE0
209#define TOUCHKEY4_11200MILISEC_BEFORE_RECALIB 0xF0
210#define TOUCHKEY4_INTERR_REPEAT_RATE_35MILISEC 0x00
211#define TOUCHKEY4_INTERR_REPEAT_RATE_70MILISEC 0x01
212#define TOUCHKEY4_INTERR_REPEAT_RATE_105MILISEC 0x02
213#define TOUCHKEY4_INTERR_REPEAT_RATE_140MILISEC 0x03
214#define TOUCHKEY4_INTERR_REPEAT_RATE_175MILISEC 0x04
215#define TOUCHKEY4_INTERR_REPEAT_RATE_210MILISEC 0x05
216#define TOUCHKEY4_INTERR_REPEAT_RATE_245MILISEC 0x06
217#define TOUCHKEY4_INTERR_REPEAT_RATE_280MILISEC 0x07
218#define TOUCHKEY4_INTERR_REPEAT_RATE_315MILISEC 0x08
219#define TOUCHKEY4_INTERR_REPEAT_RATE_350MILISEC 0x09
220#define TOUCHKEY4_INTERR_REPEAT_RATE_385MILISEC 0x0A
221#define TOUCHKEY4_INTERR_REPEAT_RATE_420MILISEC 0x0B
222#define TOUCHKEY4_INTERR_REPEAT_RATE_455MILISEC 0x0C
223#define TOUCHKEY4_INTERR_REPEAT_RATE_490MILISEC 0x0D
224#define TOUCHKEY4_INTERR_REPEAT_RATE_525MILISEC 0x0E
225#define TOUCHKEY4_INTERR_REPEAT_RATE_560MILISEC 0x0F
232#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_35MILISEC 0x00
233#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_70MILISEC 0x01
234#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_105MILISEC 0x02
235#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_140MILISEC 0x03
236#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_175MILISEC 0x04
237#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_210MILISEC 0x05
238#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_245MILISEC 0x06
239#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_280MILISEC 0x07
240#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_315MILISEC 0x08
241#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_350MILISEC 0x09
242#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_385MILISEC 0x0A
243#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_420MILISEC 0x0B
244#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_455MILISEC 0x0C
245#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_490MILISEC 0x0D
246#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_525MILISEC 0x0E
247#define TOUCHKEY4_PRESS_AND_HOLD_EVENT_AFTER_560MILISEC 0x0F
254#define TOUCHKEY4_1_SAMPLE 0x00
255#define TOUCHKEY4_2_SAMPLES 0x10
256#define TOUCHKEY4_4_SAMPLES 0x20
257#define TOUCHKEY4_8_SAMPLES 0x30
258#define TOUCHKEY4_16_SAMPLES 0x40
259#define TOUCHKEY4_32_SAMPLES 0x50
260#define TOUCHKEY4_64_SAMPLES 0x60
261#define TOUCHKEY4_128_SAMPLES 0x70
262#define TOUCHKEY4_SAMPLE_TIME_320MICROSEC 0x00
263#define TOUCHKEY4_SAMPLE_TIME_640MICROSEC 0x04
264#define TOUCHKEY4_SAMPLE_TIME_1280MICROSEC 0x08
265#define TOUCHKEY4_SAMPLE_TIME_2560MICROSEC 0x0C
266#define TOUCHKEY4_CYCLE_TIME_35MILISEC 0x00
267#define TOUCHKEY4_CYCLE_TIME_70MILISEC 0x01
268#define TOUCHKEY4_CYCLE_TIME_105MILISEC 0x02
269#define TOUCHKEY4_CYCLE_TIME_140MILISEC 0x03
276#define TOUCHKEY4_ALL_INPUTS_CALIB_DIS 0x00
277#define TOUCHKEY4_INPUT1_CALIB_EN 0x01
278#define TOUCHKEY4_INPUT2_CALIB_EN 0x02
279#define TOUCHKEY4_INPUT3_CALIB_EN 0x04
286#define TOUCHKEY4_ALL_INPUTS_INTERR_DIS 0x00
287#define TOUCHKEY4_INPUT1_INTERR_EN 0x01
288#define TOUCHKEY4_INPUT2_INTERR_EN 0x02
289#define TOUCHKEY4_INPUT3_INTERR_EN 0x04
296#define TOUCHKEY4_REPEAT_RATE_DIS 0x00
297#define TOUCHKEY4_INPUT1_REPEAT_RATE_EN 0x01
298#define TOUCHKEY4_INPUT2_REPEAT_RATE_EN 0x02
299#define TOUCHKEY4_INPUT3_REPEAT_RATE_EN 0x04
306#define TOUCHKEY4_SIGNAL_GUARD_DIS 0x00
307#define TOUCHKEY4_INPUT1_SIGNAL_GUARD_EN 0x01
308#define TOUCHKEY4_INPUT3_SIGNAL_GUARD_EN 0x04
315#define TOUCHKEY4_MULTIPLE_BLOCK_DIS 0x00
316#define TOUCHKEY4_MULTIPLE_BLOCK_EN 0x80
317#define TOUCHKEY4_SIMUL_TOUCH_NUM_1 0x00
318#define TOUCHKEY4_SIMUL_TOUCH_NUM_2 0x04
319#define TOUCHKEY4_SIMUL_TOUCH_NUM_3 0x08
326#define TOUCHKEY4_MULTIPLE_THRESHOLD_12_PERCENTS 0x00
327#define TOUCHKEY4_MULTIPLE_THRESHOLD_25_PERCENTS 0x04
328#define TOUCHKEY4_MULTIPLE_THRESHOLD_37_PERCENTS 0x08
329#define TOUCHKEY4_MULTIPLE_THRESHOLD_100_PERCENTS 0x0C
330#define TOUCHKEY4_MLTP_TOUCH_PATTERN 0x00
331#define TOUCHKEY4_PATTERN_RECOGNITION 0x02
332#define TOUCHKEY4_MLTP_EVENT_ALERT_DIS 0x00
333#define TOUCHKEY4_MLTP_EVENT_ALERT_EN 0x01
340#define TOUCHKEY4_MLTP_TOUCH_PATTERN_INPUTS_DIS 0x00
341#define TOUCHKEY4_MLTP_TOUCH_PATTERN_INPUT1_EN 0x01
342#define TOUCHKEY4_MLTP_TOUCH_PATTERN_INPUT2_EN 0x02
343#define TOUCHKEY4_MLTP_TOUCH_PATTERN_INPUT3_EN 0x04
350#define TOUCHKEY4_INPUTS_THRESHOLD_UPDT_INDIVIDUALY 0x00
351#define TOUCHKEY4_INPUT1_THRESHOLD_OVERWRITE 0x80
352#define TOUCHKEY4_ACC_INTER_DATA_CLEAR 0x00
353#define TOUCHKEY4_ACC_INTER_DATA_NOT_CLEAR 0x40
354#define TOUCHKEY4_CONS_NEG_DELTA_CNT_CLEAR 0x00
355#define TOUCHKEY4_CONS_NEG_DELTA_CNT_NOT_CLEAR 0x20
356#define TOUCHKEY4_CONS_NEG_DELTA_CNT_8 0x00
357#define TOUCHKEY4_CONS_NEG_DELTA_CNT_16 0x08
358#define TOUCHKEY4_CONS_NEG_DELTA_CNT_32 0x10
359#define TOUCHKEY4_CONS_NEG_DELTA_CNT_DIS 0x18
360#define TOUCHKEY4_REC_SAMPLES_16_UPDT_TIME_16 0x00
361#define TOUCHKEY4_REC_SAMPLES_32_UPDT_TIME_32 0x01
362#define TOUCHKEY4_REC_SAMPLES_64_UPDT_TIME_64 0x02
363#define TOUCHKEY4_REC_SAMPLES_128_UPDT_TIME_128 0x03
364#define TOUCHKEY4_REC_SAMPLES_256_UPDT_TIME_256 0x04
365#define TOUCHKEY4_REC_SAMPLES_256_UPDT_TIME_1024 0x05
366#define TOUCHKEY4_REC_SAMPLES_256_UPDT_TIME_2048 0x06
367#define TOUCHKEY4_REC_SAMPLES_256_UPDT_TIME_4096 0x07
374#define TOUCHKEY4_AVERAGE_BASED 0x00
375#define TOUCHKEY4_SUMMATION_BASED 0x80
382#define TOUCHKEY4_STBY_SENSE_MULTIPLIER_128X 0x00
383#define TOUCHKEY4_STBY_SENSE_MULTIPLIER_64X 0x01
384#define TOUCHKEY4_STBY_SENSE_MULTIPLIER_32X 0x02
385#define TOUCHKEY4_STBY_SENSE_MULTIPLIER_16X 0x03
386#define TOUCHKEY4_STBY_SENSE_MULTIPLIER_8X 0x04
387#define TOUCHKEY4_STBY_SENSE_MULTIPLIER_4X 0x05
388#define TOUCHKEY4_STBY_SENSE_MULTIPLIER_2X 0x06
389#define TOUCHKEY4_STBY_SENSE_MULTIPLIER_1X 0x07
396#define TOUCHKEY4_INPUT1_POWER_BUTTON 0x00
397#define TOUCHKEY4_INPUT2_POWER_BUTTON 0x01
398#define TOUCHKEY4_INPUT3_POWER_BUTTON 0x02
405#define TOUCHKEY4_STBY_POWER_BUTTON_DIS 0x00
406#define TOUCHKEY4_STBY_POWER_BUTTON_EN 0x40
407#define TOUCHKEY4_PWR_BUTT_TOUCH_HOLD_280MILISEC 0x00
408#define TOUCHKEY4_PWR_BUTT_TOUCH_HOLD_560MILISEC 0x11
409#define TOUCHKEY4_PWR_BUTT_TOUCH_HOLD_1120MILISEC 0x22
410#define TOUCHKEY4_PWR_BUTT_TOUCH_HOLD_2240MILISEC 0x33
411#define TOUCHKEY4_ACT_POWER_BUTTON_DIS 0x00
412#define TOUCHKEY4_ACT_POWER_BUTTON_EN 0x04
419#define TOUCHKEY4_GAIN_1 0x01
420#define TOUCHKEY4_GAIN_2 0x02
421#define TOUCHKEY4_GAIN_4 0x04
422#define TOUCHKEY4_GAIN_8 0x08
423#define TOUCHKEY4_SENS_INPUT_DIS 0x00
424#define TOUCHKEY4_SENS_INPUT_EN 0x01
425#define TOUCHKEY4_COMBO_SENS_IN_ACT_EN 0x03
426#define TOUCHKEY4_COMBO_SENS_IN_STBY_EN 0x01
427#define TOUCHKEY4_COMBO_SENS_IN_BOTH_MODES_EN 0x05
434#define TOUCHKEY4_SLAVE_ADDRESS 0x28
538 const uint8_t transfer_data );
551 uint8_t *data_out,
const uint8_t n_bytes );
608 const uint8_t en_input2,
const uint8_t en_input3 );
#define TOUCHKEY4_RETVAL
Definition touchkey4.h:77
uint8_t touchkey4_receive_byte(touchkey4_t *ctx, const uint8_t register_address)
Read byte function.
void touchkey4_default_cfg(touchkey4_t *ctx)
Click Default Configuration function.
uint8_t touchkey4_check_interrupt(touchkey4_t *ctx)
Interrupt Check function.
void touchkey4_cfg_setup(touchkey4_cfg_t *cfg)
Config Object Initialization function.
void touchkey4_set_standby_mode(touchkey4_t *ctx, const uint8_t analog_gain, const uint8_t en_input1, const uint8_t en_input2, const uint8_t en_input3)
Standby Mode Set function.
void touchkey4_read_reg(touchkey4_t *ctx, const uint8_t register_address, uint8_t *data_out, const uint8_t n_bytes)
Generic Read function.
void touchkey4_set_active_mode(touchkey4_t *ctx, const uint8_t analog_gain, const uint8_t en_input1, const uint8_t en_input2, const uint8_t en_input3)
Active Mode Set function.
void touchkey4_write_reg(touchkey4_t *ctx, const uint8_t register_address, const uint8_t transfer_data)
Generic Write function.
TOUCHKEY4_RETVAL touchkey4_init(touchkey4_t *ctx, touchkey4_cfg_t *cfg)
Initialization function.
void touchkey4_detect_touch(touchkey4_t *ctx, uint8_t *input_sens)
Touch Detect function.
void touchkey4_set_combo_mode(touchkey4_t *ctx, const uint8_t analog_gain, const uint8_t en_input1, const uint8_t en_input2, const uint8_t en_input3)
Combo Mode Set function.
void touchkey4_set_deep_sleep_mode(touchkey4_t *ctx)
DeepSleep Mode Set function.
Click configuration structure definition.
Definition touchkey4.h:468
uint32_t i2c_speed
Definition touchkey4.h:480
pin_name_t scl
Definition touchkey4.h:471
pin_name_t int_pin
Definition touchkey4.h:476
pin_name_t sda
Definition touchkey4.h:472
uint8_t i2c_address
Definition touchkey4.h:481
Click ctx object definition.
Definition touchkey4.h:449
digital_in_t int_pin
Definition touchkey4.h:452
i2c_master_t i2c
Definition touchkey4.h:456
uint8_t slave_address
Definition touchkey4.h:460