mma8x5x.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 PHYTEC Messtechnik GmbH
3  * 2016 Freie Universit├Ąt Berlin
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
33 #ifndef MMA8X5X_H
34 #define MMA8X5X_H
35 
36 #include <stdint.h>
37 #include "periph/i2c.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #ifndef MMA8X5X_I2C_ADDRESS
44 #define MMA8X5X_I2C_ADDRESS 0x1D
45 #endif
46 
50 enum {
56 };
57 
61 enum {
62  MMA8X5X_RATE_800HZ = (0 << 3),
63  MMA8X5X_RATE_400HZ = (1 << 3),
64  MMA8X5X_RATE_200HZ = (2 << 3),
65  MMA8X5X_RATE_100HZ = (3 << 3),
66  MMA8X5X_RATE_50HZ = (4 << 3),
67  MMA8X5X_RATE_1HZ25 = (5 << 3),
68  MMA8X5X_RATE_6HZ25 = (6 << 3),
69  MMA8X5X_RATE_1HZ56 = (7 << 3)
70 };
71 
75 enum {
79 };
80 
84 enum {
85  MMA8X5X_OK = 0,
90 };
91 
95 typedef struct {
97  uint8_t addr;
98  uint8_t type;
99  uint8_t rate;
100  uint8_t range;
101  uint8_t offset[3];
103 
107 typedef struct {
109 } mma8x5x_t;
110 
114 typedef struct {
115  int16_t x;
116  int16_t y;
117  int16_t z;
119 
130 int mma8x5x_init(mma8x5x_t *dev, const mma8x5x_params_t *params);
131 
142 void mma8x5x_set_user_offset(const mma8x5x_t *dev, int8_t x, int8_t y, int8_t z);
143 
149 void mma8x5x_set_active(const mma8x5x_t *dev);
150 
156 void mma8x5x_set_standby(const mma8x5x_t *dev);
157 
166 int mma8x5x_is_ready(const mma8x5x_t *dev);
167 
182 void mma8x5x_read(const mma8x5x_t *dev, mma8x5x_data_t *data);
183 
195 void mma8x5x_set_motiondetect(const mma8x5x_t *dev, uint8_t int_pin, uint8_t threshold);
196 
208 void mma8x5x_ack_int(const mma8x5x_t *dev);
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif /* MMA8X5X_H */
215 
new data ready to be read
Definition: mma8x5x.h:86
void mma8x5x_set_active(const mma8x5x_t *dev)
Set active mode, this enables periodic measurements.
uint8_t addr
I2C bus address of the device.
Definition: mma8x5x.h:97
6.25 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:68
Configuration parameters.
Definition: mma8x5x.h:95
100 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:65
1.56 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:69
200 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:64
+/- 4 g Full Scale Range
Definition: mma8x5x.h:77
void mma8x5x_set_standby(const mma8x5x_t *dev)
Set standby mode.
int16_t y
acceleration in Y direction
Definition: mma8x5x.h:116
void mma8x5x_set_motiondetect(const mma8x5x_t *dev, uint8_t int_pin, uint8_t threshold)
Configure motion detection interrupt.
400 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:63
+/- 2 g Full Scale Range
Definition: mma8x5x.h:76
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
+/- 8 g Full Scale Range
Definition: mma8x5x.h:78
uint8_t type
device type
Definition: mma8x5x.h:98
mma8x5x_params_t params
device configuration parameters
Definition: mma8x5x.h:108
void mma8x5x_set_user_offset(const mma8x5x_t *dev, int8_t x, int8_t y, int8_t z)
Set user offset correction.
no data available
Definition: mma8x5x.h:89
everything was fine
Definition: mma8x5x.h:85
int mma8x5x_init(mma8x5x_t *dev, const mma8x5x_params_t *params)
Initialize the MMA8x5x accelerometer driver.
Data type for the result data.
Definition: mma8x5x.h:114
no MMA8X5X device found on the bus
Definition: mma8x5x.h:88
i2c_t i2c
I2C bus the device is connected to.
Definition: mma8x5x.h:96
Device descriptor for MMA8x5x accelerometers.
Definition: mma8x5x.h:107
I2C communication failed.
Definition: mma8x5x.h:87
void mma8x5x_read(const mma8x5x_t *dev, mma8x5x_data_t *data)
Read accelerometer&#39;s data.
800 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:62
int16_t z
acceleration in Z direction
Definition: mma8x5x.h:117
int16_t x
acceleration in X direction
Definition: mma8x5x.h:115
12.5 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:67
50 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:66
uint8_t rate
sampling rate to use
Definition: mma8x5x.h:99
int mma8x5x_is_ready(const mma8x5x_t *dev)
Check for new set of measurement data.
void mma8x5x_ack_int(const mma8x5x_t *dev)
Acknowledge motion detection interrupt.
uint8_t range
scale range to use
Definition: mma8x5x.h:100
Low-level I2C peripheral driver interface definition.