Loading...
Searching...
No Matches
hmc5883l.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Gunar Schorcht
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
32#ifndef HMC5883L_H
33#define HMC5883L_H
34
35#ifdef __cplusplus
36extern "C"
37{
38#endif
39
40#include <stdbool.h>
41#include <stdint.h>
42
43#include "periph/gpio.h"
44#include "periph/i2c.h"
45
55
70
81
93
104
120
124typedef struct {
125 int16_t x;
126 int16_t y;
127 int16_t z;
129
133typedef struct {
134 int16_t x;
135 int16_t y;
136 int16_t z;
138
139#if MODULE_HMC5883L_INT || DOXYGEN
140
151typedef void (*hmc5883l_drdy_int_cb_t)(void *);
152
153#endif /* MODULE_HMC5883L_INT || DOXYGEN */
154
169
173typedef struct {
174 unsigned dev;
175#if MODULE_HMC5883L_INT
176 gpio_t int_pin;
177#endif
180} hmc5883l_t;
181
196
197#if MODULE_HMC5883L_INT || DOXYGEN
198
220
221#endif /* MODULE_HMC5883L_INT || DOXYGEN */
222
236
252
264
278
290
291#ifdef __cplusplus
292}
293#endif
294
295#endif /* HMC5883L_H */
Low-level GPIO peripheral driver interface definitions.
hmc5883l_dor_t
Data output rates (DOR)
Definition hmc5883l.h:61
int hmc5883l_power_down(hmc5883l_t *dev)
Power down the sensor.
int hmc5883l_data_ready(const hmc5883l_t *dev)
Data-ready status function.
int hmc5883l_init(hmc5883l_t *dev, const hmc5883l_params_t *params)
Initialize the HMC5883L sensor device.
int hmc5883l_init_int(hmc5883l_t *dev, hmc5883l_drdy_int_cb_t cb, void *arg)
Initialize and activate the DRDY interrupt of HMC5883L sensor device.
hmc5883l_error_codes_t
Definition of error codes.
Definition hmc5883l.h:47
hmc5883l_gain_t
Gain (determines the sensitivity and the range)
Definition hmc5883l.h:110
int hmc5883l_read_raw(const hmc5883l_t *dev, hmc5883l_raw_data_t *raw)
Read one sample of raw sensor data as 16 bit two's complements.
hmc5883l_meas_mode_t
Measurement modes.
Definition hmc5883l.h:76
int hmc5883l_read(const hmc5883l_t *dev, hmc5883l_data_t *data)
Read one sample of magnetic field values in milli-Gauss (mGs)
int hmc5883l_power_up(hmc5883l_t *dev)
Power up the sensor.
void(* hmc5883l_drdy_int_cb_t)(void *)
HMC5883L DRDY interrupt callback function type.
Definition hmc5883l.h:151
hmc5883l_meas_avg_t
Measurement avaraging (number of samples are averaged for output)
Definition hmc5883l.h:87
hmc5883l_op_mode_t
Operation modes.
Definition hmc5883l.h:99
@ HMC5883L_DOR_30
30 Hz
Definition hmc5883l.h:67
@ HMC5883L_DOR_7_5
7.5 Hz
Definition hmc5883l.h:65
@ HMC5883L_DOR_75
75 Hz
Definition hmc5883l.h:68
@ HMC5883L_DOR_0_75
0.75 Hz
Definition hmc5883l.h:62
@ HMC5883L_DOR_15
15 Hz (default)
Definition hmc5883l.h:66
@ HMC5883L_DOR_1_5
1.5 Hz
Definition hmc5883l.h:63
@ HMC5883L_DOR_3
3 Hz
Definition hmc5883l.h:64
@ HMC5883L_ERROR_COMMON
common error
Definition hmc5883l.h:53
@ HMC5883L_ERROR_NO_DATA
no data are available
Definition hmc5883l.h:51
@ HMC5883L_ERROR_WRONG_ID
wrong id read
Definition hmc5883l.h:50
@ HMC5883L_ERROR_RAW_DATA
reading raw data failed
Definition hmc5883l.h:52
@ HMC5883L_OK
success
Definition hmc5883l.h:48
@ HMC5883L_ERROR_I2C
any I2C communication error
Definition hmc5883l.h:49
@ HMC5883L_GAIN_390
Range +-4.7 Gs, Resolution 2.56 mGs/LSB.
Definition hmc5883l.h:116
@ HMC5883L_GAIN_330
Range +-5.6 Gs, Resolution 3.03 mGs/LSB.
Definition hmc5883l.h:117
@ HMC5883L_GAIN_1090
Range +-1.3 Gs, Resolution 0.92 mGs/LSB.
Definition hmc5883l.h:112
@ HMC5883L_GAIN_1370
Range +-0.88 Gs, Resolution 0.73 mGs/LSB.
Definition hmc5883l.h:111
@ HMC5883L_GAIN_820
Range +-1.9 Gs, Resolution 1.22 mGs/LSB.
Definition hmc5883l.h:113
@ HMC5883L_GAIN_230
Range +-8.1 Gs, Resolution 4.35 mGs/LSB.
Definition hmc5883l.h:118
@ HMC5883L_GAIN_440
Range +-4.0 Gs, Resolution 2.27 mGs/LSB.
Definition hmc5883l.h:115
@ HMC5883L_GAIN_660
Range +-2.5 Gs, Resolution 1.52 mGs/LSB.
Definition hmc5883l.h:114
@ HMC5883L_MEAS_MODE_BIAS_NEG
Negative bias config for all axes.
Definition hmc5883l.h:79
@ HMC5883L_MEAS_MODE_BIAS_POS
Positive bias config for all axes.
Definition hmc5883l.h:78
@ HMC5883L_MEAS_MODE_NORMAL
Normal measurement config.
Definition hmc5883l.h:77
@ HMC5883L_MEAS_AVG_NONE
No averaging.
Definition hmc5883l.h:88
@ HMC5883L_MEAS_AVG_2
2 samples are averaged
Definition hmc5883l.h:89
@ HMC5883L_MEAS_AVG_8
8 samples are averaged
Definition hmc5883l.h:91
@ HMC5883L_MEAS_AVG_4
4 samples are averaged
Definition hmc5883l.h:90
@ HMC5883L_OP_MODE_IDLE
Idle mode.
Definition hmc5883l.h:102
@ HMC5883L_OP_MODE_SINGLE
Single measurement.
Definition hmc5883l.h:101
@ HMC5883L_OP_MODE_CONTINUOUS
Continuous measurement.
Definition hmc5883l.h:100
Low-level I2C peripheral driver interface definition.
Magnetic field values in milli-Gauss (mGs)
Definition hmc5883l.h:124
int16_t z
magnetic field y-axis
Definition hmc5883l.h:127
int16_t y
magnetic field y-axis
Definition hmc5883l.h:126
int16_t x
magnetic field x-axis
Definition hmc5883l.h:125
HMC5883L device initialization parameters.
Definition hmc5883l.h:158
unsigned dev
I2C device.
Definition hmc5883l.h:159
hmc5883l_dor_t dor
Data output rate (default HMC5883L_DOR_15)
Definition hmc5883l.h:165
hmc5883l_meas_mode_t meas_mode
Measurement mode (default HMC5883L_MEAS_MODE_NORMAL)
Definition hmc5883l.h:163
hmc5883l_meas_avg_t meas_avg
Measurement avaraging (default HMC5883L_MEAS_AVG_NONE)
Definition hmc5883l.h:164
hmc5883l_gain_t gain
Gain (default HMC5883L_GAIN_1090)
Definition hmc5883l.h:167
hmc5883l_op_mode_t op_mode
Operation mode (HMC5883L_OP_MODE_CONTINUOUS)
Definition hmc5883l.h:166
Raw data set as two complements.
Definition hmc5883l.h:133
int16_t z
magnetic field z-axis as 16 bit two's complements
Definition hmc5883l.h:136
int16_t x
magnetic field x-axis as 16 bit two's complements
Definition hmc5883l.h:134
int16_t y
magnetic field y-axis as 16 bit two's complements
Definition hmc5883l.h:135
HMC5883L sensor device data structure type.
Definition hmc5883l.h:173
unsigned dev
I2C device.
Definition hmc5883l.h:174
hmc5883l_op_mode_t op_mode
Operation mode (HMC5883L_OP_MODE_CONTINUOUS)
Definition hmc5883l.h:178
hmc5883l_gain_t gain
Gain (default HMC5883L_GAIN_1090)
Definition hmc5883l.h:179