diff options
author | Yuval Peress <peress@chromium.org> | 2019-07-15 14:10:11 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-03 20:36:04 +0000 |
commit | dfbc632cd5b5a856086249253a98bc83d8942a29 (patch) | |
tree | 9f0359115a96ca0efe66905b5f6b1be644367430 /driver | |
parent | 083788ac19505f07bfe57a4d8b54a3b11b7554b3 (diff) | |
download | chrome-ec-dfbc632cd5b5a856086249253a98bc83d8942a29.tar.gz |
config: Refactor CONFIG_ACCEL_FIFO to enable use of IS_ENABLED
This change allows us to use the IS_ENABLED condition to replace
the various ifdef guards around the CONFIG_ACCEL_FIFO
BUG=b:137758297,chromium:981990
BRANCH=None
TEST=buildall and CTS tests on Arcada
Change-Id: I65d36bac19855e51c830a33e6f3812575e8d15d9
Signed-off-by: Yuval Peress <peress@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704164
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/accelgyro_bmi160.c | 84 | ||||
-rw-r--r-- | driver/accelgyro_lsm6dsm.c | 90 | ||||
-rw-r--r-- | driver/accelgyro_lsm6dso.c | 69 | ||||
-rw-r--r-- | driver/als_si114x.c | 38 | ||||
-rw-r--r-- | driver/als_tcs3400.c | 18 |
5 files changed, 138 insertions, 161 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index 6408bfcc79..aa4eaf13c7 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -27,9 +27,7 @@ #define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ## args) #define CPRINTS(format, args...) cprints(CC_ACCEL, format, ## args) -#ifdef CONFIG_ACCEL_FIFO -static volatile uint32_t last_interrupt_timestamp; -#endif +STATIC_IF(CONFIG_ACCEL_FIFO) volatile uint32_t last_interrupt_timestamp; /* * Struct for pairing an engineering value with the register value for a @@ -304,7 +302,6 @@ int bmi160_sec_raw_write8(const int port, } #endif -#ifdef CONFIG_ACCEL_FIFO static int enable_fifo(const struct motion_sensor_t *s, int enable) { struct bmi160_drv_data_t *data = BMI160_GET_DATA(s); @@ -333,7 +330,6 @@ static int enable_fifo(const struct motion_sensor_t *s, int enable) } return ret; } -#endif static int set_range(const struct motion_sensor_t *s, int range, @@ -386,10 +382,10 @@ static int set_data_rate(const struct motion_sensor_t *s, #endif if (rate == 0) { -#ifdef CONFIG_ACCEL_FIFO /* FIFO stop collecting events */ - enable_fifo(s, 0); -#endif + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) + enable_fifo(s, 0); + /* go to suspend mode */ ret = raw_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG, @@ -473,13 +469,12 @@ static int set_data_rate(const struct motion_sensor_t *s, } #endif -#ifdef CONFIG_ACCEL_FIFO /* * FIFO start collecting events. * They will be discarded if AP does not want them. */ - enable_fifo(s, 1); -#endif + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) + enable_fifo(s, 1); accel_cleanup: mutex_unlock(s->mutex); @@ -825,7 +820,6 @@ int list_activities(const struct motion_sensor_t *s, #ifdef CONFIG_ACCEL_INTERRUPTS -#ifdef CONFIG_ACCEL_FIFO enum fifo_state { FIFO_HEADER, FIFO_DATA_SKIP, @@ -873,10 +867,9 @@ static int bmi160_decode_header(struct motion_sensor_t *accel, int *v = s->raw_xyz; vector.flags = 0; normalize(s, v, *bp); -#ifdef CONFIG_ACCEL_SPOOF_MODE - if (s->flags & MOTIONSENSE_FLAG_IN_SPOOF_MODE) + if (IS_ENABLED(CONFIG_ACCEL_SPOOF_MODE) && + s->flags & MOTIONSENSE_FLAG_IN_SPOOF_MODE) v = s->spoof_xyz; -#endif /* defined(CONFIG_ACCEL_SPOOF_MODE) */ vector.data[X] = v[X]; vector.data[Y] = v[Y]; vector.data[Z] = v[Z]; @@ -1037,7 +1030,6 @@ static int load_fifo(struct motion_sensor_t *s, uint32_t last_ts) motion_sense_fifo_commit_data(); return EC_SUCCESS; } -#endif /* CONFIG_ACCEL_FIFO */ /** * bmi160_interrupt - called when the sensor activates the interrupt line. @@ -1047,9 +1039,9 @@ static int load_fifo(struct motion_sensor_t *s, uint32_t last_ts) */ void bmi160_interrupt(enum gpio_signal signal) { -#ifdef CONFIG_ACCEL_FIFO - last_interrupt_timestamp = __hw_clock_source_read(); -#endif + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) + last_interrupt_timestamp = __hw_clock_source_read(); + task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ACCELGYRO_BMI160_INT_EVENT, 0); } @@ -1119,34 +1111,37 @@ static int config_interrupt(const struct motion_sensor_t *s) ret = raw_write8(s->port, s->i2c_spi_addr_flags, BMI160_INT_MAP_REG(1), tmp); -#ifdef CONFIG_ACCEL_FIFO - /* map fifo water mark to int 1 */ - ret = raw_write8(s->port, s->i2c_spi_addr_flags, - BMI160_INT_FIFO_MAP, - BMI160_INT_MAP(1, FWM) | - BMI160_INT_MAP(1, FFULL)); + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + /* map fifo water mark to int 1 */ + ret = raw_write8(s->port, s->i2c_spi_addr_flags, + BMI160_INT_FIFO_MAP, + BMI160_INT_MAP(1, FWM) | + BMI160_INT_MAP(1, FFULL)); - /* configure fifo watermark to int whenever there's any data in there */ - ret = raw_write8(s->port, s->i2c_spi_addr_flags, - BMI160_FIFO_CONFIG_0, 1); + /* + * Configure fifo watermark to int whenever there's any data in + * there + */ + ret = raw_write8(s->port, s->i2c_spi_addr_flags, + BMI160_FIFO_CONFIG_0, 1); #ifdef CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT - ret = raw_write8(s->port, s->i2c_spi_addr_flags, - BMI160_FIFO_CONFIG_1, - BMI160_FIFO_HEADER_EN); + ret = raw_write8(s->port, s->i2c_spi_addr_flags, + BMI160_FIFO_CONFIG_1, + BMI160_FIFO_HEADER_EN); #else - ret = raw_write8(s->port, s->i2c_spi_addr_flags, - BMI160_FIFO_CONFIG_1, - BMI160_FIFO_TAG_INT2_EN | - BMI160_FIFO_HEADER_EN); + ret = raw_write8(s->port, s->i2c_spi_addr_flags, + BMI160_FIFO_CONFIG_1, + BMI160_FIFO_TAG_INT2_EN | + BMI160_FIFO_HEADER_EN); #endif - /* Set fifo*/ - ret = raw_read8(s->port, s->i2c_spi_addr_flags, - BMI160_INT_EN_1, &tmp); - tmp |= BMI160_INT_FWM_EN | BMI160_INT_FFUL_EN; - ret = raw_write8(s->port, s->i2c_spi_addr_flags, - BMI160_INT_EN_1, tmp); -#endif + /* Set fifo*/ + ret = raw_read8(s->port, s->i2c_spi_addr_flags, + BMI160_INT_EN_1, &tmp); + tmp |= BMI160_INT_FWM_EN | BMI160_INT_FFUL_EN; + ret = raw_write8(s->port, s->i2c_spi_addr_flags, + BMI160_INT_EN_1, tmp); + } mutex_unlock(s->mutex); return ret; } @@ -1222,10 +1217,9 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event) *event |= TASK_EVENT_MOTION_ACTIVITY_INTERRUPT( MOTIONSENSE_ACTIVITY_SIG_MOTION); #endif -#ifdef CONFIG_ACCEL_FIFO - if (interrupt & (BMI160_FWM_INT | BMI160_FFULL_INT)) + if (IS_ENABLED(CONFIG_ACCEL_FIFO) && + interrupt & (BMI160_FWM_INT | BMI160_FFULL_INT)) load_fifo(s, last_interrupt_timestamp); -#endif #ifdef CONFIG_BMI160_ORIENTATION_SENSOR irq_set_orientation(s, interrupt); #endif diff --git a/driver/accelgyro_lsm6dsm.c b/driver/accelgyro_lsm6dsm.c index 1a098f3b1e..4fc8591ee1 100644 --- a/driver/accelgyro_lsm6dsm.c +++ b/driver/accelgyro_lsm6dsm.c @@ -26,7 +26,6 @@ #define IS_FSTS_EMPTY(s) ((s).len & LSM6DSM_FIFO_EMPTY) -#ifdef CONFIG_ACCEL_FIFO static volatile uint32_t last_interrupt_timestamp; /** @@ -83,8 +82,6 @@ static inline uint8_t get_sensor_type(enum dev_fifo fifo_type) return map[fifo_type]; } -#endif - /** * @return output base register for sensor */ @@ -112,23 +109,22 @@ static int config_interrupt(const struct motion_sensor_t *accel) if (ret != EC_SUCCESS) return ret; -#ifdef CONFIG_ACCEL_FIFO - /* As soon as one sample is ready, trigger an interrupt. */ - ret = st_raw_write8(accel->port, accel->i2c_spi_addr_flags, - LSM6DSM_FIFO_CTRL1_ADDR, - OUT_XYZ_SIZE / sizeof(uint16_t)); - if (ret != EC_SUCCESS) - return ret; - int1_ctrl_val |= LSM6DSM_INT_FIFO_TH | LSM6DSM_INT_FIFO_OVR | - LSM6DSM_INT_FIFO_FULL; -#endif /* CONFIG_ACCEL_FIFO */ + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + /* As soon as one sample is ready, trigger an interrupt. */ + ret = st_raw_write8(accel->port, accel->i2c_spi_addr_flags, + LSM6DSM_FIFO_CTRL1_ADDR, + OUT_XYZ_SIZE / sizeof(uint16_t)); + if (ret != EC_SUCCESS) + return ret; + int1_ctrl_val |= LSM6DSM_INT_FIFO_TH | LSM6DSM_INT_FIFO_OVR | + LSM6DSM_INT_FIFO_FULL; + } return st_raw_write8(accel->port, accel->i2c_spi_addr_flags, LSM6DSM_INT1_CTRL, int1_ctrl_val); } -#ifdef CONFIG_ACCEL_FIFO /** * fifo_disable - set fifo mode * @accel: Motion sensor pointer: must be MOTIONSENSE_TYPE_ACCEL. @@ -437,14 +433,11 @@ static int is_fifo_empty(struct motion_sensor_t *s, struct fstatus *fsts) return IS_FSTS_EMPTY(*fsts); } -#endif /* CONFIG_ACCEL_FIFO */ - static void handle_interrupt_for_fifo(uint32_t ts) { -#ifdef CONFIG_ACCEL_FIFO - if (time_after(ts, last_interrupt_timestamp)) + if (IS_ENABLED(CONFIG_ACCEL_FIFO) && + time_after(ts, last_interrupt_timestamp)) last_interrupt_timestamp = ts; -#endif task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ACCEL_LSM6DSM_INT_EVENT, 0); } @@ -468,8 +461,7 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event) (!(*event & CONFIG_ACCEL_LSM6DSM_INT_EVENT))) return EC_ERROR_NOT_HANDLED; -#ifdef CONFIG_ACCEL_FIFO - { + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { struct fstatus fsts; uint32_t last_fifo_read_ts; uint32_t triggering_interrupt_timestamp = @@ -498,7 +490,7 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event) triggering_interrupt_timestamp == last_interrupt_timestamp) handle_interrupt_for_fifo(last_fifo_read_ts); } -#endif + return ret; } #endif /* CONFIG_ACCEL_INTERRUPTS */ @@ -576,21 +568,22 @@ static int get_range(const struct motion_sensor_t *s) int lsm6dsm_set_data_rate(const struct motion_sensor_t *s, int rate, int rnd) { struct stprivate_data *data = s->drv_data; -#ifdef CONFIG_ACCEL_FIFO - const struct motion_sensor_t *accel = LSM6DSM_MAIN_SENSOR(s); - struct lsm6dsm_data *private = LSM6DSM_GET_DATA(accel); -#endif + const struct motion_sensor_t *accel = IS_ENABLED(CONFIG_ACCEL_FIFO) ? + LSM6DSM_MAIN_SENSOR(s) : NULL; + struct lsm6dsm_data *private = IS_ENABLED(CONFIG_ACCEL_FIFO) ? + LSM6DSM_GET_DATA(accel) : NULL; int ret = EC_SUCCESS, normalized_rate = 0; uint8_t ctrl_reg, reg_val = 0; -#ifdef CONFIG_ACCEL_FIFO - /* FIFO must be disabled before setting any ODR values */ - ret = fifo_disable(accel); - if (ret != EC_SUCCESS) { - CPRINTS("Failed to disable FIFO. Error: %d", ret); - return ret; + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + /* FIFO must be disabled before setting any ODR values */ + ret = fifo_disable(accel); + if (ret != EC_SUCCESS) { + CPRINTS("Failed to disable FIFO. Error: %d", ret); + return ret; + } } -#endif + if (rate > 0) { reg_val = LSM6DSM_ODR_TO_REG(rate); normalized_rate = LSM6DSM_REG_TO_ODR(reg_val); @@ -636,16 +629,17 @@ int lsm6dsm_set_data_rate(const struct motion_sensor_t *s, int rate, int rnd) } if (ret == EC_SUCCESS) { data->base.odr = normalized_rate; -#ifdef CONFIG_ACCEL_FIFO - private->samples_to_discard[s->type] = - LSM6DSM_DISCARD_SAMPLES; - private->load_fifo_sensor_state[get_fifo_type(s)].sample_rate = - normalized_rate == 0 ? 0 : SECOND * 1000 / - normalized_rate; - ret = fifo_enable(accel); - if (ret != EC_SUCCESS) - CPRINTS("Failed to enable FIFO. Error: %d", ret); -#endif + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + private->samples_to_discard[s->type] = + LSM6DSM_DISCARD_SAMPLES; + private->load_fifo_sensor_state[get_fifo_type(s)] + .sample_rate = normalized_rate == 0 + ? 0 : SECOND * 1000 / normalized_rate; + ret = fifo_enable(accel); + if (ret != EC_SUCCESS) + CPRINTS("Failed to enable FIFO. Error: %d", + ret); + } } mutex_unlock(s->mutex); @@ -803,11 +797,11 @@ static int init(const struct motion_sensor_t *s) if (ret != EC_SUCCESS) goto err_unlock; -#ifdef CONFIG_ACCEL_FIFO - ret = fifo_disable(s); - if (ret != EC_SUCCESS) - goto err_unlock; -#endif /* CONFIG_ACCEL_FIFO */ + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + ret = fifo_disable(s); + if (ret != EC_SUCCESS) + goto err_unlock; + } #ifdef CONFIG_ACCEL_INTERRUPTS ret = config_interrupt(s); diff --git a/driver/accelgyro_lsm6dso.c b/driver/accelgyro_lsm6dso.c index c9ad09f740..617186872b 100644 --- a/driver/accelgyro_lsm6dso.c +++ b/driver/accelgyro_lsm6dso.c @@ -20,9 +20,7 @@ #define CPRINTS(format, args...) cprints(CC_ACCEL, format, ## args) -#ifdef CONFIG_ACCEL_FIFO -static volatile uint32_t last_interrupt_timestamp; -#endif /* CONFIG_ACCEL_FIFO */ +STATIC_IF(CONFIG_ACCEL_FIFO) volatile uint32_t last_interrupt_timestamp; /* * When ODR change, the sensor filters need settling time; @@ -51,12 +49,13 @@ static inline int get_xyz_reg(enum motionsensor_type type) static int config_interrupt(const struct motion_sensor_t *s) { int ret = EC_SUCCESS; - -#ifdef CONFIG_ACCEL_FIFO int int1_ctrl_val; - ret = st_raw_read8(s->port, s->i2c_spi_addr_flags, - LSM6DSO_INT1_CTRL, &int1_ctrl_val); + if (!IS_ENABLED(CONFIG_ACCEL_FIFO)) + return ret; + + ret = st_raw_read8(s->port, s->i2c_spi_addr_flags, LSM6DSO_INT1_CTRL, + &int1_ctrl_val); if (ret != EC_SUCCESS) return ret; @@ -64,8 +63,8 @@ static int config_interrupt(const struct motion_sensor_t *s) * Configure FIFO threshold to 1 sample: interrupt on watermark * will be generated every time a new data sample will be stored * in FIFO. The interrupr on watermark is cleared only when the - * number or samples still present in FIFO exceeds the configured - * threshold. + * number or samples still present in FIFO exceeds the + * configured threshold. */ ret = st_raw_write8(s->port, s->i2c_spi_addr_flags, LSM6DSO_FIFO_CTRL1_ADDR, 1); @@ -75,14 +74,12 @@ static int config_interrupt(const struct motion_sensor_t *s) int1_ctrl_val |= LSM6DSO_INT_FIFO_TH | LSM6DSO_INT_FIFO_OVR | LSM6DSO_INT_FIFO_FULL; - ret = st_raw_write8(s->port, s->i2c_spi_addr_flags, - LSM6DSO_INT1_CTRL, int1_ctrl_val); -#endif /* CONFIG_ACCEL_FIFO */ + ret = st_raw_write8(s->port, s->i2c_spi_addr_flags, LSM6DSO_INT1_CTRL, + int1_ctrl_val); return ret; } -#ifdef CONFIG_ACCEL_FIFO /** * fifo_disable - set fifo mode to LSM6DSO_FIFO_MODE_BYPASS_VAL * @s: Motion sensor pointer: must be MOTIONSENSE_TYPE_ACCEL. @@ -217,16 +214,14 @@ static int accelgyro_config_fifo(const struct motion_sensor_t *s) return fifo_enable(s); } -#endif /* CONFIG_ACCEL_FIFO */ /** * lsm6dso_interrupt - interrupt from int1 pin of sensor */ void lsm6dso_interrupt(enum gpio_signal signal) { -#ifdef CONFIG_ACCEL_FIFO - last_interrupt_timestamp = __hw_clock_source_read(); -#endif /* CONFIG_ACCEL_FIFO */ + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) + last_interrupt_timestamp = __hw_clock_source_read(); task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ACCEL_LSM6DSO_INT_EVENT, 0); @@ -245,21 +240,20 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event) (!(*event & CONFIG_ACCEL_LSM6DSO_INT_EVENT))) return EC_ERROR_NOT_HANDLED; -#ifdef CONFIG_ACCEL_FIFO - /* Read how many data patterns on FIFO to read. */ - ret = st_raw_read_n_noinc(s->port, s->i2c_spi_addr_flags, - LSM6DSO_FIFO_STS1_ADDR, - (uint8_t *)&fsts, sizeof(fsts)); - if (ret != EC_SUCCESS) - return ret; + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + /* Read how many data patterns on FIFO to read. */ + ret = st_raw_read_n_noinc(s->port, s->i2c_spi_addr_flags, + LSM6DSO_FIFO_STS1_ADDR, + (uint8_t *)&fsts, sizeof(fsts)); + if (ret != EC_SUCCESS) + return ret; - if (fsts.len & (LSM6DSO_FIFO_DATA_OVR | LSM6DSO_FIFO_FULL)) { - CPRINTS("%s FIFO Overrun: %04x", s->name, fsts.len); - } + if (fsts.len & (LSM6DSO_FIFO_DATA_OVR | LSM6DSO_FIFO_FULL)) + CPRINTS("%s FIFO Overrun: %04x", s->name, fsts.len); - if (fsts.len & LSM6DSO_FIFO_DIFF_MASK) - ret = load_fifo(s, &fsts, last_interrupt_timestamp); -#endif /* CONFIG_ACCEL_FIFO */ + if (fsts.len & LSM6DSO_FIFO_DIFF_MASK) + ret = load_fifo(s, &fsts, last_interrupt_timestamp); + } return ret; } @@ -355,9 +349,8 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd) ret = st_write_data_with_mask(s, ctrl_reg, LSM6DSO_ODR_MASK, reg_val); if (ret == EC_SUCCESS) { data->base.odr = normalized_rate; -#ifdef CONFIG_ACCEL_FIFO - accelgyro_config_fifo(s); -#endif /* CONFIG_ACCEL_FIFO */ + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) + accelgyro_config_fifo(s); } mutex_unlock(s->mutex); @@ -465,11 +458,11 @@ static int init(const struct motion_sensor_t *s) if (ret != EC_SUCCESS) goto err_unlock; -#ifdef CONFIG_ACCEL_FIFO - ret = fifo_disable(s); - if (ret != EC_SUCCESS) - goto err_unlock; -#endif /* CONFIG_ACCEL_FIFO */ + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + ret = fifo_disable(s); + if (ret != EC_SUCCESS) + goto err_unlock; + } #ifdef CONFIG_ACCEL_INTERRUPTS ret = config_interrupt(s); diff --git a/driver/als_si114x.c b/driver/als_si114x.c index 4db3fcc9d7..35405bbea7 100644 --- a/driver/als_si114x.c +++ b/driver/als_si114x.c @@ -93,9 +93,6 @@ static int si114x_read_results(struct motion_sensor_t *s, int nb) int i, ret, val; struct si114x_drv_data_t *data = SI114X_GET_DATA(s); struct si114x_typed_data_t *type_data = SI114X_GET_TYPED_DATA(s); -#ifdef CONFIG_ACCEL_FIFO - struct ec_response_motion_sensor_data vector; -#endif /* Read ALX result */ for (i = 0; i < nb; i++) { @@ -147,23 +144,24 @@ static int si114x_read_results(struct motion_sensor_t *s, int nb) if (i == nb) return EC_ERROR_UNCHANGED; -#ifdef CONFIG_ACCEL_FIFO - vector.flags = 0; - for (i = 0; i < nb; i++) - vector.data[i] = s->raw_xyz[i]; - for (i = nb; i < 3; i++) - vector.data[i] = 0; - vector.sensor_num = s - motion_sensors; - motion_sense_fifo_stage_data(&vector, s, nb, - __hw_clock_source_read()); - motion_sense_fifo_commit_data(); - /* - * TODO: get time at a more accurate spot. - * Like in si114x_interrupt - */ -#else - /* We need to copy raw_xyz into xyz with mutex */ -#endif + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + struct ec_response_motion_sensor_data vector; + + vector.flags = 0; + for (i = 0; i < nb; i++) + vector.data[i] = s->raw_xyz[i]; + for (i = nb; i < 3; i++) + vector.data[i] = 0; + vector.sensor_num = s - motion_sensors; + motion_sense_fifo_stage_data(&vector, s, nb, + __hw_clock_source_read()); + motion_sense_fifo_commit_data(); + /* + * TODO: get time at a more accurate spot. + * Like in si114x_interrupt + */ + } + /* Otherwise, we need to copy raw_xyz into xyz with mutex */ return EC_SUCCESS; } diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c index 774efd863c..7e867a606d 100644 --- a/driver/als_tcs3400.c +++ b/driver/als_tcs3400.c @@ -18,9 +18,7 @@ #define CPRINTS(fmt, args...) cprints(CC_ACCEL, "%s "fmt, __func__, ## args) -#ifdef CONFIG_ACCEL_FIFO -static volatile uint32_t last_interrupt_timestamp; -#endif +STATIC_IF(CONFIG_ACCEL_FIFO) volatile uint32_t last_interrupt_timestamp; #ifdef CONFIG_TCS_USE_LUX_TABLE /* @@ -423,10 +421,10 @@ static int tcs3400_post_events(struct motion_sensor_t *s, uint32_t last_ts) } #endif /* CONFIG_ACCEL_SPOOF_MODE */ -#ifdef CONFIG_ACCEL_FIFO - vector.sensor_num = s - motion_sensors; - motion_sense_fifo_stage_data(&vector, s, 3, last_ts); -#endif + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + vector.sensor_num = s - motion_sensors; + motion_sense_fifo_stage_data(&vector, s, 3, last_ts); + } } /* @@ -476,9 +474,9 @@ static int tcs3400_post_events(struct motion_sensor_t *s, uint32_t last_ts) void tcs3400_interrupt(enum gpio_signal signal) { -#ifdef CONFIG_ACCEL_FIFO - last_interrupt_timestamp = __hw_clock_source_read(); -#endif + if (IS_ENABLED(CONFIG_ACCEL_FIFO)) + last_interrupt_timestamp = __hw_clock_source_read(); + task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ALS_TCS3400_INT_EVENT, 0); } |