airmotion 2.1.0.0
airmotion.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef AIRMOTION_H
29#define AIRMOTION_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
53#include "spi_specifics.h"
54
80#define AIRMOTION_DEVICE_CONFIG 0x11
81#define AIRMOTION_DRIVE_CONFIG 0x13
82#define AIRMOTION_INT_CONFIG 0x14
83#define AIRMOTION_FIFO_CONFIG 0x16
84#define AIRMOTION_TEMP_DATA1 0x1D
85#define AIRMOTION_TEMP_DATA0 0x1E
86#define AIRMOTION_ACCEL_DATA_X1 0x1F
87#define AIRMOTION_ACCEL_DATA_X0 0x20
88#define AIRMOTION_ACCEL_DATA_Y1 0x21
89#define AIRMOTION_ACCEL_DATA_Y0 0x22
90#define AIRMOTION_ACCEL_DATA_Z1 0x23
91#define AIRMOTION_ACCEL_DATA_Z0 0x24
92#define AIRMOTION_GYRO_DATA_X1 0x25
93#define AIRMOTION_GYRO_DATA_X0 0x26
94#define AIRMOTION_GYRO_DATA_Y1 0x27
95#define AIRMOTION_GYRO_DATA_Y0 0x28
96#define AIRMOTION_GYRO_DATA_Z1 0x29
97#define AIRMOTION_GYRO_DATA_Z0 0x2A
98#define AIRMOTION_TMST_FSYNCH 0x2B
99#define AIRMOTION_TMST_FSYNCL 0x2C
100#define AIRMOTION_INT_STATUS 0x2D
101#define AIRMOTION_FIFO_COUNTH 0x2E
102#define AIRMOTION_FIFO_COUNTL 0x2F
103#define AIRMOTION_FIFO_DATA 0x30
104#define AIRMOTION_APEX_DATA0 0x31
105#define AIRMOTION_APEX_DATA1 0x32
106#define AIRMOTION_APEX_DATA2 0x33
107#define AIRMOTION_APEX_DATA3 0x34
108#define AIRMOTION_APEX_DATA4 0x35
109#define AIRMOTION_APEX_DATA5 0x36
110#define AIRMOTION_INT_STATUS2 0x37
111#define AIRMOTION_INT_STATUS3 0x38
112#define AIRMOTION_SIGNAL_PATH_RESET 0x4B
113#define AIRMOTION_INTF_CONFIG0 0x4C
114#define AIRMOTION_INTF_CONFIG1 0x4D
115#define AIRMOTION_PWR_MGMT0 0x4E
116#define AIRMOTION_GYRO_CONFIG0 0x4F
117#define AIRMOTION_ACCEL_CONFIG0 0x50
118#define AIRMOTION_GYRO_CONFIG1 0x51
119#define AIRMOTION_GYRO_ACCEL_CONFIG0 0x52
120#define AIRMOTION_ACCEL_CONFIG1 0x53
121#define AIRMOTION_TMST_CONFIG 0x54
122#define AIRMOTION_APEX_CONFIG0 0x56
123#define AIRMOTION_SMD_CONFIG 0x57
124#define AIRMOTION_FIFO_CONFIG1 0x5F
125#define AIRMOTION_FIFO_CONFIG2 0x60
126#define AIRMOTION_FIFO_CONFIG3 0x61
127#define AIRMOTION_FSYNC_CONFIG 0x62
128#define AIRMOTION_INT_CONFIG0 0x63
129#define AIRMOTION_INT_CONFIG1 0x64
130#define AIRMOTION_INT_SOURCE0 0x65
131#define AIRMOTION_INT_SOURCE1 0x66
132#define AIRMOTION_INT_SOURCE3 0x68
133#define AIRMOTION_INT_SOURCE4 0x69
134#define AIRMOTION_FIFO_LOST_PKT0 0x6C
135#define AIRMOTION_FIFO_LOST_PKT1 0x6D
136#define AIRMOTION_SELF_TEST_CONFIG 0x70
137#define AIRMOTION_WHO_AM_I 0x75
138#define AIRMOTION_REG_BANK_SEL 0x76
139
144#define AIRMOTION_SENSOR_CONFIG0 0x03
145#define AIRMOTION_GYRO_CONFIG_STATIC2 0x0B
146#define AIRMOTION_GYRO_CONFIG_STATIC3 0x0C
147#define AIRMOTION_GYRO_CONFIG_STATIC4 0x0D
148#define AIRMOTION_GYRO_CONFIG_STATIC5 0x0E
149#define AIRMOTION_GYRO_CONFIG_STATIC6 0x0F
150#define AIRMOTION_GYRO_CONFIG_STATIC7 0x10
151#define AIRMOTION_GYRO_CONFIG_STATIC8 0x11
152#define AIRMOTION_GYRO_CONFIG_STATIC9 0x12
153#define AIRMOTION_GYRO_CONFIG_STATIC10 0x13
154#define AIRMOTION_XG_ST_DATA 0x5F
155#define AIRMOTION_YG_ST_DATA 0x60
156#define AIRMOTION_ZG_ST_DATA 0x61
157#define AIRMOTION_TMSTVAL0 0x62
158#define AIRMOTION_TMSTVAL1 0x63
159#define AIRMOTION_TMSTVAL2 0x64
160#define AIRMOTION_INTF_CONFIG4 0x7A
161#define AIRMOTION_INTF_CONFIG5 0x7B
162
167#define AIRMOTION_ACCEL_CONFIG_STATIC2 0x03
168#define AIRMOTION_ACCEL_CONFIG_STATIC3 0x04
169#define AIRMOTION_ACCEL_CONFIG_STATIC4 0x05
170#define AIRMOTION_XA_ST_DATA 0x3B
171#define AIRMOTION_YA_ST_DATA 0x3C
172#define AIRMOTION_ZA_ST_DATA 0x3D
173
178#define AIRMOTION_APEX_CONFIG1 0x40
179#define AIRMOTION_APEX_CONFIG2 0x41
180#define AIRMOTION_APEX_CONFIG3 0x42
181#define AIRMOTION_APEX_CONFIG4 0x43
182#define AIRMOTION_APEX_CONFIG5 0x44
183#define AIRMOTION_APEX_CONFIG6 0x45
184#define AIRMOTION_APEX_CONFIG7 0x46
185#define AIRMOTION_APEX_CONFIG8 0x47
186#define AIRMOTION_APEX_CONFIG9 0x48
187#define AIRMOTION_ACCEL_WOM_X_THR 0x4A
188#define AIRMOTION_ACCEL_WOM_Y_THR 0x4B
189#define AIRMOTION_ACCEL_WOM_Z_THR 0x4C
190#define AIRMOTION_INT_SOURCE6 0x4D
191#define AIRMOTION_INT_SOURCE7 0x4E
192#define AIRMOTION_OFFSET_USER0 0x77
193#define AIRMOTION_OFFSET_USER1 0x78
194#define AIRMOTION_OFFSET_USER2 0x79
195#define AIRMOTION_OFFSET_USER3 0x7A
196#define AIRMOTION_OFFSET_USER4 0x7B
197#define AIRMOTION_OFFSET_USER5 0x7C
198#define AIRMOTION_OFFSET_USER6 0x7D
199#define AIRMOTION_OFFSET_USER7 0x7E
200#define AIRMOTION_OFFSET_USER8 0x7F
201
202 // airmotion_reg
203
220#define AIRMOTION_BANK0_SEL 0x00
221#define AIRMOTION_BANK1_SEL 0x01
222#define AIRMOTION_BANK2_SEL 0x02
223#define AIRMOTION_BANK3_SEL 0x03
224#define AIRMOTION_BANK4_SEL 0x04
225
230#define AIRMOTION_SLEW_RATE_60nS 0x00
231#define AIRMOTION_SLEW_RATE_36nS 0x01
232#define AIRMOTION_SLEW_RATE_18nS 0x02
233#define AIRMOTION_SLEW_RATE_12nS 0x03
234#define AIRMOTION_SLEW_RATE_6nS 0x04
235#define AIRMOTION_SLEW_RATE_2nS 0x05
236
241#define AIRMOTION_SPI_MODE0_MODE3 0x00
242#define AIRMOTION_SPI_MODE1_MODE2 0x01
243
244#define AIRMOTION_ENABLE_SW_RESET 0x01
245
250#define AIRMOTION_DMP_IDEL_FLAG 0x04
251#define AIRMOTION_ACTIVITY_UNKNOWN 0x00
252#define AIRMOTION_ACTIVITY_WALK 0x01
253#define AIRMOTION_ACTIVITY_RUN 0x02
254#define AIRMOTION_ACTIVITY_MASK 0x03
255
256#define AIRMOTION_TAP_NUM_MASK 0x18
257#define AIRMOTION_TAP_SINGLE 0x08
258#define AIRMOTION_TAP_DOUBLE 0x10
259#define AIRMOTION_TAP_AXIS_MASK 0x06
260#define AIRMOTION_TAP_AXIS_X 0x00
261#define AIRMOTION_TAP_AXIS_Y 0x02
262#define AIRMOTION_TAP_AXIS_Z 0x04
263#define AIRMOTION_TAP_DIR_MASK 0x01
264#define AIRMOTION_TAP_DIR_POSITIVE 0x00
265#define AIRMOTION_TAP_DIR_NEGATIVE 0x01
266
271#define AIRMOTION_INT_INT2_MODE_PULSED 0x00
272#define AIRMOTION_INT_INT2_MODE_LATCHED 0x20
273#define AIRMOTION_INT_INT2_OPEN_DRAIN 0x00
274#define AIRMOTION_INT_INT2_PUSH_PULL 0x10
275#define AIRMOTION_INT_INT2_ACTIVE_LOW 0x00
276#define AIRMOTION_INT_INT2_ACTIVE_HIGH 0x08
277#define AIRMOTION_INT_INT1_MODE_PULSED 0x00
278#define AIRMOTION_INT_INT1_MODE_LATCHED 0x04
279#define AIRMOTION_INT_INT1_OPEN_DRAIN 0x00
280#define AIRMOTION_INT_INT1_PUSH_PULL 0x02
281#define AIRMOTION_INT_INT1_ACTIVE_LOW 0x00
282#define AIRMOTION_INT_INT1_ACTIVE_HIGH 0x01
283#define AIRMOTION_INT_CONFIG_MASK 0x3F
284
289#define AIRMOTION_DRDY_INT_CLR_ON_STATUS_READ 0x00
290#define AIRMOTION_DRDY_INT_CLR_FIFO_READ 0x20
291#define AIRMOTION_DRDY_INT_CLR_STATUS_AND_REG 0x30
292#define AIRMOTION_FIFO_INT_CLR_ON_STATUS_READ 0x00
293#define AIRMOTION_FIFO_INT_CLR_FIFO_READ 0x80
294#define AIRMOTION_FIFO_INT_CLR_STATUS_AND_REG 0xc0
295#define AIRMOTION_FIFO_FULL_CLR_ON_STATUS_READ 0x00
296#define AIRMOTION_FIFO_FULL_CLR_FIFO_READ 0x02
297#define AIRMOTION_FIFO_FULL_CLR_STATUS_AND_REG 0x03
298
303#define AIRMOTION_INT_TPULSE_100uS 0x00
304#define AIRMOTION_INT_TPULSE_8uS 0x40
305#define AIRMOTION_INT_TDEASSERT_DISABLE 0x20
306#define AIRMOTION_INT_ASYNC_RESET_DISABLE 0x10
307#define AIRMOTION_INT_ASYNC_RESET_ENABLE 0x00
308#define AIRMOTION_INT_CONFIG1_MASK 0x70
309
314#define AIRMOTION_INT_UI_FSYNC_INT1_EN 0x40
315#define AIRMOTION_INT_PLL_RDY_INT1_EN 0x20
316#define AIRMOTION_INT_RESET_DONE_INT1_EN 0x10
317#define AIRMOTION_INT_UI_DRDY_INT1_EN 0x08
318#define AIRMOTION_INT_FIFO_THS_INT1_EN 0x04
319#define AIRMOTION_INT_FIFO_FULL_INT1_EN 0x02
320#define AIRMOTION_INT_UI_AGC_RDY_INT1_EN 0x01
321#define AIRMOTION_INT_SOURCE0_MASK 0x7F
322
327#define AIRMOTION_SMD_INT1_EN 0x08
328#define AIRMOTION_WOM_Z_INT1_EN 0x04
329#define AIRMOTION_WOM_Y_INT1_EN 0x02
330#define AIRMOTION_WOM_X_INT1_EN 0x01
331#define AIRMOTION_INT_SOURCE1_MASK 0x0F
332
337#define AIRMOTION_INT_UI_FSYNC_INT2_EN 0x40
338#define AIRMOTION_INT_PLL_RDY_INT2_EN 0x20
339#define AIRMOTION_INT_RESET_DONE_INT2_EN 0x10
340#define AIRMOTION_INT_UI_DRDY_INT2_EN 0x08
341#define AIRMOTION_INT_FIFO_THS_INT2_EN 0x04
342#define AIRMOTION_INT_FIFO_FULL_INT2_EN 0x02
343#define AIRMOTION_INT_UI_AGC_RDY_INT2_EN 0x01
344#define AIRMOTION_INT_SOURCE3_MASK 0x7F
345
350#define AIRMOTION_SMD_INT2_EN 0x08
351#define AIRMOTION_WOM_Z_INT2_EN 0x04
352#define AIRMOTION_WOM_Y_INT2_EN 0x02
353#define AIRMOTION_WOM_X_INT2_EN 0x01
354#define AIRMOTION_INT_SOURCE4_MASK 0x0F
355
360#define AIRMOTION_INT_SOURCE6_STEP_DET_INT1_EN 0x20
361#define AIRMOTION_INT_SOURCE6_STEP_CNT_INT1_EN 0x10
362#define AIRMOTION_INT_SOURCE6_TILT_DET_INT1_EN 0x08
363#define AIRMOTION_INT_SOURCE6_TAP_DET_INT1_EN 0x01
364#define AIRMOTION_INT_SOURCE6_MASK 0x39
365
370#define AIRMOTION_INT_SOURCE7_STEP_DET_INT2_EN 0x20
371#define AIRMOTION_INT_SOURCE7_STEP_CNT_INT2_EN 0x10
372#define AIRMOTION_INT_SOURCE7_TILT_DET_INT2_EN 0x08
373#define AIRMOTION_INT_SOURCE7_TAP_DET_INT2_EN 0x01
374#define AIRMOTION_INT_SOURCE7_MASK 0x39
375
380#define AIRMOTION_UI_FSYNC_INT_FLAG 0x40
381#define AIRMOTION_PLL_DONE_INT_FLAG 0x20
382#define AIRMOTION_RESET_DONE_INT_FLAG 0x10
383#define AIRMOTION_DATA_RDY_INT_FLAG 0x08
384#define AIRMOTION_FIFO_THS_INT_FLAG 0x04
385#define AIRMOTION_FIFO_FULL_INT_FLAG 0x02
386#define AIRMOTION_AGC_RDY_INT_FLAG 0x01
387
392#define AIRMOTION_SMD_INT_FLAG 0x08
393#define AIRMOTION_WOM_Z_INT_FLAG 0x04
394#define AIRMOTION_WOM_Y_INT_FLAG 0x02
395#define AIRMOTION_WOM_X_INT_FLAG 0x01
396
401#define AIRMOTION_STEP_DET_INT_FLAG 0x10
402#define AIRMOTION_STEP_CNT_OVF_INT_FLAG 0x08
403#define AIRMOTION_TILT_DET_INT_FLAG 0x04
404#define AIRMOTION_SLEEP_INT_FLAG 0x02
405#define AIRMOTION_TAP_DET_INT_FLAG 0x01
406
411#define AIRMOTION_FIFO_HLD_LAST_DATA_EN 0x80
412#define AIRMOTION_FIFO_COUNT_REC 0x40
413#define AIRMOTION_FIFO_COUNT_ENDIAN 0x20
414#define AIRMOTION_FIFO_DATA_ENDIAN 0x10
415#define AIRMOTION_UI_SIFS_CFG_DISABLE_I2C 0x03
416#define AIRMOTION_UI_SIFS_CFG_DISABLE_SPI 0x02
417#define AIRMOTION_INTF_CONFIG0_MASK 0xF3
418
423#define AIRMOTION_ACCEL_LP_CLK_SEL_WAKE_UP_OSC 0x00
424#define AIRMOTION_ACCEL_LP_CLK_SEL_RC_OSC 0x08
425#define AIRMOTION_ACCEL_CLKSEL_RC 0x00
426#define AIRMOTION_ACCEL_CLKSEL_PLL_OR_RC 0x01
427#define AIRMOTION_ACCEL_CLKSEL_DISABLE 0x03
428
433#define AIRMOTION_SPI_3WIRE 0x00
434#define AIRMOTION_SPI_4WIRE 0x02
435
440#define AIRMOTION_PIN9_INT2 0x00
441#define AIRMOTION_PIN9_FSYNC 0x01
442
447#define AIRMOTION_DMP_INIT_EN 0x40
448#define AIRMOTION_DMP_MEM_RESET_EN 0x20
449#define AIRMOTION_ABORT_AND_RESET 0x08
450#define AIRMOTION_TMST_STROBE 0x04
451#define AIRMOTION_FIFO_FLUSH 0x02
452
457#define AIRMOTION_PWR_TEMP_DIS 0x20
458#define AIRMOTION_PWR_IDLE_OFF 0x10
459#define AIRMOTION_PWR_GYRO_MODE_OFF 0x00
460#define AIRMOTION_PWR_GYRO_STANDBY 0x04
461#define AIRMOTION_PWR_GYRO_LN_MODE 0x0C
462#define AIRMOTION_PWR_ACCEL_MODE_OFF 0x00
463#define AIRMOTION_PWR_ACCEL_LP_MODE 0x02
464#define AIRMOTION_PWR_ACCEL_LN_MODE 0x03
465
470#define AIRMOTION_GYRO_FS_SEL_2000DPS 0x00
471#define AIRMOTION_GYRO_FS_SEL_1000DPS 0x20
472#define AIRMOTION_GYRO_FS_SEL_500DPS 0x40
473#define AIRMOTION_GYRO_FS_SEL_250DPS 0x60
474#define AIRMOTION_GYRO_FS_SEL_125DPS 0x80
475#define AIRMOTION_GYRO_FS_SEL_62DPS 0xA0
476#define AIRMOTION_GYRO_FS_SEL_32DPS 0xC0
477#define AIRMOTION_GYRO_FS_SEL_15DPS 0xE0
478#define AIRMOTION_GYRO_FS_SEL_MASK 0xE0
479#define AIRMOTION_GYRO_ODR_8kHz 0x03
480#define AIRMOTION_GYRO_ODR_4kHz 0x04
481#define AIRMOTION_GYRO_ODR_2kHz 0x05
482#define AIRMOTION_GYRO_ODR_1kHz 0x06
483#define AIRMOTION_GYRO_ODR_200Hz 0x07
484#define AIRMOTION_GYRO_ODR_100Hz 0x08
485#define AIRMOTION_GYRO_ODR_50Hz 0x09
486#define AIRMOTION_GYRO_ODR_25Hz 0x0A
487#define AIRMOTION_GYRO_ODR_12Hz 0x0B
488#define AIRMOTION_GYRO_ODR_500Hz 0x0F
489#define AIRMOTION_GYRO_ODR_MASK 0x0F
490#define AIRMOTION_GYRO_ODR_MASK 0x0F
491
496#define AIRMOTION_TEMP_FILT_BW_4kHz 0x00
497#define AIRMOTION_TEMP_FILT_BW_170Hz 0x20
498#define AIRMOTION_TEMP_FILT_BW_82Hz 0x40
499#define AIRMOTION_TEMP_FILT_BW_40Hz 0x60
500#define AIRMOTION_TEMP_FILT_BW_20Hz 0x80
501#define AIRMOTION_TEMP_FILT_BW_10Hz 0xA0
502#define AIRMOTION_TEMP_FILT_BW_5Hz_0 0xC0
503#define AIRMOTION_TEMP_FILT_BW_5Hz_1 0xE0
504#define AIRMOTION_GYRO_UI_FILT_ORD_1st 0x00
505#define AIRMOTION_GYRO_UI_FILT_ORD_2nd 0x04
506#define AIRMOTION_GYRO_UI_FILT_ORD_3rd 0x08
507#define AIRMOTION_GYRO_UI_FILT_ORD_MASK 0x0C
508#define AIRMOTION_GYRO_DEC2_M2_ORD_3rd 0x02
509#define AIRMOTION_GYRO_CONFIG1_MASK 0xEF
510
515#define AIRMOTION_ACCEL_FS_SEL_16G 0x00
516#define AIRMOTION_ACCEL_FS_SEL_8G 0x20
517#define AIRMOTION_ACCEL_FS_SEL_4G 0x40
518#define AIRMOTION_ACCEL_FS_SEL_2G 0x60
519#define AIRMOTION_ACCEL_FS_SEL_MASK 0x60
520#define AIRMOTION_ACCEL_ODR_8kHz_LN 0x03
521#define AIRMOTION_ACCEL_ODR_4kHz_LN 0x04
522#define AIRMOTION_ACCEL_ODR_2kHz_LN 0x05
523#define AIRMOTION_ACCEL_ODR_1kHz_LN 0x06
524#define AIRMOTION_ACCEL_ODR_200Hz_LP_LN 0x07
525#define AIRMOTION_ACCEL_ODR_100Hz_LP_LN 0x08
526#define AIRMOTION_ACCEL_ODR_50Hz_LP_LN 0x09
527#define AIRMOTION_ACCEL_ODR_25Hz_LP_LN 0x0A
528#define AIRMOTION_ACCEL_ODR_12Hz_LP_LN 0x0B
529#define AIRMOTION_ACCEL_ODR_6Hz_LP 0x0C
530#define AIRMOTION_ACCEL_ODR_3Hz_LP 0x0D
531#define AIRMOTION_ACCEL_ODR_1Hz_LP 0x0E
532#define AIRMOTION_ACCEL_ODR_500Hz_LP_LN 0x0F
533#define AIRMOTION_ACCEL_ODR_MASK 0x0F
534
539#define AIRMOTION_ACCEL_UI_FILT_ORD_1st 0x00
540#define AIRMOTION_ACCEL_UI_FILT_ORD_2nd 0x08
541#define AIRMOTION_ACCEL_UI_FILT_ORD_3rd 0x10
542#define AIRMOTION_ACCEL_UI_FILT_ORD_MASK 0x18
543#define AIRMOTION_ACCEL_DEC2_M2_ORD_3rd 0x04
544
549#define AIRMOTION_TMST_TO_REGS_EN 0x10
550#define AIRMOTION_TMST_RES 0x08
551#define AIRMOTION_TMST_DELTA_EN 0x04
552#define AIRMOTION_TMST_FSYNC_EN 0x02
553#define AIRMOTION_TMST_EN 0x01
554#define AIRMOTION_TMST_MASK 0x1F
555
560#define AIRMOTION_FIFO_BYPASS 0x00
561#define AIRMOTION_FIFO_STREAM_TO_FIFO 0x40
562#define AIRMOTION_FIFO_STOP_ON_FULL 0x80
563#define AIRMOTION_FIFO_CONFIG_MASK 0xC0
564
569#define AIRMOTION_FIFO_RESUME_PARTIAL_RD 0x40
570#define AIRMOTION_FIFO_WM_GT_TH 0x20
571#define AIRMOTION_FIFO_TMST_FSYNC_EN 0x08
572#define AIRMOTION_FIFO_TEMP_EN 0x04
573#define AIRMOTION_FIFO_GYRO_EN 0x02
574#define AIRMOTION_FIFO_ACCEL_EN 0x01
575
580#define AIRMOTION_DO_NOT_TAG_FSYNC 0x00
581#define AIRMOTION_FSYNC_TAG_TEMP_OUT_LSB 0x10
582#define AIRMOTION_FSYNC_GYRO_XOUT_LSB 0x20
583#define AIRMOTION_FSYNC_GYRO_YOUT_LSB 0x30
584#define AIRMOTION_FSYNC_GYRO_ZOUT_LSB 0x40
585#define AIRMOTION_FSYNC_ACCEL_XOUT_LSB 0x50
586#define AIRMOTION_FSYNC_ACCEL_YOUT_LSB 0x60
587#define AIRMOTION_FSYNC_ACCEL_ZOUT_LSB 0x70
588#define AIRMOTION_FSYNC_UI_SEL_MASK 0x70
589#define AIRMOTION_FSYNC_UI_FLAG_CLEAR_SEL 0x02
590#define AIRMOTION_FSYNC_POLARITY_RISING_EGDE 0x01
591#define AIRMOTION_FSYNC_POLARITY_FALLING_EGDE 0x01
592
597#define AIRMOTION_DMP_POVER_SAVE_EN 0x80
598#define AIRMOTION_TAP_ENABLE 0x40
599#define AIRMOTION_PED_ENABLE 0x20
600#define AIRMOTION_TILT_ENABLE 0x10
601#define AIRMOTION_R2W_ENABLE 0x08
602#define AIRMOTION_DMP_ODR_25Hz 0x00
603#define AIRMOTION_DMP_ODR_50Hz 0x02
604
609#define AIRMOTION_LOW_ENERGY_AMP_TH_SEL 0xA0
610#define AIRMOTION_DMP_POVER_SAVE_TIME_0S 0x00
611#define AIRMOTION_DMP_POVER_SAVE_TIME_4S 0x01
612#define AIRMOTION_DMP_POWER_SAVE_TIME_8S 0x02
613#define AIRMOTION_DMP_POWER_SAVE_TIME_12S 0x03
614#define AIRMOTION_DMP_POWER_SAVE_TIME_16S 0x04
615#define AIRMOTION_DMP_POWER_SAVE_TIME_20S 0x05
616#define AIRMOTION_DMP_POWER_SAVE_TIME_24S 0x06
617#define AIRMOTION_DMP_POWER_SAVE_TIME_28S 0x07
618#define AIRMOTION_DMP_POWER_SAVE_TIME_32S 0x08
619#define AIRMOTION_DMP_POWER_SAVE_TIME_36S 0x09
620#define AIRMOTION_DMP_POWER_SAVE_TIME_40S 0x0A
621#define AIRMOTION_DMP_POWER_SAVE_TIME_44S 0x0B
622#define AIRMOTION_DMP_POWER_SAVE_TIME_48S 0x0C
623#define AIRMOTION_DMP_POWER_SAVE_TIME_52S 0x0D
624#define AIRMOTION_DMP_POWER_SAVE_TIME_56S 0x0E
625#define AIRMOTION_DMP_POWER_SAVE_TIME_60S 0x0F
626
631#define AIRMOTION_PED_AMP_TH_SEL 0x80
632#define AIRMOTION_PED_STEP_CNT_TH_0_STEPS 0x00
633#define AIRMOTION_PED_STEP_CNT_TH_1_STEPS 0x01
634#define AIRMOTION_PED_STEP_CNT_TH_2_STEPS 0x02
635#define AIRMOTION_PED_STEP_CNT_TH_3_STEPS 0x03
636#define AIRMOTION_PED_STEP_CNT_TH_4_STEPS 0x04
637#define AIRMOTION_PED_STEP_CNT_TH_5_STEPS 0x05
638#define AIRMOTION_PED_STEP_CNT_TH_6_STEPS 0x06
639#define AIRMOTION_PED_STEP_CNT_TH_7_STEPS 0x07
640#define AIRMOTION_PED_STEP_CNT_TH_8_STEPS 0x08
641#define AIRMOTION_PED_STEP_CNT_TH_9_STEPS 0x09
642#define AIRMOTION_PED_STEP_CNT_TH_10_STEPS 0x0A
643#define AIRMOTION_PED_STEP_CNT_TH_11_STEPS 0x0B
644#define AIRMOTION_PED_STEP_CNT_TH_12_STEPS 0x0C
645#define AIRMOTION_PED_STEP_CNT_TH_13_STEPS 0x0D
646#define AIRMOTION_PED_STEP_CNT_TH_14_STEPS 0x0E
647#define AIRMOTION_PED_STEP_CNT_TH_15_STEPS 0x0F
648#define AIRMOTION_PED_STEP_CNT_TH_MASK 0x0F
649
654#define AIRMOTION_PED_STEP_DET_TH_0_STEPS 0x00
655#define AIRMOTION_PED_STEP_DET_TH_1_STEPS 0x20
656#define AIRMOTION_PED_STEP_DET_TH_2_STEPS 0x40
657#define AIRMOTION_PED_STEP_DET_TH_3_STEPS 0x60
658#define AIRMOTION_PED_STEP_DET_TH_4_STEPS 0x80
659#define AIRMOTION_PED_STEP_DET_TH_5_STEPS 0xA0
660#define AIRMOTION_PED_STEP_DET_TH_6_STEPS 0xC0
661#define AIRMOTION_PED_STEP_DET_TH_7_STEPS 0xE0
662#define AIRMOTION_PED_SB_TIMER_TH_0_SAMPLES 0x00
663#define AIRMOTION_PED_SB_TIMER_TH_1_SAMPLES 0x04
664#define AIRMOTION_PED_SB_TIMER_TH_2_SAMPLES 0x08
665#define AIRMOTION_PED_SB_TIMER_TH_3_SAMPLES 0x0C
666#define AIRMOTION_PED_SB_TIMER_TH_4_SAMPLES 0x10
667#define AIRMOTION_PED_SB_TIMER_TH_5_SAMPLES 0x14
668#define AIRMOTION_PED_SB_TIMER_TH_6_SAMPLES 0x18
669#define AIRMOTION_PED_SB_TIMER_TH_7_SAMPLES 0x1C
670#define AIRMOTION_PED_HI_EN_TH_SEL 0x01
671
676#define AIRMOTION_TILT_WAIT_TIME_0S 0x00
677#define AIRMOTION_TILT_WAIT_TIME_2S 0x40
678#define AIRMOTION_TILT_WAIT_TIME_4S 0x80
679#define AIRMOTION_TILT_WAIT_TIME_6S 0xC0
680#define AIRMOTION_TILT_WAIT_TIME_MASK 0xC0
681#define AIRMOTION_SLEEP_TIME_OUT_1s28 0x00
682#define AIRMOTION_SLEEP_TIME_OUT_2s56 0x08
683#define AIRMOTION_SLEEP_TIME_OUT_3s84 0x10
684#define AIRMOTION_SLEEP_TIME_OUT_5s12 0x18
685#define AIRMOTION_SLEEP_TIME_OUT_6s4 0x20
686#define AIRMOTION_SLEEP_TIME_OUT_7s68 0x28
687#define AIRMOTION_SLEEP_TIME_OUT_8s96 0x30
688#define AIRMOTION_SLEEP_TIME_OUT_10s24 0x38
689#define AIRMOTION_SLEEP_TIME_OUT_MASK 0x38
690
695#define AIRMOTION_TAP_MIN_JERK_THR 0x44
696#define AIRMOTION_TAP_MAX_OEAK_TOL 0x01
697
702#define AIRMOTION_TAP_TMAX 0x20
703#define AIRMOTION_TAP_TAVG 0x08
704#define AIRMOTION_TAP_TMIN 0x03
705
710#define AIRMOTION_SENSITIVITY_MODE_HIGH_PERF 0x00
711#define AIRMOTION_SENSITIVITY_MODE_SLOW_WALK 0x01
712
718#define AIRMOTION_DEVICE_ADDRESS_GND 0x68
719#define AIRMOTION_DEVICE_ADDRESS_VCC 0x69
720
729#define AIRMOTION_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
730#define AIRMOTION_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
731
732 // airmotion_set
733
748#define AIRMOTION_MAP_MIKROBUS( cfg, mikrobus ) \
749 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
750 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
751 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
752 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
753 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
754 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
755 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
756 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
757
758 // airmotion_map
759 // airmotion
760
771
776typedef err_t ( *airmotion_master_io_t )( struct airmotion_s*, uint8_t, uint8_t*, uint8_t );
782typedef struct airmotion_s
783{
784 digital_in_t an;
785 digital_in_t int_pin;
787 i2c_master_t i2c;
788 spi_master_t spi;
791 pin_name_t chip_select;
792 spi_master_mode_t spi_mode;
793 uint8_t slew_rate;
800
805typedef struct
806{
807 pin_name_t scl;
808 pin_name_t sda;
809 pin_name_t miso;
810 pin_name_t mosi;
811 pin_name_t sck;
812 pin_name_t cs;
813 pin_name_t an;
814 pin_name_t int_pin;
816 uint32_t i2c_speed;
817 uint8_t i2c_address;
819 uint32_t spi_speed;
820 spi_master_mode_t spi_mode;
821 spi_master_chip_select_polarity_t cs_polarity;
826
827typedef struct
828{
829 int16_t data_x;
830 int16_t data_y;
831 int16_t data_z;
832
834
835
847
864
880
895
909
924err_t airmotion_generic_write ( airmotion_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
925
940err_t airmotion_generic_read ( airmotion_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
941
954err_t airmotion_set_reg_bank( airmotion_t *ctx, uint8_t bank );
955
972err_t airmotion_reg_write ( airmotion_t *ctx, uint8_t reg_bank, uint8_t reg, uint8_t *data_in, uint8_t len );
973
988err_t airmotion_reg_read ( airmotion_t *ctx, uint8_t reg_bank, uint8_t reg, uint8_t *data_out, uint8_t len );
989
1001err_t airmotion_configure_digital_interface ( airmotion_t *ctx, uint8_t slew_rate );
1002
1012
1021uint8_t airmotion_get_int1_state ( airmotion_t *ctx );
1022
1035
1048err_t airmotion_read_temperature ( airmotion_t *ctx, float *temperature_data );
1049
1062err_t airmotion_read_timestamp ( airmotion_t *ctx, uint32_t *tmst_data );
1063
1079err_t airmotion_get_data_from_register ( airmotion_t *ctx, float *temperature_data,
1080 airmotion_data_t *accel_data, airmotion_data_t *gyro_data,
1081 uint32_t *tmst_data );
1082
1094
1108err_t airmotion_get_tap_detection ( airmotion_t *ctx, uint8_t *tap_num, uint8_t *tap_axis, uint8_t *tap_dir );
1109
1110#ifdef __cplusplus
1111}
1112#endif
1113#endif // AIRMOTION_H
1114
1115 // airmotion
1116
1117// ------------------------------------------------------------------------ END
err_t(* airmotion_master_io_t)(struct airmotion_s *, uint8_t, uint8_t *, uint8_t)
Air Motion Click driver interface.
Definition airmotion.h:776
airmotion_return_value_t
Air Motion Click return value data.
Definition airmotion.h:841
@ AIRMOTION_ERROR
Definition airmotion.h:843
@ AIRMOTION_OK
Definition airmotion.h:842
@ AIRMOTION_RESET_ERROR
Definition airmotion.h:844
airmotion_drv_t
Air Motion Click driver selector.
Definition airmotion.h:766
@ AIRMOTION_DRV_SEL_SPI
Definition airmotion.h:767
@ AIRMOTION_DRV_SEL_I2C
Definition airmotion.h:768
struct airmotion_s airmotion_t
Air Motion Click context object.
err_t airmotion_sw_reset(airmotion_t *ctx)
Air Motion software reset function.
err_t airmotion_init(airmotion_t *ctx, airmotion_cfg_t *cfg)
Air Motion initialization function.
err_t airmotion_get_data_from_register(airmotion_t *ctx, float *temperature_data, airmotion_data_t *accel_data, airmotion_data_t *gyro_data, uint32_t *tmst_data)
Air Motion read data function.
err_t airmotion_generic_write(airmotion_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Air Motion data writing function.
err_t airmotion_default_cfg(airmotion_t *ctx)
Air Motion default configuration function.
err_t airmotion_set_basic_tap_detection(airmotion_t *ctx)
Air Motion basic tap detection configuration function.
err_t airmotion_read_temperature(airmotion_t *ctx, float *temperature_data)
Air Motion read temperature function.
void airmotion_cfg_setup(airmotion_cfg_t *cfg)
Air Motion configuration object setup function.
void airmotion_drv_interface_selection(airmotion_cfg_t *cfg, airmotion_drv_t drv_sel)
Air Motion driver interface setup function.
uint8_t airmotion_get_int1_state(airmotion_t *ctx)
Air Motion read INT1 pin state function.
err_t airmotion_set_reg_bank(airmotion_t *ctx, uint8_t bank)
Air Motion set register bank function.
err_t airmotion_reg_write(airmotion_t *ctx, uint8_t reg_bank, uint8_t reg, uint8_t *data_in, uint8_t len)
Air Motion register data writing function.
err_t airmotion_get_tap_detection(airmotion_t *ctx, uint8_t *tap_num, uint8_t *tap_axis, uint8_t *tap_dir)
Air Motion get tap detection data function.
err_t airmotion_configure_digital_interface(airmotion_t *ctx, uint8_t slew_rate)
Air Motion configure digital interface function.
err_t airmotion_reg_read(airmotion_t *ctx, uint8_t reg_bank, uint8_t reg, uint8_t *data_out, uint8_t len)
Air Motion data reading function.
err_t airmotion_generic_read(airmotion_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Air Motion data reading function.
err_t airmotion_read_timestamp(airmotion_t *ctx, uint32_t *tmst_data)
Air Motion read timestamp function.
This file contains SPI specific macros, functions, etc.
Air Motion Click configuration object.
Definition airmotion.h:806
uint32_t i2c_speed
Definition airmotion.h:816
spi_master_chip_select_polarity_t cs_polarity
Definition airmotion.h:821
pin_name_t sck
Definition airmotion.h:811
spi_master_mode_t spi_mode
Definition airmotion.h:820
pin_name_t mosi
Definition airmotion.h:810
uint32_t spi_speed
Definition airmotion.h:819
pin_name_t scl
Definition airmotion.h:807
pin_name_t int_pin
Definition airmotion.h:814
pin_name_t miso
Definition airmotion.h:809
pin_name_t sda
Definition airmotion.h:808
airmotion_drv_t drv_sel
Definition airmotion.h:823
pin_name_t an
Definition airmotion.h:813
pin_name_t cs
Definition airmotion.h:812
uint8_t i2c_address
Definition airmotion.h:817
Definition airmotion.h:828
int16_t data_y
Definition airmotion.h:830
int16_t data_z
Definition airmotion.h:831
int16_t data_x
Definition airmotion.h:829
Air Motion Click context object.
Definition airmotion.h:783
airmotion_master_io_t write_f
Definition airmotion.h:796
airmotion_master_io_t read_f
Definition airmotion.h:797
spi_master_t spi
Definition airmotion.h:788
uint8_t slew_rate
Definition airmotion.h:793
spi_master_mode_t spi_mode
Definition airmotion.h:792
digital_in_t int_pin
Definition airmotion.h:785
i2c_master_t i2c
Definition airmotion.h:787
digital_in_t an
Definition airmotion.h:784
uint8_t slave_address
Definition airmotion.h:790
airmotion_drv_t drv_sel
Definition airmotion.h:794
pin_name_t chip_select
Definition airmotion.h:791