mma7455 library
v0.85
MMA7455 3-Axis Accelerometer configuration and measurement functions. Currently supports SPI only.
Main Page
Files
File List
Globals
mma7455.h
Go to the documentation of this file.
1
16
#ifndef MMA7455_H
17
#define MMA7455_H
18
19
#if defined(__cplusplus)
20
extern
"C"
{
21
#endif
22
23
24
#include "simpletools.h"
// Include simpletools lib
25
29
#define MMA7455_XOUTL 0x00 // 10 bits output value X LSB XOUT[7] XOUT[6] XOUT[5] XOUT[4] XOUT[3] XOUT[2] XOUT[1] XOUT[0]
30
34
#define MMA7455_XOUTH 0x01 // 10 bits output value X MSB -- -- -- -- -- -- XOUT[9] XOUT[8]
35
39
#define MMA7455_YOUTL 0x02 // 10 bits output value Y LSB YOUT[7] YOUT[6] YOUT[5] YOUT[4] YOUT[3] YOUT[2] YOUT[1] YOUT[0]
40
44
#define MMA7455_YOUTH 0x03 // 10 bits output value Y MSB -- -- -- -- -- -- YOUT[9] YOUT[8]
45
49
#define MMA7455_ZOUTL 0x04 // 10 bits output value Z LSB ZOUT[7] ZOUT[6] ZOUT[5] ZOUT[4] ZOUT[3] ZOUT[2] ZOUT[1] ZOUT[0]
50
54
#define MMA7455_ZOUTH 0x05 // 10 bits output value Z MSB -- -- -- -- -- -- ZOUT[9] ZOUT[8]
55
59
#define MMA7455_XOUT8 0x06 // 8 bits output value X XOUT[7] XOUT[6] XOUT[5] XOUT[4] XOUT[3] XOUT[2] XOUT[1] XOUT[0]
60
64
#define MMA7455_YOUT8 0x07 // 8 bits output value Y YOUT[7] YOUT[6] YOUT[5] YOUT[4] YOUT[3] YOUT[2] YOUT[1] YOUT[0]
65
69
#define MMA7455_ZOUT8 0x08 // 8 bits output value Z ZOUT[7] ZOUT[6] ZOUT[5] ZOUT[4] ZOUT[3] ZOUT[2] ZOUT[1] ZOUT[0]
70
74
#define MMA7455_STATUS 0x09 // Status registers -- -- -- -- -- PERR DOVR DRDY
75
79
#define MMA7455_DETSRC 0x0A // Detection source registers LDX LDY LDZ PDX PDY PDZ INT1 INT2
80
84
#define MMA7455_TOUT 0x0B // "Temperature output value" (Optional) TMP[7] TMP[6] TMP[5] TMP[4] TMP[3] TMP[2] TMP[1] TMP[0]
85
86
87
//#define MMA7455_ 0x0C // (Reserved) -- -- -- -- -- -- -- --
88
92
#define MMA7455_I2CAD 0x0D // I2C device address I 2CDIS DAD[6] DAD[5] DAD[4] DAD[3] DAD[2] DAD[1] DAD[0]
93
97
#define MMA7455_USRINF 0x0E // User information (Optional) UI[7] UI[6] UI[5] UI[4] UI[3] UI[2] UI[1] UI[0]
98
102
#define MMA7455_WHOAMI 0x0F // "Who am I" value (Optional) ID[7] ID[6] ID[5] ID[4] ID[3] ID[2] ID[1] ID[0]
103
107
#define MMA7455_XOFFL 0x10 // Offset drift X value (LSB) XOFF[7] XOFF[6] XOFF[5] XOFF[4] XOFF[3] XOFF[2] XOFF[1] XOFF[0]
108
112
#define MMA7455_XOFFH 0x11 // Offset drift X value (MSB) -- -- -- -- -- XOFF[10] XOFF[9] XOFF[8]
113
117
#define MMA7455_YOFFL 0x12 // Offset drift Y value (LSB) YOFF[7] YOFF[6] YOFF[5] YOFF[4] YOFF[3] YOFF[2] YOFF[1] YOFF[0]
118
122
#define MMA7455_YOFFH 0x13 // Offset drift Y value (MSB) -- -- -- -- -- YOFF[10] YOFF[9] YOFF[8]
123
127
#define MMA7455_ZOFFL 0x14 // Offset drift Z value (LSB) ZOFF[7] ZOFF[6] ZOFF[5] ZOFF[4] ZOFF[3] ZOFF[2] ZOFF[1] ZOFF[0]
128
132
#define MMA7455_ZOFFH 0x15 // Offset drift Z value (MSB) -- -- -- -- -- ZOFF[10] ZOFF[9] ZOFF[8]
133
137
#define MMA7455_MCTL 0x16 // Mode control LPEN DRPD SPI3W STON GLVL[1] GLVL[0] MOD[1] MOD[0]
138
142
#define MMA7455_INTRST 0x17 // Interrupt latch reset -- -- -- -- -- -- CLRINT2 CLRINT1
143
147
#define MMA7455_CTL1 0x18 // Control 1 -- THOPT ZDA YDA XDA INTRG[1] INTRG[0] INTPIN
148
152
#define MMA7455_CTL2 0x19 // Control 2 -- -- -- -- -- DRVO PDPL LDPL
153
157
#define MMA7455_LDTH 0x1A // Level detection threshold limit value LDTH[7] LDTH[6] LDTH[5] LDTH[4] LDTH[3] LDTH[2] LDTH[1] LDTH[0]
158
162
#define MMA7455_PDTH 0x1B // Pulse detection threshold limit value PDTH[7] PDTH[6] PDTH[5] PDTH[4] PDTH[3] PDTH[2] PDTH[1] PDTH[0]
163
167
#define MMA7455_PW 0x1C // Pulse duration value PD[7] PD[6] PD[5] PD[4] PD[3] PD[2] PD[1] PD[0]
168
172
#define MMA7455_LT 0x1D // Latency time value LT[7] LT[6] LT[5] LT[4] LT[3] LT[2] LT[1] LT[0]
173
177
#define MMA7455_TW 0x1E // Time window for 2nd pulse value TW[7] TW[6] TW[5] TW[4] TW[3] TW[2] TW[1] TW[0]
178
179
184
#define MMA7455_STANDBY 0b00 // Standby mode
185
190
#define MMA7455_MEASUREMENT 0b01 // Measurement mode
191
196
#define MMA7455_LEVEL_DETECT 0b10 // Measurement mode
197
202
#define MMA7455_PULSE_DETECT 0b11 // Measurement mode
203
204
208
extern
int
MMA7455_pinDat;
209
213
extern
int
MMA7455_pinClk;
214
218
extern
int
MMA7455_pinEn;
219
223
extern
int
MMA7455_gRangeVal;
224
225
235
void
MMA7455_init(
int
pinData,
int
pinClock,
int
pinEnable);
236
237
248
void
MMA7455_getxyz8(
signed
char
*x,
signed
char
*y,
signed
char
*z);
249
250
261
void
MMA7455_getxyz10(
signed
short
*x,
signed
short
*y,
signed
short
*z);
262
263
271
void
MMA7455_setOffsetX
(
signed
short
offset);
272
273
281
void
MMA7455_setOffsetY
(
signed
short
offset);
282
283
291
void
MMA7455_setOffsetZ
(
signed
short
offset);
292
293
300
unsigned
char
MMA7455_getMode();
301
302
309
void
MMA7455_setMode
(
unsigned
char
mode);
310
311
317
void
MMA7455_gRange(
unsigned
char
range);
318
319
327
void
MMA7455_writeByte
(
unsigned
char
address,
unsigned
char
value);
328
329
337
unsigned
char
MMA7455_readByte
(
unsigned
char
address);
338
339
340
#if defined(__cplusplus)
341
}
342
#endif
343
/* __cplusplus */
344
#endif
345
/* MMA7455_H */
346
347
Generated on Tue Mar 18 2014 13:23:54 for mma7455 library by
1.8.1.2