Loading...
Searching...
No Matches
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
10#pragma once
11
34
35#include <stdint.h>
36#include "periph/i2c.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
53#ifndef CONFIG_MMA8X5X_I2C_ADDRESS
54#define CONFIG_MMA8X5X_I2C_ADDRESS 0x1D
55#endif
57
61enum {
67};
68
72enum {
73 MMA8X5X_RATE_800HZ = (0 << 3),
74 MMA8X5X_RATE_400HZ = (1 << 3),
75 MMA8X5X_RATE_200HZ = (2 << 3),
76 MMA8X5X_RATE_100HZ = (3 << 3),
77 MMA8X5X_RATE_50HZ = (4 << 3),
78 MMA8X5X_RATE_1HZ25 = (5 << 3),
79 MMA8X5X_RATE_6HZ25 = (6 << 3),
81};
82
86enum {
90};
91
95enum {
101};
102
106typedef struct {
108 uint8_t addr;
109 uint8_t rate;
110 uint8_t range;
111 uint8_t offset[3];
113
117typedef struct {
119} mma8x5x_t;
120
124typedef struct {
125 int16_t x;
126 int16_t y;
127 int16_t z;
129
140int mma8x5x_init(mma8x5x_t *dev, const mma8x5x_params_t *params);
141
152void mma8x5x_set_user_offset(const mma8x5x_t *dev, int8_t x, int8_t y, int8_t z);
153
160
167
177
192void mma8x5x_read(const mma8x5x_t *dev, mma8x5x_data_t *data);
193
205void mma8x5x_set_motiondetect(const mma8x5x_t *dev, uint8_t int_pin, uint8_t threshold);
206
218void mma8x5x_ack_int(const mma8x5x_t *dev);
219
220#ifdef __cplusplus
221}
222#endif
223
void mma8x5x_set_user_offset(const mma8x5x_t *dev, int8_t x, int8_t y, int8_t z)
Set user offset correction.
int mma8x5x_init(mma8x5x_t *dev, const mma8x5x_params_t *params)
Initialize the MMA8x5x accelerometer driver.
void mma8x5x_ack_int(const mma8x5x_t *dev)
Acknowledge motion detection interrupt.
void mma8x5x_set_active(const mma8x5x_t *dev)
Set active mode, this enables periodic measurements.
void mma8x5x_set_standby(const mma8x5x_t *dev)
Set standby mode.
void mma8x5x_set_motiondetect(const mma8x5x_t *dev, uint8_t int_pin, uint8_t threshold)
Configure motion detection interrupt.
int mma8x5x_is_ready(const mma8x5x_t *dev)
Check for new set of measurement data.
void mma8x5x_read(const mma8x5x_t *dev, mma8x5x_data_t *data)
Read accelerometer's data.
@ MMA8X5X_NOI2C
I2C communication failed.
Definition mma8x5x.h:98
@ MMA8X5X_NODATA
no data available
Definition mma8x5x.h:100
@ MMA8X5X_DATA_READY
new data ready to be read
Definition mma8x5x.h:97
@ MMA8X5X_OK
everything was fine
Definition mma8x5x.h:96
@ MMA8X5X_NODEV
no MMA8X5X device found on the bus
Definition mma8x5x.h:99
@ MMA8X5X_RATE_800HZ
800 Hz Output Data Rate in WAKE mode
Definition mma8x5x.h:73
@ MMA8X5X_RATE_200HZ
200 Hz Output Data Rate in WAKE mode
Definition mma8x5x.h:75
@ MMA8X5X_RATE_100HZ
100 Hz Output Data Rate in WAKE mode
Definition mma8x5x.h:76
@ MMA8X5X_RATE_1HZ25
12.5 Hz Output Data Rate in WAKE mode
Definition mma8x5x.h:78
@ MMA8X5X_RATE_400HZ
400 Hz Output Data Rate in WAKE mode
Definition mma8x5x.h:74
@ MMA8X5X_RATE_6HZ25
6.25 Hz Output Data Rate in WAKE mode
Definition mma8x5x.h:79
@ MMA8X5X_RATE_1HZ56
1.56 Hz Output Data Rate in WAKE mode
Definition mma8x5x.h:80
@ MMA8X5X_RATE_50HZ
50 Hz Output Data Rate in WAKE mode
Definition mma8x5x.h:77
@ MMA8X5X_TYPE_MMA8453
MMA8453.
Definition mma8x5x.h:66
@ MMA8X5X_TYPE_MMA8653
MMA8653.
Definition mma8x5x.h:63
@ MMA8X5X_TYPE_MMA8652
MMA8652.
Definition mma8x5x.h:62
@ MMA8X5X_TYPE_MMA8451
MMA8451.
Definition mma8x5x.h:64
@ MMA8X5X_TYPE_MMA8452
MMA8452.
Definition mma8x5x.h:65
@ MMA8X5X_RANGE_4G
+/- 4 g Full Scale Range
Definition mma8x5x.h:88
@ MMA8X5X_RANGE_8G
+/- 8 g Full Scale Range
Definition mma8x5x.h:89
@ MMA8X5X_RANGE_2G
+/- 2 g Full Scale Range
Definition mma8x5x.h:87
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:144
Low-level I2C peripheral driver interface definition.
Data type for the result data.
Definition mma8x5x.h:124
int16_t z
acceleration in Z direction
Definition mma8x5x.h:127
int16_t y
acceleration in Y direction
Definition mma8x5x.h:126
int16_t x
acceleration in X direction
Definition mma8x5x.h:125
Configuration parameters.
Definition mma8x5x.h:106
i2c_t i2c
I2C bus the device is connected to.
Definition mma8x5x.h:107
uint8_t offset[3]
data offset in X, Y, and Z direction
Definition mma8x5x.h:111
uint8_t rate
sampling rate to use
Definition mma8x5x.h:109
uint8_t addr
I2C bus address of the device.
Definition mma8x5x.h:108
uint8_t range
scale range to use
Definition mma8x5x.h:110
Device descriptor for MMA8x5x accelerometers.
Definition mma8x5x.h:117
mma8x5x_params_t params
device configuration parameters
Definition mma8x5x.h:118