Analog Devices ADXL355 Accelerometer Library for Arduino

Tested on Arduino Due and EVAL-ADXL355-PMDZ

Examples

Functions

Initialization

PL::ADXL355::ADXL355(), PL::ADXL355::beginSPI(), PL::ADXL355::beginI2C().

Range Configuration and Scale Factor

PL::ADXL355::getRange(), PL::ADXL355::setRange(), PL::ADXL355::getAccelerationScaleFactor().

Measurement Frequency Configuration

PL::ADXL355::getOutputDataRate(), PL::ADXL355::setOutputDataRate().

Measurement Enable/Disable

Use PL::ADXL355::enableMeasurement(), PL::ADXL355::disableMeasurement(), PL::ADXL355::isMeasurementEnabled().

Single Measurement

PL::ADXL355::getAccelerations()/PL::ADXL355::getRawAccelerations().

Waveform Measurement

PL::ADXL355::getNumberOfFifoSamples(), PL::ADXL355::clearFifo(), PL::ADXL355::getAccelerationsFromFifo()/PL::ADXL355::getRawAccelerationsFromFifo().

Offset Configuration

PL::ADXL355::getOffsets()/PL::ADXL355::getRawOffsets(), PL::ADXL355::setOffsets()/PL::ADXL355::setRawOffsets().

Activity Detection

PL::ADXL355::getActivityDetectionAxes(), PL::ADXL355::setActivityDetectionAxes(), PL::ADXL355::getActivityDetectionThreshold()/PL::ADXL355::getRawActivityDetectionThreshold(), PL::ADXL355::setActivityDetectionThreshold()/PL::ADXL355::setRawActivityDetectionThreshold(), PL::ADXL355::getActivityDetectionCount(), PL::ADXL355::setActivityDetectionCount().

Temperature Measurement

PL::ADXL355::enableTemperature(), PL::ADXL355::disableTemperature(), PL::ADXL355::isTemperatureEnabled(), PL::ADXL355::getTemperature()/PL::ADXL355::getRawTemperature().

Interrupt Configuration

PL::ADXL355::getInterrupts(), PL::ADXL355::setInterrupts().

Device Information and Status

PL::ADXL355::getDeviceInfo(), PL::ADXL355::getStatus().

Self-test and Reset

PL::ADXL355::selfTest(), PL::ADXL355::reset(), PL::ADXL355::getShadowRegisters().

Other

PL::ADXL355::getHpfFrequency(), PL::ADXL355::setHpfFrequency(), PL::ADXL355::getFifoWatermark(), PL::ADXL355::setFifoWatermark(), PL::ADXL355::getSynchronization(), PL::ADXL355::setSynchronization(), PL::ADXL355::enableExternalClock(), PL::ADXL355::disableExternalClock(), PL::ADXL355::isExternalClockEnabled() PL::ADXL355::getInterruptPolarity(), PL::ADXL355::setInterruptPolarity(), PL::ADXL355::getI2CSpeed(), PL::ADXL355::setI2CSpeed(), PL::ADXL355::enableDataReady(), PL::ADXL355::disableDataReady(), PL::ADXL355::isDataReadyEnabled().

API reference

class ADXL355

ADXL355 class.

Public Functions

ADXL355()

Constructor.

__attribute__ ((deprecated("Use parameterless constructor instead and select the interface by using beginSPI or beginI2C."))) ADXL355(uint8_t csPin

SPI constructor.

Parameters:
  • csPin – SPI chip select pin

  • frequency – SPI frequency, Hz

void beginSPI(uint8_t csPin, uint32_t frequency = defaultSpiFrequency, std::shared_ptr<SPIClass> customSPI = NULL)

Initializes the SPI bus and the CS pin.

Parameters:
  • csPin – SPI chip select pin

  • frequency – SPI frequency, Hz

  • customSPI – Custom SPI bus (std::shared_ptr<SPIClass> can be created using std::make_shared<SPIClass>(…SPIClass constructor arguments…) )

void beginI2C(uint8_t address, uint32_t frequency = defaultI2cFrequency)

Initializes the I2C bus.

Parameters:
  • address – I2C target address (0x1D if ASEL = 0 or 0x53 if ASEL = 1)

  • frequency – I2C frequency, Hz

__attribute__((deprecated("Use beginSPI or beginI2C instead."))) void begin()

Initializes the SPI bus and the CS pin.

ADXL355_DeviceInfo getDeviceInfo()

Gets the device information.

Returns:

device information (should be vendorId: 0xAD, familyId: 0x1D, deviceId: 0xED)

ADXL355_Status getStatus()

Gets the device status.

Returns:

device status

uint8_t getNumberOfFifoSamples()

Gets the number of valid data samples present in the FIFO buffer.

Returns:

number of samples

uint16_t getRawTemperature()

Gets the raw temperature.

Returns:

raw temperature (1885 LSB at 25°C, −9.05 LSB/°C)

float getTemperature()

Gets the temperature.

Returns:

temperature, °C

ADXL355_RawAccelerations getRawAccelerations()

Gets the raw X-, Y- and Z-axis accelerations.

Returns:

raw accelerations

ADXL355_Accelerations getAccelerations()

Gets the X-, Y- and Z-axis accelerations.

Returns:

accelerations, g

void clearFifo()

Discards the valid 3-axis samples in the FIFO.

ADXL355_RawAccelerations getRawAccelerationsFromFifo()

Gets the raw X-, Y- and Z-axis accelerations from the FIFO.

Returns:

raw accelerations

ADXL355_Accelerations getAccelerationsFromFifo()

Gets the X-, Y- and Z-axis accelerations from the FIFO.

Returns:

accelerations, g

ADXL355_RawAccelerations getRawOffsets()

Gets the raw X-, Y- and Z-axis acceleration offsets.

Returns:

raw acceleration offsets

ADXL355_Accelerations getOffsets()

Gets the X-, Y- and Z-axis acceleration offsets.

Returns:

acceleration offsets, g

void setRawOffsets(ADXL355_RawAccelerations rawOffsets)

Sets the raw X-, Y- and Z-axis acceleration offsets.

Parameters:

rawOffsets – raw acceleration offsets

void setOffsets(ADXL355_Accelerations offsets)

Sets the X-, Y- and Z-axis acceleration offsets.

Parameters:

offsets – acceleration offsets, g

ADXL355_Axes getActivityDetectionAxes()

Gets the axes for which activity detection is enabled.

Returns:

axes for which activity detection is enabled

void setActivityDetectionAxes(ADXL355_Axes axes)

Enables and disables activity detection.

Parameters:

axes – axes for which activity detection should be enabled

uint32_t getRawActivityDetectionThreshold()

Gets the raw activity detection threshold.

Returns:

raw activity detection threshold

float getActivityDetectionThreshold()

Gets the activity detection threshold.

Returns:

activity detection threshold, g

void setRawActivityDetectionThreshold(uint32_t rawThreshold)

Sets the raw activity detection threshold.

Parameters:

rawThreshold – raw activity detection threshold (max: 524288)

void setActivityDetectionThreshold(float threshold)

Sets the activity detection threshold.

Parameters:

threshold – activity detection threshold, g

uint8_t getActivityDetectionCount()

Gets the number of consecutive events above threshold required to detect activity.

Returns:

activity count

void setActivityDetectionCount(uint8_t count)

Sets the number of consecutive events above threshold required to detect activity.

Parameters:

count – activity count

ADXL355_HpfFrequency getHpfFrequency()

Gets the high-pass filter frequency.

Returns:

high-pass filter frequency

void setHpfFrequency(ADXL355_HpfFrequency frequency)

Sets the high-pass filter frequency.

Parameters:

frequency – high-pass filter frequency

ADXL355_OutputDataRate getOutputDataRate()

Gets the output data rate.

Returns:

output data rate

void setOutputDataRate(ADXL355_OutputDataRate outputDataRate)

Sets the output data rate.

Parameters:

outputDataRate – output data rate

uint8_t getFifoWatermark()

Gets the watermark number of samples stored in the FIFO that triggers a FIFO_FULL condition.

Returns:

FIFO watermark

void setFifoWatermark(uint8_t watermark)

Sets the watermark number of samples stored in the FIFO that triggers a FIFO_FULL condition.

Parameters:

watermark – output data rate

ADXL355_Interrupts getInterrupts()

Gets the interrupts.

Returns:

interrupts

void setInterrupts(ADXL355_Interrupts interrupts)

Sets the interrupts.

Parameters:

interrupts – interrupts

ADXL355_Synchronization getSynchronization()

Gets the synchronization mode.

Returns:

synchronization mode

void setSynchronization(ADXL355_Synchronization synchronization)

Sets the synchronization mode.

Parameters:

synchronization – synchronization mode

void enableExternalClock()

Enables the external clock.

void disableExternalClock()

Disables the external clock.

bool isExternalClockEnabled()

Checksif the external clock is enabled.

Returns:

true if the external clock is enabled

ADXL355_Range getRange()

Gets the acceleration range.

Returns:

acceleration range

float getAccelerationScaleFactor()

Gets the acceleration scale factor.

Returns:

acceleration scale factor, g/LSB

void setRange(ADXL355_Range range)

Sets the acceleration range.

Parameters:

range – acceleration range

ADXL355_InterruptPolarity getInterruptPolarity()

Gets the interrupt polarity.

Returns:

interrupt polarity

void setInterruptPolarity(ADXL355_InterruptPolarity polarity)

Sets the interrupt polarity.

Parameters:

polarity – interrupt polarity

ADXL355_I2CSpeed getI2CSpeed()

Gets the I2C speed.

Returns:

I2C speed

void setI2CSpeed(ADXL355_I2CSpeed speed)

Sets the I2C speed.

Parameters:

speed – I2C speed

void enableMeasurement()

Switches mode to measurement mode.

void disableMeasurement()

Switches mode to standby mode.

bool isMeasurementEnabled()

Checks measurement mode.

Returns:

true if measurement is enabled

void enableTemperature()

Enables the temperature processing.

void disableTemperature()

Disables the temperature processing.

bool isTemperatureEnabled()

Checks if the temperature processing is enabled.

Returns:

true if the temperature processing is enabled

void enableDataReady()

Enables the data-ready output.

void disableDataReady()

Disables the data-ready output.

bool isDataReadyEnabled()

Checks if the data-ready output is enabled.

Returns:

true if the data-ready output is enabled

ADXL355_Accelerations selfTest()

Performs the self-test of the device.

Returns:

X-, Y- and Z-axis test accelerations (should be X: 0.1…0.6 g, Y: 0.1…0.6 g, Z: 0.5…3.0 g)

void reset()

Resets the device.

uint64_t getShadowRegisters()

Gets the shadow registers (0x50…0x54)

Returns:

Shadow registers value as a 64 bit integer (0x50 register value is the least significant byte)

Public Static Attributes

static constexpr uint32_t defaultSpiFrequency = 10000000

Default SPI frequency.

static constexpr uint32_t defaultI2cFrequency = 400000

Default I2C frequency.

static constexpr uint16_t temperatureInterceptLsb = 1885

Temperature intercept, LSB.

static constexpr float temperatureInterceptDegC = 25

Temperature intercept, °C.

static constexpr float temperatureSlope = -9.05

Temperature slope, LSB/°C.

static constexpr float accelerationScaleFactorRange2G = 3.9e-6

Acceleration scale factor for ±2 g range, g/LSB.

static constexpr float accelerationScaleFactorRange4G = 7.8e-6

Acceleration scale factor for ±4 g range, g/LSB.

static constexpr float accelerationScaleFactorRange8G = 15.6e-6

Acceleration scale factor for ±8 g range, g/LSB.

static constexpr uint8_t maxNumberOfFifoSamples = 96

Maximum number of the FIFO samples.

enum class PL::ADXL355_Status : uint8_t

Device status.

Values:

enumerator dataReady

a complete x-axis, y-axis, and z-axis measurement was made and results can be read

enumerator fifoFull

FIFO watermark is reached.

enumerator fifoOverrun

FIFO has overrun, and the oldest data is lost.

enumerator activity

acceleration activity is detected

enumerator nvmBusy

NVM controller is busy with a refresh, programming, or a built in self test.

enum class PL::ADXL355_Axes : uint8_t

One or multiple axes.

Values:

enumerator none

no axis

enumerator x

X-axis.

enumerator y

Y-axis.

enumerator z

Z-axis.

enum class PL::ADXL355_HpfFrequency : uint8_t

High-pass filter frequency.

Values:

enumerator none

high-pass filter disabled

enumerator hpf24_7

ODR*24.700e-4.

enumerator hpf6_2084

ODR*6.2084e-4.

enumerator hpf1_5545

ODR*1.5545e-4.

enumerator hpf0_3862

ODR*0.3862e-4.

enumerator hpf0_0954

ODR*0.0954e-4.

enumerator hpf0_0238

ODR*0.0238e-4.

enum class PL::ADXL355_OutputDataRate : uint8_t

Output data rate.

Values:

enumerator odr4000

4000 Hz (low-pass filter: 1000 Hz)

enumerator odr2000

2000 Hz (low-pass filter: 500 Hz)

enumerator odr1000

1000 Hz (low-pass filter: 250 Hz)

enumerator odr500

500 Hz (low-pass filter: 125 Hz)

enumerator odr250

250 Hz (low-pass filter: 62.5 Hz)

enumerator odr125

125 Hz (low-pass filter: 31.25 Hz)

enumerator odr62_5

62.5 Hz (low-pass filter: 15.625 Hz)

enumerator odr31_25

31.25 Hz (low-pass filter: 7.813 Hz)

enumerator odr15_625

15.625 Hz (low-pass filter: 3.906 Hz)

enumerator odr7_813

7.813 Hz (low-pass filter: 1.953 Hz)

enumerator odr3_906

3.906 Hz (low-pass filter: 0.977 Hz)

enum class PL::ADXL355_Interrupts : uint8_t

Interrupts.

Values:

enumerator none

no interrupts

enumerator dataReadyInt1

DATA_RDY interrupt enable on INT1.

enumerator fifoFullInt1

FIFO_FULL interrupt enable on INT1.

enumerator fifoOverrunInt1

FIFO_OVR interrupt enable on INT1.

enumerator activityInt1

activity interrupt enable on INT1

enumerator dataReadyInt2

DATA_RDY interrupt enable on INT2.

enumerator fifoFullInt2

FIFO_FULL interrupt enable on INT2.

enumerator fifoOverrunInt2

FIFO_OVR interrupt enable on INT2.

enumerator activityInt2

activity interrupt enable on INT2

enum class PL::ADXL355_Synchronization : uint8_t

Synchronization.

Values:

enumerator internal

internal

enumerator external

external

enumerator externalWithInterpolation

external with interpolation filter

enum class PL::ADXL355_Range : uint8_t

Acceleration range.

Values:

enumerator range2g

±2 g

enumerator range4g

±4 g

enumerator range8g

±8 g

enum class PL::ADXL355_InterruptPolarity : uint8_t

Interrupt polarity.

Values:

enumerator activeLow

fast

enumerator activeHigh

high-speed

enum class PL::ADXL355_I2CSpeed : uint8_t

I2C speed.

Values:

enumerator fast

fast

enumerator highSpeed

high-speed

struct ADXL355_DeviceInfo

Device information.

Public Members

uint8_t vendorId

Vendor ID.

uint8_t familyId

Device family ID.

uint8_t deviceId

Device ID.

uint8_t revisionId

Revision ID.

struct ADXL355_RawAccelerations

Raw accelerations.

Public Members

int32_t x

Raw X-axis acceleration.

int32_t y

Raw Y-axis acceleration.

int32_t z

Raw Z-axis acceleration.

struct ADXL355_Accelerations

Accelerations in g.

Public Members

float x

X-axis acceleration, g.

float y

Y-axis acceleration, g.

float z

Z-axis acceleration, g.