fxos8700.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 UC Berkeley
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 
28 #ifndef FXOS8700_H
29 #define FXOS8700_H
30 
31 #include <stdint.h>
32 #include "periph/i2c.h"
33 #include "fxos8700_regs.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
50 #ifdef DOXYGEN
51 #define CONFIG_FXOS8700_USE_ACC_RAW_VALUES
52 #endif
53 
58 enum {
64 };
65 
69 typedef struct {
71  uint8_t addr;
72  uint8_t acc_range;
73  uint32_t renew_interval;
75 
79 typedef struct {
80  int16_t x;
81  int16_t y;
82  int16_t z;
84 
88 typedef struct {
89  uint8_t config;
92  uint32_t last_read_time;
94 } fxos8700_t;
95 
108 int fxos8700_init(fxos8700_t* dev, const fxos8700_params_t* params);
109 
121 int fxos8700_set_active(const fxos8700_t* dev);
122 
134 int fxos8700_set_idle(const fxos8700_t* dev);
135 
150 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* FXOS8700_H */
171 
fxos8700_read_cached
int fxos8700_read_cached(const void *dev, fxos8700_measurement_t *acc, fxos8700_measurement_t *mag)
Extended read function including caching capability.
fxos8700_params_t::acc_range
uint8_t acc_range
Accelerator full-scale range.
Definition: fxos8700.h:72
fxos8700_read
int fxos8700_read(const fxos8700_t *dev, fxos8700_measurement_t *acc, fxos8700_measurement_t *mag)
Convenience function for reading acceleration and magnetic field.
FXOS8700_BUSERR
@ FXOS8700_BUSERR
error during I2C communication
Definition: fxos8700.h:63
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
fxos8700_t::acc_cached
fxos8700_measurement_t acc_cached
cached 3-axis acceleration
Definition: fxos8700.h:90
fxos8700_measurement_t::z
int16_t z
z axis of 3-axis measurement
Definition: fxos8700.h:82
fxos8700_t::last_read_time
uint32_t last_read_time
last time when cached data was refreshed
Definition: fxos8700.h:92
fxos8700_measurement_t::y
int16_t y
y axis of 3-axis measurement
Definition: fxos8700.h:81
fxos8700_t::config
uint8_t config
sensor configuration including active mode
Definition: fxos8700.h:89
fxos8700_init
int fxos8700_init(fxos8700_t *dev, const fxos8700_params_t *params)
Initialize an FXOS8700 device.
FXOS8700_NODEV
@ FXOS8700_NODEV
no FXOS8700 device found on the bus
Definition: fxos8700.h:62
FXOS8700_NOBUS
@ FXOS8700_NOBUS
errors while initializing the I2C bus
Definition: fxos8700.h:61
fxos8700_set_idle
int fxos8700_set_idle(const fxos8700_t *dev)
Convenience function for turning off the FXOS8700.
fxos8700_params_t::renew_interval
uint32_t renew_interval
Interval for cache renewal.
Definition: fxos8700.h:73
fxos8700_t::p
fxos8700_params_t p
configuration parameters
Definition: fxos8700.h:93
fxos8700_measurement_t::x
int16_t x
x axis of 3-axis measurement
Definition: fxos8700.h:80
fxos8700_params_t::addr
uint8_t addr
I2C address of this particular sensor.
Definition: fxos8700.h:71
FXOS8700_ADDRERR
@ FXOS8700_ADDRERR
no FXOS8700 device found on the bus
Definition: fxos8700.h:60
fxos8700_params_t
Parameters needed for device initialization.
Definition: fxos8700.h:69
fxos8700_t
Device descriptor for a FXOS8700 device.
Definition: fxos8700.h:88
fxos8700_params_t::i2c
i2c_t i2c
I2C device that sensor is connected to.
Definition: fxos8700.h:70
fxos8700_regs.h
Register definitions for FXOS8700 devices.
i2c.h
Low-level I2C peripheral driver interface definition.
fxos8700_t::mag_cached
fxos8700_measurement_t mag_cached
cached 3-axis magnetic field
Definition: fxos8700.h:91
fxos8700_measurement_t
Individual 3-axis measurement.
Definition: fxos8700.h:79
fxos8700_set_active
int fxos8700_set_active(const fxos8700_t *dev)
Convenience function for turning on the FXOS8700.
FXOS8700_OK
@ FXOS8700_OK
everything went as expected
Definition: fxos8700.h:59