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 
30 #ifndef MMA8X5X_H
31 #define MMA8X5X_H
32 
33 #include <stdint.h>
34 #include "periph/i2c.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #ifndef MMA8X5X_I2C_ADDRESS
41 #define MMA8X5X_I2C_ADDRESS 0x1D
42 #endif
43 
47 enum {
53 };
54 
58 enum {
59  MMA8X5X_RATE_800HZ = (0 << 3),
60  MMA8X5X_RATE_400HZ = (1 << 3),
61  MMA8X5X_RATE_200HZ = (2 << 3),
62  MMA8X5X_RATE_100HZ = (3 << 3),
63  MMA8X5X_RATE_50HZ = (4 << 3),
64  MMA8X5X_RATE_1HZ25 = (5 << 3),
65  MMA8X5X_RATE_6HZ25 = (6 << 3),
66  MMA8X5X_RATE_1HZ56 = (7 << 3)
67 };
68 
72 enum {
76 };
77 
81 enum {
82  MMA8X5X_OK = 0,
87 };
88 
92 typedef struct {
94  uint8_t addr;
95  uint8_t type;
96  uint8_t rate;
97  uint8_t range;
98  uint8_t offset[3];
100 
104 typedef struct {
106 } mma8x5x_t;
107 
111 typedef struct {
112  int16_t x;
113  int16_t y;
114  int16_t z;
116 
127 int mma8x5x_init(mma8x5x_t *dev, const mma8x5x_params_t *params);
128 
139 void mma8x5x_set_user_offset(mma8x5x_t *dev, int8_t x, int8_t y, int8_t z);
140 
146 void mma8x5x_set_active(mma8x5x_t *dev);
147 
153 void mma8x5x_set_standby(mma8x5x_t *dev);
154 
163 int mma8x5x_is_ready(mma8x5x_t *dev);
164 
179 void mma8x5x_read(mma8x5x_t *dev, mma8x5x_data_t *data);
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 #endif /* MMA8X5X_H */
186 
6.25 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:65
12.5 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:64
50 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:63
uint8_t addr
I2C bus address of the device.
Definition: mma8x5x.h:94
I2C communication failed.
Definition: mma8x5x.h:84
Configuration parameters.
Definition: mma8x5x.h:92
400 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:60
int16_t y
acceleration in Y direction
Definition: mma8x5x.h:113
+/- 2 g Full Scale Range
Definition: mma8x5x.h:73
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
uint8_t type
device type
Definition: mma8x5x.h:95
void mma8x5x_set_user_offset(mma8x5x_t *dev, int8_t x, int8_t y, int8_t z)
Set user offset correction.
void mma8x5x_read(mma8x5x_t *dev, mma8x5x_data_t *data)
Read accelerometer's data.
mma8x5x_params_t params
device configuration parameters
Definition: mma8x5x.h:105
+/- 8 g Full Scale Range
Definition: mma8x5x.h:75
int mma8x5x_is_ready(mma8x5x_t *dev)
Check for new set of measurement data.
200 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:61
800 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:59
+/- 4 g Full Scale Range
Definition: mma8x5x.h:74
100 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:62
new data ready to be read
Definition: mma8x5x.h:83
no data available
Definition: mma8x5x.h:86
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:111
i2c_t i2c
I2C bus the device is connected to.
Definition: mma8x5x.h:93
void mma8x5x_set_standby(mma8x5x_t *dev)
Set standby mode.
Device descriptor for MMA8x5x accelerometers.
Definition: mma8x5x.h:104
no MMA8X5X device found on the bus
Definition: mma8x5x.h:85
int16_t z
acceleration in Z direction
Definition: mma8x5x.h:114
int16_t x
acceleration in X direction
Definition: mma8x5x.h:112
everything was fine
Definition: mma8x5x.h:82
void mma8x5x_set_active(mma8x5x_t *dev)
Set active mode, this enables periodic measurements.
uint8_t rate
sampling rate to use
Definition: mma8x5x.h:96
uint8_t range
scale range to use
Definition: mma8x5x.h:97
1.56 Hz Ouput Data Rate in WAKE mode
Definition: mma8x5x.h:66
Low-level I2C peripheral driver interface definition.