lsm6dsl.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 
25 #ifndef LSM6DSL_H
26 #define LSM6DSL_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include "periph/i2c.h"
33 
37 enum {
38  LSM6DSL_DATA_RATE_POWER_DOWN = 0x0,
39  LSM6DSL_DATA_RATE_1_6HZ = 0xB,
40  LSM6DSL_DATA_RATE_12_5HZ = 0x1,
41  LSM6DSL_DATA_RATE_26HZ = 0x2,
42  LSM6DSL_DATA_RATE_52HZ = 0x3,
43  LSM6DSL_DATA_RATE_104HZ = 0x4,
44  LSM6DSL_DATA_RATE_208HZ = 0x5,
45  LSM6DSL_DATA_RATE_416HZ = 0x6,
46  LSM6DSL_DATA_RATE_833HZ = 0x7,
47  LSM6DSL_DATA_RATE_1_66KHZ = 0x8,
48  LSM6DSL_DATA_RATE_3_33KHZ = 0x9,
49  LSM6DSL_DATA_RATE_6_66KHZ = 0xa,
50 };
51 
55 enum {
56  LSM6DSL_DECIMATION_NOT_IN_FIFO = 0,
57  LSM6DSL_DECIMATION_NO,
58  LSM6DSL_DECIMATION_2,
59  LSM6DSL_DECIMATION_3,
60  LSM6DSL_DECIMATION_4,
61  LSM6DSL_DECIMATION_8,
62  LSM6DSL_DECIMATION_16,
63  LSM6DSL_DECIMATION_32,
64 };
65 
69 enum {
70  LSM6DSL_ACC_FS_2G = 0,
71  LSM6DSL_ACC_FS_16G,
72  LSM6DSL_ACC_FS_4G,
73  LSM6DSL_ACC_FS_8G,
74  LSM6DSL_ACC_FS_MAX,
75 };
76 
80 enum {
81  LSM6DSL_GYRO_FS_245DPS = 0,
82  LSM6DSL_GYRO_FS_500DPS,
83  LSM6DSL_GYRO_FS_1000DPS,
84  LSM6DSL_GYRO_FS_2000DPS,
85  LSM6DSL_GYRO_FS_MAX,
86 };
87 
91 typedef struct {
93  uint8_t addr;
94  uint8_t acc_odr;
95  uint8_t gyro_odr;
96  uint8_t acc_fs;
97  uint8_t gyro_fs;
98  uint8_t acc_decimation;
99  uint8_t gyro_decimation;
101 
105 typedef struct {
107 } lsm6dsl_t;
108 
112 typedef struct {
113  int16_t x;
114  int16_t y;
115  int16_t z;
117 
121 enum {
126 };
127 
137 int lsm6dsl_init(lsm6dsl_t *dev, const lsm6dsl_params_t *params);
138 
148 int lsm6dsl_read_acc(const lsm6dsl_t *dev, lsm6dsl_3d_data_t *data);
149 
159 int lsm6dsl_read_gyro(const lsm6dsl_t *dev, lsm6dsl_3d_data_t *data);
160 
174 int lsm6dsl_read_temp(const lsm6dsl_t *dev, int16_t *data);
175 
184 int lsm6dsl_acc_power_down(const lsm6dsl_t *dev);
185 
194 int lsm6dsl_gyro_power_down(const lsm6dsl_t *dev);
195 
204 int lsm6dsl_acc_power_up(const lsm6dsl_t *dev);
205 
214 int lsm6dsl_gyro_power_up(const lsm6dsl_t *dev);
215 
216 #ifdef __cplusplus
217 }
218 #endif
219 
220 #endif /* LSM6DSL_H */
221 
I2C bus error.
Definition: lsm6dsl.h:123
int16_t z
Z axis.
Definition: lsm6dsl.h:115
all good
Definition: lsm6dsl.h:122
Config error.
Definition: lsm6dsl.h:124
uint8_t acc_odr
accelerometer output data rate
Definition: lsm6dsl.h:94
uint8_t acc_decimation
accelerometer decimation
Definition: lsm6dsl.h:98
LSM6DSL device descriptor.
Definition: lsm6dsl.h:105
lsm6dsl_params_t params
driver parameters
Definition: lsm6dsl.h:106
int16_t x
X axis.
Definition: lsm6dsl.h:113
uint8_t gyro_fs
gyroscope full scale
Definition: lsm6dsl.h:97
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:108
int lsm6dsl_gyro_power_up(const lsm6dsl_t *dev)
Power up gyroscope.
uint8_t acc_fs
accelerometer full scale
Definition: lsm6dsl.h:96
int lsm6dsl_acc_power_down(const lsm6dsl_t *dev)
Power down accelerometer.
int16_t y
Y axis.
Definition: lsm6dsl.h:114
3D output data
Definition: lsm6dsl.h:112
int lsm6dsl_read_temp(const lsm6dsl_t *dev, int16_t *data)
Read temperature data.
uint8_t addr
i2c address
Definition: lsm6dsl.h:93
int lsm6dsl_read_gyro(const lsm6dsl_t *dev, lsm6dsl_3d_data_t *data)
Read gyroscope data.
i2c_t i2c
i2c bus
Definition: lsm6dsl.h:92
device error
Definition: lsm6dsl.h:125
int lsm6dsl_init(lsm6dsl_t *dev, const lsm6dsl_params_t *params)
Initialize a LSM6DSL device.
int lsm6dsl_read_acc(const lsm6dsl_t *dev, lsm6dsl_3d_data_t *data)
Read accelerometer data.
int lsm6dsl_acc_power_up(const lsm6dsl_t *dev)
Power up accelerometer.
int lsm6dsl_gyro_power_down(const lsm6dsl_t *dev)
Power down gyroscope.
uint8_t gyro_odr
gyroscope output data rate
Definition: lsm6dsl.h:95
LSM6DSL driver parameters.
Definition: lsm6dsl.h:91
uint8_t gyro_decimation
gyroscope decimation
Definition: lsm6dsl.h:99
Low-level I2C peripheral driver interface definition.