bmx055.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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 
9 #pragma once
10 
28 #include <stdint.h>
29 
30 #include "periph/i2c.h"
31 #include "periph/gpio.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
49 #ifndef CONFIG_BMX055_MAG_ADDR_DEFAULT
50 #define CONFIG_BMX055_MAG_ADDR_DEFAULT (0x10U)
51 #endif
52 
60 #ifndef CONFIG_BMX055_ACC_ADDR_DEFAULT
61 #define CONFIG_BMX055_ACC_ADDR_DEFAULT (0x18U)
62 #endif
63 
71 #ifndef CONFIG_BMX055_GYRO_ADDR_DEFAULT
72 #define CONFIG_BMX055_GYRO_ADDR_DEFAULT (0x68U)
73 #endif
79 enum {
80  BMX055_OK = 0,
81  BMX055_NOBUS = -1,
82  BMX055_NODEV = -2,
86 };
87 
91 typedef enum {
101 
105 typedef enum {
111 
115 typedef enum {
122 
126 typedef struct {
128  uint8_t addr_mag;
129  uint8_t addr_acc;
130  uint8_t addr_gyro;
131  gpio_t int1_pin;
132  gpio_t int2_pin;
133  uint8_t mag_rate;
134  uint8_t acc_range;
135  uint8_t gyro_scale;
137 
141 typedef struct {
143 } bmx055_t;
144 
156 int bmx055_init(bmx055_t *dev, const bmx055_params_t *params);
157 
168 int bmx055_mag_read(const bmx055_t *dev, int16_t *data);
169 
180 int bmx055_acc_read(const bmx055_t *dev, int16_t *data);
181 
195 int bmx055_gyro_read(const bmx055_t *dev, int16_t *data);
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
Low-level GPIO peripheral driver interface definitions.
int bmx055_gyro_read(const bmx055_t *dev, int16_t *data)
Read angular speed value in degree per second from gyroscope.
bmx055_gyro_scale_t
Measurement scale for the gyro.
Definition: bmx055.h:115
bmx055_acc_range_t
Range for Accelerometer.
Definition: bmx055.h:105
int bmx055_acc_read(const bmx055_t *dev, int16_t *data)
Read acceleration value in g from accelerometer.
int bmx055_init(bmx055_t *dev, const bmx055_params_t *params)
Initialize modules magnetometer, accelerometer, gyroscope.
bmx055_mag_rate_t
Datarate for Magnetometer.
Definition: bmx055.h:91
int bmx055_mag_read(const bmx055_t *dev, int16_t *data)
Read magnetic field value in Gauss per second from magnetometer.
@ BMX055_GYRO_SCALE_0125DPS
scale: 125 degree per second
Definition: bmx055.h:120
@ BMX055_GYRO_SCALE_0250DPS
scale: 250 degree per second
Definition: bmx055.h:119
@ BMX055_GYRO_SCALE_1000DPS
scale: 1000 degree per second
Definition: bmx055.h:117
@ BMX055_GYRO_SCALE_0500DPS
scale: 500 degree per second
Definition: bmx055.h:118
@ BMX055_GYRO_SCALE_2000DPS
scale: 2000 degree per second
Definition: bmx055.h:116
@ BMX055_ACC_RANGE_4G
range: 4g
Definition: bmx055.h:107
@ BMX055_ACC_RANGE_2G
range: 2g
Definition: bmx055.h:106
@ BMX055_ACC_RANGE_8G
range: 8g
Definition: bmx055.h:108
@ BMX055_ACC_RANGE_16G
range: 16g
Definition: bmx055.h:109
@ BMX055_MAG_DRATE_30HZ
output data rate: 30 Hz
Definition: bmx055.h:99
@ BMX055_MAG_DRATE_25HZ
output data rate: 25 Hz
Definition: bmx055.h:98
@ BMX055_MAG_DRATE_15HZ
output data rate: 15 Hz
Definition: bmx055.h:96
@ BMX055_MAG_DRATE_DEFAULT
output data rate: 10 Hz
Definition: bmx055.h:92
@ BMX055_MAG_DRATE_02HZ
output data rate: 2 Hz
Definition: bmx055.h:93
@ BMX055_MAG_DRATE_06HZ
output data rate: 6 Hz
Definition: bmx055.h:94
@ BMX055_MAG_DRATE_08HZ
output data rate: 8 Hz
Definition: bmx055.h:95
@ BMX055_MAG_DRATE_20HZ
output data rate: 20 Hz
Definition: bmx055.h:97
@ BMX055_NOWRITE
cannot write data to module
Definition: bmx055.h:84
@ BMX055_NOBUS
cannot connect to module on i2c bus
Definition: bmx055.h:81
@ BMX055_OK
exit without error
Definition: bmx055.h:80
@ BMX055_NOTREADY
no new data ready for reading
Definition: bmx055.h:85
@ BMX055_NOREAD
cannot read data from module
Definition: bmx055.h:83
@ BMX055_NODEV
cannot read any data from module
Definition: bmx055.h:82
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition: i2c.h:144
Low-level I2C peripheral driver interface definition.
Data structure holding the device parameters needed for initialization.
Definition: bmx055.h:126
uint8_t mag_rate
datarate of magnetometer
Definition: bmx055.h:133
uint8_t addr_acc
the accelerometer address on that bus
Definition: bmx055.h:129
uint8_t gyro_scale
range of gyroscope
Definition: bmx055.h:135
gpio_t int1_pin
GPIO pin connected to the INT1 line.
Definition: bmx055.h:131
uint8_t acc_range
range of accelerometer
Definition: bmx055.h:134
uint8_t addr_mag
the magnetometer address on that bus
Definition: bmx055.h:128
uint8_t addr_gyro
the gyroscope address on that bus
Definition: bmx055.h:130
gpio_t int2_pin
GPIO pin connected to the INT2 line.
Definition: bmx055.h:132
i2c_t i2c
I2C bus the device is connected to.
Definition: bmx055.h:127
Device descriptor for BMX055 sensors.
Definition: bmx055.h:141
bmx055_params_t p
Device initialization parameters.
Definition: bmx055.h:142