diff options
Diffstat (limited to 'board/redrix/sensors.c')
-rw-r--r-- | board/redrix/sensors.c | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/board/redrix/sensors.c b/board/redrix/sensors.c index e80d5f912a..01ed65f13f 100644 --- a/board/redrix/sensors.c +++ b/board/redrix/sensors.c @@ -6,8 +6,8 @@ #include "common.h" #include "accelgyro.h" #include "adc_chip.h" -#include "driver/accel_lis2dw12.h" -#include "driver/accelgyro_lsm6dso.h" +#include "driver/accel_bma2x2.h" +#include "driver/accelgyro_lsm6dsm.h" #include "driver/als_tcs3400_public.h" #include "hooks.h" #include "motion_sense.h" @@ -50,8 +50,8 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); K_MUTEX_DEFINE(g_lid_accel_mutex); K_MUTEX_DEFINE(g_base_accel_mutex); -static struct stprivate_data g_lis2dw12_data; -static struct lsm6dso_data lsm6dso_data; +static struct accelgyro_saved_data_t g_bma253_data; +static struct lsm6dsm_data lsm6dsm_data; /* TODO(b/184779333): calibrate the orientation matrix on later board stage */ static const mat33_fp_t lid_standard_ref = { @@ -125,24 +125,22 @@ struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { .name = "Lid Accel", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LIS2DW12, + .chip = MOTIONSENSE_CHIP_BMA255, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_LID, - .drv = &lis2dw12_drv, + .drv = &bma2x2_accel_drv, .mutex = &g_lid_accel_mutex, - .drv_data = &g_lis2dw12_data, - .int_signal = GPIO_EC_ACCEL_INT_R_L, + .drv_data = &g_bma253_data, .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LIS2DW12_ADDR0, - .flags = MOTIONSENSE_FLAG_INT_SIGNAL, + .i2c_spi_addr_flags = BMA2x2_I2C_ADDR1_FLAGS, .rot_standard_ref = &lid_standard_ref, /* identity matrix */ .default_range = 2, /* g */ - .min_frequency = LIS2DW12_ODR_MIN_VAL, - .max_frequency = LIS2DW12_ODR_MAX_VAL, + .min_frequency = BMA255_ACCEL_MIN_FREQ, + .max_frequency = BMA255_ACCEL_MAX_FREQ, .config = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { - .odr = 12500 | ROUND_UP_FLAG, + .odr = 10000 | ROUND_UP_FLAG, }, /* Sensor on for lid angle detection */ [SENSOR_CONFIG_EC_S3] = { @@ -154,21 +152,21 @@ struct motion_sensor_t motion_sensors[] = { [BASE_ACCEL] = { .name = "Base Accel", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSO, + .chip = MOTIONSENSE_CHIP_LSM6DSM, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dso_drv, + .drv = &lsm6dsm_drv, .mutex = &g_base_accel_mutex, - .drv_data = LSM6DSO_ST_DATA(lsm6dso_data, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, MOTIONSENSE_TYPE_ACCEL), .int_signal = GPIO_EC_IMU_INT_R_L, .flags = MOTIONSENSE_FLAG_INT_SIGNAL, .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS, + .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, .rot_standard_ref = &base_standard_ref, .default_range = 4, /* g */ - .min_frequency = LSM6DSO_ODR_MIN_VAL, - .max_frequency = LSM6DSO_ODR_MAX_VAL, + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, .config = { [SENSOR_CONFIG_EC_S0] = { .odr = 13000 | ROUND_UP_FLAG, @@ -184,21 +182,21 @@ struct motion_sensor_t motion_sensors[] = { [BASE_GYRO] = { .name = "Base Gyro", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSO, + .chip = MOTIONSENSE_CHIP_LSM6DSM, .type = MOTIONSENSE_TYPE_GYRO, .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dso_drv, + .drv = &lsm6dsm_drv, .mutex = &g_base_accel_mutex, - .drv_data = LSM6DSO_ST_DATA(lsm6dso_data, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, MOTIONSENSE_TYPE_GYRO), .int_signal = GPIO_EC_IMU_INT_R_L, .flags = MOTIONSENSE_FLAG_INT_SIGNAL, .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS, + .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, .default_range = 1000 | ROUND_UP_FLAG, /* dps */ .rot_standard_ref = &base_standard_ref, - .min_frequency = LSM6DSO_ODR_MIN_VAL, - .max_frequency = LSM6DSO_ODR_MAX_VAL, + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, .config = { [SENSOR_CONFIG_EC_S0] = { .odr = 13000 | ROUND_UP_FLAG, @@ -257,16 +255,14 @@ const struct motion_sensor_t *motion_als_sensors[] = { }; BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT); -static void baseboard_sensors_init(void) +static void board_sensors_init(void) { - /* Enable gpio interrupt for lid accel sensor */ - gpio_enable_interrupt(GPIO_EC_ACCEL_INT_R_L); /* Enable interrupt for the TCS3400 color light sensor */ gpio_enable_interrupt(GPIO_EC_ALS_RGB_INT_R_L); /* Enable gpio interrupt for base accelgyro sensor */ gpio_enable_interrupt(GPIO_EC_IMU_INT_R_L); } -DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_INIT_I2C + 1); +DECLARE_HOOK(HOOK_INIT, board_sensors_init, HOOK_PRIO_INIT_I2C + 1); /* Temperature sensor configuration */ const struct temp_sensor_t temp_sensors[] = { |