123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- #ifndef LSM6DS3_H_
- #define LSM6DS3_H_
- #include "ets_sys.h"
- #include "driver/spi_interface.h"
- #define LSM6DS3_DEBUG 1
- #if LSM6DS3_DEBUG
- void lsm6ds3_xl_print(void);
- #endif
- #define LSM6DS3_BIT(x) ((uint16_t)x)
- #define LSM6DS3_FUNC_CFG_ACCESS 0x01
- #define LSM6DS3_FUNC_CFG_EN BIT7
- #define LSM6DS3_SENSOR_SYNC_TIME_FRAME 0x04
- #define LSM6DS3_FIFO_CTRL1 0x06
- #define LSM6DS3_FIFO_CTRL2 0x07
- #define LSM6DS3_FIFO_CTRL3 0x08
- #define LSM6DS3_FIFO_CTRL4 0x09
- #define LSM6DS3_FIFO_CTRL5 0x0A
- #define LSM6DS3_INT1_CTRL 0x0D
- #define LSM6DS3_INT2_CTRL 0x0E
- #define LSM6DS3_WHO_AM_I 0x0F
- #define LSM6DS3_CTRL1_XL 0x10
- #define LSM6DS3_ODR_XL_POWERDOWN 0x00
- #define LSM6DS3_ODR_XL_13Hz 0x10
- #define LSM6DS3_ODR_XL_26Hz 0x20
- #define LSM6DS3_ODR_XL_52Hz 0x30
- #define LSM6DS3_ODR_XL_104Hz 0x40
- #define LSM6DS3_ODR_XL_208Hz 0x50
- #define LSM6DS3_ODR_XL_416Hz 0x60
- #define LSM6DS3_ODR_XL_833Hz 0x70
- #define LSM6DS3_ODR_XL_1_66kHz 0x80
- #define LSM6DS3_ODR_XL_3_33_kHz 0x90
- #define LSM6DS3_ODR_XL_6_66_kHz 0xA0
- #define LSM6DS3_FS_XL_2G 0x00
- #define LSM6DS3_FS_XL_16G 0x04
- #define LSM6DS3_FS_XL_4G 0x08
- #define LSM6DS3_FS_XL_8G 0x0C
- #define LSM6DS3_BW_XL_400Hz 0x00
- #define LSM6DS3_BW_XL_200Hz 0x01
- #define LSM6DS3_BW_XL_100Hz 0x02
- #define LSM6DS3_BW_XL_50Hz 0x03
- #define LSM6DS3_CTRL2_G 0x11
- #define LSM6DS3_ODR_G_POWERDOWN 0x00
- #define LSM6DS3_ODR_G_13Hz 0x10
- #define LSM6DS3_ODR_G_26Hz 0x20
- #define LSM6DS3_ODR_G_52Hz 0x30
- #define LSM6DS3_ODR_G_104Hz 0x40
- #define LSM6DS3_ODR_G_208Hz 0x50
- #define LSM6DS3_ODR_G_416Hz 0x60
- #define LSM6DS3_ODR_G_833Hz 0x70
- #define LSM6DS3_ODR_G_1_66kHz 0x80
- #define LSM6DS3_FS_G_245DPS 0x00
- #define LSM6DS3_FS_G_500DPS 0x04
- #define LSM6DS3_FS_G_1000DPS 0x08
- #define LSM6DS3_FS_G_2000DPS 0x0C
- #define LSM6DS3_FS_125 0x02
- #define LSM6DS3_CTRL3_C 0x12
- #define LSM6DS3_BOOT BIT7
- #define LSM6DS3_BDU BIT6
- #define LSM6DS3_H_LACTIVE BIT5
- #define LSM6DS3_PP_OD BIT4
- #define LSM6DS3_SIM BIT3
- #define LSM6DS3_IF_INC BIT2
- #define LSM6DS3_BLE BIT1
- #define LSM6DS3_SW_RESET BIT0
- #define LSM6DS3_CTRL4_C 0x13
- #define LSM6DS3_XL_SCAL_ODR BIT7
- #define LSM6DS3_SLEEP_G BIT6
- #define LSM6DS3_INT2_ON_INT1 BIT5
- #define LSM6DS3_FIFO_TEMP_EN BIT4
- #define LSM6DS3_DRDY_MASK BIT3
- #define LSM6DS3_I2C_DISABLE BIT2
- #define LSM6DS3_MODE3_EN BIT1
- #define LSM6DS3_STOP_ON_FTH BIT0
- #define LSM6DS3_CTRL5_C 0x14
- #define LSM6DS3_CTRL6_C 0x15
- #define LSM6DS3_TRIG_EN BIT7
- #define LSM6DS3_LVLEN BIT6
- #define LSM6DS3_LVL2_EN BIT5
- #define LSM6DS3_XL_HM_MODE BIT4
- #define LSM6DS3_CTRL7_G 0x16
- #define LSM6DS3_G_HM_MODE BIT7
- #define LSM6DS3_HP_G_EN BIT6
- #define LSM6DS3_HP_G_RST BIT5
- #define LSM6DS3_ROUNDING_STATUS BIT4
- #define LSM6DS3_HPCF_G_0_081Hz 0x00
- #define LSM6DS3_HPCF_G_0_324Hz 0x01
- #define LSM6DS3_HPCF_G_2_070Hz 0x02
- #define LSM6DS3_HPCF_G_1_632Hz 0x03
- #define LSM6DS3_CTRL8_XL 0x17
- #define LSM6DS3_LPF2_XL_EN BIT7
- #define LSM6DS3_HPCF_XL_SLOPE_D50 0x00
- #define LSM6DS3_HPCF_XL_HP_D100 0x20
- #define LSM6DS3_HPCF_XL_HP_D9 0x40
- #define LSM6DS3_HPCF_XL_HPD400 0x60
- #define LSM6DS3_CTRL9_XL 0x18
- #define LSM6DS3_CTRL10_C 0x19
- #define LSM6DS3_Z_EN_G BIT5
- #define LSM6DS3_Y_EN_G BIT4
- #define LSM6DS3_X_EN_G BIT3
- #define LSM6DS3_FUNC_EN BIT2
- #define LSM6DS3_PEDO_RST_STEP BIT1
- #define LSM6DS3_SIGN_MOTION_EN BIT0
- #define LSM6DS3_ORIENT_CFG_G 0x0B
- #define LSM6DS3_MASTER_CONFIG 0x1A
- #define LSM6DS3_DRDY_ON_INT1 BIT7
- #define LSM6DS3_DATA_VALID_SEL_FIFO BIT6
- #define LSM6DS3_START_CONIFG BIT4
- #define LSM6DS3_PULL_UP_EN BIT3
- #define LSM6DS3_PASS_THROUGH_MODE BIT2
- #define LSM6DS3_IRON_EN BIT1
- #define LSM6DS3_MASTER_ON BIT0
- #define LSM6DS3_WAKE_UP_SRC 0x1B
- #define LSM6DS3_TAP_SRC 0x1C
- #define LSM6DS3_D6D_SRC 0x1D
- #define LSM6DS3_STATUS_REG 0x1E
- #define LSM6DS3_OUT_TEMP_L 0x20
- #define LSM6DS3_OUT_TEMP_H 0x21
- #define LSM6DS3_OUTX_L_G 0x22
- #define LSM6DS3_OUTX_H_G 0x23
- #define LSM6DS3_OUTY_L_G 0x24
- #define LSM6DS3_OUTY_H_G 0x25
- #define LSM6DS3_OUTZ_L_G 0x26
- #define LSM6DS3_OUTZ_H_G 0x27
- #define LSM6DS3_OUTX_L_XL 0x28
- #define LSM6DS3_OUTX_H_XL 0x29
- #define LSM6DS3_OUTY_L_XL 0x2A
- #define LSM6DS3_OUTY_H_XL 0x2B
- #define LSM6DS3_OUTZ_L_XL 0x2C
- #define LSM6DS3_OUTZ_H_XL 0x2D
- #define LSM6DS3_SENSORHUB1_REG 0x2E
- #define LSM6DS3_SENSORHUB2_REG 0x2F
- #define LSM6DS3_SENSORHUB3_REG 0x30
- #define LSM6DS3_SENSORHUB4_REG 0x31
- #define LSM6DS3_SENSORHUB5_REG 0x32
- #define LSM6DS3_SENSORHUB6_REG 0x33
- #define LSM6DS3_SENSORHUB7_REG 0x34
- #define LSM6DS3_SENSORHUB8_REG 0x35
- #define LSM6DS3_SENSORHUB9_REG 0x36
- #define LSM6DS3_SENSORHUB10_REG 0x37
- #define LSM6DS3_SENSORHUB11_REG 0x38
- #define LSM6DS3_SENSORHUB12_REG 0x39
- #define LSM6DS3_FIFO_STATUS1 0x3A
- #define LSM6DS3_FIFO_STATUS2 0x3B
- #define LSM6DS3_FIFO_EMPTY BIT4
- #define LSM6DS3_FIFO_FULL BIT5
- #define LSM6DS3_FIFO_OVER_RUN BIT6
- #define LSM6DS3_FIFO_THRESHOLD BIT7
- #define LSM6DS3_FIFO_STATUS3 0x3C
- #define LSM6DS3_FIFO_STATUS4 0x3D
- #define LSM6DS3_FIFO_DATA_OUT_L 0x3E
- #define LSM6DS3_FIFO_DATA_OUT_H 0x3F
- #define LSM6DS3_TIMESTAMP0_REG 0x40
- #define LSM6DS3_TIMESTAMP1_REG 0x41
- #define LSM6DS3_TIMESTAMP2_REG 0x42
- #define LSM6DS3_STEP_TIMESTAMP_L 0x49
- #define LSM6DS3_STEP_TIMESTAMP_H 0x4A
- #define LSM6DS3_STEP_COUNTER_L 0x4B
- #define LSM6DS3_STEP_COUNTER_H 0x4C
- #define LSM6DS3_SENSORHUB13_REG 0x4D
- #define LSM6DS3_SENSORHUB14_REG 0x4E
- #define LSM6DS3_SENSORHUB15_REG 0x4F
- #define LSM6DS3_SENSORHUB16_REG 0x50
- #define LSM6DS3_SENSORHUB17_REG 0x51
- #define LSM6DS3_SENSORHUB18_REG 0x52
- #define LSM6DS3_FUNC_SRC 0x53
- #define LSM6DS3_TAP_CFG 0x58
- #define LSM6DS3_TIMER_EN BIT7
- #define LSM6DS3_PEDO_EN BIT6
- #define LSM6DS3_TILT_EN BIT5
- #define LSM6DS3_SLOPE_FDS BIT4
- #define LSM6DS3_TAP_X_EN BIT3
- #define LSM6DS3_TAP_Y_EN BIT2
- #define LSM6DS3_TAP_Z_EN BIT1
- #define LSM6DS3_LIR BIT0
- #define LSM6DS3_TAP_THS_6D 0x59
- #define LSM6DS3_INT_DUR2 0x5A
- #define LSM6DS3_WAKE_UP_THS 0x5B
- #define LSM6DS3_SINGLE_DOUBLE_TAP BIT7
- #define LSM6DS3_INACTIVITY BIT6
- #define LSM6DS3_WAKE_UP_DUR 0x5C
- #define LSM6DS3_FF_DUR5 BIT7
- #define LSM6DS3_TIMER_HR BIT4
- #define LSM6DS3_FREE_FALL 0x5D
- #define LSM6DS3_MD1_CFG 0x5E
- #define LSM6DS3_INT1_WU BIT5
- #define LSM6DS3_MD2_CFG 0x5F
- #define LSM6DS3_INT2_WU BIT5
- #define LSM6DS3_OUT_MAG_RAW_X_L 0x66
- #define LSM6DS3_OUT_MAG_RAW_X_H 0x67
- #define LSM6DS3_OUT_MAG_RAW_Y_L 0x68
- #define LSM6DS3_OUT_MAG_RAW_Y_H 0x69
- #define LSM6DS3_OUT_MAG_RAW_Z_L 0x6A
- #define LSM6DS3_OUT_MAG_RAW_Z_H 0x6B
- typedef enum {
- LSM6DS3_NO_INT = 0,
- LSM6DS3_FIFO_FULL_INT,
- LSM6DS3_FIFO_OVERFLOW_INT,
- LSM6DS3_SIGN_MOTION_INT
- } LSM6DS3_Interrupt_et;
- int32_t LSM6DS3_Enable_I2C_Bridge(uint8_t enable);
- int32_t LSM6DS3_Enable_I2C_Pullups(uint8_t enable);
- void LSM6DS3_Reset(void);
- void LSM6DS3_EnableMotion(void);
- void LSM6DS3_DisableMotion(void);
- LSM6DS3_Interrupt_et LSM6DS3_Get_Interrupts(void);
- #endif
|