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

ST LSM6DSO accelerometer and gyroscope; only the accelerometer is used. More...

Data Structures

struct  pbl_lsm6dso_state
 LSM6DSO driver state, owned by the driver. More...
 
struct  pbl_lsm6dso
 LSM6DSO accelerometer. More...
 

Macros

#define LSM6DSO_SAMPLE_SIZE_BYTES   6
 Accelerometer sample size in bytes (X, Y, Z, 16 bits each).
 
#define LSM6DSO_FIFO_WORD_SIZE_BYTES   7
 FIFO word size in bytes as read from FIFO_DATA_OUT (tag byte plus sample).
 
#define LSM6DSO_FIFO_THRESHOLD   128
 Largest FIFO watermark used, in samples (the FIFO holds up to 512).
 
#define LSM6DSO_FIFO_SIZE   LSM6DSO_FIFO_THRESHOLD
 Read buffer capacity in samples, sized to the watermark.
 
#define LSM6DSO_NUM_BUFS   2
 Number of FIFO read buffers.
 
#define PBL_LSM6DSO_DEFINE(sym, _bus, _addr, _mount, ...)
 Define an LSM6DSO.
 

Detailed Description

ST LSM6DSO accelerometer and gyroscope; only the accelerometer is used.

PBL_LSM6DSO_DEFINE(s_lsm6dso, &s_i2c2, 0x6A,
PBL_SENSOR_MOUNT_MATRIX(-1, 0, 0, 0, 1, 0, 0, 0, 1),
.int1 = ...,
.int1_in = ...);
const struct pbl_sensor *const ACCEL = &s_lsm6dso;
A sensor.
Definition driver.h:142
#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.
Definition driver.h:61
#define PBL_LSM6DSO_DEFINE(sym, _bus, _addr, _mount,...)
Define an LSM6DSO.
Definition lsm6dso.h:125
const struct pbl_sensor *const ACCEL
The board's accelerometer, which may also measure angular rate.

Data Structure Documentation

◆ pbl_lsm6dso_state

struct pbl_lsm6dso_state

LSM6DSO 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.
bool int1_requeued The INT1 servicing pass was requeued while the pad stayed high.
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.
int32_t latency_us Report latency requested in microseconds, or PBL_SENSOR_LATENCY_NONE.
uint32_t num_int1_irqs Number of INT1 interrupts taken.
uint32_t num_recoveries Number of stream recoveries performed.
uint16_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_lsm6dso

struct pbl_lsm6dso

LSM6DSO accelerometer.

Data Fields
struct pbl_i2c_dev i2c I2C device.
struct pbl_irq_spec int1 INT1 interrupt line.
struct pbl_gpio int1_in INT1 input, to read back the pad level.
struct pbl_sensor sensor Sensor, child of the I2C bus.
struct pbl_lsm6dso_state * state Driver state.

Macro Definition Documentation

◆ LSM6DSO_FIFO_SIZE

#define LSM6DSO_FIFO_SIZE   LSM6DSO_FIFO_THRESHOLD

Read buffer capacity in samples, sized to the watermark.

◆ LSM6DSO_FIFO_THRESHOLD

#define LSM6DSO_FIFO_THRESHOLD   128

Largest FIFO watermark used, in samples (the FIFO holds up to 512).

◆ LSM6DSO_FIFO_WORD_SIZE_BYTES

#define LSM6DSO_FIFO_WORD_SIZE_BYTES   7

FIFO word size in bytes as read from FIFO_DATA_OUT (tag byte plus sample).

◆ LSM6DSO_NUM_BUFS

#define LSM6DSO_NUM_BUFS   2

Number of FIFO read buffers.

◆ LSM6DSO_SAMPLE_SIZE_BYTES

#define LSM6DSO_SAMPLE_SIZE_BYTES   6

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

◆ PBL_LSM6DSO_DEFINE

#define PBL_LSM6DSO_DEFINE (   sym,
  _bus,
  _addr,
  _mount,
  ... 
)
Value:
static struct pbl_lsm6dso_state sym##_lsm6dso_state; \
PBL_DEVICE_INSTANCE(sym, struct pbl_lsm6dso, struct pbl_sensor, sensor) { \
.sensor = PBL_SENSOR_INIT(sym, "lsm6dso", &(_bus)->dev, &pbl_lsm6dso_ops, pbl_lsm6dso_chans, \
.state = &sym##_lsm6dso_state, .i2c = PBL_I2C_DEV(_bus, _addr), __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
LSM6DSO driver state, owned by the driver.
Definition lsm6dso.h:42
LSM6DSO accelerometer.
Definition lsm6dso.h:96
#define LSM6DSO_NUM_BUFS
Number of FIFO read buffers.
Definition lsm6dso.h:39
#define LSM6DSO_FIFO_SIZE
Read buffer capacity in samples, sized to the watermark.
Definition lsm6dso.h:37
#define LSM6DSO_FIFO_WORD_SIZE_BYTES
FIFO word size in bytes as read from FIFO_DATA_OUT (tag byte plus sample).
Definition lsm6dso.h:33
@ 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 an LSM6DSO.

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 remaining fields: int1 and int1_in.