48 #define GYROREG_CTRL1 0x20
49 #define GYROREG_CTRL4 0x23
50 #define GYROREG_OUTXL 0x28
61 Error gyroWriteByte(uint8_t reg, uint8_t val) {
101 static double gyroSumX = 0, gyroSumY = 0, gyroSumZ = 0;
102 static double gyroFilterX = 0, gyroFilterY = 0, gyroFilterZ = 0;
124 int16_t x = *(int8_t *)(&xh);
128 int16_t y = *(int8_t *)(&yh);
132 int16_t z = *(int8_t *)(&zh);
138 v->
x = (((double)x) * 250 / 0x8000);
139 v->
y = (((double)y) * 250 / 0x8000);
140 v->
z = (((double)z) * 250 / 0x8000);
143 v->
x = (((double)x) * 500 / 0x8000);
144 v->
y = (((double)y) * 500 / 0x8000);
145 v->
z = (((double)z) * 500 / 0x8000);
148 v->
x = (((double)x) * 2000 / 0x8000);
149 v->
y = (((double)y) * 2000 / 0x8000);
150 v->
z = (((double)z) * 2000 / 0x8000);
156 gyroSumX = gyroSumX - gyroFilterX + v->
x;
160 gyroSumY = gyroSumY - gyroFilterY + v->
y;
164 gyroSumZ = gyroSumZ - gyroFilterZ + v->
z;