ADXL345_I2C Class Reference
ADXL345 triple axis, digital interface, accelerometer. More...
#include <ADXL345_I2C.h>
Public Member Functions | |
ADXL345_I2C (PinName sda, PinName scl) | |
Constructor. | |
char | getDevId (void) |
Read the device ID register on the device. | |
int | getTapThreshold (void) |
Read the tap threshold on the device. | |
void | setTapThreshold (int threshold) |
Set the tap threshold. | |
int | getOffset (int axis) |
Get the current offset for a particular axis. | |
void | setOffset (int axis, char offset) |
Set the offset for a particular axis. | |
int | getTapDuration (void) |
Get the tap duration required to trigger an event. | |
void | setTapDuration (int duration_us) |
Set the tap duration required to trigger an event. | |
float | getTapLatency (void) |
Get the tap latency between the detection of a tap and the time window. | |
void | setTapLatency (int latency_ms) |
Set the tap latency between the detection of a tap and the time window. | |
float | getWindowTime (void) |
Get the time of window between tap latency and a double tap. | |
void | setWindowTime (int window_ms) |
Set the time of the window between tap latency and a double tap. | |
int | getActivityThreshold (void) |
Get the threshold value for detecting activity. | |
void | setActivityThreshold (int threshold) |
Set the threshold value for detecting activity. | |
int | getInactivityThreshold (void) |
Get the threshold value for detecting inactivity. | |
void | setInactivityThreshold (int threshold) |
Set the threshold value for detecting inactivity. | |
int | getTimeInactivity (void) |
Get the time required for inactivity to be declared. | |
void | setTimeInactivity (int timeInactivity) |
Set the time required for inactivity to be declared. | |
int | getActivityInactivityControl (void) |
Get the activity/inactivity control settings. | |
void | setActivityInactivityControl (int settings) |
Set the activity/inactivity control settings. | |
int | getFreefallThreshold (void) |
Get the threshold for free fall detection. | |
void | setFreefallThreshold (int threshold) |
Set the threshold for free fall detection. | |
int | getFreefallTime (void) |
Get the time required to generate a free fall interrupt. | |
void | setFreefallTime (int freefallTime_ms) |
Set the time required to generate a free fall interrupt. | |
int | getTapAxisControl (void) |
Get the axis tap settings. | |
void | setTapAxisControl (int settings) |
Set the axis tap settings. | |
int | getTapSource (void) |
Get the source of a tap. | |
void | setPowerMode (char mode) |
Set the power mode. | |
void | setDataRate (int rate) |
Set the data rate. | |
int | getPowerControl (void) |
Get the power control settings. | |
void | setPowerControl (int settings) |
Set the power control settings. | |
int | getInterruptEnableControl (void) |
Get the interrupt enable settings. | |
void | setInterruptEnableControl (int settings) |
Set the interrupt enable settings. | |
int | getInterruptMappingControl (void) |
Get the interrupt mapping settings. | |
void | setInterruptMappingControl (int settings) |
Set the interrupt mapping settings. | |
int | getInterruptSource (void) |
Get the interrupt source. | |
int | getDataFormatControl (void) |
Get the data format settings. | |
void | setDataFormatControl (int settings) |
Set the data format settings. | |
void | getOutput (int *readings) |
Get the output of all three axes. | |
int | getAx () |
Get acceleration of X axis. | |
int | getAy () |
Get acceleration of Y axis. | |
int | getAz () |
Get acceleration of Z axis. | |
int | getFifoControl (void) |
Get the FIFO control settings. | |
void | setFifoControl (int settings) |
Set the FIFO control settings. | |
int | getFifoStatus (void) |
Get FIFO status. |
Detailed Description
ADXL345 triple axis, digital interface, accelerometer.
Definition at line 106 of file ADXL345_I2C.h.
Constructor & Destructor Documentation
ADXL345_I2C | ( | PinName | sda, |
PinName | scl | ||
) |
Constructor.
Includes.
- Parameters:
-
sda mbed pin to use for sda line of I2C interface. scl mbed pin to use for SCL line of I2C interface. cs mbed pin to use for not chip select line of I2C interface.
LICENSE
Copyright (c) 2010 ARM Limited
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
DESCRIPTION
ADXL345, triple axis, digital interface, accelerometer.
Datasheet:
http://www.analog.com/static/imported-files/data_sheets/ADXL345.pdf
Definition at line 40 of file ADXL345_I2C.cpp.
Member Function Documentation
int getActivityInactivityControl | ( | void | ) |
Get the activity/inactivity control settings.
D7 D6 D5 D4 +-----------+--------------+--------------+--------------+ | ACT ac/dc | ACT_X enable | ACT_Y enable | ACT_Z enable | +-----------+--------------+--------------+--------------+
D3 D2 D1 D0 +-------------+----------------+----------------+----------------+ | INACT ac/dc | INACT_X enable | INACT_Y enable | INACT_Z enable | +-------------+----------------+----------------+----------------+
See datasheet for details.
- Returns:
- The contents of the ACT_INACT_CTL register.
Definition at line 178 of file ADXL345_I2C.cpp.
int getActivityThreshold | ( | void | ) |
Get the threshold value for detecting activity.
- Returns:
- The threshold value for detecting activity as an 8-bit number. Scale factor is 62.5mg/LSB.
Definition at line 142 of file ADXL345_I2C.cpp.
int getAx | ( | ) |
Get acceleration of X axis.
- Returns:
- Accelerometer value for the x-axis.
Definition at line 311 of file ADXL345_I2C.cpp.
int getAy | ( | ) |
Get acceleration of Y axis.
- Returns:
- Accelerometer value for the y-axis
Definition at line 321 of file ADXL345_I2C.cpp.
int getAz | ( | ) |
Get acceleration of Z axis.
- Returns:
- Accelerometer value for the z-axis
Definition at line 330 of file ADXL345_I2C.cpp.
int getDataFormatControl | ( | void | ) |
Get the data format settings.
- Returns:
- The contents of the DATA_FORMAT register.
Definition at line 287 of file ADXL345_I2C.cpp.
char getDevId | ( | void | ) |
Read the device ID register on the device.
- Returns:
- The device ID code
Definition at line 50 of file ADXL345_I2C.cpp.
int getFifoControl | ( | void | ) |
Get the FIFO control settings.
- Returns:
- The contents of the FIFO_CTL register.
Definition at line 354 of file ADXL345_I2C.cpp.
int getFifoStatus | ( | void | ) |
Get FIFO status.
- Returns:
- The contents of the FIFO_STATUS register.
Definition at line 366 of file ADXL345_I2C.cpp.
int getFreefallThreshold | ( | void | ) |
Get the threshold for free fall detection.
- Returns:
- The threshold value for free-fall detection, as an 8-bit number, with scale factor 62.5mg/LSB.
Definition at line 190 of file ADXL345_I2C.cpp.
int getFreefallTime | ( | void | ) |
Get the time required to generate a free fall interrupt.
- Returns:
- The minimum time that the value of all axes must be less than the freefall threshold to generate a free-fall interrupt, in milliseconds.
Definition at line 202 of file ADXL345_I2C.cpp.
int getInactivityThreshold | ( | void | ) |
Get the threshold value for detecting inactivity.
- Returns:
- The threshold value for detecting inactivity as an 8-bit number. Scale factor is 62.5mg/LSB.
Definition at line 154 of file ADXL345_I2C.cpp.
int getInterruptEnableControl | ( | void | ) |
Get the interrupt enable settings.
- Returns:
- The contents of the INT_ENABLE register.
Definition at line 257 of file ADXL345_I2C.cpp.
int getInterruptMappingControl | ( | void | ) |
Get the interrupt mapping settings.
- Returns:
- The contents of the INT_MAP register.
Definition at line 269 of file ADXL345_I2C.cpp.
int getInterruptSource | ( | void | ) |
Get the interrupt source.
- Returns:
- The contents of the INT_SOURCE register.
Definition at line 281 of file ADXL345_I2C.cpp.
int getOffset | ( | int | axis ) |
Get the current offset for a particular axis.
- Parameters:
-
axis 0x00 -> X-axis 0x01 -> Y-axis 0x02 -> Z-axis
- Returns:
- The current offset as an 8-bit 2's complement number with scale factor 15.6mg/LSB.
Definition at line 68 of file ADXL345_I2C.cpp.
void getOutput | ( | int * | readings ) |
Get the output of all three axes.
- Parameters:
-
Pointer to a buffer to hold the accelerometer value for the x-axis, y-axis and z-axis [in that order].
Definition at line 341 of file ADXL345_I2C.cpp.
int getPowerControl | ( | void | ) |
Get the power control settings.
See datasheet for details.
- Returns:
- The contents of the POWER_CTL register.
Definition at line 245 of file ADXL345_I2C.cpp.
int getTapAxisControl | ( | void | ) |
Get the axis tap settings.
D3 D2 D1 D0 +----------+--------------+--------------+--------------+ | Suppress | TAP_X enable | TAP_Y enable | TAP_Z enable | +----------+--------------+--------------+--------------+
(D7-D4 are 0s).
See datasheet for more details.
- Returns:
- The contents of the TAP_AXES register.
Definition at line 216 of file ADXL345_I2C.cpp.
int getTapDuration | ( | void | ) |
Get the tap duration required to trigger an event.
- Returns:
- The max time that an event must be above the tap threshold to qualify as a tap event, in microseconds.
Definition at line 100 of file ADXL345_I2C.cpp.
float getTapLatency | ( | void | ) |
Get the tap latency between the detection of a tap and the time window.
- Returns:
- The wait time from the detection of a tap event to the start of the time window during which a possible second tap event can be detected in milliseconds.
Definition at line 114 of file ADXL345_I2C.cpp.
int getTapSource | ( | void | ) |
Get the source of a tap.
- Returns:
- The contents of the ACT_TAP_STATUS register.
Definition at line 228 of file ADXL345_I2C.cpp.
int getTapThreshold | ( | void | ) |
Read the tap threshold on the device.
- Returns:
- The tap threshold as an 8-bit number with a scale factor of 62.5mg/LSB.
Definition at line 56 of file ADXL345_I2C.cpp.
int getTimeInactivity | ( | void | ) |
Get the time required for inactivity to be declared.
- Returns:
- The amount of time that acceleration must be less than the inactivity threshold for inactivity to be declared, in seconds.
Definition at line 166 of file ADXL345_I2C.cpp.
float getWindowTime | ( | void | ) |
Get the time of window between tap latency and a double tap.
- Returns:
- The amount of time after the expiration of the latency time during which a second valid tap can begin, in milliseconds.
Definition at line 128 of file ADXL345_I2C.cpp.
void setActivityInactivityControl | ( | int | settings ) |
Set the activity/inactivity control settings.
D7 D6 D5 D4 +-----------+--------------+--------------+--------------+ | ACT ac/dc | ACT_X enable | ACT_Y enable | ACT_Z enable | +-----------+--------------+--------------+--------------+
D3 D2 D1 D0 +-------------+----------------+----------------+----------------+ | INACT ac/dc | INACT_X enable | INACT_Y enable | INACT_Z enable | +-------------+----------------+----------------+----------------+
See datasheet for details.
- Parameters:
-
settings The control byte to write to the ACT_INACT_CTL register.
Definition at line 184 of file ADXL345_I2C.cpp.
void setActivityThreshold | ( | int | threshold ) |
Set the threshold value for detecting activity.
- Parameters:
-
threshold The threshold value for detecting activity as an 8-bit number. Scale factor is 62.5mg/LSB. A value of 0 may result in undesirable behavior if the activity interrupt is enabled.
Definition at line 148 of file ADXL345_I2C.cpp.
void setDataFormatControl | ( | int | settings ) |
Set the data format settings.
- Parameters:
-
settings The control byte to write to the DATA_FORMAT register.
Definition at line 293 of file ADXL345_I2C.cpp.
void setDataRate | ( | int | rate ) |
Set the data rate.
- Parameters:
-
rate The rate code (see defines or datasheet).
Definition at line 299 of file ADXL345_I2C.cpp.
void setFifoControl | ( | int | settings ) |
Set the FIFO control settings.
- Parameters:
-
The control byte to write to the FIFO_CTL register.
Definition at line 360 of file ADXL345_I2C.cpp.
void setFreefallThreshold | ( | int | threshold ) |
Set the threshold for free fall detection.
- Returns:
- The threshold value for free-fall detection, as an 8-bit number, with scale factor 62.5mg/LSB. A value of 0 may result in undesirable behavior if the free-fall interrupt is enabled. Values between 300 mg and 600 mg (0x05 to 0x09) are recommended.
Definition at line 196 of file ADXL345_I2C.cpp.
void setFreefallTime | ( | int | freefallTime_ms ) |
Set the time required to generate a free fall interrupt.
- Returns:
- The minimum time that the value of all axes must be less than the freefall threshold to generate a free-fall interrupt, in milliseconds. A value of 0 may result in undesirable behavior if the free-fall interrupt is enabled. Values between 100 ms and 350 ms (0x14 to 0x46) are recommended.
Definition at line 208 of file ADXL345_I2C.cpp.
void setInactivityThreshold | ( | int | threshold ) |
Set the threshold value for detecting inactivity.
- Parameters:
-
threshold The threshold value for detecting inactivity as an 8-bit number. Scale factor is 62.5mg/LSB.
Definition at line 160 of file ADXL345_I2C.cpp.
void setInterruptEnableControl | ( | int | settings ) |
Set the interrupt enable settings.
- Parameters:
-
settings The control byte to write to the INT_ENABLE register.
Definition at line 263 of file ADXL345_I2C.cpp.
void setInterruptMappingControl | ( | int | settings ) |
Set the interrupt mapping settings.
- Parameters:
-
settings The control byte to write to the INT_MAP register.
Definition at line 275 of file ADXL345_I2C.cpp.
void setOffset | ( | int | axis, |
char | offset | ||
) |
Set the offset for a particular axis.
- Parameters:
-
axis 0x00 -> X-axis 0x01 -> Y-axis 0x02 -> Z-axis offset The offset as an 8-bit 2's complement number with scale factor 15.6mg/LSB.
Definition at line 84 of file ADXL345_I2C.cpp.
void setPowerControl | ( | int | settings ) |
Set the power control settings.
See datasheet for details.
- Parameters:
-
The control byte to write to the POWER_CTL register.
Definition at line 251 of file ADXL345_I2C.cpp.
void setPowerMode | ( | char | mode ) |
Set the power mode.
- Parameters:
-
mode 0 -> Normal operation. 1 -> Reduced power operation.
Definition at line 234 of file ADXL345_I2C.cpp.
void setTapAxisControl | ( | int | settings ) |
Set the axis tap settings.
D3 D2 D1 D0 +----------+--------------+--------------+--------------+ | Suppress | TAP_X enable | TAP_Y enable | TAP_Z enable | +----------+--------------+--------------+--------------+
(D7-D4 are 0s).
See datasheet for more details.
- Parameters:
-
The control byte to write to the TAP_AXES register.
Definition at line 222 of file ADXL345_I2C.cpp.
void setTapDuration | ( | int | duration_us ) |
Set the tap duration required to trigger an event.
- Parameters:
-
duration_us The max time that an event must be above the tap threshold to qualify as a tap event, in microseconds. Time will be normalized by the scale factor which is 625us/LSB. A value of 0 disables the single/double tap functions.
Definition at line 106 of file ADXL345_I2C.cpp.
void setTapLatency | ( | int | latency_ms ) |
Set the tap latency between the detection of a tap and the time window.
- Parameters:
-
latency_ms The wait time from the detection of a tap event to the start of the time window during which a possible second tap event can be detected in milliseconds. A value of 0 disables the double tap function.
Definition at line 120 of file ADXL345_I2C.cpp.
void setTapThreshold | ( | int | threshold ) |
Set the tap threshold.
- Parameters:
-
The tap threshold as an 8-bit number with a scale factor of 62.5mg/LSB.
Definition at line 62 of file ADXL345_I2C.cpp.
void setTimeInactivity | ( | int | timeInactivity ) |
Set the time required for inactivity to be declared.
- Parameters:
-
inactivity The amount of time that acceleration must be less than the inactivity threshold for inactivity to be declared, in seconds. A value of 0 results in an interrupt when the output data is less than the threshold inactivity.
Definition at line 172 of file ADXL345_I2C.cpp.
void setWindowTime | ( | int | window_ms ) |
Set the time of the window between tap latency and a double tap.
- Parameters:
-
window_ms The amount of time after the expiration of the latency time during which a second valid tap can begin, in milliseconds.
Definition at line 134 of file ADXL345_I2C.cpp.
Generated on Mon Jul 18 2022 01:22:24 by 1.7.2