Loading...
Searching...
No Matches
lsm6dsxx.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 OTA keys S.A.
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 *
8 */
9
27#ifndef LSM6DSXX_H
28#define LSM6DSXX_H
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include "periph/i2c.h"
35
39enum {
40 LSM6DSXX_DATA_RATE_POWER_DOWN = 0x0,
41 LSM6DSXX_DATA_RATE_1_6HZ = 0xB,
42 LSM6DSXX_DATA_RATE_12_5HZ = 0x1,
43 LSM6DSXX_DATA_RATE_26HZ = 0x2,
44 LSM6DSXX_DATA_RATE_52HZ = 0x3,
45 LSM6DSXX_DATA_RATE_104HZ = 0x4,
46 LSM6DSXX_DATA_RATE_208HZ = 0x5,
47 LSM6DSXX_DATA_RATE_416HZ = 0x6,
48 LSM6DSXX_DATA_RATE_833HZ = 0x7,
49 LSM6DSXX_DATA_RATE_1_66KHZ = 0x8,
50 LSM6DSXX_DATA_RATE_3_33KHZ = 0x9,
51 LSM6DSXX_DATA_RATE_6_66KHZ = 0xa,
52};
53
57enum {
58 LSM6DSXX_DECIMATION_NOT_IN_FIFO = 0,
59 LSM6DSXX_DECIMATION_NO,
60 LSM6DSXX_DECIMATION_2,
61 LSM6DSXX_DECIMATION_3,
62 LSM6DSXX_DECIMATION_4,
63 LSM6DSXX_DECIMATION_8,
64 LSM6DSXX_DECIMATION_16,
65 LSM6DSXX_DECIMATION_32,
66};
67
71enum {
72 LSM6DSXX_ACC_FS_2G = 0,
73 LSM6DSXX_ACC_FS_16G,
74 LSM6DSXX_ACC_FS_4G,
75 LSM6DSXX_ACC_FS_8G,
76 LSM6DSXX_ACC_FS_MAX,
77};
78
82enum {
83 LSM6DSXX_GYRO_FS_245DPS = 0,
84 LSM6DSXX_GYRO_FS_500DPS,
85 LSM6DSXX_GYRO_FS_1000DPS,
86 LSM6DSXX_GYRO_FS_2000DPS,
87 LSM6DSXX_GYRO_FS_MAX,
88};
89
93typedef struct {
95 uint8_t addr;
96 uint8_t acc_odr;
97 uint8_t gyro_odr;
98 uint8_t acc_fs;
99 uint8_t gyro_fs;
103
111
115typedef struct {
116 int16_t x;
117 int16_t y;
118 int16_t z;
120
124enum {
129};
130
141
152
163
177int lsm6dsxx_read_temp(const lsm6dsxx_t *dev, int16_t *data);
178
188
198
208
218
219#ifdef __cplusplus
220}
221#endif
222
223#endif /* LSM6DSXX_H */
int lsm6dsxx_acc_power_down(const lsm6dsxx_t *dev)
Power down accelerometer.
int lsm6dsxx_gyro_power_down(const lsm6dsxx_t *dev)
Power down gyroscope.
int lsm6dsxx_gyro_power_up(const lsm6dsxx_t *dev)
Power up gyroscope.
int lsm6dsxx_acc_power_up(const lsm6dsxx_t *dev)
Power up accelerometer.
int lsm6dsxx_read_acc(const lsm6dsxx_t *dev, lsm6dsxx_3d_data_t *data)
Read accelerometer data.
int lsm6dsxx_init(lsm6dsxx_t *dev, const lsm6dsxx_params_t *params)
Initialize a LSM6DSXX device.
int lsm6dsxx_read_gyro(const lsm6dsxx_t *dev, lsm6dsxx_3d_data_t *data)
Read gyroscope data.
int lsm6dsxx_read_temp(const lsm6dsxx_t *dev, int16_t *data)
Read temperature data.
@ LSM6DSXX_ERROR_DEV
device error
Definition lsm6dsxx.h:128
@ LSM6DSXX_OK
all good
Definition lsm6dsxx.h:125
@ LSM6DSXX_ERROR_CNF
Config error.
Definition lsm6dsxx.h:127
@ LSM6DSXX_ERROR_BUS
I2C bus error.
Definition lsm6dsxx.h:126
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
3D output data
Definition lsm6dsxx.h:115
int16_t x
X axis.
Definition lsm6dsxx.h:116
int16_t y
Y axis.
Definition lsm6dsxx.h:117
int16_t z
Z axis.
Definition lsm6dsxx.h:118
LSM6DSXX driver parameters.
Definition lsm6dsxx.h:93
uint8_t acc_fs
accelerometer full scale
Definition lsm6dsxx.h:98
uint8_t acc_odr
accelerometer output data rate
Definition lsm6dsxx.h:96
uint8_t gyro_odr
gyroscope output data rate
Definition lsm6dsxx.h:97
i2c_t i2c
i2c bus
Definition lsm6dsxx.h:94
uint8_t gyro_decimation
gyroscope decimation
Definition lsm6dsxx.h:101
uint8_t gyro_fs
gyroscope full scale
Definition lsm6dsxx.h:99
uint8_t addr
i2c address
Definition lsm6dsxx.h:95
uint8_t acc_decimation
accelerometer decimation
Definition lsm6dsxx.h:100
LSM6DSXX device descriptor.
Definition lsm6dsxx.h:107
uint8_t temperature_scaling_factor
temperature scaling factor
Definition lsm6dsxx.h:109
lsm6dsxx_params_t params
driver parameters
Definition lsm6dsxx.h:108