Loading...
Searching...
No Matches
lsm303dlhc.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
22
23#include <stdint.h>
24#include "periph/i2c.h"
25#include "periph/gpio.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
35#define LSM303DLHC_ACC_DEFAULT_ADDRESS (0x19)
36#define LSM303DLHC_MAG_DEFAULT_ADDRESS (0x1e)
38
54
64
78
91
95typedef struct {
96 int16_t x_axis;
97 int16_t y_axis;
98 int16_t z_axis;
100
115
122
133
154
178
188int lsm303dlhc_read_temp(const lsm303dlhc_t *dev, int16_t *value);
189
199
209
210#ifdef __cplusplus
211}
212#endif
213
Low-level GPIO peripheral driver interface definitions.
lsm303dlhc_acc_scale_t
Possible accelerometer scales.
Definition lsm303dlhc.h:58
int lsm303dlhc_enable(const lsm303dlhc_t *dev)
Enable the given sensor.
int lsm303dlhc_read_temp(const lsm303dlhc_t *dev, int16_t *value)
Read a temperature value from the sensor.
lsm303dlhc_mag_gain_t
Possible magnetometer gain values.
Definition lsm303dlhc.h:82
int lsm303dlhc_disable(const lsm303dlhc_t *dev)
Disable the given sensor.
int lsm303dlhc_read_acc(const lsm303dlhc_t *dev, lsm303dlhc_3d_data_t *data)
Read a accelerometer value from the sensor.
int lsm303dlhc_init(lsm303dlhc_t *dev, const lsm303dlhc_params_t *params)
Initialize a new LSM303DLHC device.
lsm303dlhc_acc_sample_rate_t
Possible accelerometer sample rates.
Definition lsm303dlhc.h:42
int lsm303dlhc_read_mag(const lsm303dlhc_t *dev, lsm303dlhc_3d_data_t *data)
Read a magnetometer value from the sensor.
lsm303dlhc_mag_sample_rate_t
Possible magnetometer sample rates.
Definition lsm303dlhc.h:68
@ LSM303DLHC_ACC_SCALE_4G
+- 4g range
Definition lsm303dlhc.h:60
@ LSM303DLHC_ACC_SCALE_8G
+- 8g range
Definition lsm303dlhc.h:61
@ LSM303DLHC_ACC_SCALE_16G
+-16g range
Definition lsm303dlhc.h:62
@ LSM303DLHC_ACC_SCALE_2G
+- 2g range
Definition lsm303dlhc.h:59
@ LSM303DLHC_MAG_GAIN_330_295_GAUSS
330Gauss XYZ 295Gauss Z
Definition lsm303dlhc.h:88
@ LSM303DLHC_MAG_GAIN_855_760_GAUSS
855Gauss XYZ 760Gauss Z
Definition lsm303dlhc.h:84
@ LSM303DLHC_MAG_GAIN_450_400_GAUSS
450Gauss XYZ 400Gauss Z
Definition lsm303dlhc.h:86
@ LSM303DLHC_MAG_GAIN_1100_980_GAUSS
1100Gauss XYZ 980Gauss Z
Definition lsm303dlhc.h:83
@ LSM303DLHC_MAG_GAIN_670_600_GAUSS
670Gauss XYZ 600Gauss Z
Definition lsm303dlhc.h:85
@ LSM303DLHC_MAG_GAIN_230_205_GAUSS
230Gauss XYZ 205Gauss Z
Definition lsm303dlhc.h:89
@ LSM303DLHC_MAG_GAIN_400_355_GAUSS
400Gauss XYZ 355Gauss Z
Definition lsm303dlhc.h:87
@ LSM303DLHC_ACC_SAMPLE_RATE_N1344HZ_L5376HZ
1344Hz normal mode, 5376Hz low power mode
Definition lsm303dlhc.h:51
@ LSM303DLHC_ACC_SAMPLE_RATE_1620HZ
1620Hz sample rate
Definition lsm303dlhc.h:50
@ LSM303DLHC_ACC_SAMPLE_RATE_1HZ
1Hz sample rate
Definition lsm303dlhc.h:43
@ LSM303DLHC_ACC_SAMPLE_RATE_10HZ
10Hz sample rate
Definition lsm303dlhc.h:44
@ LSM303DLHC_ACC_SAMPLE_RATE_25HZ
25Hz sample rate
Definition lsm303dlhc.h:45
@ LSM303DLHC_ACC_SAMPLE_RATE_400HZ
400Hz sample rate
Definition lsm303dlhc.h:49
@ LSM303DLHC_ACC_SAMPLE_RATE_50HZ
50Hz sample rate
Definition lsm303dlhc.h:46
@ LSM303DLHC_ACC_SAMPLE_RATE_100HZ
100Hz sample rate
Definition lsm303dlhc.h:47
@ LSM303DLHC_ACC_SAMPLE_RATE_200HZ
200Hz sample rate
Definition lsm303dlhc.h:48
@ LSM303DLHC_MAG_SAMPLE_RATE_15HZ
15 Hz sample rate
Definition lsm303dlhc.h:73
@ LSM303DLHC_MAG_SAMPLE_RATE_7_5HZ
7.5 Hz sample rate
Definition lsm303dlhc.h:72
@ LSM303DLHC_MAG_SAMPLE_RATE_75HZ
75 Hz sample rate
Definition lsm303dlhc.h:75
@ LSM303DLHC_MAG_SAMPLE_RATE_3HZ
3 Hz sample rate
Definition lsm303dlhc.h:71
@ LSM303DLHC_MAG_SAMPLE_RATE_30HZ
30 Hz sample rate
Definition lsm303dlhc.h:74
@ LSM303DLHC_MAG_SAMPLE_RATE_0_75HZ
0.75Hz sample rate
Definition lsm303dlhc.h:69
@ LSM303DLHC_MAG_SAMPLE_RATE_220HZ
220 Hz sample rate
Definition lsm303dlhc.h:76
@ LSM303DLHC_MAG_SAMPLE_RATE_1_5HZ
1.5 Hz sample rate
Definition lsm303dlhc.h:70
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
3d data container
Definition lsm303dlhc.h:95
int16_t z_axis
surprise, holds the z axis value
Definition lsm303dlhc.h:98
int16_t y_axis
holds the y axis value.
Definition lsm303dlhc.h:97
int16_t x_axis
holds the x axis value.
Definition lsm303dlhc.h:96
Data structure holding all the information needed for initialization.
Definition lsm303dlhc.h:104
lsm303dlhc_acc_sample_rate_t acc_rate
accelerometer sample rate
Definition lsm303dlhc.h:108
uint8_t acc_addr
accelerometer I2C address
Definition lsm303dlhc.h:106
lsm303dlhc_acc_scale_t acc_scale
accelerometer scale factor
Definition lsm303dlhc.h:109
uint8_t mag_addr
magnetometer I2C address
Definition lsm303dlhc.h:110
gpio_t mag_pin
magnetometer EXTI pin
Definition lsm303dlhc.h:111
gpio_t acc_pin
accelerometer EXTI pin
Definition lsm303dlhc.h:107
lsm303dlhc_mag_sample_rate_t mag_rate
magnetometer sample rate
Definition lsm303dlhc.h:112
lsm303dlhc_mag_gain_t mag_gain
magnetometer gain
Definition lsm303dlhc.h:113
i2c_t i2c
I2C bus used.
Definition lsm303dlhc.h:105
Device descriptor for LSM303DLHC sensors.
Definition lsm303dlhc.h:119
lsm303dlhc_params_t params
device initialization parameters
Definition lsm303dlhc.h:120