Go to the documentation of this file.
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
53 #define CAPWHEEL_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56 cfg. clr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
57 cfg. rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
64 #define CAPWHEEL_RETVAL uint8_t
66 #define CAPWHEEL_OK 0x00
67 #define CAPWHEEL_INIT_ERROR 0xFF
74 #define CAPWHEEL_DEVICE_ADDR 0x64
81 #define CAPWHEEL_DEVICE_INFO_REG 0x00
82 #define CAPWHEEL_SYSTEM_FLAGS_REG 0x01
83 #define CAPWHEEL_WHEEL_COORDNT_REG 0x02
84 #define CAPWHEEL_TOUCH_BYTES_REG 0x03
85 #define CAPWHEEL_COUNTS_REG 0x04
86 #define CAPWHEEL_LTA_REG 0x05
87 #define CAPWHEEL_MULTIPLIERS_REG 0x06
88 #define CAPWHEEL_COMPENS_REG 0x07
89 #define CAPWHEEL_PROXSETT_REG 0x08
90 #define CAPWHEEL_THRESH_REG 0x09
91 #define CAPWHEEL_TIMINGS_REG 0x0A
92 #define CAPWHEEL_TARGETS_REG 0x0B
93 #define CAPWHEEL_PWM_DUTY_REG 0x0C
94 #define CAPWHEEL_PWM_LIM_REG 0x0D
95 #define CAPWHEEL_ACTIVE_CHANN_REG 0x0E
96 #define CAPWHEEL_BUZZER_REG 0x0F
103 #define CAPWHEEL_DEV_INFO_NBYTES 2
104 #define CAPWHEEL_SYST_FLAGS_NBYTES 1
105 #define CAPWHEEL_WHEEL_NBYTES 4
106 #define CAPWHEEL_TOUCH_NBYTES 2
107 #define CAPWHEEL_COUNTS_NBYTES 18
108 #define CAPWHEEL_LTA_NBYTES 18
109 #define CAPWHEEL_MULTIPL_NBYTES 9
110 #define CAPWHEEL_COMPENS_NBYTES 9
111 #define CAPWHEEL_PROXSETT_NBYTES 6
112 #define CAPWHEEL_THRESH_NBYTES 10
113 #define CAPWHEEL_TIMINGS_NBYTES 13
114 #define CAPWHEEL_TARGETS_NBYTES 10
115 #define CAPWHEEL_PWM_DUTY_NBYTES 8
116 #define CAPWHEEL_PWM_LIM_NBYTES 2
117 #define CAPWHEEL_ACT_CHANN_NBYTES 2
118 #define CAPWHEEL_BUZZER_NBYTES 1
125 #define CAPWHEEL_BUZZER_EN 0x80
126 #define CAPWHEEL_BUZZER_DC_HIGH 0x04
127 #define CAPWHEEL_BUZZER_DC_LOW 0x00
128 #define CAPWHEEL_BUZZER_PERM_EN 0x02
129 #define CAPWHEEL_BUZZER_BURST_EN 0x01
136 #define CAPWHEEL_CH0_PROX_EN 0x001
137 #define CAPWHEEL_CH1_EN 0x002
138 #define CAPWHEEL_CH2_EN 0x004
139 #define CAPWHEEL_CH3_EN 0x008
140 #define CAPWHEEL_CH4_EN 0x010
141 #define CAPWHEEL_CH5_EN 0x020
142 #define CAPWHEEL_CH6_EN 0x040
143 #define CAPWHEEL_CH7_EN 0x080
144 #define CAPWHEEL_CH8_EN 0x100
145 #define CAPWHEEL_CH9_EN 0x200
152 #define CAPWHEEL_PWM_OFF 0x00
153 #define CAPWHEEL_PWM_CONST 0x20
154 #define CAPWHEEL_PWM_DECR_0_PERCENTS 0x80
155 #define CAPWHEEL_PWM_DECR_LIM 0xA0
156 #define CAPWHEEL_PWM_INCR_100_PERCENTS 0xC0
157 #define CAPWHEEL_PWM_INCR_LIM 0xE0
158 #define CAPWHEEL_PWM_DUTY_0_PERCENTS 0x00
159 #define CAPWHEEL_PWM_DUTY_25_PERCENTS 0x10
160 #define CAPWHEEL_PWM_DUTY_50_PERCENTS 0x18
161 #define CAPWHEEL_PWM_DUTY_75_PERCENTS 0x1C
162 #define CAPWHEEL_PWM_DUTY_100_PERCENTS 0x1F
169 #define CAPWHEEL_DATA_READY 0
170 #define CAPWHEEL_DATA_NOT_READY 1
171 #define CAPWHEEL_ADDR_ERROR 0xFF
172 #define CAPWHEEL_NBYTES_ERROR 0xFE
173 #define CAPWHEEL_CH_SEL_ERROR 0xFD
174 #define CAPWHEEL_OK 0x00
181 #define CAPWHEEL_LED_BRIGHTNESS_INTENSITY 0
182 #define CAPWHEEL_LED_BRIGHTNESS_NUMBER 1
401 #endif // _CAPWHEEL_H_
void capwheel_default_cfg(capwheel_t *ctx)
Click Default Configuration function.
void capwheel_get_data(capwheel_t *ctx, uint16_t *wheel_data)
Data Get function.
uint8_t i2c_address
Definition: capwheel.h:233
uint8_t capwheel_write_reg(capwheel_t *ctx, uint8_t register_address, uint8_t *data_in, uint8_t n_bytes)
Generic Write function.
pin_name_t scl
Definition: capwheel.h:222
void capwheel_generic_read(capwheel_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void capwheel_cfg_setup(capwheel_cfg_t *cfg)
Config Object Initialization function.
uint8_t capwheel_check_data_ready(capwheel_t *ctx)
Data Ready Check function.
pin_name_t clr
Definition: capwheel.h:227
pin_name_t rdy
Definition: capwheel.h:228
uint32_t i2c_speed
Definition: capwheel.h:232
void capwheel_reset(capwheel_t *ctx)
Reset function.
digital_out_t clr
Definition: capwheel.h:199
void capwheel_generic_write(capwheel_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void capwheel_set_output(capwheel_t *ctx, uint16_t input_data, uint8_t output_mode)
Output Set function.
i2c_master_t i2c
Definition: capwheel.h:207
Click ctx object definition.
Definition: capwheel.h:195
pin_name_t sda
Definition: capwheel.h:223
uint8_t slave_address
Definition: capwheel.h:211
uint8_t capwheel_enable_chann(capwheel_t *ctx, uint16_t sel_chann)
Channel Enable function.
Click configuration structure definition.
Definition: capwheel.h:218
digital_in_t rdy
Definition: capwheel.h:203
#define CAPWHEEL_RETVAL
Definition: capwheel.h:64
uint8_t capwheel_read_reg(capwheel_t *ctx, uint8_t register_address, uint8_t *data_out, uint8_t n_bytes)
Generic Read function.
void capwheel_set_threshold(capwheel_t *ctx, uint8_t thresh_value)
Threshold Set function.
CAPWHEEL_RETVAL capwheel_init(capwheel_t *ctx, capwheel_cfg_t *cfg)
Initialization function.