PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Sensor
libmma7455
getxyz10.c
1
/*
2
* @file getxyz10.c
3
*
4
* @author Andy Lindsay
5
*
6
* @version 0.50
7
*
8
* @copyright
9
* Copyright (C) Parallax, Inc. 2014. All Rights MIT Licensed.
10
*
11
* @brief Gets 10 bit x, y, and z axis measurements from the Parallax MMA7455
12
* 3-Axis Accelerometer Module.
13
*/
14
15
16
#include "
simpletools.h
"
17
#include "
mma7455.h
"
18
19
20
int
MMA7455_pinDat
,
MMA7455_pinClk
,
MMA7455_pinEn
;
21
22
23
void
MMA7455_getxyz10
(
signed
short
*
x
,
signed
short
*y,
signed
short
*z)
24
{
25
int
temp;
26
unsigned
char
byteLow, byteHigh;
27
int
regAddr[6] = {
MMA7455_XOUTL
,
MMA7455_XOUTH
,
MMA7455_YOUTL
,
MMA7455_YOUTH
,
MMA7455_ZOUTL
,
MMA7455_ZOUTH
};
28
signed
short
*val[3] = {
x
, y, z};
29
for
(
int
i = 0; i < 6; i += 2)
30
{
31
byteLow =
MMA7455_readByte
(regAddr[i]);
// Get value from register
32
byteHigh =
MMA7455_readByte
(regAddr[i+1]);
// Get value from register
33
if
((1 & (byteHigh >> 1))) byteHigh |= 0b11111100;
34
*val[i/2] = ((
signed
short) byteHigh << 8) | byteLow;
35
}
36
}
37
38
MMA7455_YOUTL
#define MMA7455_YOUTL
Definition:
mma7455.h:39
MMA7455_YOUTH
#define MMA7455_YOUTH
Definition:
mma7455.h:44
MMA7455_getxyz10
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...
Definition:
getxyz10.c:23
MMA7455_XOUTL
#define MMA7455_XOUTL
Definition:
mma7455.h:29
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
MMA7455_readByte
unsigned char MMA7455_readByte(unsigned char address)
Read a value from an MMA7455 register.
Definition:
readByte.c:27
MMA7455_pinEn
int MMA7455_pinEn
Definition:
getMode.c:19
MMA7455_XOUTH
#define MMA7455_XOUTH
Definition:
mma7455.h:34
MMA7455_pinDat
int MMA7455_pinDat
Definition:
getMode.c:19
x
int x
Definition:
07 Box and Lines.c:13
MMA7455_ZOUTH
#define MMA7455_ZOUTH
Definition:
mma7455.h:54
mma7455.h
Simplifies reading Parallax MMA7455 3-Axis Accelerometer Module.
MMA7455_pinClk
int MMA7455_pinClk
Definition:
getMode.c:19
MMA7455_ZOUTL
#define MMA7455_ZOUTL
Definition:
mma7455.h:49
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17