lis3mdl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 HAW Hamburg
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 
24 #ifndef LIS3MDL_H
25 #define LIS3MDL_H
26 
27 #include <stdint.h>
28 #include "periph/i2c.h"
29 #include "periph/gpio.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
38 typedef struct {
39  int16_t x_axis;
40  int16_t y_axis;
41  int16_t z_axis;
43 
47 typedef enum {
53 
57 typedef enum {
63 
67 typedef enum {
76 
80 typedef enum {
86 
90 typedef enum {
94 } lis3mdl_op_t;
95 
99 typedef struct {
101  uint8_t addr;
108 
109 
113 typedef struct {
115 } lis3mdl_t;
116 
126 int lis3mdl_init(lis3mdl_t *dev, const lis3mdl_params_t *params);
127 
134 void lis3mdl_read_mag(const lis3mdl_t *dev, lis3mdl_3d_data_t *data);
135 
142 void lis3mdl_read_temp(const lis3mdl_t *dev, int16_t *value);
143 
149 void lis3mdl_enable(const lis3mdl_t *dev);
150 
156 void lis3mdl_disable(const lis3mdl_t *dev);
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif /* LIS3MDL_H */
163 
lis3mdl_read_temp
void lis3mdl_read_temp(const lis3mdl_t *dev, int16_t *value)
Reads the temperature value of LIS3MDL.
lis3mdl_init
int lis3mdl_init(lis3mdl_t *dev, const lis3mdl_params_t *params)
Initialize a new LIS3DML device.
LIS3MDL_Z_MODE_LOW
@ LIS3MDL_Z_MODE_LOW
Low-power mode.
Definition: lis3mdl.h:58
LIS3MDL_ODR_2_5Hz
@ LIS3MDL_ODR_2_5Hz
5.000Hz
Definition: lis3mdl.h:70
lis3mdl_enable
void lis3mdl_enable(const lis3mdl_t *dev)
Enable the LIS3MDL device.
lis3mdl_odr_t
lis3mdl_odr_t
Output data rate [Hz] for LIS3MDL.
Definition: lis3mdl.h:67
lis3mdl_t
Device descriptor for LIS3MDL sensor.
Definition: lis3mdl.h:113
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
lis3mdl_params_t::op_mode
lis3mdl_op_t op_mode
Operation mode.
Definition: lis3mdl.h:106
LIS3MDL_SCALE_8G
@ LIS3MDL_SCALE_8G
+- 8 gauss
Definition: lis3mdl.h:82
LIS3MDL_SCALE_12G
@ LIS3MDL_SCALE_12G
+- 12 gauss
Definition: lis3mdl.h:83
LIS3MDL_ODR_80HZ
@ LIS3MDL_ODR_80HZ
80.000Hz
Definition: lis3mdl.h:74
lis3mdl_z_mode_t
lis3mdl_z_mode_t
Operating mode of z-axis for LIS3MDL.
Definition: lis3mdl.h:57
lis3mdl_t::params
lis3mdl_params_t params
Initialization parameters.
Definition: lis3mdl.h:114
LIS3MDL_XY_MODE_LOW
@ LIS3MDL_XY_MODE_LOW
Low-power mode.
Definition: lis3mdl.h:48
LIS3DML_ODR_20HZ
@ LIS3DML_ODR_20HZ
20.000Hz
Definition: lis3mdl.h:72
lis3mdl_3d_data_t
3d data container of the LIS3MDL sensor
Definition: lis3mdl.h:38
LIS3MDL_SCALE_4G
@ LIS3MDL_SCALE_4G
+- 4 gauss
Definition: lis3mdl.h:81
LIS3MDL_Z_MODE_ULTRA
@ LIS3MDL_Z_MODE_ULTRA
Ultra-High-performance mode.
Definition: lis3mdl.h:61
LIS3MDL_ODR_10Hz
@ LIS3MDL_ODR_10Hz
10.000Hz
Definition: lis3mdl.h:71
LIS3MDL_OP_SNGL_CONV
@ LIS3MDL_OP_SNGL_CONV
Single-conversion mode.
Definition: lis3mdl.h:92
LIS3MDL_SCALE_16G
@ LIS3MDL_SCALE_16G
+- 16 gauss
Definition: lis3mdl.h:84
lis3mdl_3d_data_t::y_axis
int16_t y_axis
Magnometer data from y_axis.
Definition: lis3mdl.h:40
lis3mdl_3d_data_t::x_axis
int16_t x_axis
Magnometer data from x-axis.
Definition: lis3mdl.h:39
lis3mdl_params_t::i2c
i2c_t i2c
I2C device.
Definition: lis3mdl.h:100
LIS3DML_ODR_40HZ
@ LIS3DML_ODR_40HZ
40.000Hz
Definition: lis3mdl.h:73
lis3mdl_params_t::xy_mode
lis3mdl_xy_mode_t xy_mode
Power mode of x- and y-axis.
Definition: lis3mdl.h:102
lis3mdl_scale_t
lis3mdl_scale_t
Scale [gauss] for LIS3MDL.
Definition: lis3mdl.h:80
LIS3MDL_XY_MODE_HIGH
@ LIS3MDL_XY_MODE_HIGH
High-performance mode.
Definition: lis3mdl.h:50
LIS3MDL_Z_MODE_HIGH
@ LIS3MDL_Z_MODE_HIGH
High-performance mode.
Definition: lis3mdl.h:60
LIS3MDL_ODR_0_625Hz
@ LIS3MDL_ODR_0_625Hz
0.625Hz
Definition: lis3mdl.h:68
lis3mdl_params_t::scale
lis3mdl_scale_t scale
Scale factor.
Definition: lis3mdl.h:105
LIS3MDL_OP_CONT_CONV
@ LIS3MDL_OP_CONT_CONV
Continous-conversion mode.
Definition: lis3mdl.h:91
gpio.h
Low-level GPIO peripheral driver interface definitions.
lis3mdl_params_t
Device initialization parameters.
Definition: lis3mdl.h:99
lis3mdl_disable
void lis3mdl_disable(const lis3mdl_t *dev)
Disable the LIS3MDL device.
lis3mdl_xy_mode_t
lis3mdl_xy_mode_t
Operating mode of x- and y-axis for LIS3MDL.
Definition: lis3mdl.h:47
lis3mdl_3d_data_t::z_axis
int16_t z_axis
Magnometer data from z_axis.
Definition: lis3mdl.h:41
LIS3MDL_ODR_1_25Hz
@ LIS3MDL_ODR_1_25Hz
1.250Hz
Definition: lis3mdl.h:69
LIS3MDL_OP_PDOWN
@ LIS3MDL_OP_PDOWN
Power-down mode.
Definition: lis3mdl.h:93
LIS3MDL_XY_MODE_ULTRA
@ LIS3MDL_XY_MODE_ULTRA
Ultra-High-performance mode.
Definition: lis3mdl.h:51
lis3mdl_params_t::addr
uint8_t addr
Magnometer I2C address.
Definition: lis3mdl.h:101
lis3mdl_params_t::z_mode
lis3mdl_z_mode_t z_mode
Power mode of z-axis.
Definition: lis3mdl.h:103
LIS3MDL_XY_MODE_MEDIUM
@ LIS3MDL_XY_MODE_MEDIUM
Medium-performance mode.
Definition: lis3mdl.h:49
lis3mdl_params_t::odr
lis3mdl_odr_t odr
Output data rate.
Definition: lis3mdl.h:104
LIS3MDL_Z_MODE_MEDIUM
@ LIS3MDL_Z_MODE_MEDIUM
Medium-performance mode.
Definition: lis3mdl.h:59
lis3mdl_read_mag
void lis3mdl_read_mag(const lis3mdl_t *dev, lis3mdl_3d_data_t *data)
Reads the magnometer value of LIS3MDL.
i2c.h
Low-level I2C peripheral driver interface definition.
lis3mdl_op_t
lis3mdl_op_t
Operating modes.
Definition: lis3mdl.h:90