diff options
-rw-r--r-- | common/motion_sense.c | 10 | ||||
-rw-r--r-- | include/config.h | 6 | ||||
-rw-r--r-- | include/motion_sense.h | 7 |
3 files changed, 15 insertions, 8 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index c72165bc7e..7602d62334 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -39,6 +39,8 @@ test_export_static unsigned int motion_interval; /* Delay between FIFO interruption. */ static unsigned int motion_int_interval; +/* Minimum time in between running motion sense task loop. */ +unsigned int motion_min_interval = CONFIG_MOTION_MIN_SENSE_WAIT_TIME * MSEC; #ifdef CONFIG_CMD_ACCEL_INFO static int accel_disp; #endif @@ -769,8 +771,8 @@ void motion_sense_task(void) * Guarantee some minimum delay to allow other lower * priority tasks to run. */ - if (wait_us < MIN_MOTION_SENSE_WAIT_TIME) - wait_us = MIN_MOTION_SENSE_WAIT_TIME; + if (wait_us < motion_min_interval) + wait_us = motion_min_interval; } else { wait_us = -1; } @@ -914,7 +916,7 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args) else sensor->config[SENSOR_CONFIG_AP].ec_rate = MAX(in->ec_rate.data, - MIN_MOTION_SENSE_WAIT_TIME / MSEC); + motion_min_interval / MSEC); /* Bound the new sampling rate. */ motion_sense_set_motion_intervals(); @@ -1327,7 +1329,7 @@ static int command_accel_read_xyz(int argc, char **argv) ccprintf("vector not ready\n"); ccprintf("Last calib. data %d: %-5d %-5d %-5d\n", id, sensor->xyz[X], sensor->xyz[Y], sensor->xyz[Z]); - task_wait_event(MIN_MOTION_SENSE_WAIT_TIME); + task_wait_event(motion_min_interval); } return EC_SUCCESS; } diff --git a/include/config.h b/include/config.h index c55c18f0e1..cba750888c 100644 --- a/include/config.h +++ b/include/config.h @@ -741,6 +741,12 @@ */ #undef CONFIG_GPIO_LARGE_ALT_INFO +/* + * Define the minimal amount of time (in ms) betwen running motion sense task + * loop. + */ +#define CONFIG_MOTION_MIN_SENSE_WAIT_TIME 3 + /*****************************************************************************/ /* diff --git a/include/motion_sense.h b/include/motion_sense.h index e2572a364d..e45188b7c8 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -42,10 +42,6 @@ enum sensor_config { /* Next 8 events for sensor interrupt lines */ #define TASK_EVENT_MOTION_INTERRUPT_MASK (0xff << 2) -/* Minimum time in between running motion sense task loop. */ -#define MIN_MOTION_SENSE_WAIT_TIME (3 * MSEC) -#define MAX_MOTION_SENSE_WAIT_TIME (60000 * MSEC) - #define ROUND_UP_FLAG (1 << 31) #define BASE_ODR(_odr) ((_odr) & ~ROUND_UP_FLAG) @@ -135,6 +131,9 @@ struct motion_sensor_t { extern struct motion_sensor_t motion_sensors[]; extern const unsigned motion_sensor_count; +/* optionally defined at board level */ +extern unsigned int motion_min_interval; + /* * Priority of the motion sense resume/suspend hooks, to be sure associated * hooks are scheduled properly. |