PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
driver.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <pbl/device.h>
#include <pbl/drivers/sensor.h>
#include <pbl/kernel/cache.h>
#include <pbl/kernel/compiler.h>
#include <pbl/kernel/mutex.h>
#include <pbl/kernel/work.h>
#include <pbl/util/bits.h>
#include <pbl/util/math.h>
#include <pbl/util/size.h>

Data Structures

struct  pbl_sensor_mount
 Mounting of a sensor in the device. More...
 
struct  pbl_sensor_ops
 Driver operations. More...
 
struct  pbl_sensor_state
 Class runtime state. More...
 
struct  pbl_sensor
 A sensor. More...
 
struct  pbl_sensor_rate
 Sampling interval of a sensor, as measured from the time of its frames. More...
 

Macros

#define PBL_SENSOR_MOUNT_MATRIX(xx, xy, xz, yx, yy, yz, zx, zy, zz)
 Initializer for a struct pbl_sensor_mount, from the rows of a mount matrix.
 
#define PBL_SENSOR_MOUNT_IDENTITY   PBL_SENSOR_MOUNT_MATRIX(1, 0, 0, 0, 1, 0, 0, 0, 1)
 Identity mounting, for sensors aligned with the device or without vector types.
 
#define PBL_SENSOR_STATE_DEFINE(sym)
 Define the class state of sensor sym, without batch buffers, for sensors that are only read.
 
#define PBL_SENSOR_STREAM_STATE_DEFINE(sym, _num_bufs, _buf_size)
 Define the class state of streaming sensor sym, with its batch buffers.
 
#define PBL_SENSOR_INIT(sym, _name, _parent, _ops, _chans, _events, ...)
 Initializer for the struct pbl_sensor of sensor sym.
 

Functions

void pbl_sensor_lock (const struct pbl_sensor *sensor)
 Take the device lock.
 
void pbl_sensor_unlock (const struct pbl_sensor *sensor)
 Release the device lock.
 
uint8_t * pbl_sensor_buf_alloc (const struct pbl_sensor *sensor, uint16_t *size)
 Get a free batch buffer.
 
void pbl_sensor_buf_free (const struct pbl_sensor *sensor, const uint8_t *data)
 Give back a buffer from pbl_sensor_buf_alloc() without reporting it.
 
void pbl_sensor_report (const struct pbl_sensor *sensor, const struct pbl_sensor_batch *batch)
 Report a batch to the listener.
 
void pbl_sensor_report_event (const struct pbl_sensor *sensor, const struct pbl_sensor_event *event)
 Report an event to the listener.
 
static uint16_t pbl_sensor_latency_to_frames (int32_t latency_us, uint32_t interval_us, uint16_t max)
 Convert a report latency to the frames a driver queues before reporting them.
 
void pbl_sensor_rate_reset (struct pbl_sensor_rate *rate, uint32_t nominal_us)
 Start measuring a sampling interval over, from the nominal one.
 
uint32_t pbl_sensor_rate_update (struct pbl_sensor_rate *rate, uint64_t timestamp_us, uint32_t frames)
 Take the time of a frame into the measurement of a sampling interval.