Go to the documentation of this file.
42 #ifdef PREINIT_SUPPORTED
46 #ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 #include "drv_i2c_master.h"
55 #include "drv_spi_master.h"
68 #define ACCEL6_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
70 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
71 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
72 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
73 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
74 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
81 #define ACCEL6_MASTER_I2C 0
82 #define ACCEL6_MASTER_SPI 1
89 #define ACCEL6_RETVAL uint8_t
91 #define ACCEL6_OK 0x00
92 #define ACCEL6_INIT_ERROR 0xFF
99 #define ACCEL6_CHIP_ID 0xFB
100 #define ACCEL6_SOFT_RESET 0xB6
107 #define ACCEL6_AXIS_X 0x02
108 #define ACCEL6_AXIS_Y 0x04
109 #define ACCEL6_AXIS_Z 0x06
116 #define ACCEL6_REG_CHIP_ID 0x00
117 #define ACCEL6_REG_AXIS_X_LSB 0x02
118 #define ACCEL6_REG_AXIS_X_MSB 0x03
119 #define ACCEL6_REG_AXIS_Y_LSB 0x04
120 #define ACCEL6_REG_AXIS_Y_MSB 0x05
121 #define ACCEL6_REG_AXIS_Z_LSB 0x06
122 #define ACCEL6_REG_AXIS_Z_MSB 0x07
123 #define ACCEL6_REG_TEMPERATURE 0x08
124 #define ACCEL6_REG_INT_STATUS_0 0x09
125 #define ACCEL6_REG_INT_STATUS_1 0x0A
126 #define ACCEL6_REG_INT_STATUS_2 0x0B
127 #define ACCEL6_REG_INT_STATUS_3 0x0C
128 #define ACCEL6_REG_FIFO_STATUS 0x0E
129 #define ACCEL6_REG_PMU_RANGE 0x0F
130 #define ACCEL6_REG_PMU_BW 0x10
131 #define ACCEL6_REG_PMU_LPW 0x11
132 #define ACCEL6_REG_PMU_LOW_POWER 0x12
133 #define ACCEL6_REG_ACCD_HBW 0x13
134 #define ACCEL6_REG_BGW_SOFTRESET 0x14
135 #define ACCEL6_REG_INT_EN_0 0x16
136 #define ACCEL6_REG_INT_EN_1 0x17
137 #define ACCEL6_REG_INT_EN_2 0x18
138 #define ACCEL6_REG_INT_MAP_0 0x19
139 #define ACCEL6_REG_INT_MAP_1 0x1A
140 #define ACCEL6_REG_INT_MAP_2 0x1B
141 #define ACCEL6_REG_INT_SRC 0x1E
142 #define ACCEL6_REG_INT_OUT_CTRL 0x20
143 #define ACCEL6_REG_INT_RST_LATCH 0x21
144 #define ACCEL6_REG_INT1 0x23
145 #define ACCEL6_REG_INT2 0x24
146 #define ACCEL6_REG_INT3 0x25
147 #define ACCEL6_REG_INT4 0x26
148 #define ACCEL6_REG_INT5 0x27
149 #define ACCEL6_REG_INT6 0x28
150 #define ACCEL6_REG_INT7 0x29
151 #define ACCEL6_REG_INT8 0x2A
152 #define ACCEL6_REG_INT9 0x2B
153 #define ACCEL6_REG_INT_A 0x2C
154 #define ACCEL6_REG_INT_B 0x2D
155 #define ACCEL6_REG_INT_C 0x2E
156 #define ACCEL6_REG_INT_D 0x2F
157 #define ACCEL6_REG_FIFO_CONFIG_0 0x30
158 #define ACCEL6_REG_PMU_SELF_TEST 0x32
159 #define ACCEL6_REG_TRIM_NVM_CTRL 0x33
160 #define ACCEL6_REG_BGW_SPI3_WDT 0x34
161 #define ACCEL6_REG_OFC_CTRL 0x36
162 #define ACCEL6_REG_OFC_SETTINGS 0x37
163 #define ACCEL6_REG_OFC_OFFSET_X 0x38
164 #define ACCEL6_REG_OFC_OFFSET_Y 0x39
165 #define ACCEL6_REG_OFC_OFFSET_Z 0x3A
166 #define ACCEL6_REG_TRIM_GP_0 0x3B
167 #define ACCEL6_REG_TRIM_GP_1 0x3C
168 #define ACCEL6_REG_FIFO_CONFIG_1 0x3E
169 #define ACCEL6_REG_FIFO_DATA 0x3F
176 #define ACCEL6_STATUS_0_FLAT_INT 0x80
177 #define ACCEL6_STATUS_0_ORIENT_INT 0x40
178 #define ACCEL6_STATUS_0_SINGLE_TAP_INT 0x20
179 #define ACCEL6_STATUS_0_DOUBLE_TAP_INT 0x10
180 #define ACCEL6_STATUS_0_MOTION_INT 0x08
181 #define ACCEL6_STATUS_0_SLOPE_INT 0x04
182 #define ACCEL6_STATUS_0_HIGH_INT 0x02
183 #define ACCEL6_STATUS_0_LOW_INT 0x01
190 #define ACCEL6_STATUS_1_DATA_INT 0x80
191 #define ACCEL6_STATUS_1_FIFO_WM_INT 0x40
192 #define ACCEL6_STATUS_1_FIFO_FULL_INT 0x20
199 #define ACCEL6_STATUS_2_TAP_SING 0x80
200 #define ACCEL6_STATUS_2_TAP_FIRST_Z 0x40
201 #define ACCEL6_STATUS_2_TAP_FIRST_Y 0x20
202 #define ACCEL6_STATUS_2_TAP_FIRST_X 0x10
203 #define ACCEL6_STATUS_2_SLOPE_SING 0x08
204 #define ACCEL6_STATUS_2_SLOPE_FIRST_Z 0x04
205 #define ACCEL6_STATUS_2_SLOPE_FIRST_Y 0x02
206 #define ACCEL6_STATUS_2_SLOPE_FIRST_X 0x01
213 #define ACCEL6_STATUS_3_FLAT_POSITION 0x80
214 #define ACCEL6_STATUS_3_ORIENT_Z_UPWARD 0x00
215 #define ACCEL6_STATUS_3_ORIENT_Z_DOWNWARD 0x40
216 #define ACCEL6_STATUS_3_ORIENT_XY_UPRIGHT 0x00
217 #define ACCEL6_STATUS_3_ORIENT_XY_UPSIDE 0x10
218 #define ACCEL6_STATUS_3_ORIENT_XY_LANDSCAPE_LEFT 0x20
219 #define ACCEL6_STATUS_3_ORIENT_XY_LANDSCAPE_RIGHT 0x30
220 #define ACCEL6_STATUS_3_HIGH_SING_POSITIVE 0x00
221 #define ACCEL6_STATUS_3_HIGH_SING_NEGATIVE 0x08
222 #define ACCEL6_STATUS_3_HIGH_FIRST_Z 0x04
223 #define ACCEL6_STATUS_3_HIGH_FIRST_Y 0x02
224 #define ACCEL6_STATUS_3_HIGH_FIRST_X 0x01
231 #define ACCEL6_PMU_RANGE_2g 0x03
232 #define ACCEL6_PMU_RANGE_4g 0x05
233 #define ACCEL6_PMU_RANGE_8g 0x08
234 #define ACCEL6_PMU_RANGE_16g 0x0C
241 #define ACCEL6_PMU_BW_7_81Hz 0x08
242 #define ACCEL6_PMU_BW_15_63Hz 0x09
243 #define ACCEL6_PMU_BW_31_25Hz 0x0A
244 #define ACCEL6_PMU_BW_62_5Hz 0x0B
245 #define ACCEL6_PMU_BW_125Hz 0x0C
246 #define ACCEL6_PMU_BW_250Hz 0x0D
247 #define ACCEL6_PMU_BW_500Hz 0x0E
254 #define ACCEL6_PMU_LPW_NORMAL_MODE 0x00
255 #define ACCEL6_PMU_LPW_DEEP_SUSPEND_MODE 0x20
256 #define ACCEL6_PMU_LPW_LOW_POWER_MODE 0x40
257 #define ACCEL6_PMU_LPW_SUSPEND_MODE 0x80
258 #define ACCEL6_PMU_LPW_SLEEP_0_5ms 0x05
259 #define ACCEL6_PMU_LPW_SLEEP_1ms 0x06
260 #define ACCEL6_PMU_LPW_SLEEP_2ms 0x07
261 #define ACCEL6_PMU_LPW_SLEEP_4ms 0x08
262 #define ACCEL6_PMU_LPW_SLEEP_6ms 0x09
263 #define ACCEL6_PMU_LPW_SLEEP_10ms 0x0A
264 #define ACCEL6_PMU_LPW_SLEEP_25ms 0x0B
265 #define ACCEL6_PMU_LPW_SLEEP_50ms 0x0C
266 #define ACCEL6_PMU_LPW_SLEEP_100ms 0x0D
267 #define ACCEL6_PMU_LPW_SLEEP_500ms 0x0E
274 #define ACCEL6_INT_EN_0_FLAT_ENABLE 0x80
275 #define ACCEL6_INT_EN_0_ORIENT_ENABLE 0x40
276 #define ACCEL6_INT_EN_0_SINGLE_TAP_ENABLE 0x20
277 #define ACCEL6_INT_EN_0_DOUBLE_TAP_ENABLE 0x10
278 #define ACCEL6_INT_EN_0_SLOPE_Z_ENABLE 0x04
279 #define ACCEL6_INT_EN_0_SLOPE_Y_ENABLE 0x02
280 #define ACCEL6_INT_EN_0_SLOPE_X_ENABLE 0x01
287 #define ACCEL6_INT_EN_1_FIFO_WM_ENABLE 0x40
288 #define ACCEL6_INT_EN_1_FIFO_FULL_ENABLE 0x20
289 #define ACCEL6_INT_EN_1_DATA_ENABLE 0x10
290 #define ACCEL6_INT_EN_1_LOW_ENABLE 0x08
291 #define ACCEL6_INT_EN_1_HIGH_Z_ENABLE 0x04
292 #define ACCEL6_INT_EN_1_HIGH_Y_ENABLE 0x02
293 #define ACCEL6_INT_EN_1_HIGH_X_ENABLE 0x01
300 #define ACCEL6_INT_EN_2_MOTION_ENABLE 0x08
301 #define ACCEL6_INT_EN_2_MOTION_Z_ENABLE 0x04
302 #define ACCEL6_INT_EN_2_MOTION_Y_ENABLE 0x02
303 #define ACCEL6_INT_EN_2_MOTION_X_ENABLE 0x01
310 #define ACCEL6_INT1_MAP_FLAT_ENABLE 0x80
311 #define ACCEL6_INT1_MAP_ORIENT_ENABLE 0x40
312 #define ACCEL6_INT1_MAP_SINGLE_TAP_ENABLE 0x20
313 #define ACCEL6_INT1_MAP_DOUBLE_TAP_ENABLE 0x10
314 #define ACCEL6_INT1_MAP_MOTION_ENABLE 0x08
315 #define ACCEL6_INT1_MAP_SLOPE_ENABLE 0x04
316 #define ACCEL6_INT1_MAP_HIGH_ENABLE 0x02
317 #define ACCEL6_INT1_MAP_LOW_ENABLE 0x01
324 #define ACCEL6_INT2_MAP_DATA_ENABLE 0x80
325 #define ACCEL6_INT2_MAP_FIFO_WM_ENABLE 0x40
326 #define ACCEL6_INT2_MAP_FIFO_FULL_ENABLE 0x20
327 #define ACCEL6_INT1_MAP_DATA_ENABLE 0x01
328 #define ACCEL6_INT1_MAP_FIFO_WM_ENABLE 0x02
329 #define ACCEL6_INT1_MAP_FIFO_FULL_ENABLE 0x04
336 #define ACCEL6_INT2_MAP_FLAT_ENABLE 0x80
337 #define ACCEL6_INT2_MAP_ORIENT_ENABLE 0x40
338 #define ACCEL6_INT2_MAP_SINGLE_TAP_ENABLE 0x20
339 #define ACCEL6_INT2_MAP_DOUBLE_TAP_ENABLE 0x10
340 #define ACCEL6_INT2_MAP_MOTION_ENABLE 0x08
341 #define ACCEL6_INT2_MAP_SLOPE_ENABLE 0x04
342 #define ACCEL6_INT2_MAP_HIGH_ENABLE 0x02
343 #define ACCEL6_INT2_MAP_LOW_ENABLE 0x01
350 #define ACCEL6_INT_SRC_DATA 0x20
351 #define ACCEL6_INT_SRC_TAP 0x10
352 #define ACCEL6_INT_SRC_MOTION 0x08
353 #define ACCEL6_INT_SRC_SLOPE 0x04
354 #define ACCEL6_INT_SRC_HIGH 0x02
355 #define ACCEL6_INT_SRC_LOW 0x01
362 #define ACCEL6_INT2_CTRL_OPEN_DRAIN 0x08
363 #define ACCEL6_INT1_CTRL_OPEN_DRAIN 0x02
364 #define ACCEL6_INT2_CTRL_ACTIVE_HIGH_LEVEL 0x04
365 #define ACCEL6_INT1_CTRL_ACTIVE_HIGH_LEVEL 0x01
372 #define ACCEL6_LATCH_RESET_INT 0x80
373 #define ACCEL6_LATCH_INT_250ms 0x01
374 #define ACCEL6_LATCH_INT_500ms 0x02
375 #define ACCEL6_LATCH_INT_1sec 0x03
376 #define ACCEL6_LATCH_INT_2sec 0x04
377 #define ACCEL6_LATCH_INT_4sec 0x05
378 #define ACCEL6_LATCH_INT_8sec 0x06
379 #define ACCEL6_LATCH_INT_250us 0x09
380 #define ACCEL6_LATCH_INT_500us 0x0A
381 #define ACCEL6_LATCH_INT_1ms 0x0B
382 #define ACCEL6_LATCH_INT_12_5ms 0x0C
383 #define ACCEL6_LATCH_INT_25ms 0x0D
384 #define ACCEL6_LATCH_INT_50ms 0x0E
391 #define ACCEL6_TAP_QUIET_30ms 0x00
392 #define ACCEL6_TAP_QUIET_20ms 0x80
393 #define ACCEL6_TAP_SHOCK_50ms 0x00
394 #define ACCEL6_TAP_SHOCK_75ms 0x40
395 #define ACCEL6_TAP_DUR_50ms 0x00
396 #define ACCEL6_TAP_DUR_100ms 0x01
397 #define ACCEL6_TAP_DUR_150ms 0x02
398 #define ACCEL6_TAP_DUR_200ms 0x03
399 #define ACCEL6_TAP_DUR_250ms 0x04
400 #define ACCEL6_TAP_DUR_375ms 0x05
401 #define ACCEL6_TAP_DUR_500ms 0x06
402 #define ACCEL6_TAP_DUR_700ms 0x07
409 #define ACCEL6_TAP_2_SAMPLES 0x00
410 #define ACCEL6_TAP_4_SAMPLES 0x40
411 #define ACCEL6_TAP_8_SAMPLES 0x80
412 #define ACCEL6_TAP_16_SAMPLES 0xC0
419 #define ACCEL6_SELF_TEST_SING_POSITIVE 0x40
420 #define ACCEL6_SELF_TEST_SING_NEGATIVE 0x00
421 #define ACCEL6_SELF_TEST_DISABLE 0x00
422 #define ACCEL6_SELF_TEST_X_AXIS 0x01
423 #define ACCEL6_SELF_TEST_Y_AXIS 0x02
424 #define ACCEL6_SELF_TEST_Z_AXIS 0x03
431 #define ACCEL6_I2C_ENABLE 0x04
432 #define ACCEL6_I2C_DISABLE 0x00
433 #define ACCEL6_I2C_WTD_1ms 0x00
434 #define ACCEL6_I2C_WTD_50ms 0x02
435 #define ACCEL6_SPI_4_WIRE 0x00
436 #define ACCEL6_SPI_3_WIRE 0x01
443 #define ACCEL6_OFFSET_RESET 0x80
444 #define ACCEL6_OFFSET_TRIGGER_X_AXIS 0x20
445 #define ACCEL6_OFFSET_TRIGGER_Y_AXIS 0x40
446 #define ACCEL6_OFFSET_TRIGGER_Z_AXIS 0x60
447 #define ACCEL6_OFFSET_NOT_TRIGGER 0x00
448 #define ACCEL6_OFC_HP_X_ENABLE 0x04
449 #define ACCEL6_OFC_HP_Y_ENABLE 0x02
450 #define ACCEL6_OFC_HP_Z_ENABLE 0x01
457 #define ACCEL6_OFFSET_TARGET_Z_0g 0x00
458 #define ACCEL6_OFFSET_TARGET_Z_PLUS_1g 0x20
459 #define ACCEL6_OFFSET_TARGET_Z_MINUS_1g 0x40
460 #define ACCEL6_OFFSET_TARGET_Y_PLUS_1g 0x08
461 #define ACCEL6_OFFSET_TARGET_Y_MINUS_1g 0x10
462 #define ACCEL6_OFFSET_TARGET_X_PLUS_1g 0x02
463 #define ACCEL6_OFFSET_TARGET_X_MINUS_1g 0x04
464 #define ACCEL6_OFFSET_CUT_OFF_1Hz 0x00
465 #define ACCEL6_OFFSET_CUT_OFF_10Hz 0x01
472 #define ACCEL6_FIFO_MODE_BYPASS 0x00
473 #define ACCEL6_FIFO_MODE_FIFO 0x40
474 #define ACCEL6_FIFO_MODE_STREAM 0x80
475 #define ACCEL6_FIFO_SELECT_XYZ_AXIS 0x00
476 #define ACCEL6_FIFO_SELECT_X_AXIS 0x01
477 #define ACCEL6_FIFO_SELECT_Y_AXIS 0x02
478 #define ACCEL6_FIFO_SELECT_Z_AXIS 0x03
486 #define DEVICE_ERROR 0x04
487 #define DEVICE_OK 0x00
494 #define TAP_X_NEGATIVE 0x01
495 #define TAP_Y_NEGATIVE 0x02
496 #define TAP_Z_NEGATIVE 0x03
497 #define TAP_X_POSITIVE 0x04
498 #define TAP_Y_POSITIVE 0x05
499 #define TAP_Z_POSITIVE 0x06
507 #define SLOPE_X_NEGATIVE 0x01
508 #define SLOPE_Y_NEGATIVE 0x02
509 #define SLOPE_Z_NEGATIVE 0x03
510 #define SLOPE_X_POSITIVE 0x04
511 #define SLOPE_Y_POSITIVE 0x05
512 #define SLOPE_Z_POSITIVE 0x06
513 #define NON_SLOPE 0x00
520 #define Z_ORIENT_UPWARD_LOOKING 0x01
521 #define Z_ORIENT_DOWNWARD_LOOKING 0x02
522 #define XY_ORIENT_UPSIDE_DOWN 0x01
523 #define XY_ORIENT_LANDSCAPE_LEFT 0x02
524 #define XY_ORIENT_LANDSCAPE_RIGHT 0x03
525 #define XY_ORIENT_UPRIGHT 0x04
uint32_t spi_speed
Definition: accel6.h:588
void accel6_data_offset(accel6_t *ctx, uint8_t set_offset, float *offset_data)
Functions for set offset.
Click configuration structure definition.
Definition: accel6.h:574
float accel6_get_axis(accel6_t *ctx, uint8_t axis)
Functions for read axis data.
uint32_t i2c_speed
Definition: accel6.h:586
uint8_t i2c_address
Definition: accel6.h:587
pin_name_t sck
Definition: accel6.h:581
void accel6_generic_write(accel6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void accel6_generic_read(accel6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
pin_name_t miso
Definition: accel6.h:579
float accel6_get_temperature(accel6_t *ctx)
Functions for read temperature.
spi_master_t spi
Definition: accel6.h:555
pin_name_t scl
Definition: accel6.h:577
void accel6_get_orient(accel6_t *ctx, uint8_t *z_orient, uint8_t *xy_orient)
Functions for read orient.
void accel6_soft_reset(accel6_t *ctx)
Functions for software reset.
float device_freq
Definition: accel6.h:566
spi_master_chip_select_polarity_t cs_polarity
Definition: accel6.h:590
uint8_t accel6_select_t
Communication type.
Definition: accel6.h:538
i2c_master_t i2c
Definition: accel6.h:554
float device_gaus
Definition: accel6.h:565
void accel6_cfg_setup(accel6_cfg_t *cfg)
Config Object Initialization function.
uint8_t spi_mode
Definition: accel6.h:589
float dev_freq
Definition: accel6.h:595
ACCEL6_RETVAL accel6_init(accel6_t *ctx, accel6_cfg_t *cfg)
Initialization function.
accel6_select_t master_sel
Definition: accel6.h:563
void accel6_default_cfg(accel6_t *ctx, uint8_t range_data, uint8_t bw_data, uint8_t lpw_data)
Click Default Configuration function.
float dev_gaus
Definition: accel6.h:594
uint8_t slave_address
Definition: accel6.h:559
pin_name_t chip_select
Definition: accel6.h:560
pin_name_t cs
Definition: accel6.h:582
uint8_t accel6_get_slope_status(accel6_t *ctx)
Functions for detect slope on the x/y/z axis.
accel6_select_t sel
Definition: accel6.h:592
struct accel6_s accel6_t
Click ctx object definition.
accel6_master_io_t write_f
Definition: accel6.h:561
uint8_t accel6_get_tap_status(accel6_t *ctx)
Functions for detect tap on the x/y/z axis.
#define ACCEL6_RETVAL
Definition: accel6.h:89
void(* accel6_master_io_t)(struct accel6_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition: accel6.h:543
digital_out_t cs
Definition: accel6.h:550
Click ctx object definition.
Definition: accel6.h:549
accel6_master_io_t read_f
Definition: accel6.h:562
pin_name_t mosi
Definition: accel6.h:580
pin_name_t sda
Definition: accel6.h:578