49 #define ACCREG_CTRL1 0x20
50 #define ACCREG_CTRL4 0x23
51 #define ACCREG_XL 0x28
62 Error accWriteRegister(uint8_t reg, uint8_t val) {
104 static double accSumX = 0;
105 static double accSumY = 0;
106 static double accSumZ = 0;
107 static double accFilterX = 0;
108 static double accFilterY = 0;
109 static double accFilterZ = 0;
131 int16_t x = *(int8_t *)(&xh);
135 int16_t y = *(int8_t *)(&yh);
139 int16_t z = *(int8_t *)(&zh);
145 v->
x = (((double)x) * 2 / 0x8000);
146 v->
y = (((double)y) * 2 / 0x8000);
147 v->
z = (((double)z) * 2 / 0x8000);
150 v->
x = (((double)x) * 4 / 0x8000);
151 v->
y = (((double)y) * 4 / 0x8000);
152 v->
z = (((double)z) * 4 / 0x8000);
155 v->
x = (((double)x) * 8 / 0x8000);
156 v->
y = (((double)y) * 8 / 0x8000);
157 v->
z = (((double)z) * 8 / 0x8000);
160 v->
x = (((double)x) * 16 / 0x8000);
161 v->
y = (((double)y) * 16 / 0x8000);
162 v->
z = (((double)z) * 16 / 0x8000);
168 accSumX = accSumX - accFilterX + v->
x;
172 accSumY = accSumY - accFilterY + v->
y;
176 accSumZ = accSumZ - accFilterZ + v->
z;