krane: Fix g-sensor reference point.
bmi160 on krane rev3 is rotated.
TEST=sysjump rw; boot into UI and see UI rotates accordingly.
BRANCH=None
Commit-Ready: Yilun Lin
Tested-by: Yilun Lin
@@ -356,6 +356,15 @@ static struct mutex g_lid_mutex;
static struct bmi160_drv_data_t g_bmi160_data;
+#ifdef BOARD_KRANE
+/* Matrix to rotate accelerometer into standard reference frame */
+const mat33_fp_t lid_standard_ref_rev3 = {
+ {0, FLOAT_TO_FP(-1), 0},
+ {FLOAT_TO_FP(1), 0, 0},
+ {0, 0, FLOAT_TO_FP(1)}
+};
+#endif /* BOARD_KRANE */
+
/* Matrix to rotate accelerometer into standard reference frame */
const mat33_fp_t lid_standard_ref = {
{FLOAT_TO_FP(1), 0, 0},
@@ -444,6 +453,19 @@ struct motion_sensor_t motion_sensors[] = {
},
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+
+#ifdef BOARD_KRANE
+static void fix_krane_ref(void)
+{
+ if (board_get_version() != 3)
+ return;
+
+ motion_sensors[LID_ACCEL].rot_standard_ref = &lid_standard_ref_rev3;
+ motion_sensors[LID_GYRO].rot_standard_ref = &lid_standard_ref_rev3;
+}
+DECLARE_HOOK(HOOK_INIT, fix_krane_ref, HOOK_PRIO_INIT_ADC + 1);
+#endif /* BOARD_KRANE */
+
#endif /* SECTION_IS_RW */
int board_allow_i2c_passthru(int port)
