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 
22 #ifndef LSM6DSL_H
23 #define LSM6DSL_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "periph/i2c.h"
30 
32 enum {
33  LSM6DSL_DATA_RATE_POWER_DOWN = 0x0,
34  LSM6DSL_DATA_RATE_1_6HZ = 0xB,
35  LSM6DSL_DATA_RATE_12_5HZ = 0x1,
36  LSM6DSL_DATA_RATE_26HZ = 0x2,
37  LSM6DSL_DATA_RATE_52HZ = 0x3,
38  LSM6DSL_DATA_RATE_104HZ = 0x4,
39  LSM6DSL_DATA_RATE_208HZ = 0x5,
40  LSM6DSL_DATA_RATE_416HZ = 0x6,
41  LSM6DSL_DATA_RATE_833HZ = 0x7,
42  LSM6DSL_DATA_RATE_1_66KHZ = 0x8,
43  LSM6DSL_DATA_RATE_3_33KHZ = 0x9,
44  LSM6DSL_DATA_RATE_6_66KHZ = 0xa,
45 };
46 
48 enum {
49  LSM6DSL_DECIMATION_NOT_IN_FIFO = 0,
50  LSM6DSL_DECIMATION_NO = 1,
51  LSM6DSL_DECIMATION_2 = 2,
52  LSM6DSL_DECIMATION_3 = 3,
53  LSM6DSL_DECIMATION_4 = 4,
54  LSM6DSL_DECIMATION_8 = 5,
55  LSM6DSL_DECIMATION_16 = 6,
56  LSM6DSL_DECIMATION_32 = 7,
57 };
58 
60 enum {
61  LSM6DSL_ACC_FS_2G = 0,
62  LSM6DSL_ACC_FS_4G = 2,
63  LSM6DSL_ACC_FS_8G = 3,
64  LSM6DSL_ACC_FS_16G = 1,
65 };
66 
68 enum {
69  LSM6DSL_GYRO_FS_245DPS = 0,
70  LSM6DSL_GYRO_FS_500DPS = 1,
71  LSM6DSL_GYRO_FS_1000DPS = 2,
72  LSM6DSL_GYRO_FS_2000DPS = 3,
73 };
74 
76 typedef struct {
78  uint8_t addr;
79  uint8_t acc_odr;
80  uint8_t gyro_odr;
81  uint8_t acc_fs;
82  uint8_t gyro_fs;
83  uint8_t acc_decimation;
84  uint8_t gyro_decimation;
86 
88 typedef struct {
90 } lsm6dsl_t;
91 
93 typedef struct {
94  int16_t x;
95  int16_t y;
96  int16_t z;
98 
108 int lsm6dsl_init(lsm6dsl_t *dev, const lsm6dsl_params_t *params);
109 
120 
131 
141 int lsm6dsl_read_temp(lsm6dsl_t *dev, int16_t *data);
142 
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif /* LSM6DSL_H */
148 
int16_t z
Z axis.
Definition: lsm6dsl.h:96
int lsm6dsl_read_acc(lsm6dsl_t *dev, lsm6dsl_3d_data_t *data)
Read accelerometer data.
uint8_t acc_odr
accelerometer output data rate
Definition: lsm6dsl.h:79
uint8_t acc_decimation
accelerometer decimation
Definition: lsm6dsl.h:83
LSM6DSL device descriptor.
Definition: lsm6dsl.h:88
lsm6dsl_params_t params
driver parameters
Definition: lsm6dsl.h:89
int lsm6dsl_read_gyro(lsm6dsl_t *dev, lsm6dsl_3d_data_t *data)
Read gyroscope data.
int16_t x
X axis.
Definition: lsm6dsl.h:94
int lsm6dsl_read_temp(lsm6dsl_t *dev, int16_t *data)
Read temperature data.
uint8_t gyro_fs
gyroscope full scale
Definition: lsm6dsl.h:82
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
uint8_t acc_fs
accelerometer full scale
Definition: lsm6dsl.h:81
int16_t y
Y axis.
Definition: lsm6dsl.h:95
3D output data
Definition: lsm6dsl.h:93
uint8_t addr
i2c address
Definition: lsm6dsl.h:78
i2c_t i2c
i2c bus
Definition: lsm6dsl.h:77
int lsm6dsl_init(lsm6dsl_t *dev, const lsm6dsl_params_t *params)
Initialize a LSM6DSL device.
uint8_t gyro_odr
gyroscope output data rate
Definition: lsm6dsl.h:80
LSM6DSL driver parameters.
Definition: lsm6dsl.h:76
uint8_t gyro_decimation
gyroscope decimation
Definition: lsm6dsl.h:84
Low-level I2C peripheral driver interface definition.