diff options
Diffstat (limited to 'include/motion_sense_fifo.h')
-rw-r--r-- | include/motion_sense_fifo.h | 80 |
1 files changed, 33 insertions, 47 deletions
diff --git a/include/motion_sense_fifo.h b/include/motion_sense_fifo.h index d47c23af94..6b306b5f29 100644 --- a/include/motion_sense_fifo.h +++ b/include/motion_sense_fifo.h @@ -7,8 +7,14 @@ #define __CROS_EC_MOTION_SENSE_FIFO_H #include "motion_sense.h" +#include "task.h" + +extern struct queue motion_sense_fifo; +extern int wake_up_needed; +extern int fifo_int_enabled; +extern int fifo_queue_count; +extern int motion_sense_fifo_lost; -/** Allowed async events. */ enum motion_sense_async_event { ASYNC_EVENT_FLUSH = MOTIONSENSE_SENSOR_FLAG_FLUSH | MOTIONSENSE_SENSOR_FLAG_TIMESTAMP, @@ -16,26 +22,6 @@ enum motion_sense_async_event { MOTIONSENSE_SENSOR_FLAG_TIMESTAMP, }; -/** Whether or not we need to wake up the AP. */ -extern int motion_sense_fifo_wake_up_needed; - -/** - * Insert an async event into the fifo. - * - * @param sensor The sensor that generated the async event. - * @param event The event to insert. - */ -void motion_sense_fifo_insert_async_event( - struct motion_sensor_t *sensor, - enum motion_sense_async_event event); - -/** - * Insert a timestamp into the fifo. - * - * @param timestamp The timestamp to insert. - */ -void motion_sense_fifo_add_timestamp(uint32_t timestamp); - /** * Stage data to the fifo, including a timestamp. This data will not be * available to the AP until motion_sense_fifo_commit_data is called. @@ -46,46 +32,46 @@ void motion_sense_fifo_add_timestamp(uint32_t timestamp); * @param time accurate time (ideally measured in an interrupt) the sample * was taken at */ -void motion_sense_fifo_stage_data( - struct ec_response_motion_sensor_data *data, - struct motion_sensor_t *sensor, - int valid_data, - uint32_t time); +void motion_sense_fifo_stage_data(struct ec_response_motion_sensor_data *data, + struct motion_sensor_t *sensor, + int valid_data, + uint32_t time); /** - * Commit all the currently staged data to the fifo. Doing so makes it readable - * to the AP. + * Commits all staged data to the fifo. If multiple readings were placed using + * the same timestamps, they will be spread out. */ void motion_sense_fifo_commit_data(void); /** - * Get information about the fifo. + * Insert an async event into the fifo. * - * @param fifo_info The struct to modify with the current information about the - * fifo. - * @param reset Whether or not to reset statistics after reading them. + * @param sensor Pointer to the sensor generating the event. + * @param evt The event to insert. */ -void motion_sense_fifo_get_info( - struct ec_response_motion_sense_fifo_info *fifo_info, - int reset); +void motion_sense_insert_async_event(struct motion_sensor_t *sensor, + enum motion_sense_async_event evt); /** - * Check whether or not the fifo has gone over its threshold. + * Stage a timestamp into the fifo. + * + * @param timestamp The timestamp to stage. + */ +void motion_sense_fifo_stage_timestamp(uint32_t timestamp); + +/** + * Get information about the fifo. * - * @return 1 if yes, 0 for no. + * @param fifo_info The struct to store the info. */ -int motion_sense_fifo_over_thres(void); +void motion_sense_get_fifo_info( + struct ec_response_motion_sense_fifo_info *fifo_info); /** - * Read available committed entries from the fifo. + * Checks if either the AP should be woken up due to the fifo. * - * @param capacity_bytes The number of bytes available to be written to `out`. - * @param max_count The maximum number of entries to be placed in `out`. - * @param out The target to copy the data into. - * @param out_size The number of bytes written to `out`. - * @return The number of entries written to `out`. + * @return 1 if the AP should be woken up, 0 otherwise. */ -int motion_sense_fifo_read(int capacity_bytes, int max_count, void *out, - uint16_t *out_size); +int motion_sense_fifo_is_wake_up_needed(void); -#endif /*__CROS_EC_MOTION_SENSE_FIFO_H */ +#endif /* __CROS_EC_MOTION_SENSE_FIFO_H */ |