PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
LIS2DW12

ST LIS2DW12 accelerometer. More...

Data Structures

struct  pbl_lis2dw12_state
 LIS2DW12 driver state, owned by the driver. More...
 
struct  pbl_lis2dw12
 LIS2DW12 accelerometer. More...
 

Macros

#define LIS2DW12_FIFO_SIZE   32
 FIFO depth in samples.
 
#define LIS2DW12_FIFO_WTM_MAX   31
 Largest FIFO watermark in samples, what its threshold field holds.
 
#define LIS2DW12_SAMPLE_SIZE_BYTES   6
 Sample size in bytes (X, Y, Z, 16 bits each).
 
#define LIS2DW12_NUM_BUFS   2
 Number of FIFO read buffers.
 
#define PBL_LIS2DW12_DEFINE(sym, _bus, _addr, _mount, ...)
 Define a LIS2DW12.
 

Detailed Description

ST LIS2DW12 accelerometer.

.int1 = ...,
.int1_in = ...);
const struct pbl_sensor *const ACCEL = &s_lis2dw12;
A sensor.
Definition driver.h:142
#define PBL_SENSOR_MOUNT_IDENTITY
Identity mounting, for sensors aligned with the device or without vector types.
Definition driver.h:71
#define PBL_LIS2DW12_DEFINE(sym, _bus, _addr, _mount,...)
Define a LIS2DW12.
Definition lis2dw12.h:127
const struct pbl_sensor *const ACCEL
The board's accelerometer, which may also measure angular rate.

Data Structure Documentation

◆ pbl_lis2dw12_state

struct pbl_lis2dw12_state

LIS2DW12 driver state, owned by the driver.

Data Fields
bool double_tap_detection_enabled Double tap detection requested.
bool drain_pending A FIFO drain stopped for lack of a buffer.
bool fifo_on The FIFO is batching: a sampling interval and a report latency are set.
uint32_t int1_period_ms Expected INT1 period in milliseconds.
uint64_t int1_time_us Time of the last INT1 interrupt, in microseconds of uptime.
bool int1_time_valid int1_time_us is yet to be used.
struct pbl_wallclock_work int1_wdt_timer Watchdog timer detecting a stalled INT1 stream.
uint64_t last_fifo_read_tick Time of the last FIFO read.
uint8_t last_sample[LIS2DW12_SAMPLE_SIZE_BYTES] Most recent raw sample, returned by reads while streaming.
uint64_t last_sample_timestamp_us Time of last_sample, in microseconds of uptime.
bool last_sample_valid last_sample holds a sample.
int32_t latency_us Report latency requested in microseconds, or PBL_SENSOR_LATENCY_NONE.
uint32_t num_recoveries Number of stream recoveries performed.
uint8_t num_samples FIFO watermark in samples, derived from the report latency, 0 for no batches.
uint8_t range Range in effect, an index among the supported ones.
struct pbl_sensor_rate rate Measured sampling interval.
uint32_t rate_frames Frames reported since the last read timed by the INT1 interrupt.
bool recovery_deferred A stream recovery waits for a buffer to finish draining the FIFO.
bool recovery_pending A stream recovery is queued.
uint32_t req_interval_us Sampling interval requested, 0 when only events keep the part sampling.
uint32_t sampling_interval_us Sampling interval in microseconds, 0 when not sampling.
bool shake_detection_enabled Shake detection requested.
uint8_t shake_stuck_passes Consecutive watchdog passes with INT1 stuck high in shake-only mode.
uint8_t wk_ths_curr Current wake-up (shake) threshold register value.
int32_t wk_ths_mm_s2 Wake-up (shake) threshold requested, in mm/s².
bool wu_active Wake-up condition currently asserted, to report a shake once per assertion.

◆ pbl_lis2dw12

struct pbl_lis2dw12

LIS2DW12 accelerometer.

Data Fields
struct pbl_i2c_dev i2c I2C device.
struct pbl_irq_spec int1 INT1 interrupt line.

Without one the part is only reset and left powered down, and streaming and shake detection are not supported.

struct pbl_gpio int1_in INT1 input, to read back the pad level, none without int1.
struct pbl_sensor sensor Sensor, child of the I2C bus.
struct pbl_lis2dw12_state * state Driver state.

Macro Definition Documentation

◆ LIS2DW12_FIFO_SIZE

#define LIS2DW12_FIFO_SIZE   32

FIFO depth in samples.

◆ LIS2DW12_FIFO_WTM_MAX

#define LIS2DW12_FIFO_WTM_MAX   31

Largest FIFO watermark in samples, what its threshold field holds.

◆ LIS2DW12_NUM_BUFS

#define LIS2DW12_NUM_BUFS   2

Number of FIFO read buffers.

◆ LIS2DW12_SAMPLE_SIZE_BYTES

#define LIS2DW12_SAMPLE_SIZE_BYTES   6

Sample size in bytes (X, Y, Z, 16 bits each).

◆ PBL_LIS2DW12_DEFINE

#define PBL_LIS2DW12_DEFINE (   sym,
  _bus,
  _addr,
  _mount,
  ... 
)
Value:
static struct pbl_lis2dw12_state sym##_lis2dw12_state; \
PBL_DEVICE_INSTANCE(sym, struct pbl_lis2dw12, struct pbl_sensor, sensor) { \
.sensor = PBL_SENSOR_INIT(sym, "lis2dw12", &(_bus)->dev, &pbl_lis2dw12_ops, \
pbl_lis2dw12_chans, PBL_BIT(PBL_SENSOR_EVENT_SHAKE), _mount), \
.state = &sym##_lis2dw12_state, .i2c = PBL_I2C_DEV(_bus, _addr) __VA_OPT__(, ) __VA_ARGS__, \
}
#define PBL_I2C_DEV(_bus, _addr)
Initializer for a struct pbl_i2c_dev.
Definition i2c.h:159
#define PBL_SENSOR_STREAM_STATE_DEFINE(sym, _num_bufs, _buf_size)
Define the class state of streaming sensor sym, with its batch buffers.
Definition driver.h:181
#define PBL_SENSOR_INIT(sym, _name, _parent, _ops, _chans, _events,...)
Initializer for the struct pbl_sensor of sensor sym.
Definition driver.h:206
LIS2DW12 accelerometer.
Definition lis2dw12.h:95
LIS2DW12 driver state, owned by the driver.
Definition lis2dw12.h:39
#define LIS2DW12_FIFO_SIZE
FIFO depth in samples.
Definition lis2dw12.h:30
#define LIS2DW12_NUM_BUFS
Number of FIFO read buffers.
Definition lis2dw12.h:36
#define LIS2DW12_SAMPLE_SIZE_BYTES
Sample size in bytes (X, Y, Z, 16 bits each).
Definition lis2dw12.h:34
@ PBL_SENSOR_EVENT_SHAKE
Shake, a motion above PBL_SENSOR_EVENT_ATTR_THRESHOLD.
Definition sensor.h:350
#define PBL_BIT(n)
Unsigned 32-bit value with a single bit set.
Definition bits.h:31

Define a LIS2DW12.

Only one instance is supported.

Parameters
symSymbol of the instance, a struct pbl_sensor.
_busI2C bus.
_addr7-bit I2C address.
_mountMounting, from PBL_SENSOR_MOUNT_MATRIX().
...Designated initializers of the optional fields: int1 and int1_in.