mag3110.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 PHYTEC Messtechnik GmbH
3  * 2017 HAW Hamburg
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
32 #ifndef MAG3110_H
33 #define MAG3110_H
34 
35 #include <stdint.h>
36 #include <stdbool.h>
37 #include "periph/i2c.h"
38 
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #endif
43 
47 enum {
52 };
53 
54 #ifndef MAG3110_I2C_ADDRESS
55 #define MAG3110_I2C_ADDRESS 0x0E
56 #endif
57 
58 #define MAG3110_DROS_8000_16 0
59 #define MAG3110_DROS_4000_32 1
60 #define MAG3110_DROS_2000_64 2
61 #define MAG3110_DROS_1000_128 3
62 #define MAG3110_DROS_4000_16 4
63 #define MAG3110_DROS_2000_32 5
64 #define MAG3110_DROS_1000_64 6
65 #define MAG3110_DROS_0500_128 7
66 #define MAG3110_DROS_2000_16 8
67 #define MAG3110_DROS_1000_32 9
68 #define MAG3110_DROS_0500_64 10
69 #define MAG3110_DROS_0250_128 11
70 #define MAG3110_DROS_1000_16 12
71 #define MAG3110_DROS_0500_32 13
72 #define MAG3110_DROS_0250_64 14
73 #define MAG3110_DROS_0125_128 15
74 #define MAG3110_DROS_0500_16 16
75 #define MAG3110_DROS_0250_32 17
76 #define MAG3110_DROS_0125_64 18
77 #define MAG3110_DROS_0063_128 19
78 #define MAG3110_DROS_0250_16 20
79 #define MAG3110_DROS_0125_32 21
80 #define MAG3110_DROS_0063_64 22
81 #define MAG3110_DROS_0031_128 23
82 #define MAG3110_DROS_0125_16 24
83 #define MAG3110_DROS_0063_32 25
84 #define MAG3110_DROS_0031_64 26
85 #define MAG3110_DROS_0016_128 27
86 #define MAG3110_DROS_0063_16 28
87 #define MAG3110_DROS_0031_32 29
88 #define MAG3110_DROS_0016_64 30
89 #define MAG3110_DROS_0008_128 31
90 #define MAG3110_DROS_DEFAULT MAG3110_DROS_0125_128
95 typedef struct {
97  uint8_t addr;
98  uint8_t type;
99  uint8_t dros;
100  int16_t offset[3];
102 
106 typedef struct {
108 } mag3110_t;
109 
113 typedef struct {
114  int16_t x;
115  int16_t y;
116  int16_t z;
118 
130 int mag3110_init(mag3110_t *dev, const mag3110_params_t *params);
131 
144 int mag3110_set_user_offset(mag3110_t *dev, int16_t x, int16_t y, int16_t z);
145 
154 int mag3110_set_active(mag3110_t *dev);
155 
165 
175 int mag3110_is_ready(mag3110_t *dev);
176 
188 int mag3110_read(mag3110_t *dev, mag3110_data_t *data);
189 
199 int mag3110_read_dtemp(mag3110_t *dev, int8_t *dtemp);
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 
205 #endif /* MAG3110_H */
206 
Configuration parameters.
Definition: mag3110.h:95
int mag3110_init(mag3110_t *dev, const mag3110_params_t *params)
Initialise the MAG3110 magnetometer driver.
uint8_t addr
I2C bus address of the device.
Definition: mag3110.h:97
int mag3110_set_active(mag3110_t *dev)
Set active mode, this enables periodic measurements.
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
int mag3110_set_user_offset(mag3110_t *dev, int16_t x, int16_t y, int16_t z)
Set user offset correction.
Device configuration failed.
Definition: mag3110.h:51
mag3110_params_t params
device configuration parameters
Definition: mag3110.h:107
all good
Definition: mag3110.h:48
int mag3110_is_ready(mag3110_t *dev)
Check for new set of measurement data.
int mag3110_set_standby(mag3110_t *dev)
Set standby mode.
int mag3110_read(mag3110_t *dev, mag3110_data_t *data)
Read magnetometer's data.
uint8_t type
device type
Definition: mag3110.h:98
int16_t z
acceleration in Z direction
Definition: mag3110.h:116
I2C communication failed.
Definition: mag3110.h:49
i2c_t i2c
I2C bus the device is connected to.
Definition: mag3110.h:96
Device MAG3110 not found.
Definition: mag3110.h:50
Data type for the result data.
Definition: mag3110.h:113
int16_t y
acceleration in Y direction
Definition: mag3110.h:115
int16_t x
acceleration in X direction
Definition: mag3110.h:114
int mag3110_read_dtemp(mag3110_t *dev, int8_t *dtemp)
Read die temperature.
uint8_t dros
sampling rate to use
Definition: mag3110.h:99
Device descriptor for MAG3110 magnetometer.
Definition: mag3110.h:106
Low-level I2C peripheral driver interface definition.