PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
PropWare::ADXL345 Class Reference
+ Collaboration diagram for PropWare::ADXL345:

Classes

union  ActivityDetection
 Bit-mapping for Register::ACT_INACT_CTL. More...
 
struct  ActivityDetection.fields
 
union  DataFormat
 Bit-mapping for Register::DATA_FORMAT. More...
 
struct  DataFormat.fields
 
union  FIFOControl
 Bit-mapping for Register::FIFO_CONTROL. More...
 
struct  FIFOControl.fields
 
union  FIFOStatus
 Bit-mapping for Register::FIFO_STATUS. More...
 
struct  FIFOStatus.fields
 
union  InterruptEnable
 Bit-mapping for Register::INTERRUPT_ENABLE. More...
 
struct  InterruptEnable.fields
 
union  InterruptMapping
 Bit-mapping for Register::INTERRUPT_MAPPING. More...
 
struct  InterruptMapping.fields
 
union  InterruptSources
 Bit-mapping for Register::INTERRUPT_SOURCES. More...
 
struct  InterruptSources.fields
 
union  PowerControl
 Bit-mapping for Register::POWER_SAVINGS. More...
 
struct  PowerControl.fields
 
union  RateAndPowerMode
 Bit-mapping for Register::RATE_AND_POWER_MODE. More...
 
struct  RateAndPowerMode.fields
 
union  TapAxes
 Bit-mapping for Register::TAP_AXES. More...
 
struct  TapAxes.fields
 
union  TapSource
 Bit-mapping for Register::TAP_SOURCE. More...
 
struct  TapSource.fields
 

Public Types

enum  Register {
  Register::DEVICE_ID,
  Register::TAP_THRESHOLD = 0x1D,
  Register::X_AXIS_OFFSET,
  Register::Y_AXIS_OFFSET,
  Register::Z_AXIS_OFFSET,
  Register::TAP_DURATION,
  Register::TAP_LATENCY,
  Register::TAP_WINDOW,
  Register::ACTIVITY_THRESHOLD,
  Register::INACTIVITY_THRESHOLD,
  Register::INACTIVITY_TIME,
  Register::ACT_INACT_CTL,
  Register::FREE_FALL_THRESHOLD,
  Register::FREE_FALL_TIME,
  Register::TAP_AXES,
  Register::TAP_SOURCE,
  Register::RATE_AND_POWER_MODE,
  Register::POWER_CONTROL,
  Register::INTERRUPT_ENABLE,
  Register::INTERRUPT_MAPPING,
  Register::INTERRUPT_SOURCES,
  Register::DATA_FORMAT,
  Register::X_AXIS_0,
  Register::X_AXIS_1,
  Register::Y_AXIS_0,
  Register::Y_AXIS_1,
  Register::Z_AXIS_0,
  Register::Z_AXIS_1,
  Register::FIFO_CONTROL,
  Register::FIFO_STATUS
}
 Register map for all registers on the device. More...
 
enum  Axis {
  X,
  Y,
  Z,
  AXES
}
 Convenience enumeration for selecting axes via the ADXL345::read_axis() method.
 
enum  DataRate {
  _6_25_HZ = 6,
  _12_5_HZ,
  _25_HZ,
  _50_HZ,
  _100_HZ,
  _200_HZ,
  _400_HZ,
  _800_HZ,
  _1600_HZ,
  _3200_HZ
}
 Data rate codes for the Register::RATE_AND_POWER_MODE register. More...
 
enum  WakeupFrequency {
  HZ_8,
  HZ_4,
  HZ_2,
  HZ_1
}
 Wakeup frequency codes for the Register::POWER_SAVINGS register. More...
 
enum  Range {
  _2G,
  _4G,
  _8G,
  _16G
}
 Selection of data ranges. More...
 
enum  FIFOMode {
  BYPASS,
  FIFO,
  STREAM,
  TRIGGER
}
 Data codes for the various modes of operation that the FIFO can assume. More...
 

Public Member Functions

 ADXL345 (SPI &bus, const Pin::Mask csMask, const bool alwaysSetSPIMode=false)
 Create an object which communicates over the given SPI bus. More...
 
 ADXL345 (const Pin::Mask csMask, const bool alwaysSetSPIMode=true)
 Create an object which communicates over the shared SPI bus. More...
 
void always_set_spi_mode (const bool alwaysSetMode)
 Choose whether to always set the SPI mode before writing to the device; Useful when multiple devices with different SPI specifications are connected to the bus. More...
 
void start (const bool autoSleep=false, const bool link=false, const bool sleep=false, const bool measure=true, const WakeupFrequency wakeupFrequency=WakeupFrequency::HZ_8) const
 Convenience function to start the device in a sane fashion for basic reading. More...
 
void read (int16_t *values) const
 Retrieve the values from all 3 axes with a fast, 6-byte successive read. More...
 
int16_t read_axis (const Axis axis) const
 Read data for all three axes and return only the requested axis. More...
 
int16_t read_x () const
 Read data for all three axes and return only the x-axis. More...
 
int16_t read_y () const
 Read data for all three axes and return only the y-axis. More...
 
int16_t read_z () const
 Read data for all three axes and return only the z-axis. More...
 
void write (const Register address, const uint8_t value) const
 Perform a manual write to the device. More...
 
uint8_t read (const Register address) const
 Perform a single manual read from the device. More...
 
void read (const Register startingAddress, const size_t words, int16_t *result) const
 Perform a manual, multi-byte read from the device. More...
 
void set_bit (const Register address, const Bit bit) const
 Set a single bit in a register on the device. More...
 
void clear_bit (const Register address, const Bit bit) const
 Clear a single bit in a register on the device. More...
 

Static Public Member Functions

static double scale (const int value, const Range range)
 Scale the non-justified, raw accelerometer value to a human-readable number. More...
 

Static Public Attributes

static const SPI::Mode SPI_MODE = SPI::Mode::MODE_3
 
static const uint8_t DEVICE_ID = 0xE5
 The ADXL345 is hardwired for a device ID of 0xE5
 
static constexpr double FULL_RESOLUTION_SCALE = 0.004
 The highest resolution that the device is capable of. Resolution will become less precise (larger number) as Range increases. Use the ADXL345::scale method to get the human-readable value for acceleration.
 

Detailed Description

Examples
ADXL345_Demo.cpp.

Definition at line 32 of file adxl345.h.


Class Documentation

◆ PropWare::ADXL345::ActivityDetection

union PropWare::ADXL345::ActivityDetection

Bit-mapping for Register::ACT_INACT_CTL.

Definition at line 299 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::ActivityDetection:
Class Members
struct ActivityDetection fields
uint8_t raw

◆ PropWare::ADXL345::ActivityDetection.fields

struct PropWare::ADXL345::ActivityDetection.fields

Definition at line 300 of file adxl345.h.

Class Members
unsigned int activeAcDc: 1

Select between ac-coupled and dc-couple operation. Low for dc-coupled, high for ac-coupled.

unsigned int activeXEnable: 1

Enable x-axis participation in detecting activity

unsigned int activeYEnable: 1

Enable y-axis participation in detecting activity

unsigned int activeZEnable: 1

Enable z-axis participation in detecting activity

unsigned int inactiveAcDc: 1

Select between ac-coupled and dc-couple operation. Low for dc-coupled, high for ac-coupled.

unsigned int inactiveXEnable: 1

Enable x-axis participation in detecting inactivity

unsigned int inactiveYEnable: 1

Enable y-axis participation in detecting inactivity

unsigned int inactiveZEnable: 1

Enable z-axis participation in detecting inactivity

◆ PropWare::ADXL345::DataFormat

union PropWare::ADXL345::DataFormat

Bit-mapping for Register::DATA_FORMAT.

Definition at line 507 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::DataFormat:
Class Members
struct DataFormat fields
uint8_t raw

◆ PropWare::ADXL345::DataFormat.fields

struct PropWare::ADXL345::DataFormat.fields

Definition at line 508 of file adxl345.h.

Class Members
unsigned int fullResolution: 1

When set high, the resolution will always be 4 mg/LSB no matter the range. When set low, the resolution will change with the range and the data will remain 10 bits wide.

unsigned int invertedInterrupts: 1

When set high, interrupts will be active high instead of active low.

unsigned int justify: 1

When set high, data will be left (MSB) justified. When cleared low, it will be right justified and sign extended.

Range range: 2

Data range of the device

unsigned int selfTest

Setting high will enable self-test mode, causing a shift in the output data. Cleared low for normal operation.

unsigned int spiMode

When set high, the device will work in 3-wire SPI mode. Cleared low for 4-wire SPI mode.

◆ PropWare::ADXL345::FIFOControl

union PropWare::ADXL345::FIFOControl

Bit-mapping for Register::FIFO_CONTROL.

Definition at line 543 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::FIFOControl:
Class Members
struct FIFOControl fields
uint8_t raw

◆ PropWare::ADXL345::FIFOControl.fields

struct PropWare::ADXL345::FIFOControl.fields

Definition at line 544 of file adxl345.h.

Class Members
FIFOMode fifoMode: 2

Set the mode that the FIFO will assume.

unsigned int samples: 5

The function of these bits depends on the FIFO mode selected via FIFOContro::fifoMode. Entering a value of 0 in the samples bits immediately sets the watermark status bit in Register::INTERRUPT_SOURCE, regardless of which FIFO mode is selected. Undesirable operation may occur if a value of 0 is used for the samples bits when trigger mode is used.

unsigned int trigger: 1

Clear low to link the trigger event of trigger mode to INT1, and set high to link the trigger event to INT2.

◆ PropWare::ADXL345::FIFOStatus

union PropWare::ADXL345::FIFOStatus

Bit-mapping for Register::FIFO_STATUS.

Definition at line 568 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::FIFOStatus:
Class Members
struct FIFOStatus fields
uint8_t raw

◆ PropWare::ADXL345::FIFOStatus.fields

struct PropWare::ADXL345::FIFOStatus.fields

Definition at line 569 of file adxl345.h.

Class Members
unsigned int entries: 6

These bits report how many data values are stored in FIFO.

unsigned int fifoTrigger: 1

Set high when a trigger event is occurring. Cleared low otherwise.

unsigned int unused: 1

Unused bit

◆ PropWare::ADXL345::InterruptEnable

union PropWare::ADXL345::InterruptEnable

Bit-mapping for Register::INTERRUPT_ENABLE.

Definition at line 432 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::InterruptEnable:
Class Members
struct InterruptEnable fields
uint8_t raw

◆ PropWare::ADXL345::InterruptEnable.fields

struct PropWare::ADXL345::InterruptEnable.fields

Definition at line 433 of file adxl345.h.

Class Members
unsigned int activity: 1

Enable interrupt generation for the activity event

unsigned int dataReady: 1

Enable interrupt generation for the data ready event

unsigned int doubleTap: 1

Enable interrupt generation for the double tap event

unsigned int freeFall: 1

Enable interrupt generation for the free fall event

unsigned int inactivity: 1

Enable interrupt generation for the inactivity event

unsigned int overrun: 1

Enable interrupt generation for the overrun event

unsigned int singleTap: 1

Enable interrupt generation for the single tap event

unsigned int watermark: 1

Enable interrupt generation for the watermark event

◆ PropWare::ADXL345::InterruptMapping

union PropWare::ADXL345::InterruptMapping

Bit-mapping for Register::INTERRUPT_MAPPING.

Definition at line 449 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::InterruptMapping:
Class Members
struct InterruptMapping fields
uint8_t raw

◆ PropWare::ADXL345::InterruptMapping.fields

struct PropWare::ADXL345::InterruptMapping.fields

Definition at line 450 of file adxl345.h.

Class Members
unsigned int activity: 1

When set high, the activity event will be mapped to pin INT1, otherwise INT0.

unsigned int dataReady: 1

When set high, the data ready event will be mapped to pin INT1, otherwise INT0.

unsigned int doubleTap: 1

When set high, the double tap event will be mapped to pin INT1, otherwise INT0.

unsigned int freeFall: 1

When set high, the free fall event will be mapped to pin INT1, otherwise INT0.

unsigned int inactivity: 1

When set high, the inactivity event will be mapped to pin INT1, otherwise INT0.

unsigned int overrun: 1

When set high, the overrun event will be mapped to pin INT1, otherwise INT0.

unsigned int singleTap: 1

When set high, the single tap event will be mapped to pin INT1, otherwise INT0.

unsigned int watermark: 1

When set high, the watermark event will be mapped to pin INT1, otherwise INT0.

◆ PropWare::ADXL345::InterruptSources

union PropWare::ADXL345::InterruptSources

Bit-mapping for Register::INTERRUPT_SOURCES.

Definition at line 490 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::InterruptSources:
Class Members
struct InterruptSources fields
uint8_t raw

◆ PropWare::ADXL345::InterruptSources.fields

struct PropWare::ADXL345::InterruptSources.fields

Definition at line 491 of file adxl345.h.

Class Members
unsigned int activity: 1

When set, an activity event has occurred.

unsigned int dataReady: 1

When set, a data ready event has occurred.

unsigned int doubleTap: 1

When set, a double tap event has occurred.

unsigned int freeFall: 1

When set, a free fall event has occurred.

unsigned int inactivity: 1

When set, an inactivity event has occurred.

unsigned int overrun: 1

When set, an overrun event has occurred.

unsigned int singleTap: 1

When set, a single tap event has occurred.

unsigned int watermark: 1

When set, a watermark event has occurred.

◆ PropWare::ADXL345::PowerControl

union PropWare::ADXL345::PowerControl

Bit-mapping for Register::POWER_SAVINGS.

Definition at line 385 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::PowerControl:
Class Members
struct PowerControl fields
uint8_t raw

◆ PropWare::ADXL345::PowerControl.fields

struct PropWare::ADXL345::PowerControl.fields

Definition at line 386 of file adxl345.h.

Class Members
unsigned int autoSleep: 1

When set high, the device will automatically enter a low-power sleep mode any time the sampled activity dips below the threshold configured via Register::INACTIVITY_THRESHOLD for at least the amount of time configured via Register::INACTIVITY_TIME. Clearing the bit low will disable automatic sleep mode.

When clearing the AUTO_SLEEP bit, it is recommended that the part be placed into standby mode and then set back to measurement mode with a subsequent write. This is done to ensure that the device is properly biased if sleep mode is manually disabled; otherwise, the first few samples of data after the AUTO_SLEEP bit is cleared may have additional noise, especially if the device was asleep when the bit was cleared.

unsigned int link: 1

Set high to enable linked mode and clear low for concurrent functionality of inactivity and activity functions. See the datasheet for a far more verbose explanation.

unsigned int measure: 1

Set high for normal operation and low for standby mode. When in standby mode, power consumption is at a minimum but now measurements can be made. The device is booted in standby mode.

unsigned int sleep: 1

When set high, the device will be put into sleep mode. Low for normal operation. While in sleep mode, the device's sample rate is set by PowerControl::wakeup.

When clearing the sleep bit, it is recommended that the part be placed into standby mode and then set back to measurement mode with a subsequent write. This is done to ensure that the device is properly biased if sleep mode is manually disabled; otherwise, the first few samples of data after the sleep bit is cleared may have additional noise, especially if the device was asleep when the bit was cleared

WakeupFrequency wakeup: 2

Frequency of reading when in sleep mode

◆ PropWare::ADXL345::RateAndPowerMode

union PropWare::ADXL345::RateAndPowerMode

Bit-mapping for Register::RATE_AND_POWER_MODE.

Definition at line 367 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::RateAndPowerMode:
Class Members
struct RateAndPowerMode fields
uint8_t raw

◆ PropWare::ADXL345::RateAndPowerMode.fields

struct PropWare::ADXL345::RateAndPowerMode.fields

Definition at line 368 of file adxl345.h.

Class Members
DataRate dataRate: 3

Set the data polling rate.

unsigned int lowPowerMode: 1

Enable or disable low-power mode. Low power mode has a somewhat higher noise but reduces power consumption. True to enable low power mode, false for normal operation.

◆ PropWare::ADXL345::TapAxes

union PropWare::ADXL345::TapAxes

Bit-mapping for Register::TAP_AXES.

Definition at line 324 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::TapAxes:
Class Members
struct TapAxes fields
uint8_t raw

◆ PropWare::ADXL345::TapAxes.fields

struct PropWare::ADXL345::TapAxes.fields

Definition at line 325 of file adxl345.h.

Class Members
unsigned int suppress: 1

When set high, suppress double-tap detection for too high of an acceleration (as set per Register::TAP_THRESHOLD)

unsigned int tapXEnable: 1

Enable x-axis participation in tap detection

unsigned int tapYEnable: 1

Enable y-axis participation in tap detection

unsigned int tapZEnable: 1

Enable z-axis participation in tap detection

◆ PropWare::ADXL345::TapSource

union PropWare::ADXL345::TapSource

Bit-mapping for Register::TAP_SOURCE.

Definition at line 344 of file adxl345.h.

+ Collaboration diagram for PropWare::ADXL345::TapSource:
Class Members
struct TapSource fields
uint8_t raw

◆ PropWare::ADXL345::TapSource.fields

struct PropWare::ADXL345::TapSource.fields

Definition at line 345 of file adxl345.h.

Class Members
unsigned int asleep: 1

When set, the device is sleeping

unsigned int xActivity: 1

When set, activity was detected on the x-axis

unsigned int xTapped: 1

When set, a tap was detected on the x-axis

unsigned int yActivity: 1

When set, activity was detected on the y-axis

unsigned int yTapped: 1

When set, a tap was detected on the y-axis

unsigned int zActivity: 1

When set, activity was detected on the z-axis

unsigned int zTapped: 1

When set, a tap was detected on the z-axis

Member Enumeration Documentation

◆ DataRate

Data rate codes for the Register::RATE_AND_POWER_MODE register.

Enumeration names are based on the data rate with underscores representing decimal points for 6.25 and 12.5 Hz.

Enumerator
_6_25_HZ 

Output data rate (Hz) = 6.25, Bandwidth (Hz) = 3.125, Current (uA) = 145

_12_5_HZ 

Output data rate (Hz) = 12.5, Bandwidth (Hz) = 6.25, Current (uA) = 100

_25_HZ 

Output data rate (Hz) = 25, Bandwidth (Hz) = 12.5, Current (uA) = 145

_50_HZ 

Output data rate (Hz) = 50, Bandwidth (Hz) = 25, Current (uA) = 145

_100_HZ 

Output data rate (Hz) = 100, Bandwidth (Hz) = 50, Current (uA) = 145

_200_HZ 

Output data rate (Hz) = 200, Bandwidth (Hz) = 100, Current (uA) = 145

_400_HZ 

Output data rate (Hz) = 400, Bandwidth (Hz) = 200, Current (uA) = 100

_800_HZ 

Output data rate (Hz) = 800, Bandwidth (Hz) = 400, Current (uA) = 65

_1600_HZ 

Output data rate (Hz) = 1600, Bandwidth (Hz) = 800, Current (uA) = 55

_3200_HZ 

Output data rate (Hz) = 3200, Bandwidth (Hz) = 1600, Current (uA) = 40

Definition at line 237 of file adxl345.h.

◆ FIFOMode

Data codes for the various modes of operation that the FIFO can assume.

Enumerator
BYPASS 

FIFO is bypassed.

FIFO 

FIFO collects up to 32 values and then stops collecting data, collecting new data only when FIFO is not full.

STREAM 

FIFO holds the last 32 data values. When FIFO is full, the oldest data is overwritten with newer data.

TRIGGER 

When triggered by the trigger bit, FIFO holds the last data samples before the trigger event and then continues to collect data until full. New data is collected only when FIFO is not full.

Definition at line 275 of file adxl345.h.

◆ Range

Selection of data ranges.

Larger data ranges decrease the device's precision

Enumerator
_2G 

Data range will be +/- 2 g

_4G 

Data range will be +/- 4 g

_8G 

Data range will be +/- 8 g

_16G 

Data range will be +/- 16 g

Definition at line 265 of file adxl345.h.

◆ Register

Register map for all registers on the device.

Enumerator
DEVICE_ID 

Device ID.

Name: DEVID, Access: read-only, Reset value: 0b11100101

TAP_THRESHOLD 

Tap threshold.

Name: THRESH_TAP, Access: read/write, Reset value: 0

X_AXIS_OFFSET 

X-axis offset.

Name: OFSX, Access: read/write, Reset value: 0

Y_AXIS_OFFSET 

Y-axis offset.

Name: OFSY, Access: read/write, Reset value: 0

Z_AXIS_OFFSET 

Z-axis offset.

Name: OFSZ, Access: read/write, Reset value: 0

TAP_DURATION 

Tap duration.

Name: DUR, Access: read/write, Reset value: 0

TAP_LATENCY 

Tap latency.

Name: Latent, Access: read/write, Reset value: 0

TAP_WINDOW 

Tap window.

Name: Window, Access: read/write, Reset value: 0

ACTIVITY_THRESHOLD 

Activity threshold.

Name: THRESH_ACT, Access: read/write, Reset value: 0

INACTIVITY_THRESHOLD 

Inactivity threshold.

Name: THRESH_INACT, Access: read/write, Reset value: 0

INACTIVITY_TIME 

Inactivity time.

Name: TIME_INACT, Access: read/write, Reset value: 0

ACT_INACT_CTL 

Axis enable control for activity and inactivity detection.

Name: ACT_INACT_CTL, Access: read/write, Reset value: 0

FREE_FALL_THRESHOLD 

Free-fall threshold.

Name: THRESH_FF, Access: read/write, Reset value: 0

FREE_FALL_TIME 

Free-fall time Name: TIME_FF, Access: read/write, Reset value: 0

TAP_AXES 

Axis control for tap/double tap.

Name: TAP_AXES, Access: read/write, Reset value: 0

TAP_SOURCE 

Source of tap/double tap.

Name: ACT_TAP_STATUS, Access: read-only, Reset value: 0

RATE_AND_POWER_MODE 

Data rate and power mode control.

Name: BW_RATE, Access: read/write, Reset value: 0b00001010

POWER_CONTROL 

Control of the power-saving features.

Name: POWER_CTL, Access: read/write, Reset value: 0

INTERRUPT_ENABLE 

Interrupt enable control.

Name: INT_ENABLE, Access: read/write, Reset value: 0

INTERRUPT_MAPPING 

Interrupt mapping control.

Name: INT_MAP, Access: read/write, Reset value: 0

INTERRUPT_SOURCES 

Source of interrupts.

Name: INT_SOURCE, Access: read-only, Reset value: 0b00000010

DATA_FORMAT 

Data format control.

Name: DATA_FORMAT, Access: read/write, Reset value: 0

X_AXIS_0 

X-Axis Data 0.

Name: DATAX0, Access: read-only, Reset value: 0

X_AXIS_1 

X-Axis Data 1.

Name: DATAX1, Access: read-only, Reset value: 0

Y_AXIS_0 

Y-Axis Data 0.

Name: DATAY0, Access: read-only, Reset value: 0

Y_AXIS_1 

Y-Axis Data 1.

Name: DATAY1, Access: read-only, Reset value: 0

Z_AXIS_0 

Z-Axis Data 0.

Name: DATAZ0, Access: read-only, Reset value: 0

Z_AXIS_1 

Z-Axis Data 1.

Name: DATAZ1, Access: read-only, Reset value: 0

FIFO_CONTROL 

FIFO control.

Name: FIFO_CTL, Access: read/write, Reset value: 0

FIFO_STATUS 

FIFO status.

Name: FIFO_STATUS, Access: read-only, Reset value: 0

Definition at line 37 of file adxl345.h.

◆ WakeupFrequency

Wakeup frequency codes for the Register::POWER_SAVINGS register.

Enumerator
HZ_8 

Device will wake up 8 times per second to take readings

HZ_4 

Device will wake up 4 times per second to take readings

HZ_2 

Device will wake up 2 times per second to take readings

HZ_1 

Device will wake up 1 times per second to take readings

Definition at line 253 of file adxl345.h.

Constructor & Destructor Documentation

◆ ADXL345() [1/2]

PropWare::ADXL345::ADXL345 ( SPI bus,
const Pin::Mask  csMask,
const bool  alwaysSetSPIMode = false 
)

Create an object which communicates over the given SPI bus.

Parameters
[in]busSPI bus for communication
[in]csMaskChip-select's pin mask
[in]alwaysSetSPIModeWhen true, the SPI bus's mode will always be set prior to communication

Definition at line 615 of file adxl345.h.

+ Here is the call graph for this function:

◆ ADXL345() [2/2]

PropWare::ADXL345::ADXL345 ( const Pin::Mask  csMask,
const bool  alwaysSetSPIMode = true 
)

Create an object which communicates over the shared SPI bus.

Parameters
[in]csMaskChip-select's pin mask
[in]alwaysSetSPIModeWhen true, the SPI bus's mode will always be set prior to communication

Definition at line 630 of file adxl345.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ always_set_spi_mode()

void PropWare::ADXL345::always_set_spi_mode ( const bool  alwaysSetMode)

Choose whether to always set the SPI mode before writing to the device; Useful when multiple devices with different SPI specifications are connected to the bus.

Parameters
[in]alwaysSetModeFor any non-zero value, the SPI modes will always be set before a write routine

Definition at line 645 of file adxl345.h.

◆ clear_bit()

void PropWare::ADXL345::clear_bit ( const Register  address,
const Bit  bit 
) const

Clear a single bit in a register on the device.

This method is highly inefficient (runtime performance) for multi-bit modifications. Use this only when code size or code legibility is more important than runtime performance.

Parameters
[in]addressAddress of the register to modify
[in]bitBit in the register that should be cleared low

Definition at line 800 of file adxl345.h.

◆ read() [1/3]

uint8_t PropWare::ADXL345::read ( const Register  address) const

Perform a single manual read from the device.

Parameters
[in]addressAddress of the register that should be read
Returns
Value in the register

Definition at line 745 of file adxl345.h.

+ Here is the call graph for this function:

◆ read() [2/3]

void PropWare::ADXL345::read ( const Register  startingAddress,
const size_t  words,
int16_t *  result 
) const

Perform a manual, multi-byte read from the device.

Parameters
[in]addressAddress of the first register to read
[in]wordsNumber of 2-byte words to read
[out]result[]Memory location were resulting data can be stored

Definition at line 763 of file adxl345.h.

◆ read() [3/3]

void PropWare::ADXL345::read ( int16_t *  values) const

Retrieve the values from all 3 axes with a fast, 6-byte successive read.

Parameters
[out]valuesMemory where 6-bytes can be stored. Note that this MUST be an array of 2-byte variables. DO NOT cast an array of 4-byte variables (such as an array of ints) and pass that address in.

Definition at line 678 of file adxl345.h.

+ Here is the caller graph for this function:

◆ read_axis()

int16_t PropWare::ADXL345::read_axis ( const Axis  axis) const

Read data for all three axes and return only the requested axis.

Parameters
[in]axisAxis which should be read
Returns
Reading from the requested axis

Definition at line 689 of file adxl345.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_x()

int16_t PropWare::ADXL345::read_x ( ) const

Read data for all three axes and return only the x-axis.

Returns
Reading from the x-axis

Definition at line 700 of file adxl345.h.

+ Here is the call graph for this function:

◆ read_y()

int16_t PropWare::ADXL345::read_y ( ) const

Read data for all three axes and return only the y-axis.

Returns
Reading from the y-axis

Definition at line 709 of file adxl345.h.

+ Here is the call graph for this function:

◆ read_z()

int16_t PropWare::ADXL345::read_z ( ) const

Read data for all three axes and return only the z-axis.

Returns
Reading from the z-axis

Definition at line 718 of file adxl345.h.

+ Here is the call graph for this function:

◆ scale()

static double PropWare::ADXL345::scale ( const int  value,
const Range  range 
)
static

Scale the non-justified, raw accelerometer value to a human-readable number.

This method is only necessary when the fullResolution bit of ADXL345::DataFormat is cleared low. If it is high, simply multiply the raw value by ADXL345::FULL_RESOLUTION_SCALE to achieve the correct result.

Parameters
[in]valueRaw accelerometer
[in]rangeThe range that was selected at the time the reading was made.
Returns
Human-readable acceleration value for the requested axis

Definition at line 603 of file adxl345.h.

◆ set_bit()

void PropWare::ADXL345::set_bit ( const Register  address,
const Bit  bit 
) const

Set a single bit in a register on the device.

This method is highly inefficient (runtime performance) for multi-bit modifications. Use this only when code size or code legibility is more important than runtime performance.

Parameters
[in]addressAddress of the register to modify
[in]bitBit in the register that should be set high

Definition at line 786 of file adxl345.h.

◆ start()

void PropWare::ADXL345::start ( const bool  autoSleep = false,
const bool  link = false,
const bool  sleep = false,
const bool  measure = true,
const WakeupFrequency  wakeupFrequency = WakeupFrequency::HZ_8 
) const

Convenience function to start the device in a sane fashion for basic reading.

See the documentation of PowerControl::fields for detailed descriptions of each parameter

Parameters
[in]autoSleepSet the auto-sleep feature
[in]linkSet the link feature
[in]sleepSet the sleep mode
[in]measureSet the standby mode
[in]wakeupFrequencySet the wakeup frequency

Definition at line 660 of file adxl345.h.

+ Here is the call graph for this function:

◆ write()

void PropWare::ADXL345::write ( const Register  address,
const uint8_t  value 
) const

Perform a manual write to the device.

Parameters
[in]addressAddress of the register that should be modified
[in]valueValue that should be written to the register

Definition at line 728 of file adxl345.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: