diff options
Diffstat (limited to 'driver')
-rw-r--r-- | driver/als_si114x.c | 14 | ||||
-rw-r--r-- | driver/als_si114x.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/driver/als_si114x.c b/driver/als_si114x.c index 4e941a0534..f1b6d23966 100644 --- a/driver/als_si114x.c +++ b/driver/als_si114x.c @@ -163,6 +163,16 @@ void si114x_interrupt(enum gpio_signal signal) CONFIG_ALS_SI114X_INT_EVENT, 0); } +#ifdef CONFIG_ALS_SI114X_POLLING +static void si114x_read_deferred(void) +{ + task_set_event(TASK_ID_MOTIONSENSE, + CONFIG_ALS_SI114X_INT_EVENT, 0); + +} +DECLARE_DEFERRED(si114x_read_deferred); +#endif + /** * irq_handler - bottom half of the interrupt stack. * Ran from the motion_sense task, finds the events that raised the interrupt. @@ -266,6 +276,10 @@ static int read(const struct motion_sensor_t *s, vector_3_t v) return EC_ERROR_INVAL; } ret = raw_write8(s->port, s->addr, SI114X_REG_COMMAND, cmd); +#ifdef CONFIG_ALS_SI114X_POLLING + hook_call_deferred(&si114x_read_deferred_data, + SI114x_POLLING_DELAY); +#endif ret = EC_RES_IN_PROGRESS; break; case SI114X_ALS_IN_PROGRESS_PS_PENDING: diff --git a/driver/als_si114x.h b/driver/als_si114x.h index 5fbc3c665f..78fed24c78 100644 --- a/driver/als_si114x.h +++ b/driver/als_si114x.h @@ -211,6 +211,9 @@ /* Time to wait before re-initializing the device if access is denied */ #define SI114X_DENIED_THRESHOLD (10 * SECOND) +/* Delay used for deferred callback when polling is enabled */ +#define SI114x_POLLING_DELAY (8 * MSEC) + extern const struct accelgyro_drv si114x_drv; enum si114x_state { |