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