Loading...
Searching...
No Matches
qmc5883l.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 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
55#ifndef QMC5883L_H
56#define QMC5883L_H
57
58#ifdef __cplusplus
59extern "C"
60{
61#endif
62
63#include <stdint.h>
64
65#include "periph/gpio.h"
66#include "periph/i2c.h"
67
71#define QMC5883L_ADDR (0x0d)
72
76enum {
82};
83
93typedef enum {
94 QMC5883L_ODR_10HZ = (0u << 2),
95 QMC5883L_ODR_50HZ = (1u << 2),
96 QMC5883L_ODR_100HZ = (2u << 2),
97 QMC5883L_ODR_200HZ = (3u << 2),
99
110typedef enum {
111 QMC5883L_RNG_2G = (0u << 4),
112 QMC5883L_RNG_8G = (1u << 4),
114
124typedef enum {
125 QMC5883L_OSR_512 = (0u << 6),
126 QMC5883L_OSR_256 = (1u << 6),
127 QMC5883L_OSR_128 = (2u << 6),
128 QMC5883L_OSR_64 = (3u << 6),
130
141
145typedef struct {
147 gpio_t pin_drdy;
148 uint8_t cfg;
149} qmc5883l_t;
150
165
178
196int qmc5883l_read(const qmc5883l_t *dev, int16_t *data_out);
197
218int qmc5883l_read_raw(const qmc5883l_t *dev, int16_t *data_out);
219
231
243
244#if defined(MODULE_QMC5883L_INT) || defined(DOXYGEN)
273int qmc5883l_init_int(const qmc5883l_t *dev, gpio_cb_t cb, void *arg);
274
288
300#endif /* defined(MODULE_QMC5883L_INT) || defined(DOXYGEN) */
301
302#ifdef __cplusplus
303}
304#endif
305
306#endif /* QMC5883L_H */
Low-level GPIO peripheral driver interface definitions.
void(* gpio_cb_t)(void *arg)
Signature of event callback functions triggered from interrupts.
Definition gpio.h:147
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
int qmc5883l_read_raw(const qmc5883l_t *dev, int16_t *data_out)
Read RAW data from the device.
int qmc5883l_read(const qmc5883l_t *dev, int16_t *data_out)
Read sampled data from the device [converted to milli-Gauss].
int qmc5883l_irq_disable(const qmc5883l_t *dev)
Disable the data ready (DRDY) interrupt.
qmc5883l_rng_t
Output value range.
Definition qmc5883l.h:110
qmc5883l_osr_t
Over sample rate (bandwidth of internal digital filter)
Definition qmc5883l.h:124
qmc5883l_odr_t
Output data rate.
Definition qmc5883l.h:93
int qmc5883l_poweron(const qmc5883l_t *dev)
Power on the sensor (put it into continuous sampling mode)
int qmc5883l_irq_enable(const qmc5883l_t *dev)
Enable the data ready (DRDY) interrupt.
int qmc5883l_poweroff(const qmc5883l_t *dev)
Power off the sensor (put it into standby mode)
int qmc5883l_init_int(const qmc5883l_t *dev, gpio_cb_t cb, void *arg)
Initialize data ready (DRDY) interrupt notifications.
int qmc5883l_init(qmc5883l_t *dev, const qmc5883l_params_t *params)
Initialize the given QMC5883L magnetic sensor.
int qmc5883l_data_ready(const qmc5883l_t *dev)
Check if new data is available.
@ QMC5883L_RNG_2G
2 Gauss data output range
Definition qmc5883l.h:111
@ QMC5883L_RNG_8G
8 Gauss data output range
Definition qmc5883l.h:112
@ QMC5883L_OSR_256
256 samples per reading
Definition qmc5883l.h:126
@ QMC5883L_OSR_64
64 samples per reading
Definition qmc5883l.h:128
@ QMC5883L_OSR_512
512 samples per reading
Definition qmc5883l.h:125
@ QMC5883L_OSR_128
128 samples per reading
Definition qmc5883l.h:127
@ QMC5883L_ODR_50HZ
50Hz data output rate
Definition qmc5883l.h:95
@ QMC5883L_ODR_100HZ
100Hz data output rate
Definition qmc5883l.h:96
@ QMC5883L_ODR_10HZ
10Hz data output rate
Definition qmc5883l.h:94
@ QMC5883L_ODR_200HZ
200Hz data output rate
Definition qmc5883l.h:97
@ QMC5883L_BUSERR
i2c bus error
Definition qmc5883l.h:80
@ QMC5883L_OK
success
Definition qmc5883l.h:77
@ QMC5883L_OVERFLOW
at least one axis overflowed its range
Definition qmc5883l.h:79
@ QMC5883L_NOCFG
configuration error
Definition qmc5883l.h:81
@ QMC5883L_NODATA
no data are available
Definition qmc5883l.h:78
Low-level I2C peripheral driver interface definition.
QMC5883L initialization parameters.
Definition qmc5883l.h:134
qmc5883l_rng_t rng
output data range
Definition qmc5883l.h:138
qmc5883l_odr_t odr
output data rate
Definition qmc5883l.h:137
i2c_t i2c
I2C bus the sensor is connected to.
Definition qmc5883l.h:135
qmc5883l_osr_t osr
oversampling rate
Definition qmc5883l.h:139
gpio_t pin_drdy
DRDY ISR pin, set to GPIO_UNDEF if unused.
Definition qmc5883l.h:136
QMC5883L device descriptor.
Definition qmc5883l.h:145
gpio_t pin_drdy
DRDY interrupt pin.
Definition qmc5883l.h:147
uint8_t cfg
actual applied device configuration
Definition qmc5883l.h:148
i2c_t i2c
I2C bus the sensor is connected to.
Definition qmc5883l.h:146