Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
59 #define HAPTIC3_REG_CHIP_REV 0x00
60 #define HAPTIC3_REG_IRQ_EVENT1 0x03
61 #define HAPTIC3_REG_IRQ_EVENT_WARNING_DIAG 0x04
62 #define HAPTIC3_REG_IRQ_EVENT_SEQ_DIAG 0x05
63 #define HAPTIC3_REG_IRQ_STATUS1 0x06
64 #define HAPTIC3_REG_IRQ_MASK1 0x07
65 #define HAPTIC3_REG_CIF_I2C1 0x08
66 #define HAPTIC3_REG_FRQ_LRA_PER_H 0x0A
67 #define HAPTIC3_REG_FRQ_LRA_PER_L 0x0B
68 #define HAPTIC3_REG_ACTUATOR1 0x0C
69 #define HAPTIC3_REG_ACTUATOR2 0x0D
70 #define HAPTIC3_REG_ACTUATOR3 0x0E
71 #define HAPTIC3_REG_CALIB_V2I_H 0x0F
72 #define HAPTIC3_REG_CALIB_V2I_L 0x10
73 #define HAPTIC3_REG_CALIB_IMP_H 0x11
74 #define HAPTIC3_REG_CALIB_IMP_L 0x12
75 #define HAPTIC3_REG_TOP_CFG1 0x13
76 #define HAPTIC3_REG_TOP_CFG2 0x14
77 #define HAPTIC3_REG_TOP_CFG3 0x15
78 #define HAPTIC3_REG_TOP_CFG4 0x16
79 #define HAPTIC3_REG_TOP_INT_CFG1 0x17
80 #define HAPTIC3_REG_TOP_INT_CFG6_H 0x1C
81 #define HAPTIC3_REG_TOP_INT_CFG6_L 0x1D
82 #define HAPTIC3_REG_TOP_INT_CFG7_H 0x1E
83 #define HAPTIC3_REG_TOP_INT_CFG7_L 0x1F
84 #define HAPTIC3_REG_TOP_INT_CFG8 0x20
85 #define HAPTIC3_REG_TOP_CTL1 0x22
86 #define HAPTIC3_REG_TOP_CTL2 0x23
87 #define HAPTIC3_REG_SEQ_CTL1 0x24
88 #define HAPTIC3_REG_SWG_C1 0x25
89 #define HAPTIC3_REG_SWG_C2 0x26
90 #define HAPTIC3_REG_SWG_C3 0x27
91 #define HAPTIC3_REG_SEQ_CTL2 0x28
92 #define HAPTIC3_REG_GPI_0_CTL 0x29
93 #define HAPTIC3_REG_GPI_1_CTL 0x2A
94 #define HAPTIC3_REG_GPI_2_CTL 0x2B
95 #define HAPTIC3_REG_MEM_CTL1 0x2C
96 #define HAPTIC3_REG_MEM_CTL2 0x2D
97 #define HAPTIC3_REG_ADC_DATA_H1 0x2E
98 #define HAPTIC3_REG_ADC_DATA_L1 0x2F
99 #define HAPTIC3_REG_POLARITY 0x43
100 #define HAPTIC3_REG_LRA_AVR_H 0x44
101 #define HAPTIC3_REG_LRA_AVR_L 0x45
102 #define HAPTIC3_REG_FRQ_LRA_PER_ACT_H 0x46
103 #define HAPTIC3_REG_FRQ_LRA_PER_ACT_L 0x47
104 #define HAPTIC3_REG_FRQ_PHASE_H 0x48
105 #define HAPTIC3_REG_FRQ_PHASE_L 0x49
106 #define HAPTIC3_REG_FRQ_CTL 0x4C
107 #define HAPTIC3_REG_TRIM3 0x5F
108 #define HAPTIC3_REG_TRIM4 0x60
109 #define HAPTIC3_REG_TRIM6 0x62
110 #define HAPTIC3_REG_TOP_CFG5 0x6E
111 #define HAPTIC3_REG_IRQ_EVENT_ACTUATOR_FAULT 0x81
112 #define HAPTIC3_REG_IRQ_STATUS2 0x82
113 #define HAPTIC3_REG_IRQ_MASK2 0x83
114 #define HAPTIC3_REG_SNP_MEM_X 0x84
132 #define HAPTIC3_CHIP_REV 0xDA
138 #define HAPTIC3_TOP_CFG1_EMB_MODE_MANUAL 0x00
139 #define HAPTIC3_TOP_CFG1_EMB_MODE_AUTO 0x80
140 #define HAPTIC3_TOP_CFG1_EMB_MODE_MASK 0x80
141 #define HAPTIC3_TOP_CFG1_ACT_TYPE_LRA 0x00
142 #define HAPTIC3_TOP_CFG1_ACT_TYPE_ERM 0x20
143 #define HAPTIC3_TOP_CFG1_ACT_TYPE_MASK 0x20
144 #define HAPTIC3_TOP_CFG1_BEMF_SENSE_CUSTOM_WF 0x00
145 #define HAPTIC3_TOP_CFG1_BEMF_SENSE_STANDARD 0x10
146 #define HAPTIC3_TOP_CFG1_BEMF_SENSE_MASK 0x10
147 #define HAPTIC3_TOP_CFG1_FREQ_TRACK_DISABLE 0x00
148 #define HAPTIC3_TOP_CFG1_FREQ_TRACK_ENABLE 0x08
149 #define HAPTIC3_TOP_CFG1_FREQ_TRACK_MASK 0x08
150 #define HAPTIC3_TOP_CFG1_ACCEL_DISABLE 0x00
151 #define HAPTIC3_TOP_CFG1_ACCEL_ENABLE 0x04
152 #define HAPTIC3_TOP_CFG1_ACCEL_MASK 0x04
153 #define HAPTIC3_TOP_CFG1_RAPID_STOP_DISABLE 0x00
154 #define HAPTIC3_TOP_CFG1_RAPID_STOP_ENABLE 0x02
155 #define HAPTIC3_TOP_CFG1_RAPID_STOP_MASK 0x02
156 #define HAPTIC3_TOP_CFG1_AMPLITUDE_PID_DISABLE 0x00
157 #define HAPTIC3_TOP_CFG1_AMPLITUDE_PID_ENABLE 0x01
158 #define HAPTIC3_TOP_CFG1_AMPLITUDE_PID_MASK 0x01
164 #define HAPTIC3_TOP_CTL1_SEQ_STOP 0x00
165 #define HAPTIC3_TOP_CTL1_SEQ_START 0x10
166 #define HAPTIC3_TOP_CTL1_SEQ_MASK 0x10
167 #define HAPTIC3_TOP_CTL1_STANDBY_DISABLE 0x00
168 #define HAPTIC3_TOP_CTL1_STANDBY_ENABLE 0x08
169 #define HAPTIC3_TOP_CTL1_STANDBY_MASK 0x08
170 #define HAPTIC3_TOP_CTL1_OP_MODE_INACTIVE 0x00
171 #define HAPTIC3_TOP_CTL1_OP_MODE_DRO 0x01
172 #define HAPTIC3_TOP_CTL1_OP_MODE_PWM 0x02
173 #define HAPTIC3_TOP_CTL1_OP_MODE_RTWM 0x03
174 #define HAPTIC3_TOP_CTL1_OP_MODE_ETWM 0x04
175 #define HAPTIC3_TOP_CTL1_OP_MODE_MASK 0x07
181 #define HAPTIC3_ACTUATOR_VOLTAGE_MIN 0.0
182 #define HAPTIC3_ACTUATOR_VOLTAGE_MAX 6.0
183 #define HAPTIC3_ACTUATOR_VOLTAGE_RESOLUTION 0.0234
184 #define HAPTIC3_ACTUATOR_IMAX_MIN 28.6
185 #define HAPTIC3_ACTUATOR_IMAX_MAX 251.8
186 #define HAPTIC3_ACTUATOR_IMAX_DIVIDER 7.2
187 #define HAPTIC3_ACTUATOR_IMAX_RESOLUTION 0x1F
188 #define HAPTIC3_ACTUATOR_IMPEDANCE_MIN 4.0
189 #define HAPTIC3_ACTUATOR_IMPEDANCE_MAX 50.0
190 #define HAPTIC3_ACTUATOR_V2I_FACTOR_DIVIDER 1.6104
191 #define HAPTIC3_ACTUATOR_LRA_FREQ_MIN 0.0
192 #define HAPTIC3_ACTUATOR_LRA_FREQ_MAX 300.0
193 #define HAPTIC3_ACTUATOR_LRA_FREQ_RESOLUTION 0.00000133332
194 #define HAPTIC3_VIBRATION_LEVEL_MIN -1.0
195 #define HAPTIC3_VIBRATION_LEVEL_MAX 1.0
196 #define HAPTIC3_VIBRATION_LEVEL_MIN_ACC_EN 0.0
197 #define HAPTIC3_VIBRATION_LEVEL_RESOLUTION 0.008
198 #define HAPTIC3_ROUND_TO_NEAREST_INT 0.5
204 #define HAPTIC3_DEFAULT_ACTUATOR_TYPE HAPTIC3_TOP_CFG1_ACT_TYPE_LRA
205 #define HAPTIC3_DEFAULT_ACTUATOR_ABS_VOLT 2.808
206 #define HAPTIC3_DEFAULT_ACTUATOR_NOM_VOLT 2.106
207 #define HAPTIC3_DEFAULT_ACTUATOR_IMAX 194.0
208 #define HAPTIC3_DEFAULT_ACTUATOR_IMPEDANCE 16.0
209 #define HAPTIC3_DEFAULT_ACTUATOR_LRA_FREQ 174.0
216 #define HAPTIC3_DEVICE_ADDRESS 0x4A
234 #define HAPTIC3_MAP_MIKROBUS( cfg, mikrobus ) \
235 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
236 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
237 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
238 cfg.irq = MIKROBUS( mikrobus, MIKROBUS_INT )
haptic3_return_value_t
HAPTIC 3 Click return value data.
Definition: haptic3.h:285
err_t haptic3_set_actuator_lra_freq(haptic3_t *ctx, float frequency)
HAPTIC 3 set actuator lra freq function.
err_t haptic3_set_operation_mode(haptic3_t *ctx, uint8_t op_mode)
HAPTIC 3 set operation mode function.
digital_in_t irq
Definition: haptic3.h:253
err_t haptic3_write_register(haptic3_t *ctx, uint8_t reg, uint8_t data_in)
HAPTIC 3 write register function.
err_t haptic3_get_vibration_level(haptic3_t *ctx, float *level)
HAPTIC 3 get vibration level function.
HAPTIC 3 Click configuration object.
Definition: haptic3.h:268
err_t haptic3_set_actuator_impedance(haptic3_t *ctx, float impedance)
HAPTIC 3 set actuator impedance function.
err_t haptic3_init(haptic3_t *ctx, haptic3_cfg_t *cfg)
HAPTIC 3 initialization function.
err_t haptic3_set_actuator_abs_volt(haptic3_t *ctx, float abs_volt)
HAPTIC 3 set actuator abs volt function.
err_t haptic3_check_communication(haptic3_t *ctx)
HAPTIC 3 check communication function.
uint32_t i2c_speed
Definition: haptic3.h:275
err_t haptic3_default_cfg(haptic3_t *ctx)
HAPTIC 3 default configuration function.
HAPTIC 3 Click context object.
Definition: haptic3.h:248
void haptic3_disable_device(haptic3_t *ctx)
HAPTIC 3 disable device function.
err_t haptic3_set_actuator_imax(haptic3_t *ctx, float max_curr)
HAPTIC 3 set actuator imax function.
digital_out_t en
Definition: haptic3.h:250
@ HAPTIC3_OK
Definition: haptic3.h:286
err_t haptic3_set_freq_track(haptic3_t *ctx, uint8_t freq_track_en)
HAPTIC 3 set freq track function.
void haptic3_enable_device(haptic3_t *ctx)
HAPTIC 3 enable device function.
pin_name_t irq
Definition: haptic3.h:273
@ HAPTIC3_ERROR
Definition: haptic3.h:287
uint8_t slave_address
Definition: haptic3.h:259
err_t haptic3_set_vibration_level(haptic3_t *ctx, float level)
HAPTIC 3 set vibration level function.
err_t haptic3_write_register_bits(haptic3_t *ctx, uint8_t reg, uint8_t mask, uint8_t data_in)
HAPTIC 3 write register bits function.
uint8_t haptic3_get_int_pin(haptic3_t *ctx)
HAPTIC 3 get INT pin function.
uint8_t i2c_address
Definition: haptic3.h:276
pin_name_t scl
Definition: haptic3.h:269
err_t haptic3_generic_read(haptic3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
HAPTIC 3 I2C reading function.
pin_name_t en
Definition: haptic3.h:272
i2c_master_t i2c
Definition: haptic3.h:256
err_t haptic3_set_actuator_type(haptic3_t *ctx, uint8_t type)
HAPTIC 3 set actuator type function.
err_t haptic3_generic_write(haptic3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
HAPTIC 3 I2C writing function.
err_t haptic3_set_actuator_nom_volt(haptic3_t *ctx, float nom_volt)
HAPTIC 3 set actuator nom volt function.
err_t haptic3_set_acceleration_mode(haptic3_t *ctx, uint8_t accel_en)
HAPTIC 3 set acceleration mode function.
void haptic3_cfg_setup(haptic3_cfg_t *cfg)
HAPTIC 3 configuration object setup function.
pin_name_t sda
Definition: haptic3.h:270
err_t haptic3_read_register(haptic3_t *ctx, uint8_t reg, uint8_t *data_out)
HAPTIC 3 read register function.