lsm303dlhc.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universit├Ąt Berlin
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 
21 #ifndef LSM303DLHC_H
22 #define LSM303DLHC_H
23 
24 #include <stdint.h>
25 #include "periph/i2c.h"
26 #include "periph/gpio.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
36 #define LSM303DLHC_ACC_DEFAULT_ADDRESS (0x19)
37 #define LSM303DLHC_MAG_DEFAULT_ADDRESS (0x1e)
38 
43 typedef enum {
55 
59 typedef enum {
65 
69 typedef enum {
79 
83  typedef enum {
92 
96 typedef struct {
97  int16_t x_axis;
98  int16_t y_axis;
99  int16_t z_axis;
101 
105 typedef struct {
107  uint8_t acc_address;
108  uint8_t mag_address;
109  gpio_t acc_pin;
110  gpio_t mag_pin;
113 } lsm303dlhc_t;
114 
118 typedef struct {
120  uint8_t acc_addr;
121  gpio_t acc_pin;
124  uint8_t mag_addr;
125  gpio_t mag_pin;
129 
147 int lsm303dlhc_init(lsm303dlhc_t *dev, i2c_t i2c, gpio_t acc_pin, gpio_t mag_pin,
148  uint8_t acc_address,
149  lsm303dlhc_acc_sample_rate_t acc_sample_rate,
150  lsm303dlhc_acc_scale_t acc_scale,
151  uint8_t mag_address,
152  lsm303dlhc_mag_sample_rate_t mag_sample_rate,
153  lsm303dlhc_mag_gain_t mag_gain);
154 
175 
199 
209 int lsm303dlhc_read_temp(lsm303dlhc_t *dev, int16_t *value);
210 
220 
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 
235 #endif /* LSM303DLHC_H */
236 
uint8_t mag_address
magnetometer's I2C address
Definition: lsm303dlhc.h:108
i2c_t i2c
I2C device.
Definition: lsm303dlhc.h:106
Low-level GPIO peripheral driver interface definitions.
int lsm303dlhc_read_temp(lsm303dlhc_t *dev, int16_t *value)
Read a temperature value from the sensor.
uint8_t mag_addr
magnetometer I2C address
Definition: lsm303dlhc.h:124
3d data container
Definition: lsm303dlhc.h:96
lsm303dlhc_mag_sample_rate_t
Possible magnetometer sample rates.
Definition: lsm303dlhc.h:69
i2c_t i2c
I2C bus used.
Definition: lsm303dlhc.h:119
gpio_t mag_pin
magnetometer EXTI pin
Definition: lsm303dlhc.h:125
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
lsm303dlhc_acc_scale_t acc_scale
accelerometer scale factor
Definition: lsm303dlhc.h:111
lsm303dlhc_mag_gain_t
Possible magnetometer gain values.
Definition: lsm303dlhc.h:83
gpio_t mag_pin
magnetometer's data ready pin
Definition: lsm303dlhc.h:110
int lsm303dlhc_read_acc(lsm303dlhc_t *dev, lsm303dlhc_3d_data_t *data)
Read a accelerometer value from the sensor.
Device descriptor for LSM303DLHC sensors.
Definition: lsm303dlhc.h:105
450Gauss XYZ 400Gauss Z
Definition: lsm303dlhc.h:87
lsm303dlhc_acc_scale_t acc_scale
accelerometer scale factor
Definition: lsm303dlhc.h:123
lsm303dlhc_mag_gain_t mag_gain
magnetometer gain
Definition: lsm303dlhc.h:112
int16_t z_axis
surprise, holds the z axis value
Definition: lsm303dlhc.h:99
230Gauss XYZ 205Gauss Z
Definition: lsm303dlhc.h:90
int16_t y_axis
holds the y axis value.
Definition: lsm303dlhc.h:98
1100Gauss XYZ 980Gauss Z
Definition: lsm303dlhc.h:84
gpio_t acc_pin
accelerometer's data ready pin
Definition: lsm303dlhc.h:109
lsm303dlhc_acc_scale_t
Possible accelerometer scales.
Definition: lsm303dlhc.h:59
int16_t x_axis
holds the x axis value.
Definition: lsm303dlhc.h:97
gpio_t acc_pin
accelerometer EXTI pin
Definition: lsm303dlhc.h:121
int lsm303dlhc_enable(lsm303dlhc_t *dev)
Enable the given sensor.
uint8_t acc_addr
accelerometer I2C address
Definition: lsm303dlhc.h:120
Data structure holding all the information needed for initialization.
Definition: lsm303dlhc.h:118
lsm303dlhc_mag_gain_t mag_gain
magnetometer gain
Definition: lsm303dlhc.h:127
int lsm303dlhc_init(lsm303dlhc_t *dev, i2c_t i2c, gpio_t acc_pin, gpio_t mag_pin, uint8_t acc_address, lsm303dlhc_acc_sample_rate_t acc_sample_rate, lsm303dlhc_acc_scale_t acc_scale, uint8_t mag_address, lsm303dlhc_mag_sample_rate_t mag_sample_rate, lsm303dlhc_mag_gain_t mag_gain)
Initialize a new LSM303DLHC device.
int lsm303dlhc_read_mag(lsm303dlhc_t *dev, lsm303dlhc_3d_data_t *data)
Read a magnetometer value from the sensor.
855Gauss XYZ 760Gauss Z
Definition: lsm303dlhc.h:85
400Gauss XYZ 355Gauss Z
Definition: lsm303dlhc.h:88
uint8_t acc_address
accelerometer's I2C address
Definition: lsm303dlhc.h:107
330Gauss XYZ 295Gauss Z
Definition: lsm303dlhc.h:89
lsm303dlhc_acc_sample_rate_t acc_rate
accelerometer sample rate
Definition: lsm303dlhc.h:122
lsm303dlhc_acc_sample_rate_t
Possible accelerometer sample rates.
Definition: lsm303dlhc.h:43
670Gauss XYZ 600Gauss Z
Definition: lsm303dlhc.h:86
1344Hz normal mode, 5376Hz low power mode
Definition: lsm303dlhc.h:52
lsm303dlhc_mag_sample_rate_t mag_rate
magnetometer sample rate
Definition: lsm303dlhc.h:126
int lsm303dlhc_disable(lsm303dlhc_t *dev)
Disable the given sensor.
Low-level I2C peripheral driver interface definition.