39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
73#define TOUCHPAD3_GENERAL_INDEX_LOCATION 0x00
79#define TOUCHPAD3_GENERAL_RX_CH_ADD 0x01
80#define TOUCHPAD3_GENERAL_TX_CH_ADD 0x02
81#define TOUCHPAD3_GENERAL_RX_SC_L_ADD 0x04
82#define TOUCHPAD3_GENERAL_RX_SC_H_ADD 0x05
83#define TOUCHPAD3_GENERAL_TX_SC_L_ADD 0x06
84#define TOUCHPAD3_GENERAL_TX_SC_H_ADD 0x07
91#define TOUCHPAD3_GENERAL_RX_CH 0x05
92#define TOUCHPAD3_GENERAL_TX_CH 0x04
93#define TOUCHPAD3_GENERAL_RX_SC_L 0x33
94#define TOUCHPAD3_GENERAL_RX_SC_H 0x33
95#define TOUCHPAD3_GENERAL_TX_SC_L 0x00
96#define TOUCHPAD3_GENERAL_TX_SC_H 0x40
102#define TOUCHPAD3_DECODING_INDEX_LOCATION 0x30
108#define TOUCHPAD3_DEC_FLIP_STATE_ADD 0x00
109#define TOUCHPAD3_DEC_NUM_AVG_ADD 0x01
110#define TOUCHPAD3_DEC_MIN_TOUCH_DISTANCE_ADD 0x04
116#define TOUCHPAD3_DEC_FLIP_STATE 0x04
117#define TOUCHPAD3_DEC_NUM_AVG 0x08
118#define TOUCHPAD3_DEC_MIN_TOUCH_DISTANCE 0x01
136#define TOUCHPAD3_REG_WRITE 0x55, 0x04, 0x15
138#define TOUCHPAD3_RX_MAP_INDEX_ADD 0x01
139#define TOUCHPAD3_RX_CH1_ADD 0x00
140#define TOUCHPAD3_RX_CH2_ADD 0x01
141#define TOUCHPAD3_RX_CH3_ADD 0x02
142#define TOUCHPAD3_RX_CH4_ADD 0x03
143#define TOUCHPAD3_RX_CH5_ADD 0x04
149#define TOUCHPAD3_RX_CH1 0x08
150#define TOUCHPAD3_RX_CH2 0x07
151#define TOUCHPAD3_RX_CH3 0x06
152#define TOUCHPAD3_RX_CH4 0x05
153#define TOUCHPAD3_RX_CH5 0x04
159#define TOUCHPAD3_TX_MAP_INDEX_ADD 0x02
160#define TOUCHPAD3_TX_CH1_ADD 0x00
161#define TOUCHPAD3_TX_CH2_ADD 0x01
162#define TOUCHPAD3_TX_CH3_ADD 0x02
163#define TOUCHPAD3_TX_CH4_ADD 0x03
169#define TOUCHPAD3_TX_CH1 0x0D
170#define TOUCHPAD3_TX_CH2 0x06
171#define TOUCHPAD3_TX_CH3 0x03
172#define TOUCHPAD3_TX_CH4 0x02
178#define TOUCHPAD3_SET_COMMAND 0x55
179#define TOUCHPAD3_CMD_ENABLE_TOUCH 0x00
180#define TOUCHPAD3_CMD_DISABLE_TOUCH 0x01
181#define TOUCHPAD3_CMD_SCAN_BASELINE 0x14
182#define TOUCHPAD3_CMD_WRITE_REGISTER 0x15
183#define TOUCHPAD3_CMD_READ_REGISTER 0x16
184#define TOUCHPAD3_CMD_WRITE_NVRAM 0x17
185#define TOUCHPAD3_CMD_SOFTWARE_SLEEP 0x18
186#define TOUCHPAD3_CMD_ERASE_NVRAM 0x19
187#define TOUCHPAD3_CMD_MANUFACTURING_TEST 0x1A
188#define TOUCHPAD3_CMD_DEVICE_ID 0x83
194#define TOUCHPAD3_GENERAL_INDEX_BYTE 0x00
195#define TOUCHPAD3_SENSOR_MAP_RX_INDEX_BYTE 0x01
196#define TOUCHPAD3_SENSOR_MAP_TX_INDEX_BYTE 0x02
197#define TOUCHPAD3_SELF_INDEX_BYTE 0x10
198#define TOUCHPAD3_MUTUAL_INDEX_BYTE 0x20
199#define TOUCHPAD3_DECODING_INDEX_BYTE 0x30
200#define TOUCHPAD3_GESTURES_INDEX_BYTE 0x50
201#define TOUCHPAD3_CONFIGURATION_INDEX_BYTE 0xF0
202#define TOUCHPAD3_I_O_STATUS_INDEX_BYTE 0xF1
208#define TOUCHPAD3_GENERAL_OFFSET_BYTE_RX_CHANNELS 0x01
209#define TOUCHPAD3_GENERAL_OFFSET_BYTE_TX_CHANNELS 0x02
210#define TOUCHPAD3_GENERAL_OFFSET_BYTE_RX_SCALING_LSB 0x04
211#define TOUCHPAD3_GENERAL_OFFSET_BYTE_RX_SCALING_MSB 0x05
212#define TOUCHPAD3_GENERAL_OFFSET_BYTE_TX_SCALING_LSB 0x06
213#define TOUCHPAD3_GENERAL_OFFSET_BYTE_TX_SCALING_MSB 0x07
220#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_0 0x00
221#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_1 0x01
222#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_2 0x02
223#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_3 0x03
224#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_4 0x04
225#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_5 0x05
226#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_6 0x06
227#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_7 0x07
228#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_8 0x08
229#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_9 0x09
230#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_10 0x0A
231#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_11 0x0B
232#define TOUCHPAD3_SENSOR_MAP_RX_OFFSET_BYTE_RX_PIN_MAP_12 0x0C
238#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_0 0x00
239#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_1 0x01
240#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_2 0x02
241#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_3 0x03
242#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_4 0x04
243#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_5 0x05
244#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_6 0x06
245#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_7 0x07
246#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_8 0x08
247#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_9 0x09
248#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_10 0x0A
249#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_11 0x0B
250#define TOUCHPAD3_SENSOR_MAP_TX_OFFSET_BYTE_RX_PIN_MAP_12 0x0C
256#define TOUCHPAD3_SELF_OFFSET_BYTE_SELF_SCAN_TIME 0x00
257#define TOUCHPAD3_SELF_OFFSET_BYTE_SELF_THRESHOLD 0x01
263#define TOUCHPAD3_MUTUAL_OFFSET_BYTE_MUTUAL_SCAN_TIME 0x00
264#define TOUCHPAD3_MUTUAL_OFFSET_BYTE_MUTUAL_THRESHOLD 0x01
270#define TOUCHPAD3_DECODING_OFFSET_BYTE_FLIP_STATE 0x00
271#define TOUCHPAD3_DECODING_OFFSET_BYTE_NUMBER_OF_AVG 0x01
272#define TOUCHPAD3_DECODING_OFFSET_BYTE_MIN_TOUCH_DIST 0x04
273#define TOUCHPAD3_DECODING_OFFSET_BYTE_PEN_DOWN_TIMER 0x05
274#define TOUCHPAD3_DECODING_OFFSET_BYTE_PEN_UP_TIMER 0x06
275#define TOUCHPAD3_DECODING_OFFSET_BYTE_TOUCH_SUPPR_VALUE 0x07
281#define TOUCHPAD3_GESTURES_OFFSET_BYTE_RX_SWIPE_LEN 0x00
282#define TOUCHPAD3_GESTURES_OFFSET_BYTE_TX_SWIPE_LEN 0x01
283#define TOUCHPAD3_GESTURES_OFFSET_BYTE_SWIPE_BOUNDARY 0x02
284#define TOUCHPAD3_GESTURES_OFFSET_BYTE_SWIPE_HOLD_THD 0x03
285#define TOUCHPAD3_GESTURES_OFFSET_BYTE_SWIPE_TIME_LSB 0x04
286#define TOUCHPAD3_GESTURES_OFFSET_BYTE_SWIPE_TIME_MSB 0x05
287#define TOUCHPAD3_GESTURES_OFFSET_BYTE_TAP_TIME_LSB 0x06
288#define TOUCHPAD3_GESTURES_OFFSET_BYTE_TAP_TIME_MSB 0x07
289#define TOUCHPAD3_GESTURES_OFFSET_BYTE_TAP_THD 0x08
290#define TOUCHPAD3_GESTURES_OFFSET_BYTE_MIN_SWIPE_VELOCITY 0x09
291#define TOUCHPAD3_GESTURES_OFFSET_BYTE_DOUBLE_TAP_TIME_LSB 0x0A
292#define TOUCHPAD3_GESTURES_OFFSET_BYTE_DOUBLE_TAP_TIME_MSB 0x0B
293#define TOUCHPAD3_GESTURES_OFFSET_BYTE_GESTURE_EDGE_KEEP_OUT 0x0C
299#define TOUCHPAD3_CONFIG_OFFSET_BYTE_SLP_LSW_LSB 0x00
300#define TOUCHPAD3_CONFIG_OFFSET_BYTE_SLP_LSW_MSB 0x01
301#define TOUCHPAD3_CONFIG_OFFSET_BYTE_SLP_MSW_LSB 0x02
302#define TOUCHPAD3_CONFIG_OFFSET_BYTE_SLP_MSW_MSB 0x03
303#define TOUCHPAD3_CONFIG_OFFSET_BYTE_TOUCH_PCK_CFG 0x07
304#define TOUCHPAD3_CONFIG_OFFSET_BYTE_GESTURE_PCK_CFG 0x09
305#define TOUCHPAD3_CONFIG_OFFSET_BYTE_STATUS_PCK_CFG 0x0A
311#define TOUCHPAD3_IOSTATUS_OFFSET_BYTE_TX_SHORT_STATUS_LSB 0x02
312#define TOUCHPAD3_IOSTATUS_OFFSET_BYTE_TX_SHORT_STATUS_MSB 0x03
313#define TOUCHPAD3_IOSTATUS_OFFSET_BYTE_RX_SHORT_STATUS_LSB 0x06
314#define TOUCHPAD3_IOSTATUS_OFFSET_BYTE_RX_SHORT_STATUS_MSB 0x07
320#define TOUCHPAD3_CONFIG_TOUCH_GESTURE_PCK_DISABLE 0x01
321#define TOUCHPAD3_CONFIG_TOUCH_GESTURE_PCK_ENABLE 0x81
327#define TOUCHPAD3_TOUCH_GESTURE_DISABLE 0x00
328#define TOUCHPAD3_TOUCH_GESTURE_ENABLE 0x01
334#define TOUCHPAD3_GESTURE_SINGLE_TAP 0x10
335#define TOUCHPAD3_GESTURE_SINGLE_TAP_HOLD 0x11
336#define TOUCHPAD3_GESTURE_DOUBLE_TAP 0x20
337#define TOUCHPAD3_GESTURE_UP_SWIPE 0x31
338#define TOUCHPAD3_GESTURE_UP_SWIPE_HOLD 0x32
339#define TOUCHPAD3_GESTURE_RIGHT_SWIPE 0x41
340#define TOUCHPAD3_GESTURE_RIGHT_SWIPE_HOLD 0x42
341#define TOUCHPAD3_GESTURE_DOWN_SWIPE 0x51
342#define TOUCHPAD3_GESTURE_DOWN_SWIPE_HOLD 0x52
343#define TOUCHPAD3_GESTURE_LEFT_SWIPE 0x61
344#define TOUCHPAD3_GESTURE_LEFT_SWIPE_HOLD 0x62
350#define TOUCHPAD3_CMD_STATUS_SUCCESS 0x00
351#define TOUCHPAD3_CMD_STATUS_PARAM_OUT_OF_RANGE 0x80
352#define TOUCHPAD3_CMD_STATUS_TIMEOUT 0xFE
353#define TOUCHPAD3_CMD_STATUS_UNRECOGNIZED 0xFF
354#define TOUCHPAD3_CMD_STATUS_INVALID_PARAM 0xFD
355#define TOUCHPAD3_CMD_STATUS_MISSING_OR_EXTRA_PARAM 0xFC
361#define TOUCHPAD3_T_AND_G_ID_BIT_MASK 0x0F
362#define TOUCHPAD3_TCH_STATE_BIT_MASK 0x01
363#define TOUCHPAD3_PEN_STATE_BIT_MASK 0x01
364#define TOUCHPAD3_5_BIT_MASK 0x1F
370#define TOUCHPAD3_INT_STATUS_LOW 0x00
371#define TOUCHPAD3_INT_STATUS_HIGH 0x01
377#define TOUCHPAD3_STATUS_ERROR 0x00
378#define TOUCHPAD3_STATUS_SUCCESS 0x01
384#define TOUCHPAD3_STATE_TCH 0x00
385#define TOUCHPAD3_STATE_GST 0x01
386#define TOUCHPAD3_LEN_TCH 0x05
387#define TOUCHPAD3_LEN_GST 0x02
394#define TOUCHPAD3_SET_DEV_ADDR 0x25
412#define TOUCHPAD3_MAP_MIKROBUS( cfg, mikrobus ) \
413 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
414 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
415 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
416 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t touchpad3_get_touch(touchpad3_t *ctx, touch_data_t *tch_data, uint16_t *x_axis, uint16_t *y_axis)
Touchpad 3 get touch data function.
uint8_t touchpad3_write_reg(touchpad3_t *ctx, uint8_t index_loc, uint8_t offset_loc, uint8_t tx_data, uint8_t *p_response)
Touchpad 3 write register data function.
void touchpad3_sensor_mapping_configuration(touchpad3_t *ctx)
Touchpad 3 sensor mapping configuration function.
uint8_t touchpad3_read_reg(touchpad3_t *ctx, uint8_t index_loc, uint8_t offset_loc, uint8_t *read_data, uint8_t *p_response)
Touchpad 3 read register data function.
err_t touchpad3_init(touchpad3_t *ctx, touchpad3_cfg_t *cfg)
Touchpad 3 initialization function.
uint32_t touchpad3_get_device_id(touchpad3_t *ctx)
Touchpad 3 get device id function.
void touchpad3_decoding_configuration(touchpad3_t *ctx)
Touchpad 3 decoding configuration function.
void touchpad3_hw_reset(touchpad3_t *ctx)
Touchpad 3 hardware reset function.
uint8_t touchpad3_cmd_protocol(touchpad3_t *ctx, cmd_protocol_t cmd_data, uint8_t *p_tx_data, uint8_t *p_rx_data)
Touchpad 3 command protocol function.
uint8_t touchpad3_get_gesture(touchpad3_t *ctx, touch_data_t *gst_data, uint8_t *gesture)
Touchpad 3 get gesture data function.
void touchpad3_cfg_setup(touchpad3_cfg_t *cfg)
Touchpad 3 configuration object setup function.
err_t touchpad3_generic_read(touchpad3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Touchpad 3 I2C reading function.
uint8_t touchpad3_config_touch(touchpad3_t *ctx, uint8_t en_touch)
Touchpad 3 configure touch function.
uint8_t touchpad3_manufacturing_test(touchpad3_t *ctx)
Touchpad 3 manufacturing test function.
void touchpad3_generic_write(touchpad3_t *ctx, uint8_t *tx_buf, uint8_t tx_len)
Touchpad 3 I2C writing function.
err_t touchpad3_default_cfg(touchpad3_t *ctx)
Touchpad 3 default configuration function.
uint8_t touchpad3_config_gesture(touchpad3_t *ctx, uint8_t en_gesture)
Touchpad 3 configure gesture function.
uint8_t touchpad3_get_int(touchpad3_t *ctx)
Touchpad 3 get interrupt function..
void touchpad3_general_configuration(touchpad3_t *ctx)
Touchpad 3 general configuration function.
uint16_t x_axis
Definition main.c:31
uint16_t y_axis
Definition main.c:32
Definition touchpad3.h:466
uint8_t n_tx_bytes
Definition touchpad3.h:468
uint8_t cmd
Definition touchpad3.h:467
uint8_t n_rx_bytes
Definition touchpad3.h:469
Definition touchpad3.h:459
uint8_t tch_state
Definition touchpad3.h:461
uint8_t touch_id
Definition touchpad3.h:460
uint8_t pen_state
Definition touchpad3.h:462
Touchpad 3 Click configuration object.
Definition touchpad3.h:446
uint32_t i2c_speed
Definition touchpad3.h:453
pin_name_t scl
Definition touchpad3.h:447
pin_name_t int_pin
Definition touchpad3.h:451
pin_name_t sda
Definition touchpad3.h:448
pin_name_t rst
Definition touchpad3.h:450
uint8_t i2c_address
Definition touchpad3.h:454
Touchpad 3 Click context object.
Definition touchpad3.h:426
digital_in_t int_pin
Definition touchpad3.h:431
i2c_master_t i2c
Definition touchpad3.h:434
digital_out_t rst
Definition touchpad3.h:428
uint8_t slave_address
Definition touchpad3.h:437
touchpad3_return_value_t
Touchpad 3 Click return value data.
Definition touchpad3.h:477
@ TOUCHPAD3_OK
Definition touchpad3.h:478
@ TOUCHPAD3_ERROR
Definition touchpad3.h:479