Go to the documentation of this file.
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 C6DOFIMU13_MAG_SELFTEST_RESP 0x0C
74 #define C6DOFIMU13_MAG_MORE_INFO_VER 0x0D
75 #define C6DOFIMU13_MAG_MORE_INFO 0x0E
76 #define C6DOFIMU13_MAG_WHO_I_AM 0x0F
77 #define C6DOFIMU13_MAG_OUT_X_LSB 0x10
78 #define C6DOFIMU13_MAG_OUT_X_MSB 0x11
79 #define C6DOFIMU13_MAG_OUT_Y_LSB 0x12
80 #define C6DOFIMU13_MAG_OUT_Y_MSB 0x13
81 #define C6DOFIMU13_MAG_OUT_Z_LSB 0x14
82 #define C6DOFIMU13_MAG_OUT_Z_MSB 0x15
83 #define C6DOFIMU13_MAG_STAT 0x18
84 #define C6DOFIMU13_MAG_CTL_1 0x1B
85 #define C6DOFIMU13_MAG_CTL_2 0x1C
86 #define C6DOFIMU13_MAG_CTL_3 0x1D
87 #define C6DOFIMU13_MAG_CTL_4 0x1E
88 #define C6DOFIMU13_MAG_OFFS_X_LSB 0x20
89 #define C6DOFIMU13_MAG_OFFS_X_MSB 0x21
90 #define C6DOFIMU13_MAG_OFFS_Y_LSB 0x22
91 #define C6DOFIMU13_MAG_OFFS_Y_MSB 0x23
92 #define C6DOFIMU13_MAG_OFFS_Z_LSB 0x24
93 #define C6DOFIMU13_MAG_OFFS_Z_MSB 0x25
94 #define C6DOFIMU13_MAG_ITHR_L 0x26
95 #define C6DOFIMU13_MAG_ITHR_H 0x27
96 #define C6DOFIMU13_MAG_TEMP_VAL 0x31
102 #define C6DOFIMU13_ACCEL_SR 0x03
103 #define C6DOFIMU13_ACCEL_OPSTAT 0x04
104 #define C6DOFIMU13_ACCEL_INTEN 0x06
105 #define C6DOFIMU13_ACCEL_MODE 0x07
106 #define C6DOFIMU13_ACCEL_SRTFR 0x08
107 #define C6DOFIMU13_ACCEL_TAPEN 0x09
108 #define C6DOFIMU13_ACCEL_TTTRX 0x0A
109 #define C6DOFIMU13_ACCEL_TTTRY 0x0B
110 #define C6DOFIMU13_ACCEL_TTTRZ 0x0C
111 #define C6DOFIMU13_ACCEL_XOUT_EX_L 0x0D
112 #define C6DOFIMU13_ACCEL_XOUT_EX_H 0x0E
113 #define C6DOFIMU13_ACCEL_YOUT_EX_L 0x0F
114 #define C6DOFIMU13_ACCEL_YOUT_EX_H 0x10
115 #define C6DOFIMU13_ACCEL_ZOUT_EX_L 0x11
116 #define C6DOFIMU13_ACCEL_ZOUT_EX_H 0x12
117 #define C6DOFIMU13_ACCEL_OUTCFG 0x20
118 #define C6DOFIMU13_ACCEL_XOFFL 0x21
119 #define C6DOFIMU13_ACCEL_XOFFH 0x22
120 #define C6DOFIMU13_ACCEL_YOFFL 0x23
121 #define C6DOFIMU13_ACCEL_YOFFH 0x24
122 #define C6DOFIMU13_ACCEL_ZOFFL 0x25
123 #define C6DOFIMU13_ACCEL_ZOFFH 0x26
124 #define C6DOFIMU13_ACCEL_XGAIN 0x27
125 #define C6DOFIMU13_ACCEL_YGAIN 0x28
126 #define C6DOFIMU13_ACCEL_ZGAIN 0x29
127 #define C6DOFIMU13_ACCEL_PCODE 0x3B
145 #define C6DOFIMU13_MAG_STAT_DRDY 0x40
146 #define C6DOFIMU13_MAG_STAT_DOR 0x20
152 #define C6DOFIMU13_MAG_CTL_1_PC_NORM 0x80
153 #define C6DOFIMU13_MAG_CTL_1_PC_STBY 0x00
154 #define C6DOFIMU13_MAG_CTL_1_ODR_05 0x00
155 #define C6DOFIMU13_MAG_CTL_1_ODR_10 0x08
156 #define C6DOFIMU13_MAG_CTL_1_ODR_20 0x10
157 #define C6DOFIMU13_MAG_CTL_1_ODR_100 0x18
158 #define C6DOFIMU13_MAG_CTL_1_FS_DEF 0x02
159 #define C6DOFIMU13_MAG_CTL_1_FS_NORM 0x00
165 #define C6DOFIMU13_MAG_CTL_3_SRST_SR 0x80
166 #define C6DOFIMU13_MAG_CTL_3_SRST_NOP 0x00
167 #define C6DOFIMU13_MAG_CTL_3_FRC_SM 0x40
168 #define C6DOFIMU13_MAG_CTL_3_FRC_NOP 0x00
169 #define C6DOFIMU13_MAG_CTL_3_STC_EN 0x10
170 #define C6DOFIMU13_MAG_CTL_3_STC_NOP 0x00
171 #define C6DOFIMU13_MAG_CTL_3_TCS_EN 0x02
172 #define C6DOFIMU13_MAG_CTL_3_TCS_NOP 0x00
173 #define C6DOFIMU13_MAG_CTL_3_OCL_EN 0x01
174 #define C6DOFIMU13_MAG_CTL_3_OCL_NOP 0x00
180 #define C6DOFIMU13_MAG_CTL_4_RS_S_14 0x00
181 #define C6DOFIMU13_MAG_CTL_4_RS_S_15 0x10
187 #define C6DOFIMU13_MAG_SENS 0.15
188 #define C6DOFIMU13_MAG_ORIENTATION_COEF -1.0
194 #define C6DOFIMU13_MAG_RES_14_BIT 0x00
195 #define C6DOFIMU13_MAG_RES_15_BIT 0x01
196 #define C6DOFIMU13_MAG_OP_MODE_S_SHOT 0x00
197 #define C6DOFIMU13_MAG_OP_MODE_CONT 0x01
198 #define C6DOFIMU13_MAG_TEMP_MEAS_OFF 0x00
199 #define C6DOFIMU13_MAG_TEMP_MEAS_ON 0x01
205 #define C6DOFIMU13_MAG_AXIS_X 0x00
206 #define C6DOFIMU13_MAG_AXIS_Y 0x01
207 #define C6DOFIMU13_MAG_AXIS_Z 0x02
213 #define C6DOFIMU13_ACCEL_SR_TAP_XP 0x01
214 #define C6DOFIMU13_ACCEL_SR_TAP_XN 0x02
215 #define C6DOFIMU13_ACCEL_SR_TAP_YP 0x04
216 #define C6DOFIMU13_ACCEL_SR_TAP_YN 0x08
217 #define C6DOFIMU13_ACCEL_SR_TAP_ZP 0x10
218 #define C6DOFIMU13_ACCEL_SR_TAP_ZN 0x20
219 #define C6DOFIMU13_ACCEL_SR_AC_INT 0x80
225 #define C6DOFIMU13_ACCEL_OPSTAT_WAKE 0x01
226 #define C6DOFIMU13_ACCEL_OPSTAT_WDT 0x10
227 #define C6DOFIMU13_ACCEL_OPSTAT_OTPA 0x80
233 #define C6DOFIMU13_ACCEL_INTEN_TIXPEN 0x01
234 #define C6DOFIMU13_ACCEL_INTEN_TIXNEN 0x02
235 #define C6DOFIMU13_ACCEL_INTEN_TIYPEN 0x04
236 #define C6DOFIMU13_ACCEL_INTEN_TIYNEN 0x08
237 #define C6DOFIMU13_ACCEL_INTEN_TIZPEN 0x10
238 #define C6DOFIMU13_ACCEL_INTEN_TIZNEN 0x20
239 #define C6DOFIMU13_ACCEL_INTEN_AC_INT_EN 0x80
245 #define C6DOFIMU13_ACCEL_MODE_STDBY 0x00
246 #define C6DOFIMU13_ACCEL_MODE_WAKE 0x01
247 #define C6DOFIMU13_ACCEL_MODE_WDT_NEG 0x10
248 #define C6DOFIMU13_ACCEL_MODE_WDT_POS 0x20
249 #define C6DOFIMU13_ACCEL_MODE_IPP 0x40
250 #define C6DOFIMU13_ACCEL_MODE_IAH 0x80
256 #define C6DOFIMU13_ACCEL_SRTFR_RATE_32 0x00
257 #define C6DOFIMU13_ACCEL_SRTFR_RATE_16 0x01
258 #define C6DOFIMU13_ACCEL_SRTFR_RATE_8 0x02
259 #define C6DOFIMU13_ACCEL_SRTFR_RATE_4 0x03
260 #define C6DOFIMU13_ACCEL_SRTFR_RATE_2 0x04
261 #define C6DOFIMU13_ACCEL_SRTFR_RATE_1 0x05
262 #define C6DOFIMU13_ACCEL_SRTFR_RATE_0_5 0x06
263 #define C6DOFIMU13_ACCEL_SRTFR_RATE_0_25 0x07
264 #define C6DOFIMU13_ACCEL_SRTFR_RATE_64 0x08
265 #define C6DOFIMU13_ACCEL_SRTFR_RATE_128 0x09
266 #define C6DOFIMU13_ACCEL_SRTFR_RATE_256 0x0A
267 #define C6DOFIMU13_ACCEL_SRTFR_FLIP_TAPX 0x10
268 #define C6DOFIMU13_ACCEL_SRTFR_FLIP_TAPY 0x20
269 #define C6DOFIMU13_ACCEL_SRTFR_FLIP_TAPZ 0x40
270 #define C6DOFIMU13_ACCEL_SRTFR_TAP_LATCH 0x80
276 #define C6DOFIMU13_ACCEL_TAPEN_TAPXPEN 0x01
277 #define C6DOFIMU13_ACCEL_TAPEN_TAPXNEN 0x02
278 #define C6DOFIMU13_ACCEL_TAPEN_TAPYPEN 0x04
279 #define C6DOFIMU13_ACCEL_TAPEN_TAPYNEN 0x08
280 #define C6DOFIMU13_ACCEL_TAPEN_TAPZPEN 0x10
281 #define C6DOFIMU13_ACCEL_TAPEN_TAPZNEN 0x20
282 #define C6DOFIMU13_ACCEL_TAPEN_THRDUR 0x40
283 #define C6DOFIMU13_ACCEL_TAPEN_TAP_EN 0x80
289 #define C6DOFIMU13_ACCEL_OUTCFG_RANGE_2 0x00
290 #define C6DOFIMU13_ACCEL_OUTCFG_RANGE_4 0x10
291 #define C6DOFIMU13_ACCEL_OUTCFG_RANGE_8 0x20
292 #define C6DOFIMU13_ACCEL_OUTCFG_RANGE_16 0x30
293 #define C6DOFIMU13_ACCEL_OUTCFG_RES_6 0x00
294 #define C6DOFIMU13_ACCEL_OUTCFG_RES_7 0x01
295 #define C6DOFIMU13_ACCEL_OUTCFG_RES_8 0x02
296 #define C6DOFIMU13_ACCEL_OUTCFG_RES_10 0x03
297 #define C6DOFIMU13_ACCEL_OUTCFG_RES_12 0x04
298 #define C6DOFIMU13_ACCEL_OUTCFG_RES_14 0x05
304 #define C6DOFIMU13_ACCEL_AXIS_X 0x00
305 #define C6DOFIMU13_ACCEL_AXIS_Y 0x01
306 #define C6DOFIMU13_ACCEL_AXIS_Z 0x02
314 #define C6DOFIMU13_DEV_ADDRESS_ACCEL_GND 0x4C
315 #define C6DOFIMU13_DEV_ADDRESS_ACCEL_VCC 0x6C
316 #define C6DOFIMU13_DEV_ADDRESS_MAG 0x0C
334 #define C6DOFIMU13_MAP_MIKROBUS( cfg, mikrobus ) \
335 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
336 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
337 cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
338 cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_INT )
778 #endif // C6DOFIMU13_H
pin_name_t in2
Definition: c6dofimu13.h:376
err_t c6dofimu13_init(c6dofimu13_t *ctx, c6dofimu13_cfg_t *cfg)
6DOF IMU 13 initialization function.
float calc_coef
Definition: c6dofimu13.h:363
c6dofimu13_return_value_t
6DOF IMU 13 Click return value data.
Definition: c6dofimu13.h:389
pin_name_t in1
Definition: c6dofimu13.h:377
uint8_t c6dofimu13_get_in2(c6dofimu13_t *ctx)
6DOF IMU 13 get in2 pin state function.
err_t c6dofimu13_mag_init(c6dofimu13_t *ctx, uint8_t res, uint8_t op_mode, uint8_t temp_meas)
6DOF IMU 13 Magnetometer initialize function.
uint8_t i2c_address
Definition: c6dofimu13.h:380
uint8_t c6dofimu13_get_in1(c6dofimu13_t *ctx)
6DOF IMU 13 get in1 pin state function.
err_t c6dofimu13_accel_get_raw_y(c6dofimu13_t *ctx, int16_t *result)
6DOF IMU 13 Accelerometer get RAW Y-Axis data function.
err_t c6dofimu13_mag_get_z(c6dofimu13_t *ctx, float *result)
6DOF IMU 13 Magnetometer get Z-Axis data function.
6DOF IMU 13 Click configuration object.
Definition: c6dofimu13.h:372
@ C6DOFIMU13_ERROR
Definition: c6dofimu13.h:391
pin_name_t scl
Definition: c6dofimu13.h:373
err_t c6dofimu13_accel_offset(c6dofimu13_t *ctx, int16_t offset, uint8_t axis)
6DOF IMU 13 set accelerometer offset function.
err_t c6dofimu13_mag_get_x(c6dofimu13_t *ctx, float *result)
6DOF IMU 13 Magnetometer get X-Axis data function.
void c6dofimu13_cfg_setup(c6dofimu13_cfg_t *cfg)
6DOF IMU 13 configuration object setup function.
err_t c6dofimu13_generic_write(c6dofimu13_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
6DOF IMU 13 I2C writing function.
digital_in_t in1
Definition: c6dofimu13.h:352
pin_name_t sda
Definition: c6dofimu13.h:374
err_t c6dofimu13_default_cfg(c6dofimu13_t *ctx)
6DOF IMU 13 default configuration function.
err_t c6dofimu13_accel_get_z(c6dofimu13_t *ctx, float *result)
6DOF IMU 13 Accelerometer get Z-Axis data function.
err_t c6dofimu13_accel_get_x(c6dofimu13_t *ctx, float *result)
6DOF IMU 13 Accelerometer get X-Axis data function.
i2c_master_t i2c
Definition: c6dofimu13.h:356
err_t c6dofimu13_accel_get_data(c6dofimu13_t *ctx, float *accel_x, float *accel_y, float *accel_z)
6DOF IMU 13 Accelerometer get X, Y, and Z-Axis data function.
err_t c6dofimu13_accel_get_raw_x(c6dofimu13_t *ctx, int16_t *result)
6DOF IMU 13 Accelerometer get RAW X-Axis data function.
@ C6DOFIMU13_OK
Definition: c6dofimu13.h:390
digital_in_t in2
Definition: c6dofimu13.h:351
err_t c6dofimu13_generic_read(c6dofimu13_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
6DOF IMU 13 I2C reading function.
err_t c6dofimu13_mag_offset(c6dofimu13_t *ctx, int16_t offset, uint8_t axis)
6DOF IMU 13 set magnetometer offset function.
err_t c6dofimu13_accel_get_y(c6dofimu13_t *ctx, float *result)
6DOF IMU 13 Accelerometer get Y-Axis data function.
err_t c6dofimu13_accel_init(c6dofimu13_t *ctx, uint8_t samp_rate, uint8_t samp_range, uint8_t samp_res)
6DOF IMU 13 Accelerometer initialize function.
err_t c6dofimu13_mag_get_y(c6dofimu13_t *ctx, float *result)
6DOF IMU 13 Magnetometer get Y-Axis data function.
uint8_t slave_address
Definition: c6dofimu13.h:360
uint32_t i2c_speed
Definition: c6dofimu13.h:379
err_t c6dofimu13_accel_get_raw_z(c6dofimu13_t *ctx, int16_t *result)
6DOF IMU 13 Accelerometer get RAW Z-Axis data function.
err_t c6dofimu13_set_slave_address(c6dofimu13_t *ctx, uint8_t slave_address)
6DOF IMU 13 set slave address function.
6DOF IMU 13 Click context object.
Definition: c6dofimu13.h:348
err_t c6dofimu13_mag_get_data(c6dofimu13_t *ctx, float *mag_x, float *mag_y, float *mag_z)
6DOF IMU 13 Magnetometer get X, Y, and Z-Axis data function.