gyro_result = gyro_self_test(gyro, gyro_st); 的結果為04
static int gyro_self_test(long *bias_regular, long *bias_st)
{
int jj, result = 0;
unsigned char tmp[3];//3
float st_shift, st_shift_cust, st_shift_var;
if (i2c_read(st.hw->addr, 0x0D, 3, tmp))
return 0x07;
if (i2c_read(st.hw->addr, 0x0D, 7, tmp))
return 0x07;
tmp[0] &= 0x1F;
tmp[1] &= 0x1F;
tmp[2] &= 0x1F;
// tmp[5] &= 0x1F;
// tmp[6] &= 0x1F;
// tmp[7] &= 0x1F;
for (jj = 0; jj < 3; jj++) {
st_shift_cust = labs(bias_regular[jj] - bias_st[jj]) / 65536.f;
if (tmp[jj]) {
st_shift = 3275.f / test.gyro_sens;
while (--tmp[jj])
st_shift *= 1.046f;
st_shift_var = st_shift_cust / st_shift - 1.f;
if (fabs(st_shift_var) > test.max_gyro_var)
result |= 1 << jj;
} else if ((st_shift_cust < test.min_dps) ||
(st_shift_cust > test.max_dps))
result |= 1 << jj;
}
return result;
} |