PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Simplifies reading Parallax MMA7455 3-Axis Accelerometer Module. More...
#include "simpletools.h"
Go to the source code of this file.
Macros | |
#define | MMA7455_XOUTL 0x00 |
#define | MMA7455_XOUTH 0x01 |
#define | MMA7455_YOUTL 0x02 |
#define | MMA7455_YOUTH 0x03 |
#define | MMA7455_ZOUTL 0x04 |
#define | MMA7455_ZOUTH 0x05 |
#define | MMA7455_XOUT8 0x06 |
#define | MMA7455_YOUT8 0x07 |
#define | MMA7455_ZOUT8 0x08 |
#define | MMA7455_STATUS 0x09 |
#define | MMA7455_DETSRC 0x0A |
#define | MMA7455_TOUT 0x0B |
#define | MMA7455_I2CAD 0x0D |
#define | MMA7455_USRINF 0x0E |
#define | MMA7455_WHOAMI 0x0F |
#define | MMA7455_XOFFL 0x10 |
#define | MMA7455_XOFFH 0x11 |
#define | MMA7455_YOFFL 0x12 |
#define | MMA7455_YOFFH 0x13 |
#define | MMA7455_ZOFFL 0x14 |
#define | MMA7455_ZOFFH 0x15 |
#define | MMA7455_MCTL 0x16 |
#define | MMA7455_INTRST 0x17 |
#define | MMA7455_CTL1 0x18 |
#define | MMA7455_CTL2 0x19 |
#define | MMA7455_LDTH 0x1A |
#define | MMA7455_PDTH 0x1B |
#define | MMA7455_PW 0x1C |
#define | MMA7455_LT 0x1D |
#define | MMA7455_TW 0x1E |
#define | MMA7455_STANDBY 0b00 |
#define | MMA7455_MEASUREMENT 0b01 |
#define | MMA7455_LEVEL_DETECT 0b10 |
#define | MMA7455_PULSE_DETECT 0b11 |
Functions | |
void | MMA7455_init (int pinData, int pinClock, int pinEnable) |
Initialize the sensor. More... | |
void | MMA7455_getxyz10 (signed short *x, signed short *y, signed short *z) |
Get 10 bit x, y, and z axis measurements. The range is +/- 8 g with values of +/- 64 corresponding to +/- 1 g. More... | |
void | MMA7455_getxyz8 (signed char *x, signed char *y, signed char *z) |
Get 8 bit x, y, and z axis measurements. More... | |
void | MMA7455_setOffsetX (signed short offset) |
Set value automatically added to X value measurement. Start with value that's twice the zero offset error, and repeat the test. It may take a several iterations. More... | |
void | MMA7455_setOffsetY (signed short offset) |
Set value automatically added to Y value measurement. Start with value that's twice the zero offset error, and repeat the test. It may take a several iterations. More... | |
void | MMA7455_setOffsetZ (signed short offset) |
Set value automatically added to Z value measurement. Start with value that's twice the zero offset error, and repeat the test. It may take a several iterations. More... | |
unsigned char | MMA7455_getMode () |
Get the mode of operation: (0) standby, (1) measurement, (2) level error detection, (3) pulse impact detection. More... | |
void | MMA7455_setMode (unsigned char mode) |
Set the mode of operation: (0) standby, (1) measurement, (2) level error detection, (3) pulse impact detection. More... | |
void | MMA7455_gRange (unsigned char range) |
Set the g measurement range to +/- 2, +/-4, or +/- 8 g. More... | |
void | MMA7455_writeByte (unsigned char address, unsigned char value) |
write a byte value to an MMA7455 register More... | |
unsigned char | MMA7455_readByte (unsigned char address) |
Read a value from an MMA7455 register. More... | |
Variables | |
int | MMA7455_pinDat |
int | MMA7455_pinClk |
int | MMA7455_pinEn |
Simplifies reading Parallax MMA7455 3-Axis Accelerometer Module.
Definition in file mma7455.h.
#define MMA7455_DETSRC 0x0A |
#define MMA7455_INTRST 0x17 |
#define MMA7455_LEVEL_DETECT 0b10 |
#define MMA7455_MEASUREMENT 0b01 |
#define MMA7455_PULSE_DETECT 0b11 |
#define MMA7455_STANDBY 0b00 |
#define MMA7455_STATUS 0x09 |
#define MMA7455_USRINF 0x0E |
#define MMA7455_WHOAMI 0x0F |
unsigned char MMA7455_getMode | ( | ) |
void MMA7455_getxyz10 | ( | signed short * | x, |
signed short * | y, | ||
signed short * | z | ||
) |
Get 10 bit x, y, and z axis measurements. The range is +/- 8 g with values of +/- 64 corresponding to +/- 1 g.
*x | Address pointer to a signed short x variable. |
*y | Address pointer to a signed short y variable. |
*z | Address pointer to a signed short z variable. |
Definition at line 23 of file getxyz10.c.
Get 8 bit x, y, and z axis measurements.
These measurements are scaled by the MMA7455_gRrange function so that the measurement will fit in a single signed byte (from -128 to 127).
The gRange default value is 8, which causes +/- 1 g to correspond to +/- 16.
Setting gRange to 4 causes +/- 1 g to correspond to +/- 32, and setting gRange to 2 causes +/- 1 g to correspond with +/- 64. See the MMA7455_gRange function's Details section for more info.
*x | Address pointer to a signed char x variable. |
*y | Address pointer to a signed char y variable. |
*z | Address pointer to a signed char z variable. |
Definition at line 24 of file getxyz8.c.
void MMA7455_gRange | ( | unsigned char | range | ) |
Set the g measurement range to +/- 2, +/-4, or +/- 8 g.
This function makes the chip apply scalars to the values reported by MMA7455_getxyz8 so that the measurement will fit in a value that ranges from -128 to + 127. If grange is set to 2, there is no scaling with values of +/-64 corresponding to +/-1 g. If grange is set to 4 for +/- 4 g, then values of +/- 32 correspond to +/-1 g. If grange is set to 8, values of +/- 16 correspond to +/- 1g.
range | Valid range values are 2, 4, and 8. |
Definition at line 23 of file gRangec.c.
void MMA7455_init | ( | int | pinData, |
int | pinClock, | ||
int | pinEnable | ||
) |
Read a value from an MMA7455 register.
address | MMA7455 register address. |
Definition at line 27 of file readByte.c.
void MMA7455_setMode | ( | unsigned char | mode | ) |
void MMA7455_setOffsetX | ( | signed short | offset | ) |
Set value automatically added to X value measurement. Start with value that's twice the zero offset error, and repeat the test. It may take a several iterations.
offset | Twice the value you want the chip to add to the x axis measurement |
Definition at line 24 of file setOffset.c.
void MMA7455_setOffsetY | ( | signed short | offset | ) |
Set value automatically added to Y value measurement. Start with value that's twice the zero offset error, and repeat the test. It may take a several iterations.
offset | Twice the value you want the chip to add to the y axis measurement |
Definition at line 30 of file setOffset.c.
void MMA7455_setOffsetZ | ( | signed short | offset | ) |
Set value automatically added to Z value measurement. Start with value that's twice the zero offset error, and repeat the test. It may take a several iterations.
offset | Twice the value you want the chip to add to the z axis measurement |
Definition at line 36 of file setOffset.c.
write a byte value to an MMA7455 register
address | MMA7455 register address. |
value | Configuration value for the register. |
Definition at line 26 of file writeByte.c.
int MMA7455_pinClk |
int MMA7455_pinDat |