User | Revision | Line number | New contents of line |
gbeardall |
0:dbea5fa1cd2c
|
1
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
2
|
* @author Peter Swanson
|
gbeardall |
0:dbea5fa1cd2c
|
3
|
* A personal note from me: Jesus Christ has changed my life so much it blows my mind. I say this because
|
gbeardall |
0:dbea5fa1cd2c
|
4
|
* today, religion is thought of as something that you do or believe and has about as
|
gbeardall |
0:dbea5fa1cd2c
|
5
|
* little impact on a person as their political stance. But for me, God gives me daily
|
gbeardall |
0:dbea5fa1cd2c
|
6
|
* strength and has filled my life with the satisfaction that I could never find in any
|
gbeardall |
0:dbea5fa1cd2c
|
7
|
* of the other things that I once looked for it in.
|
gbeardall |
0:dbea5fa1cd2c
|
8
|
* If your interested, heres verse that changed my life:
|
gbeardall |
0:dbea5fa1cd2c
|
9
|
* Rom 8:1-3: "Therefore, there is now no condemnation for those who are in Christ Jesus,
|
gbeardall |
0:dbea5fa1cd2c
|
10
|
* because through Christ Jesus, the law of the Spirit who gives life has set
|
gbeardall |
0:dbea5fa1cd2c
|
11
|
* me free from the law of sin (which brings...) and death. For what the law
|
gbeardall |
0:dbea5fa1cd2c
|
12
|
* was powerless to do in that it was weakened by the flesh, God did by sending
|
gbeardall |
0:dbea5fa1cd2c
|
13
|
* His own Son in the likeness of sinful flesh to be a sin offering. And so He
|
gbeardall |
0:dbea5fa1cd2c
|
14
|
* condemned sin in the flesh in order that the righteous requirements of the
|
gbeardall |
0:dbea5fa1cd2c
|
15
|
* (God's) law might be fully met in us, who live not according to the flesh
|
gbeardall |
0:dbea5fa1cd2c
|
16
|
* but according to the Spirit."
|
gbeardall |
0:dbea5fa1cd2c
|
17
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
18
|
* @section LICENSE
|
gbeardall |
0:dbea5fa1cd2c
|
19
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
20
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
gbeardall |
0:dbea5fa1cd2c
|
21
|
* of this software and associated documentation files (the "Software"), to deal
|
gbeardall |
0:dbea5fa1cd2c
|
22
|
* in the Software without restriction, including without limitation the rights
|
gbeardall |
0:dbea5fa1cd2c
|
23
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
gbeardall |
0:dbea5fa1cd2c
|
24
|
* copies of the Software, and to permit persons to whom the Software is
|
gbeardall |
0:dbea5fa1cd2c
|
25
|
* furnished to do so, subject to the following conditions:
|
gbeardall |
0:dbea5fa1cd2c
|
26
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
27
|
* The above copyright notice and this permission notice shall be included in
|
gbeardall |
0:dbea5fa1cd2c
|
28
|
* all copies or substantial portions of the Software.
|
gbeardall |
0:dbea5fa1cd2c
|
29
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
30
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
gbeardall |
0:dbea5fa1cd2c
|
31
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
gbeardall |
0:dbea5fa1cd2c
|
32
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
gbeardall |
0:dbea5fa1cd2c
|
33
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
gbeardall |
0:dbea5fa1cd2c
|
34
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
gbeardall |
0:dbea5fa1cd2c
|
35
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
gbeardall |
0:dbea5fa1cd2c
|
36
|
* THE SOFTWARE.
|
gbeardall |
0:dbea5fa1cd2c
|
37
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
38
|
* @section DESCRIPTION
|
gbeardall |
0:dbea5fa1cd2c
|
39
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
40
|
* ADXL345, triple axis, I2C interface, accelerometer.
|
gbeardall |
0:dbea5fa1cd2c
|
41
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
42
|
* Datasheet:
|
gbeardall |
0:dbea5fa1cd2c
|
43
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
44
|
* http://www.analog.com/static/imported-files/data_sheets/ADXL345.pdf
|
gbeardall |
0:dbea5fa1cd2c
|
45
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
46
|
|
gbeardall |
0:dbea5fa1cd2c
|
47
|
|
gbeardall |
0:dbea5fa1cd2c
|
48
|
|
gbeardall |
0:dbea5fa1cd2c
|
49
|
#ifndef ADXL345_I2C_H
|
gbeardall |
0:dbea5fa1cd2c
|
50
|
#define ADXL345_I2C_H
|
gbeardall |
0:dbea5fa1cd2c
|
51
|
|
gbeardall |
0:dbea5fa1cd2c
|
52
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
53
|
* Includes
|
gbeardall |
0:dbea5fa1cd2c
|
54
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
55
|
#include "mbed.h"
|
gbeardall |
0:dbea5fa1cd2c
|
56
|
|
gbeardall |
0:dbea5fa1cd2c
|
57
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
58
|
* Defines
|
gbeardall |
0:dbea5fa1cd2c
|
59
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
60
|
//Registers.
|
gbeardall |
0:dbea5fa1cd2c
|
61
|
#define ADXL345_DEVID_REG 0x00
|
gbeardall |
0:dbea5fa1cd2c
|
62
|
#define ADXL345_THRESH_TAP_REG 0x1D
|
gbeardall |
0:dbea5fa1cd2c
|
63
|
#define ADXL345_OFSX_REG 0x1E
|
gbeardall |
0:dbea5fa1cd2c
|
64
|
#define ADXL345_OFSY_REG 0x1F
|
gbeardall |
0:dbea5fa1cd2c
|
65
|
#define ADXL345_OFSZ_REG 0x20
|
gbeardall |
0:dbea5fa1cd2c
|
66
|
#define ADXL345_DUR_REG 0x21
|
gbeardall |
0:dbea5fa1cd2c
|
67
|
#define ADXL345_LATENT_REG 0x22
|
gbeardall |
0:dbea5fa1cd2c
|
68
|
#define ADXL345_WINDOW_REG 0x23
|
gbeardall |
0:dbea5fa1cd2c
|
69
|
#define ADXL345_THRESH_ACT_REG 0x24
|
gbeardall |
0:dbea5fa1cd2c
|
70
|
#define ADXL345_THRESH_INACT_REG 0x25
|
gbeardall |
0:dbea5fa1cd2c
|
71
|
#define ADXL345_TIME_INACT_REG 0x26
|
gbeardall |
0:dbea5fa1cd2c
|
72
|
#define ADXL345_ACT_INACT_CTL_REG 0x27
|
gbeardall |
0:dbea5fa1cd2c
|
73
|
#define ADXL345_THRESH_FF_REG 0x28
|
gbeardall |
0:dbea5fa1cd2c
|
74
|
#define ADXL345_TIME_FF_REG 0x29
|
gbeardall |
0:dbea5fa1cd2c
|
75
|
#define ADXL345_TAP_AXES_REG 0x2A
|
gbeardall |
0:dbea5fa1cd2c
|
76
|
#define ADXL345_ACT_TAP_STATUS_REG 0x2B
|
gbeardall |
0:dbea5fa1cd2c
|
77
|
#define ADXL345_BW_RATE_REG 0x2C
|
gbeardall |
0:dbea5fa1cd2c
|
78
|
#define ADXL345_POWER_CTL_REG 0x2D
|
gbeardall |
0:dbea5fa1cd2c
|
79
|
#define ADXL345_INT_ENABLE_REG 0x2E
|
gbeardall |
0:dbea5fa1cd2c
|
80
|
#define ADXL345_INT_MAP_REG 0x2F
|
gbeardall |
0:dbea5fa1cd2c
|
81
|
#define ADXL345_INT_SOURCE_REG 0x30
|
gbeardall |
0:dbea5fa1cd2c
|
82
|
#define ADXL345_DATA_FORMAT_REG 0x31
|
gbeardall |
0:dbea5fa1cd2c
|
83
|
#define ADXL345_DATAX0_REG 0x32
|
gbeardall |
0:dbea5fa1cd2c
|
84
|
#define ADXL345_DATAX1_REG 0x33
|
gbeardall |
0:dbea5fa1cd2c
|
85
|
#define ADXL345_DATAY0_REG 0x34
|
gbeardall |
0:dbea5fa1cd2c
|
86
|
#define ADXL345_DATAY1_REG 0x35
|
gbeardall |
0:dbea5fa1cd2c
|
87
|
#define ADXL345_DATAZ0_REG 0x36
|
gbeardall |
0:dbea5fa1cd2c
|
88
|
#define ADXL345_DATAZ1_REG 0x37
|
gbeardall |
0:dbea5fa1cd2c
|
89
|
#define ADXL345_FIFO_CTL 0x38
|
gbeardall |
0:dbea5fa1cd2c
|
90
|
#define ADXL345_FIFO_STATUS 0x39
|
gbeardall |
0:dbea5fa1cd2c
|
91
|
|
gbeardall |
0:dbea5fa1cd2c
|
92
|
//Data rate codes.
|
gbeardall |
0:dbea5fa1cd2c
|
93
|
#define ADXL345_3200HZ 0x0F
|
gbeardall |
0:dbea5fa1cd2c
|
94
|
#define ADXL345_1600HZ 0x0E
|
gbeardall |
0:dbea5fa1cd2c
|
95
|
#define ADXL345_800HZ 0x0D
|
gbeardall |
0:dbea5fa1cd2c
|
96
|
#define ADXL345_400HZ 0x0C
|
gbeardall |
0:dbea5fa1cd2c
|
97
|
#define ADXL345_200HZ 0x0B
|
gbeardall |
0:dbea5fa1cd2c
|
98
|
#define ADXL345_100HZ 0x0A
|
gbeardall |
0:dbea5fa1cd2c
|
99
|
#define ADXL345_50HZ 0x09
|
gbeardall |
0:dbea5fa1cd2c
|
100
|
#define ADXL345_25HZ 0x08
|
gbeardall |
0:dbea5fa1cd2c
|
101
|
#define ADXL345_12HZ5 0x07
|
gbeardall |
0:dbea5fa1cd2c
|
102
|
#define ADXL345_6HZ25 0x06
|
gbeardall |
0:dbea5fa1cd2c
|
103
|
|
gbeardall |
0:dbea5fa1cd2c
|
104
|
// read or write bytes
|
gbeardall |
0:dbea5fa1cd2c
|
105
|
#define ADXL345_I2C_READ 0xA7
|
gbeardall |
0:dbea5fa1cd2c
|
106
|
#define ADXL345_I2C_WRITE 0xA6
|
gbeardall |
0:dbea5fa1cd2c
|
107
|
#define ADXL345_I2C_ADDRESS 0x53 //the ADXL345 7-bit address is 0x53 when ALT ADDRESS is low as it is on the sparkfun chip: when ALT ADDRESS is high the address is 0x1D
|
gbeardall |
0:dbea5fa1cd2c
|
108
|
|
gbeardall |
0:dbea5fa1cd2c
|
109
|
/////////////when ALT ADDRESS pin is high:
|
gbeardall |
0:dbea5fa1cd2c
|
110
|
//#define ADXL345_I2C_READ 0x3B
|
gbeardall |
0:dbea5fa1cd2c
|
111
|
//#define ADXL345_I2C_WRITE 0x3A
|
gbeardall |
0:dbea5fa1cd2c
|
112
|
//#define ADXL345_I2C_ADDRESS 0x1D
|
gbeardall |
0:dbea5fa1cd2c
|
113
|
|
gbeardall |
0:dbea5fa1cd2c
|
114
|
#define ADXL345_X 0x00
|
gbeardall |
0:dbea5fa1cd2c
|
115
|
#define ADXL345_Y 0x01
|
gbeardall |
0:dbea5fa1cd2c
|
116
|
#define ADXL345_Z 0x02
|
gbeardall |
0:dbea5fa1cd2c
|
117
|
|
gbeardall |
0:dbea5fa1cd2c
|
118
|
|
gbeardall |
0:dbea5fa1cd2c
|
119
|
|
gbeardall |
0:dbea5fa1cd2c
|
120
|
// modes
|
gbeardall |
0:dbea5fa1cd2c
|
121
|
#define MeasurementMode 0x08
|
gbeardall |
0:dbea5fa1cd2c
|
122
|
|
gbeardall |
0:dbea5fa1cd2c
|
123
|
|
gbeardall |
0:dbea5fa1cd2c
|
124
|
|
gbeardall |
0:dbea5fa1cd2c
|
125
|
|
gbeardall |
0:dbea5fa1cd2c
|
126
|
|
gbeardall |
0:dbea5fa1cd2c
|
127
|
|
gbeardall |
0:dbea5fa1cd2c
|
128
|
|
gbeardall |
0:dbea5fa1cd2c
|
129
|
class ADXL345_I2C {
|
gbeardall |
0:dbea5fa1cd2c
|
130
|
|
gbeardall |
0:dbea5fa1cd2c
|
131
|
public:
|
gbeardall |
0:dbea5fa1cd2c
|
132
|
|
gbeardall |
0:dbea5fa1cd2c
|
133
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
134
|
* Constructor.
|
gbeardall |
0:dbea5fa1cd2c
|
135
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
136
|
* @param mosi mbed pin to use for SDA line of I2C interface.
|
gbeardall |
0:dbea5fa1cd2c
|
137
|
* @param sck mbed pin to use for SCL line of I2C interface.
|
gbeardall |
0:dbea5fa1cd2c
|
138
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
139
|
ADXL345_I2C(PinName sda, PinName scl);
|
gbeardall |
0:dbea5fa1cd2c
|
140
|
|
gbeardall |
0:dbea5fa1cd2c
|
141
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
142
|
* Get the output of all three axes.
|
gbeardall |
0:dbea5fa1cd2c
|
143
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
144
|
* @param Pointer to a buffer to hold the accelerometer value for the
|
gbeardall |
0:dbea5fa1cd2c
|
145
|
* x-axis, y-axis and z-axis [in that order].
|
gbeardall |
0:dbea5fa1cd2c
|
146
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
147
|
void getOutput(int* readings);
|
gbeardall |
0:dbea5fa1cd2c
|
148
|
|
gbeardall |
0:dbea5fa1cd2c
|
149
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
150
|
* Read the device ID register on the device.
|
gbeardall |
0:dbea5fa1cd2c
|
151
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
152
|
* @return The device ID code [0xE5]
|
gbeardall |
0:dbea5fa1cd2c
|
153
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
154
|
char getDeviceID(void);
|
gbeardall |
0:dbea5fa1cd2c
|
155
|
|
gbeardall |
0:dbea5fa1cd2c
|
156
|
|
gbeardall |
0:dbea5fa1cd2c
|
157
|
|
gbeardall |
0:dbea5fa1cd2c
|
158
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
159
|
* Set the power mode.
|
gbeardall |
0:dbea5fa1cd2c
|
160
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
161
|
* @param mode 0 -> Normal operation.
|
gbeardall |
0:dbea5fa1cd2c
|
162
|
* 1 -> Reduced power operation.
|
gbeardall |
0:dbea5fa1cd2c
|
163
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
164
|
int setPowerMode(char mode);
|
gbeardall |
0:dbea5fa1cd2c
|
165
|
|
gbeardall |
0:dbea5fa1cd2c
|
166
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
167
|
* Set the power control settings.
|
gbeardall |
0:dbea5fa1cd2c
|
168
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
169
|
* See datasheet for details.
|
gbeardall |
0:dbea5fa1cd2c
|
170
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
171
|
* @param The control byte to write to the POWER_CTL register.
|
gbeardall |
0:dbea5fa1cd2c
|
172
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
173
|
int setPowerControl(char settings);
|
gbeardall |
0:dbea5fa1cd2c
|
174
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
175
|
* Get the power control settings.
|
gbeardall |
0:dbea5fa1cd2c
|
176
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
177
|
* See datasheet for details.
|
gbeardall |
0:dbea5fa1cd2c
|
178
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
179
|
* @return The contents of the POWER_CTL register.
|
gbeardall |
0:dbea5fa1cd2c
|
180
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
181
|
char getPowerControl(void);
|
gbeardall |
0:dbea5fa1cd2c
|
182
|
|
gbeardall |
0:dbea5fa1cd2c
|
183
|
|
gbeardall |
0:dbea5fa1cd2c
|
184
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
185
|
* Get the data format settings.
|
gbeardall |
0:dbea5fa1cd2c
|
186
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
187
|
* @return The contents of the DATA_FORMAT register.
|
gbeardall |
0:dbea5fa1cd2c
|
188
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
189
|
|
gbeardall |
0:dbea5fa1cd2c
|
190
|
char getDataFormatControl(void);
|
gbeardall |
0:dbea5fa1cd2c
|
191
|
|
gbeardall |
0:dbea5fa1cd2c
|
192
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
193
|
* Set the data format settings.
|
gbeardall |
0:dbea5fa1cd2c
|
194
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
195
|
* @param settings The control byte to write to the DATA_FORMAT register.
|
gbeardall |
0:dbea5fa1cd2c
|
196
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
197
|
int setDataFormatControl(char settings);
|
gbeardall |
0:dbea5fa1cd2c
|
198
|
|
gbeardall |
0:dbea5fa1cd2c
|
199
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
200
|
* Set the data rate.
|
gbeardall |
0:dbea5fa1cd2c
|
201
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
202
|
* @param rate The rate code (see #defines or datasheet).
|
gbeardall |
0:dbea5fa1cd2c
|
203
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
204
|
int setDataRate(char rate);
|
gbeardall |
0:dbea5fa1cd2c
|
205
|
|
gbeardall |
0:dbea5fa1cd2c
|
206
|
|
gbeardall |
0:dbea5fa1cd2c
|
207
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
208
|
* Get the current offset for a particular axis.
|
gbeardall |
0:dbea5fa1cd2c
|
209
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
210
|
* @param axis 0x00 -> X-axis
|
gbeardall |
0:dbea5fa1cd2c
|
211
|
* 0x01 -> Y-axis
|
gbeardall |
0:dbea5fa1cd2c
|
212
|
* 0x02 -> Z-axis
|
gbeardall |
0:dbea5fa1cd2c
|
213
|
* @return The current offset as an 8-bit 2's complement number with scale
|
gbeardall |
0:dbea5fa1cd2c
|
214
|
* factor 15.6mg/LSB.
|
gbeardall |
0:dbea5fa1cd2c
|
215
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
216
|
|
gbeardall |
0:dbea5fa1cd2c
|
217
|
char getOffset(char axis);
|
gbeardall |
0:dbea5fa1cd2c
|
218
|
|
gbeardall |
0:dbea5fa1cd2c
|
219
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
220
|
* Set the offset for a particular axis.
|
gbeardall |
0:dbea5fa1cd2c
|
221
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
222
|
* @param axis 0x00 -> X-axis
|
gbeardall |
0:dbea5fa1cd2c
|
223
|
* 0x01 -> Y-axis
|
gbeardall |
0:dbea5fa1cd2c
|
224
|
* 0x02 -> Z-axis
|
gbeardall |
0:dbea5fa1cd2c
|
225
|
* @param offset The offset as an 8-bit 2's complement number with scale
|
gbeardall |
0:dbea5fa1cd2c
|
226
|
* factor 15.6mg/LSB.
|
gbeardall |
0:dbea5fa1cd2c
|
227
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
228
|
int setOffset(char axis, char offset);
|
gbeardall |
0:dbea5fa1cd2c
|
229
|
|
gbeardall |
0:dbea5fa1cd2c
|
230
|
|
gbeardall |
0:dbea5fa1cd2c
|
231
|
|
gbeardall |
0:dbea5fa1cd2c
|
232
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
233
|
* Get the FIFO control settings.
|
gbeardall |
0:dbea5fa1cd2c
|
234
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
235
|
* @return The contents of the FIFO_CTL register.
|
gbeardall |
0:dbea5fa1cd2c
|
236
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
237
|
char getFifoControl(void);
|
gbeardall |
0:dbea5fa1cd2c
|
238
|
|
gbeardall |
0:dbea5fa1cd2c
|
239
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
240
|
* Set the FIFO control settings.
|
gbeardall |
0:dbea5fa1cd2c
|
241
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
242
|
* @param The control byte to write to the FIFO_CTL register.
|
gbeardall |
0:dbea5fa1cd2c
|
243
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
244
|
int setFifoControl(char settings);
|
gbeardall |
0:dbea5fa1cd2c
|
245
|
|
gbeardall |
0:dbea5fa1cd2c
|
246
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
247
|
* Get FIFO status.
|
gbeardall |
0:dbea5fa1cd2c
|
248
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
249
|
* @return The contents of the FIFO_STATUS register.
|
gbeardall |
0:dbea5fa1cd2c
|
250
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
251
|
char getFifoStatus(void);
|
gbeardall |
0:dbea5fa1cd2c
|
252
|
|
gbeardall |
0:dbea5fa1cd2c
|
253
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
254
|
* Read the tap threshold on the device.
|
gbeardall |
0:dbea5fa1cd2c
|
255
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
256
|
* @return The tap threshold as an 8-bit number with a scale factor of
|
gbeardall |
0:dbea5fa1cd2c
|
257
|
* 62.5mg/LSB.
|
gbeardall |
0:dbea5fa1cd2c
|
258
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
259
|
char getTapThreshold(void);
|
gbeardall |
0:dbea5fa1cd2c
|
260
|
|
gbeardall |
0:dbea5fa1cd2c
|
261
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
262
|
* Set the tap threshold.
|
gbeardall |
0:dbea5fa1cd2c
|
263
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
264
|
* @param The tap threshold as an 8-bit number with a scale factor of
|
gbeardall |
0:dbea5fa1cd2c
|
265
|
* 62.5mg/LSB.
|
gbeardall |
0:dbea5fa1cd2c
|
266
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
267
|
int setTapThreshold(char threshold);
|
gbeardall |
0:dbea5fa1cd2c
|
268
|
|
gbeardall |
0:dbea5fa1cd2c
|
269
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
270
|
* Get the tap duration required to trigger an event.
|
gbeardall |
0:dbea5fa1cd2c
|
271
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
272
|
* @return The max time that an event must be above the tap threshold to
|
gbeardall |
0:dbea5fa1cd2c
|
273
|
* qualify as a tap event, in microseconds.
|
gbeardall |
0:dbea5fa1cd2c
|
274
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
275
|
float getTapDuration(void);
|
gbeardall |
0:dbea5fa1cd2c
|
276
|
|
gbeardall |
0:dbea5fa1cd2c
|
277
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
278
|
* Set the tap duration required to trigger an event.
|
gbeardall |
0:dbea5fa1cd2c
|
279
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
280
|
* @param duration_us The max time that an event must be above the tap
|
gbeardall |
0:dbea5fa1cd2c
|
281
|
* threshold to qualify as a tap event, in microseconds.
|
gbeardall |
0:dbea5fa1cd2c
|
282
|
* Time will be normalized by the scale factor which is
|
gbeardall |
0:dbea5fa1cd2c
|
283
|
* 625us/LSB. A value of 0 disables the single/double
|
gbeardall |
0:dbea5fa1cd2c
|
284
|
* tap functions.
|
gbeardall |
0:dbea5fa1cd2c
|
285
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
286
|
int setTapDuration(short int duration_us);
|
gbeardall |
0:dbea5fa1cd2c
|
287
|
|
gbeardall |
0:dbea5fa1cd2c
|
288
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
289
|
* Get the tap latency between the detection of a tap and the time window.
|
gbeardall |
0:dbea5fa1cd2c
|
290
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
291
|
* @return The wait time from the detection of a tap event to the start of
|
gbeardall |
0:dbea5fa1cd2c
|
292
|
* the time window during which a possible second tap event can be
|
gbeardall |
0:dbea5fa1cd2c
|
293
|
* detected in milliseconds.
|
gbeardall |
0:dbea5fa1cd2c
|
294
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
295
|
float getTapLatency(void);
|
gbeardall |
0:dbea5fa1cd2c
|
296
|
|
gbeardall |
0:dbea5fa1cd2c
|
297
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
298
|
* Set the tap latency between the detection of a tap and the time window.
|
gbeardall |
0:dbea5fa1cd2c
|
299
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
300
|
* @param latency_ms The wait time from the detection of a tap event to the
|
gbeardall |
0:dbea5fa1cd2c
|
301
|
* start of the time window during which a possible
|
gbeardall |
0:dbea5fa1cd2c
|
302
|
* second tap event can be detected in milliseconds.
|
gbeardall |
0:dbea5fa1cd2c
|
303
|
* A value of 0 disables the double tap function.
|
gbeardall |
0:dbea5fa1cd2c
|
304
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
305
|
int setTapLatency(short int latency_ms);
|
gbeardall |
0:dbea5fa1cd2c
|
306
|
|
gbeardall |
0:dbea5fa1cd2c
|
307
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
308
|
* Get the time of window between tap latency and a double tap.
|
gbeardall |
0:dbea5fa1cd2c
|
309
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
310
|
* @return The amount of time after the expiration of the latency time
|
gbeardall |
0:dbea5fa1cd2c
|
311
|
* during which a second valid tap can begin, in milliseconds.
|
gbeardall |
0:dbea5fa1cd2c
|
312
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
313
|
float getWindowTime(void);
|
gbeardall |
0:dbea5fa1cd2c
|
314
|
|
gbeardall |
0:dbea5fa1cd2c
|
315
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
316
|
* Set the time of the window between tap latency and a double tap.
|
gbeardall |
0:dbea5fa1cd2c
|
317
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
318
|
* @param window_ms The amount of time after the expiration of the latency
|
gbeardall |
0:dbea5fa1cd2c
|
319
|
* time during which a second valid tap can begin,
|
gbeardall |
0:dbea5fa1cd2c
|
320
|
* in milliseconds.
|
gbeardall |
0:dbea5fa1cd2c
|
321
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
322
|
int setWindowTime(short int window_ms);
|
gbeardall |
0:dbea5fa1cd2c
|
323
|
|
gbeardall |
0:dbea5fa1cd2c
|
324
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
325
|
* Get the threshold value for detecting activity.
|
gbeardall |
0:dbea5fa1cd2c
|
326
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
327
|
* @return The threshold value for detecting activity as an 8-bit number.
|
gbeardall |
0:dbea5fa1cd2c
|
328
|
* Scale factor is 62.5mg/LSB.
|
gbeardall |
0:dbea5fa1cd2c
|
329
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
330
|
char getActivityThreshold(void);
|
gbeardall |
0:dbea5fa1cd2c
|
331
|
|
gbeardall |
0:dbea5fa1cd2c
|
332
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
333
|
* Set the threshold value for detecting activity.
|
gbeardall |
0:dbea5fa1cd2c
|
334
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
335
|
* @param threshold The threshold value for detecting activity as an 8-bit
|
gbeardall |
0:dbea5fa1cd2c
|
336
|
* number. Scale factor is 62.5mg/LSB. A value of 0 may
|
gbeardall |
0:dbea5fa1cd2c
|
337
|
* result in undesirable behavior if the activity
|
gbeardall |
0:dbea5fa1cd2c
|
338
|
* interrupt is enabled.
|
gbeardall |
0:dbea5fa1cd2c
|
339
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
340
|
int setActivityThreshold(char threshold);
|
gbeardall |
0:dbea5fa1cd2c
|
341
|
|
gbeardall |
0:dbea5fa1cd2c
|
342
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
343
|
* Get the threshold value for detecting inactivity.
|
gbeardall |
0:dbea5fa1cd2c
|
344
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
345
|
* @return The threshold value for detecting inactivity as an 8-bit number.
|
gbeardall |
0:dbea5fa1cd2c
|
346
|
* Scale factor is 62.5mg/LSB.
|
gbeardall |
0:dbea5fa1cd2c
|
347
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
348
|
char getInactivityThreshold(void);
|
gbeardall |
0:dbea5fa1cd2c
|
349
|
|
gbeardall |
0:dbea5fa1cd2c
|
350
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
351
|
* Set the threshold value for detecting inactivity.
|
gbeardall |
0:dbea5fa1cd2c
|
352
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
353
|
* @param threshold The threshold value for detecting inactivity as an
|
gbeardall |
0:dbea5fa1cd2c
|
354
|
* 8-bit number. Scale factor is 62.5mg/LSB.
|
gbeardall |
0:dbea5fa1cd2c
|
355
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
356
|
int setInactivityThreshold(char threshold);
|
gbeardall |
0:dbea5fa1cd2c
|
357
|
|
gbeardall |
0:dbea5fa1cd2c
|
358
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
359
|
* Get the time required for inactivity to be declared.
|
gbeardall |
0:dbea5fa1cd2c
|
360
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
361
|
* @return The amount of time that acceleration must be less than the
|
gbeardall |
0:dbea5fa1cd2c
|
362
|
* inactivity threshold for inactivity to be declared, in
|
gbeardall |
0:dbea5fa1cd2c
|
363
|
* seconds.
|
gbeardall |
0:dbea5fa1cd2c
|
364
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
365
|
char getTimeInactivity(void);
|
gbeardall |
0:dbea5fa1cd2c
|
366
|
|
gbeardall |
0:dbea5fa1cd2c
|
367
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
368
|
* Set the time required for inactivity to be declared.
|
gbeardall |
0:dbea5fa1cd2c
|
369
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
370
|
* @param inactivity The amount of time that acceleration must be less than
|
gbeardall |
0:dbea5fa1cd2c
|
371
|
* the inactivity threshold for inactivity to be
|
gbeardall |
0:dbea5fa1cd2c
|
372
|
* declared, in seconds. A value of 0 results in an
|
gbeardall |
0:dbea5fa1cd2c
|
373
|
* interrupt when the output data is less than the
|
gbeardall |
0:dbea5fa1cd2c
|
374
|
* threshold inactivity.
|
gbeardall |
0:dbea5fa1cd2c
|
375
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
376
|
int setTimeInactivity(char timeInactivity);
|
gbeardall |
0:dbea5fa1cd2c
|
377
|
|
gbeardall |
0:dbea5fa1cd2c
|
378
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
379
|
* Get the activity/inactivity control settings.
|
gbeardall |
0:dbea5fa1cd2c
|
380
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
381
|
* D7 D6 D5 D4
|
gbeardall |
0:dbea5fa1cd2c
|
382
|
* +-----------+--------------+--------------+--------------+
|
gbeardall |
0:dbea5fa1cd2c
|
383
|
* | ACT ac/dc | ACT_X enable | ACT_Y enable | ACT_Z enable |
|
gbeardall |
0:dbea5fa1cd2c
|
384
|
* +-----------+--------------+--------------+--------------+
|
gbeardall |
0:dbea5fa1cd2c
|
385
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
386
|
* D3 D2 D1 D0
|
gbeardall |
0:dbea5fa1cd2c
|
387
|
* +-------------+----------------+----------------+----------------+
|
gbeardall |
0:dbea5fa1cd2c
|
388
|
* | INACT ac/dc | INACT_X enable | INACT_Y enable | INACT_Z enable |
|
gbeardall |
0:dbea5fa1cd2c
|
389
|
* +-------------+----------------+----------------+----------------+
|
gbeardall |
0:dbea5fa1cd2c
|
390
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
391
|
* See datasheet for details.
|
gbeardall |
0:dbea5fa1cd2c
|
392
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
393
|
* @return The contents of the ACT_INACT_CTL register.
|
gbeardall |
0:dbea5fa1cd2c
|
394
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
395
|
char getActivityInactivityControl(void);
|
gbeardall |
0:dbea5fa1cd2c
|
396
|
|
gbeardall |
0:dbea5fa1cd2c
|
397
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
398
|
* Set the activity/inactivity control settings.
|
gbeardall |
0:dbea5fa1cd2c
|
399
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
400
|
* D7 D6 D5 D4
|
gbeardall |
0:dbea5fa1cd2c
|
401
|
* +-----------+--------------+--------------+--------------+
|
gbeardall |
0:dbea5fa1cd2c
|
402
|
* | ACT ac/dc | ACT_X enable | ACT_Y enable | ACT_Z enable |
|
gbeardall |
0:dbea5fa1cd2c
|
403
|
* +-----------+--------------+--------------+--------------+
|
gbeardall |
0:dbea5fa1cd2c
|
404
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
405
|
* D3 D2 D1 D0
|
gbeardall |
0:dbea5fa1cd2c
|
406
|
* +-------------+----------------+----------------+----------------+
|
gbeardall |
0:dbea5fa1cd2c
|
407
|
* | INACT ac/dc | INACT_X enable | INACT_Y enable | INACT_Z enable |
|
gbeardall |
0:dbea5fa1cd2c
|
408
|
* +-------------+----------------+----------------+----------------+
|
gbeardall |
0:dbea5fa1cd2c
|
409
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
410
|
* See datasheet for details.
|
gbeardall |
0:dbea5fa1cd2c
|
411
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
412
|
* @param settings The control byte to write to the ACT_INACT_CTL register.
|
gbeardall |
0:dbea5fa1cd2c
|
413
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
414
|
int setActivityInactivityControl(char settings);
|
gbeardall |
0:dbea5fa1cd2c
|
415
|
|
gbeardall |
0:dbea5fa1cd2c
|
416
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
417
|
* Get the threshold for free fall detection.
|
gbeardall |
0:dbea5fa1cd2c
|
418
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
419
|
* @return The threshold value for free-fall detection, as an 8-bit number,
|
gbeardall |
0:dbea5fa1cd2c
|
420
|
* with scale factor 62.5mg/LSB.
|
gbeardall |
0:dbea5fa1cd2c
|
421
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
422
|
char getFreefallThreshold(void);
|
gbeardall |
0:dbea5fa1cd2c
|
423
|
|
gbeardall |
0:dbea5fa1cd2c
|
424
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
425
|
* Set the threshold for free fall detection.
|
gbeardall |
0:dbea5fa1cd2c
|
426
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
427
|
* @return The threshold value for free-fall detection, as an 8-bit number,
|
gbeardall |
0:dbea5fa1cd2c
|
428
|
* with scale factor 62.5mg/LSB. A value of 0 may result in
|
gbeardall |
0:dbea5fa1cd2c
|
429
|
* undesirable behavior if the free-fall interrupt is enabled.
|
gbeardall |
0:dbea5fa1cd2c
|
430
|
* Values between 300 mg and 600 mg (0x05 to 0x09) are recommended.
|
gbeardall |
0:dbea5fa1cd2c
|
431
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
432
|
int setFreefallThreshold(char threshold);
|
gbeardall |
0:dbea5fa1cd2c
|
433
|
|
gbeardall |
0:dbea5fa1cd2c
|
434
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
435
|
* Get the time required to generate a free fall interrupt.
|
gbeardall |
0:dbea5fa1cd2c
|
436
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
437
|
* @return The minimum time that the value of all axes must be less than
|
gbeardall |
0:dbea5fa1cd2c
|
438
|
* the freefall threshold to generate a free-fall interrupt, in
|
gbeardall |
0:dbea5fa1cd2c
|
439
|
* milliseconds.
|
gbeardall |
0:dbea5fa1cd2c
|
440
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
441
|
char getFreefallTime(void);
|
gbeardall |
0:dbea5fa1cd2c
|
442
|
|
gbeardall |
0:dbea5fa1cd2c
|
443
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
444
|
* Set the time required to generate a free fall interrupt.
|
gbeardall |
0:dbea5fa1cd2c
|
445
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
446
|
* @return The minimum time that the value of all axes must be less than
|
gbeardall |
0:dbea5fa1cd2c
|
447
|
* the freefall threshold to generate a free-fall interrupt, in
|
gbeardall |
0:dbea5fa1cd2c
|
448
|
* milliseconds. A value of 0 may result in undesirable behavior
|
gbeardall |
0:dbea5fa1cd2c
|
449
|
* if the free-fall interrupt is enabled. Values between 100 ms
|
gbeardall |
0:dbea5fa1cd2c
|
450
|
* and 350 ms (0x14 to 0x46) are recommended.
|
gbeardall |
0:dbea5fa1cd2c
|
451
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
452
|
int setFreefallTime(short int freefallTime_ms);
|
gbeardall |
0:dbea5fa1cd2c
|
453
|
|
gbeardall |
0:dbea5fa1cd2c
|
454
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
455
|
* Get the axis tap settings.
|
gbeardall |
0:dbea5fa1cd2c
|
456
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
457
|
* D3 D2 D1 D0
|
gbeardall |
0:dbea5fa1cd2c
|
458
|
* +----------+--------------+--------------+--------------+
|
gbeardall |
0:dbea5fa1cd2c
|
459
|
* | Suppress | TAP_X enable | TAP_Y enable | TAP_Z enable |
|
gbeardall |
0:dbea5fa1cd2c
|
460
|
* +----------+--------------+--------------+--------------+
|
gbeardall |
0:dbea5fa1cd2c
|
461
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
462
|
* (D7-D4 are 0s).
|
gbeardall |
0:dbea5fa1cd2c
|
463
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
464
|
* See datasheet for more details.
|
gbeardall |
0:dbea5fa1cd2c
|
465
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
466
|
* @return The contents of the TAP_AXES register.
|
gbeardall |
0:dbea5fa1cd2c
|
467
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
468
|
char getTapAxisControl(void);
|
gbeardall |
0:dbea5fa1cd2c
|
469
|
|
gbeardall |
0:dbea5fa1cd2c
|
470
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
471
|
* Set the axis tap settings.
|
gbeardall |
0:dbea5fa1cd2c
|
472
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
473
|
* D3 D2 D1 D0
|
gbeardall |
0:dbea5fa1cd2c
|
474
|
* +----------+--------------+--------------+--------------+
|
gbeardall |
0:dbea5fa1cd2c
|
475
|
* | Suppress | TAP_X enable | TAP_Y enable | TAP_Z enable |
|
gbeardall |
0:dbea5fa1cd2c
|
476
|
* +----------+--------------+--------------+--------------+
|
gbeardall |
0:dbea5fa1cd2c
|
477
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
478
|
* (D7-D4 are 0s).
|
gbeardall |
0:dbea5fa1cd2c
|
479
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
480
|
* See datasheet for more details.
|
gbeardall |
0:dbea5fa1cd2c
|
481
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
482
|
* @param The control byte to write to the TAP_AXES register.
|
gbeardall |
0:dbea5fa1cd2c
|
483
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
484
|
int setTapAxisControl(char settings);
|
gbeardall |
0:dbea5fa1cd2c
|
485
|
|
gbeardall |
0:dbea5fa1cd2c
|
486
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
487
|
* Get the source of a tap.
|
gbeardall |
0:dbea5fa1cd2c
|
488
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
489
|
* @return The contents of the ACT_TAP_STATUS register.
|
gbeardall |
0:dbea5fa1cd2c
|
490
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
491
|
char getTapSource(void);
|
gbeardall |
0:dbea5fa1cd2c
|
492
|
|
gbeardall |
0:dbea5fa1cd2c
|
493
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
494
|
* Get the interrupt enable settings.
|
gbeardall |
0:dbea5fa1cd2c
|
495
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
496
|
* @return The contents of the INT_ENABLE register.
|
gbeardall |
0:dbea5fa1cd2c
|
497
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
498
|
|
gbeardall |
0:dbea5fa1cd2c
|
499
|
char getInterruptEnableControl(void);
|
gbeardall |
0:dbea5fa1cd2c
|
500
|
|
gbeardall |
0:dbea5fa1cd2c
|
501
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
502
|
* Set the interrupt enable settings.
|
gbeardall |
0:dbea5fa1cd2c
|
503
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
504
|
* @param settings The control byte to write to the INT_ENABLE register.
|
gbeardall |
0:dbea5fa1cd2c
|
505
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
506
|
int setInterruptEnableControl(char settings);
|
gbeardall |
0:dbea5fa1cd2c
|
507
|
|
gbeardall |
0:dbea5fa1cd2c
|
508
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
509
|
* Get the interrupt mapping settings.
|
gbeardall |
0:dbea5fa1cd2c
|
510
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
511
|
* @return The contents of the INT_MAP register.
|
gbeardall |
0:dbea5fa1cd2c
|
512
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
513
|
char getInterruptMappingControl(void);
|
gbeardall |
0:dbea5fa1cd2c
|
514
|
|
gbeardall |
0:dbea5fa1cd2c
|
515
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
516
|
* Set the interrupt mapping settings.
|
gbeardall |
0:dbea5fa1cd2c
|
517
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
518
|
* @param settings The control byte to write to the INT_MAP register.
|
gbeardall |
0:dbea5fa1cd2c
|
519
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
520
|
int setInterruptMappingControl(char settings);
|
gbeardall |
0:dbea5fa1cd2c
|
521
|
|
gbeardall |
0:dbea5fa1cd2c
|
522
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
523
|
* Get the interrupt source.
|
gbeardall |
0:dbea5fa1cd2c
|
524
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
525
|
* @return The contents of the INT_SOURCE register.
|
gbeardall |
0:dbea5fa1cd2c
|
526
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
527
|
char getInterruptSource(void);
|
gbeardall |
0:dbea5fa1cd2c
|
528
|
|
gbeardall |
0:dbea5fa1cd2c
|
529
|
|
gbeardall |
0:dbea5fa1cd2c
|
530
|
private:
|
gbeardall |
0:dbea5fa1cd2c
|
531
|
|
gbeardall |
0:dbea5fa1cd2c
|
532
|
I2C i2c_;
|
gbeardall |
0:dbea5fa1cd2c
|
533
|
|
gbeardall |
0:dbea5fa1cd2c
|
534
|
|
gbeardall |
0:dbea5fa1cd2c
|
535
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
536
|
* Read one byte from a register on the device.
|
gbeardall |
0:dbea5fa1cd2c
|
537
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
538
|
* @param: - the address to be read from
|
gbeardall |
0:dbea5fa1cd2c
|
539
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
540
|
* @return: the value of the data read
|
gbeardall |
0:dbea5fa1cd2c
|
541
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
542
|
char SingleByteRead(char address);
|
gbeardall |
0:dbea5fa1cd2c
|
543
|
|
gbeardall |
0:dbea5fa1cd2c
|
544
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
545
|
* Write one byte to a register on the device.
|
gbeardall |
0:dbea5fa1cd2c
|
546
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
547
|
* @param:
|
gbeardall |
0:dbea5fa1cd2c
|
548
|
- address of the register to write to.
|
gbeardall |
0:dbea5fa1cd2c
|
549
|
- the value of the data to store
|
gbeardall |
0:dbea5fa1cd2c
|
550
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
551
|
|
gbeardall |
0:dbea5fa1cd2c
|
552
|
|
gbeardall |
0:dbea5fa1cd2c
|
553
|
int SingleByteWrite(char address, char data);
|
gbeardall |
0:dbea5fa1cd2c
|
554
|
|
gbeardall |
0:dbea5fa1cd2c
|
555
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
556
|
* Read several consecutive bytes on the device and store them in a given location.
|
gbeardall |
0:dbea5fa1cd2c
|
557
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
558
|
* @param startAddress: The address of the first register to read from.
|
gbeardall |
0:dbea5fa1cd2c
|
559
|
* @param ptr_output: a pointer to the location to store the data being read
|
gbeardall |
0:dbea5fa1cd2c
|
560
|
* @param size: The number of bytes to read.
|
gbeardall |
0:dbea5fa1cd2c
|
561
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
562
|
void multiByteRead(char startAddress, char* ptr_output, int size);
|
gbeardall |
0:dbea5fa1cd2c
|
563
|
|
gbeardall |
0:dbea5fa1cd2c
|
564
|
/**
|
gbeardall |
0:dbea5fa1cd2c
|
565
|
* Write several consecutive bytes on the device.
|
gbeardall |
0:dbea5fa1cd2c
|
566
|
*
|
gbeardall |
0:dbea5fa1cd2c
|
567
|
* @param startAddress: The address of the first register to write to.
|
gbeardall |
0:dbea5fa1cd2c
|
568
|
* @param ptr_data: Pointer to a location which contains the data to write.
|
gbeardall |
0:dbea5fa1cd2c
|
569
|
* @param size: The number of bytes to write.
|
gbeardall |
0:dbea5fa1cd2c
|
570
|
*/
|
gbeardall |
0:dbea5fa1cd2c
|
571
|
int multiByteWrite(char startAddress, char* ptr_data, int size);
|
gbeardall |
0:dbea5fa1cd2c
|
572
|
|
gbeardall |
0:dbea5fa1cd2c
|
573
|
};
|
gbeardall |
0:dbea5fa1cd2c
|
574
|
|
gbeardall |
0:dbea5fa1cd2c
|
575
|
#endif /* ADXL345_I2C_H */
|