Merge pull request #1269 from pkendall64/crsf-max-output
[ExpressLRS.git] / src / lib / GSENSOR / stk8baxx.h
blobaa890178e06152c6ad3649a51a0bc48ce87d92ef
1 #pragma once
3 #include "targets.h"
4 #include "Wire.h"
6 class STK8xxx
8 private:
9 void ReadAccRegister(uint8_t reg, uint8_t *data);
10 void WriteAccRegister(uint8_t reg, uint8_t data);
11 void STK8xxx_Suspend_mode();
12 bool STK8xxx_Check_chipid();
13 public:
14 void STK8xxx_Anymotion_init();
15 void STK8xxx_Sigmotion_init();
16 void STK8xxx_Disable_Motion();
17 int STK8xxx_Initialization();
18 int STK8xxx_Get_Sensitivity();
19 void STK8xxx_Getregister_data(float *X_DataOut, float *Y_DataOut, float *Z_DataOut);
22 #define STK8xxx_SLAVE_ADDRESS 0x18
24 #define STK_REG_CHIPID 0x00
25 /* STK8321 or STK8323 CHIP ID = 0x23 */
26 #define STK8xxx_CHIPID_VAL 0x23
27 #define STK8327_CHIPID_VAL 0x26
28 /* STK8BAxx */
29 /* S or R resolution = 10 bit */
30 #define STK8BA50_X_CHIPID_VAL 0x86
31 #define STK8BA5X_CHIPID_VAL 0x87
33 #define STK8xxx_REG_POWMODE 0x11
34 #define STK8xxx_VAL_SLEEP_05 0b0000
35 #define STK8xxx_VAL_SLEEP_1 0b0110
36 #define STK8xxx_VAL_SLEEP_2 0b0111
37 #define STK8xxx_VAL_SLEEP_4 0b1000
38 #define STK8xxx_VAL_SLEEP_6 0b1001
39 #define STK8xxx_VAL_SLEEP_10 0b1010
40 #define STK8xxx_VAL_SLEEP_25 0b1011
41 #define STK8xxx_VAL_SLEEP_50 0b1100
42 #define STK8xxx_VAL_SLEEP_100 0b1101
43 #define STK8xxx_VAL_SLEEP_500 0b1110
44 #define STK8xxx_VAL_SLEEP_1000 0b1111
45 #define STK8xxx_VAL_LOWPOWER bit(6)
46 #define STK8xxx_VAL_SUSPEND bit(7)
48 #define STK8xxx_REG_RANGESEL 0x0F
49 #define STK8xxx_RANGE_2G 0x03
50 #define STK8xxx_RANGE_4G 0x05
51 #define STK8xxx_RANGE_8G 0x08
53 #define STK8xxx_REG_XOUT1 0x02
54 #define STK8xxx_REG_XOUT2 0x03
55 #define STK8xxx_REG_YOUT1 0x04
56 #define STK8xxx_REG_YOUT2 0x05
57 #define STK8xxx_REG_ZOUT1 0x06
58 #define STK8xxx_REG_ZOUT2 0x07
60 #define STK8xxx_REG_BWSEL 0x10
61 #define STK8xxx_VAL_BW_7_81 0b01000
62 #define STK8xxx_VAL_BW_15_63 0b01001
63 #define STK8xxx_VAL_BW_31_25 0b01010
64 #define STK8xxx_VAL_BW_62_5 0b01011
65 #define STK8xxx_VAL_BW_125 0b01100
66 #define STK8xxx_VAL_BW_250 0b01101
67 #define STK8xxx_VAL_BW_500 0b01110
68 #define STK8xxx_VAL_BW_1000 0b01111
70 #define STK8xxx_REG_SWRST 0x14
71 #define STK8xxx_VAL_RST_DFLTS 0xB6
73 #define STK8xxx_REG_INTEN1 0x16
74 #define STK8xxx_VAL_SLP_EN_X bit(0)
75 #define STK8xxx_VAL_SLP_EN_Y bit(1)
76 #define STK8xxx_VAL_SLP_EN_Z bit(2)
78 #define STK8xxx_REG_INTCFG1 0x20
79 #define STK8xxx_VAL_INT_LV bit(0)
80 #define STK8xxx_VAL_INT_OD bit(1)
82 #define STK8xxx_REG_SLOPETHD 0x28
83 #define STK8xxx_VAL_SLP_DFLT 0x14
85 #define STK8xxx_REG_SIGMOT2 0x2A
86 #define STK8xxx_VAL_SKIP_TIME bit(0)
87 #define STK8xxx_VAL_SIG_MOT_EN bit(1)
88 #define STK8xxx_VAL_ANY_MOT_EN bit(2)
90 #define STK8xxx_REG_INTMAP1 0x19
91 #define STK8xxx_VAL_SIGMOT2INT1 bit(0)
92 #define STK8xxx_VAL_ANYMOT2INT1 bit(2)
94 #define STK8xxx_REG_INTFCFG 0x34
95 #define STK8xxx_VAL_I2C_WDT_SEL bit(1)
96 #define STK8xxx_VAL_I2C_WDT_EN bit(2)