LSM9DS1 Library  0.7.0-alpha
C Library for the LSM9DS1 device.
lsm9ds1.h
Go to the documentation of this file.
1 /*
2  * This file is part of the lsm9ds1 library (https://github.com/ChristopherJD/lsm9ds1.git).
3  * Copyright (c) 2019 Christopher Jordan-Denny.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, version 3.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
29 #ifndef LSM9DS1_H_
30 #define LSM9DS1_H_
31 
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36 
37 #include <stdbool.h>
38 #include <stdint.h>
39 #include "lsm9ds1_debug.h"
40 #include "lsm9ds1_config.h"
41 
42 #define _BUILD_VERSION BUILD_VERSION
43 
47 typedef struct lsm9ds1_data_t
48 {
49  lsm9ds1_temperature_t temperature;
50  accelerometer_raw_data_t accelerometer;
51  mag_raw_data_t magnetometer;
52  gyro_raw_data_t gyroscope;
54 
56  float x;
57  float y;
58  float z;
60 
61 typedef struct mag_converted_data_t {
62  float x;
63  float y;
64  float z;
66 
67 typedef struct gyro_converted_data_t {
68  float x;
69  float y;
70  float z;
72 
76 typedef struct lsm9ds1_converted_data_t {
77  float temperature;
78  accelerometer_converted_data_t accelerometer;
79  mag_converted_data_t magnetometer;
80  gyro_converted_data_t gyroscope;
82 
86 typedef struct lsm9ds1_device_t {
87  bool initialized;
88  lsm9ds1_settings_t settings;
89  lsm9ds1_xfer_bus_t xfer_bus;
90  lsm9ds1_data_t raw_data;
91  lsm9ds1_converted_data_t converted_data;
92  lsm9ds1_sub_devices_t sub_device;
93 
94  lsm9ds1_status_t (*update_temp)(struct lsm9ds1_device_t *self);
95  lsm9ds1_status_t (*update_accel)(struct lsm9ds1_device_t *self);
96  lsm9ds1_status_t (*update_mag)(struct lsm9ds1_device_t *self);
97  lsm9ds1_status_t (*update_gyro)(struct lsm9ds1_device_t *self);
98  lsm9ds1_status_t (*update)(struct lsm9ds1_device_t *self);
100 
136 lsm9ds1_status_t get_temp(lsm9ds1_temperature_t *temperature);
137 
177 
216 
256 
282 
312 
313 #ifdef __cplusplus
314 }
315 #endif
316 
317 #endif /* LSM9DS1_H_ */
Stores the converted data for each sub device.
Definition: lsm9ds1.h:76
enum lsm9ds1_status lsm9ds1_status_t
Contains the possible error codes returned by the functions.
Definition: lsm9ds1.h:55
Definition: lsm9ds1.h:67
lsm9ds1_status_t get_temp(lsm9ds1_temperature_t *temperature)
Read the temperature of the LSM9DS1.
struct lsm9ds1_device_t lsm9ds1_device_t
Data and configurations for the lsm9ds1 device.
struct lsm9ds1_converted_data_t lsm9ds1_converted_data_t
Stores the converted data for each sub device.
Stores the raw data for each sub device.
Definition: lsm9ds1.h:47
lsm9ds1_status_t get_accel(accelerometer_converted_data_t *data)
Read the accelerometer of the LSM9DS1.
lsm9ds1_status_t lsm9ds1_close()
Close the LSM9DS1.
Definition: lsm9ds1.h:61
Data and configurations for the lsm9ds1 device.
Definition: lsm9ds1.h:86
lsm9ds1_status_t get_gyro(gyro_converted_data_t *data)
Read the gyroscope from the LSM9DS1.
lsm9ds1_status_t get_mag(mag_converted_data_t *data)
Read the magnetometer of the LSM9DS1.
lsm9ds1_status_t lsm9ds1_init()
Initialize the LSM9DS1.
struct lsm9ds1_data_t lsm9ds1_data_t
Stores the raw data for each sub device.