diff options
-rw-r--r-- | common/motion_sense.c | 11 | ||||
-rw-r--r-- | driver/accel_bma2x2.c | 5 | ||||
-rw-r--r-- | driver/accelgyro_bmi160.c | 5 | ||||
-rw-r--r-- | driver/als_si114x.c | 1 | ||||
-rw-r--r-- | include/accelgyro.h | 8 | ||||
-rw-r--r-- | include/ec_commands.h | 12 |
6 files changed, 30 insertions, 12 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 140f1a9aa7..17806aabfe 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -1636,20 +1636,21 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args) case MOTIONSENSE_CMD_PERFORM_CALIB: /* Verify sensor number is valid. */ sensor = host_sensor_id_to_real_sensor( - in->sensor_offset.sensor_num); + in->perform_calib.sensor_num); if (sensor == NULL) return EC_RES_INVALID_PARAM; if (!sensor->drv->perform_calib) return EC_RES_INVALID_COMMAND; - ret = sensor->drv->perform_calib(sensor); + ret = sensor->drv->perform_calib( + sensor, in->perform_calib.enable); if (ret != EC_SUCCESS) return ret; - ret = sensor->drv->get_offset(sensor, out->sensor_offset.offset, - &out->sensor_offset.temp); + ret = sensor->drv->get_offset(sensor, out->perform_calib.offset, + &out->perform_calib.temp); if (ret != EC_SUCCESS) return ret; - args->response_size = sizeof(out->sensor_offset); + args->response_size = sizeof(out->perform_calib); break; #ifdef CONFIG_ACCEL_FIFO diff --git a/driver/accel_bma2x2.c b/driver/accel_bma2x2.c index d828912232..9a63bdc1ba 100644 --- a/driver/accel_bma2x2.c +++ b/driver/accel_bma2x2.c @@ -188,11 +188,14 @@ static int read(const struct motion_sensor_t *s, intv3_t v) return EC_SUCCESS; } -static int perform_calib(const struct motion_sensor_t *s) +static int perform_calib(const struct motion_sensor_t *s, int enable) { int ret, val, status, rate, range, i; timestamp_t deadline; + if (!enable) + return EC_SUCCESS; + ret = raw_read8(s->port, s->i2c_spi_addr_flags, BMA2x2_OFFSET_CTRL_ADDR, &val); if (ret) diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index 3be5f58a83..5fb79194d1 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -637,11 +637,14 @@ int get_scale(const struct motion_sensor_t *s, return EC_SUCCESS; } -static int perform_calib(const struct motion_sensor_t *s) +static int perform_calib(const struct motion_sensor_t *s, int enable) { int ret, val, en_flag, status, rate; timestamp_t deadline; + if (!enable) + return EC_SUCCESS; + rate = get_data_rate(s); /* * Temporary set frequency to 100Hz to get enough data in a short diff --git a/driver/als_si114x.c b/driver/als_si114x.c index 5cfc19c6a8..2ac8f1ccbd 100644 --- a/driver/als_si114x.c +++ b/driver/als_si114x.c @@ -598,7 +598,6 @@ const struct accelgyro_drv si114x_drv = { .get_data_rate = get_data_rate, .set_offset = set_offset, .get_offset = get_offset, - .perform_calib = NULL, #ifdef CONFIG_ACCEL_INTERRUPTS .irq_handler = irq_handler, #endif diff --git a/include/accelgyro.h b/include/accelgyro.h index 244b989de0..65a09b1965 100644 --- a/include/accelgyro.h +++ b/include/accelgyro.h @@ -106,7 +106,13 @@ struct accelgyro_drv { int (*get_scale)(const struct motion_sensor_t *s, uint16_t *scale, int16_t *temp); - int (*perform_calib)(const struct motion_sensor_t *s); + /** + * Request performing/entering calibration. + * Either a one shot mode (enable is not used), + * or enter/exit a calibration state. + */ + int (*perform_calib)(const struct motion_sensor_t *s, + int enable); #ifdef CONFIG_ACCEL_INTERRUPTS /** * handler for interrupts triggered by the sensor: it runs in task and diff --git a/include/ec_commands.h b/include/ec_commands.h index 3c0810504f..cdf7c67c5d 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -2590,14 +2590,20 @@ struct ec_params_motion_sense { /* * Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA - * and MOTIONSENSE_CMD_PERFORM_CALIB. */ struct __ec_todo_unpacked { uint8_t sensor_num; - } info, info_3, data, fifo_flush, perform_calib, - list_activities; + } info, info_3, data, fifo_flush, list_activities; /* + * Used for MOTIONSENSE_CMD_PERFORM_CALIB: + * Allow entering/exiting the calibration mode. + */ + struct __ec_todo_unpacked { + uint8_t sensor_num; + uint8_t enable; + } perform_calib; + /* * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR * and MOTIONSENSE_CMD_SENSOR_RANGE. */ |