38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_i2c_master.h"
52#define TOUCHPAD_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
56 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
63#define TOUCHPAD_RETVAL uint8_t
65#define TOUCHPAD_OK 0x00
66#define TOUCHPAD_INIT_ERROR 0xFF
73#define TOUCHPAD_DEVICE_SLAVE_ADDR 0x25
81#define TOUCHPAD_REG_FW_MAJOR 0x00
82#define TOUCHPAD_REG_FW_MINOR 0x01
83#define TOUCHPAD_REG_APP_ID_LSB 0x02
84#define TOUCHPAD_REG_APP_ID_MSB 0x03
85#define TOUCHPAD_REG_CMD 0x04
86#define TOUCHPAD_REG_MODE 0x05
87#define TOUCHPAD_REG_MODE_CON 0x06
89#define TOUCHPAD_REG_TOUCH_STATE 0x10
90#define TOUCHPAD_REG_TOUCH_X 0x11
91#define TOUCHPAD_REG_TOUCH_Y 0x12
92#define TOUCHPAD_REG_TOUCH_LSB 0x13
93#define TOUCHPAD_REG_GESTURE_STATE 0x14
94#define TOUCHPAD_REG_GESTURE_DIAG 0x15
96#define TOUCHPAD_REG_NUM_OF_X_CHANNELS 0x20
97#define TOUCHPAD_REG_NUM_OF_Y_CHANNELS 0x21
98#define TOUCHPAD_REG_SCAN_COUNT 0x22
99#define TOUCHPAD_REG_TOUCH_THR_X 0x23
100#define TOUCHPAD_REG_TOUCH_THR_Y 0x24
102#define TOUCHPAD_REG_ACTIVE_PERIOD_LSB 0x25
103#define TOUCHPAD_REG_ACTIVE_PERIOD_MSB 0x26
104#define TOUCHPAD_REG_IDLE_PERIOD_LSB 0x27
105#define TOUCHPAD_REG_IDLE_PERIOD_MSB 0x28
106#define TOUCHPAD_REG_IDLE_TIMEOUT 0x29
107#define TOUCHPAD_REG_HYSTERESIS 0x2A
109#define TOUCHPAD_REG_DEBOUNCE_UP 0x2B
110#define TOUCHPAD_REG_DEBOUNCE_DOWN 0x2C
111#define TOUCHPAD_REG_FILTER_TYPE 0x31
112#define TOUCHPAD_REG_FILTER_THR 0x32
113#define TOUCHPAD_REG_LARGE_ACTIVATION_THR_LSB 0x35
114#define TOUCHPAD_REG_LARGE_ACTIVATION_THR_MSB 0x36
116#define TOUCHPAD_REG_HORIZONTAL_SWIPE_DISTANCE 0x37
117#define TOUCHPAD_REG_VERTICAL_SWIPE_DISTANCE 0x38
118#define TOUCHPAD_REG_SWIPE_HOLD_BOUNDARY 0x39
119#define TOUCHPAD_REG_TAP_DISTANCE 0x3A
120#define TOUCHPAD_REG_DISTANCE_BETWEEN_TAPS 0x3B
121#define TOUCHPAD_REG_TAP_HOLD_TIME_LSB 0x3C
122#define TOUCHPAD_REG_TAP_HOLD_TIME_MSB 0x3D
123#define TOUCHPAD_REG_GESTURE_CLICK_TIME 0x3E
124#define TOUCHPAD_REG_SWIPE_HOLD_THRESHOLD 0x3F
125#define TOUCHPAD_REG_MIN_SWIPE_VELOCITY 0x40
126#define TOUCHPAD_REG_HORIZONTAL_GESTURE_ANGLE 0x41
127#define TOUCHPAD_REG_VERTICAL_GESTURE_ANGLE 0x42
134#define TOUCHPAD_MODE_STANDBY 0x00
135#define TOUCHPAD_MODE_GESTURE 0x01
136#define TOUCHPAD_MODE_TOUCH_ONLY 0x02
137#define TOUCHPAD_MODE_FULL 0x03
138#define TOUCHPAD_MODE_RAW_ADC 0x04
145#define TOUCHPAD_RAWADC_TYPE_RES_1_2 0x00
146#define TOUCHPAD_RAWADC_TYPE_RES_1 0x01
147#define TOUCHPAD_RAWADC_TYPE_RES_2 0x02
154#define TOUCHPAD_CMD_NV_STORAGE_WRITE 0x80
155#define TOUCHPAD_CMD_RESTORE_DEF_CONFIG 0x40
156#define TOUCHPAD_CMD_CONFIG_CTRL 0x20
157#define TOUCHPAD_CMD_EXECUTE_MANU_TEST 0x08
158#define TOUCHPAD_CMD_FORCE_BASELINE 0x01
165#define TOUCHPAD_PERIOD_10ms 0x0142
166#define TOUCHPAD_PERIOD_20ms 0x0284
167#define TOUCHPAD_PERIOD_50ms 0x064C
168#define TOUCHPAD_PERIOD_1000ms 0x0C99
175#define TOUCHPAD_TOUCH_IS_PRESENT 0x01
176#define TOUCHPAD_GESTURE_IS_PRESENT 0x02
177#define TOUCHPAD_LARGE_ACT_IS_PRESENT 0x04
184#define TOUCHPAD_GS_NO_GESTURE_PRESENT 0x00
185#define TOUCHPAD_GS_SINGLE_CLICK 0x10
186#define TOUCHPAD_GS_CLICK_AND_HOLD 0x11
187#define TOUCHPAD_GS_DOUBLE_CLICK 0x20
188#define TOUCHPAD_GS_DOWN_SWIPE 0x31
189#define TOUCHPAD_GS_DOWN_SWIPE_AND_HOLD 0x32
190#define TOUCHPAD_GS_RIGHT_SWIPE 0x41
191#define TOUCHPAD_GS_RIGHT_SWIPE_AND_HOLD 0x42
192#define TOUCHPAD_GS_UP_SWIPE 0x51
193#define TOUCHPAD_GS_UP_SWIPE_AND_HOLD 0x52
194#define TOUCHPAD_GS_LEFT_SWIPE 0x61
195#define TOUCHPAD_GS_LEFT_SWIPE_AND_HOLD 0x62
202#define TOUCHPAD_EVENT_TOUCH 1
203#define TOUCHPAD_EVENT_GESTURE 2
204#define TOUCHPAD_NO_EVENT 0
211#define TOUCHPAD_GD_CLICK_TIMEOUT 0x01
212#define TOUCHPAD_GD_SWIPE_TIMEOUT 0x02
213#define TOUCHPAD_GD_GENERAL_TIMEOUT 0x03
214#define TOUCHPAD_GD_CLICK_THR_EXCEEDED 0x04
215#define TOUCHPAD_GD_SWIPE_THR_EXCEEDED 0x05
216#define TOUCHPAD_GD_SWIPE_HOLD_THR 0x06
217#define TOUCHPAD_GD_SWIPE_OPPOSITE_DIR_THR 0x07
218#define TOUCHPAD_GD_SWIPE_HOLD_VALUE 0x09
219#define TOUCHPAD_GD_OUTSIDE_SWIPE 0x0A
#define TOUCHPAD_RETVAL
Definition: touchpad.h:63
uint8_t touchpad_get_interrupt_state(touchpad_t *ctx)
Get interrupt state.
void touchpad_cfg_setup(touchpad_cfg_t *cfg)
Config Object Initialization function.
void touchpad_generic_read(touchpad_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void touchpad_default_cfg(touchpad_t *ctx)
Click Default Configuration function.
void touchpad_get_touch_coordinate(touchpad_t *ctx, touchpad_cord_t *cord)
Get touch coordinate.
TOUCHPAD_RETVAL touchpad_init(touchpad_t *ctx, touchpad_cfg_t *cfg)
Initialization function.
void touchpad_generic_write(touchpad_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t touchpad_get_gesture_type(touchpad_t *ctx)
Gesture type.
void touchpad_reset(touchpad_t *ctx)
Hardware Reset.
uint8_t touchpad_get_event_state(touchpad_t *ctx)
Get event state.
Click configuration structure definition.
Definition: touchpad.h:256
uint32_t i2c_address
Definition: touchpad.h:270
pin_name_t scl
Definition: touchpad.h:259
uint8_t i2c_speed
Definition: touchpad.h:269
pin_name_t int_pin
Definition: touchpad.h:265
pin_name_t sda
Definition: touchpad.h:260
pin_name_t rst
Definition: touchpad.h:264
Coordinate structure definition.
Definition: touchpad.h:278
uint16_t x
Definition: touchpad.h:279
uint16_t y
Definition: touchpad.h:280
Click ctx object definition.
Definition: touchpad.h:233
digital_in_t int_pin
Definition: touchpad.h:240
i2c_master_t i2c
Definition: touchpad.h:244
digital_out_t rst
Definition: touchpad.h:236
uint8_t slave_address
Definition: touchpad.h:248