PL::Adxl355 class
-
class Adxl355 : public PL::Lockable
ADXL355 controller class.
Public Functions
Initializes a new instance of the ADXL355 class.
- Parameters:
spi – SPI interface
sclkFrequency – SCLK frequency in Hz
csPin – CS pin
-
virtual esp_err_t Lock(TickType_t timeout = portMAX_DELAY) override
Locks the object.
- Parameters:
timeout – timeout in FreeRTOS ticks
- Returns:
error code
-
virtual esp_err_t Unlock() override
Unlocks the object.
- Returns:
error code
-
esp_err_t Initialize()
Initializes the ADXL355 controller.
- Returns:
error code
-
esp_err_t ReadDeviceInfo(Adxl355_DeviceInfo &deviceInfo)
Reads the device information.
- Parameters:
deviceInfo – device information (should be vendorId: 0xAD, familyId: 0x1D, deviceId: 0xED)
- Returns:
error code
-
esp_err_t ReadStatus(Adxl355_Status &status)
Reads the device status.
- Parameters:
status – device status
- Returns:
error code
-
esp_err_t ReadNumberOfFifoSamples(uint8_t &numberOfFifoSamples)
Reads the number of valid data samples present in the FIFO buffer.
- Parameters:
numberOfFifoSamples – number of samples
- Returns:
error code
-
esp_err_t ReadRawTemperature(uint16_t &rawTemperature)
Reads the raw temperature.
- Parameters:
rawTemperature – raw temperature (1885 LSB at 25°C, −9.05 LSB/°C)
- Returns:
error code
-
esp_err_t ReadTemperature(float &temperature)
Reads the temperature.
- Parameters:
temperature – temperature, °C
- Returns:
error code
-
esp_err_t ReadRawAccelerations(Adxl355_RawAccelerations &rawAccelerations)
Reads the raw X-, Y- and Z-axis accelerations.
- Parameters:
rawAccelerations – raw accelerations
- Returns:
error code
-
esp_err_t ReadAccelerations(Adxl355_Accelerations &accelerations)
Reads the X-, Y- and Z-axis accelerations.
- Parameters:
accelerations – accelerations, g
- Returns:
error code
-
esp_err_t ClearFifo()
Discards the valid 3-axis samples in the FIFO.
- Returns:
error code
-
esp_err_t ReadRawAccelerationsFromFifo(Adxl355_RawAccelerations &rawAccelerations)
Reads the raw X-, Y- and Z-axis accelerations from the FIFO.
- Parameters:
rawAccelerations – raw accelerations
timeout – timeout in FreeRTOS ticks
- Returns:
error code
-
esp_err_t ReadAccelerationsFromFifo(Adxl355_Accelerations &accelerations)
Reads the X-, Y- and Z-axis accelerations from the FIFO.
- Parameters:
accelerations – accelerations, g
timeout – timeout in FreeRTOS ticks
- Returns:
error code
-
esp_err_t ReadRawOffsets(Adxl355_RawAccelerations &rawOffsets)
Reads the raw X-, Y- and Z-axis acceleration offsets.
- Parameters:
rawOffsets – raw acceleration offsets
- Returns:
error code
-
esp_err_t ReadOffsets(Adxl355_Accelerations &offsets)
Reads the X-, Y- and Z-axis acceleration offsets.
- Parameters:
offsets – acceleration offsets, g
- Returns:
error code
-
esp_err_t SetRawOffsets(Adxl355_RawAccelerations rawOffsets)
Sets the raw X-, Y- and Z-axis acceleration offsets.
- Parameters:
rawOffsets – raw acceleration offsets
- Returns:
error code
-
esp_err_t SetOffsets(Adxl355_Accelerations offsets)
Sets the X-, Y- and Z-axis acceleration offsets.
- Parameters:
offsets – acceleration offsets, g
- Returns:
error code
-
esp_err_t ReadActivityDetectionAxes(Adxl355_Axes &axes)
Reads the axes for which activity detection is enabled.
- Parameters:
axes – axes for which activity detection is enabled
- Returns:
error code
-
esp_err_t SetActivityDetectionAxes(Adxl355_Axes axes)
Enables and disables activity detection.
- Parameters:
axes – axes for which activity detection should be enabled
- Returns:
error code
-
esp_err_t ReadRawActivityDetectionThreshold(uint32_t &rawThreshold)
Reads the raw activity detection threshold.
- Parameters:
rawThreshold – raw activity detection threshold
- Returns:
error code
-
esp_err_t ReadActivityDetectionThreshold(float &threshold)
Reads the activity detection threshold.
- Parameters:
threshold – activity detection threshold, g
- Returns:
error code
-
esp_err_t SetRawActivityDetectionThreshold(uint32_t rawThreshold)
Sets the raw activity detection threshold.
- Parameters:
rawThreshold – raw activity detection threshold (max: 524288)
rawThreshold – error code
-
esp_err_t SetActivityDetectionThreshold(float threshold)
Sets the activity detection threshold.
- Parameters:
threshold – activity detection threshold, g
- Returns:
error code
-
esp_err_t ReadActivityDetectionCount(uint8_t &count)
Reads the number of consecutive events above threshold required to detect activity.
- Parameters:
count – activity detection count
- Returns:
error code
-
esp_err_t SetActivityDetectionCount(uint8_t count)
Sets the number of consecutive events above threshold required to detect activity.
- Parameters:
count – activity detection count
- Returns:
error code
-
esp_err_t ReadHpfFrequency(Adxl355_HpfFrequency &frequency)
Reads the high-pass filter frequency.
- Parameters:
frequency – high-pass filter frequency
- Returns:
error code
-
esp_err_t SetHpfFrequency(Adxl355_HpfFrequency frequency)
Sets the high-pass filter frequency.
- Parameters:
frequency – high-pass filter frequency
- Returns:
error code
-
esp_err_t ReadOutputDataRate(Adxl355_OutputDataRate &outputDataRate)
Reads the output data rate.
- Parameters:
outputDataRate – output data rate
- Returns:
error code
-
esp_err_t SetOutputDataRate(Adxl355_OutputDataRate outputDataRate)
Sets the output data rate.
- Parameters:
outputDataRate – output data rate
- Returns:
error code
-
esp_err_t ReadFifoWatermark(uint8_t &watermark)
Reads the watermark number of samples stored in the FIFO that triggers a FIFO_FULL condition.
- Parameters:
watermark – FIFO watermark
- Returns:
error code
-
esp_err_t 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
- Returns:
error code
-
esp_err_t ReadInterrupts(Adxl355_Interrupts &interrupts)
Reads the interrupts.
- Parameters:
interrupts – interrupts
- Returns:
error code
-
esp_err_t SetInterrupts(Adxl355_Interrupts interrupts)
Sets the interrupts.
- Parameters:
interrupts – interrupts
- Returns:
error code
-
esp_err_t ReadSynchronization(Adxl355_Synchronization &synchronization)
Reads the synchronization mode.
- Parameters:
synchronization – synchronization mode
- Returns:
error code
-
esp_err_t SetSynchronization(Adxl355_Synchronization synchronization)
Sets the synchronization mode.
- Parameters:
synchronization – synchronization mode
- Returns:
error code
-
esp_err_t EnableExternalClock()
Enables the external clock.
- Returns:
error code
-
esp_err_t DisableExternalClock()
Disables the external clock.
- Returns:
error code
-
esp_err_t IsExternalClockEnabled(bool &isEnabled)
Checksif the external clock is enabled.
- Parameters:
isEnabled – true if the external clock is enabled
- Returns:
error code
-
esp_err_t ReadRange(Adxl355_Range &range)
Reads the acceleration range.
- Parameters:
range – acceleration range
- Returns:
error code
-
esp_err_t ReadAccelerationScaleFactor(float &accelerationScaleFactor)
Reads the acceleration scale factor.
- Parameters:
accelerationScaleFactor – acceleration scale factor, g/LSB
- Returns:
error code
-
esp_err_t SetRange(Adxl355_Range range)
Sets the acceleration range.
- Parameters:
range – acceleration range
- Returns:
error code
-
esp_err_t ReadInterruptPolarity(Adxl355_InterruptPolarity &polarity)
Reads the interrupt polarity.
- Parameters:
polarity – interrupt polarity
- Returns:
error code
-
esp_err_t SetInterruptPolarity(Adxl355_InterruptPolarity polarity)
Sets the interrupt polarity.
- Parameters:
polarity – interrupt polarity
- Returns:
error code
-
esp_err_t ReadI2CSpeed(Adxl355_I2CSpeed &speed)
Reads the I2C speed.
- Parameters:
speed – I2C speed
- Returns:
error code
-
esp_err_t SetI2CSpeed(Adxl355_I2CSpeed speed)
Sets the I2C speed.
- Parameters:
speed – I2C speed
- Returns:
error code
-
esp_err_t EnableMeasurement()
Switches mode to measurement mode.
- Returns:
error code
-
esp_err_t DisableMeasurement()
Switches mode to standby mode.
- Returns:
error code
-
esp_err_t IsMeasurementEnabled(bool &isEnabled)
Checks measurement mode.
- Parameters:
isEnabled – true if measurement is enabled
- Returns:
error code
-
esp_err_t EnableTemperature()
Enables the temperature processing.
- Returns:
error code
-
esp_err_t DisableTemperature()
Disables the temperature processing.
- Returns:
error code
-
esp_err_t IsTemperatureEnabled(bool &isEnabled)
Checks if the temperature processing is enabled.
- Parameters:
isEnabled – true if the temperature processing is enabled
- Returns:
error code
-
esp_err_t EnableDataReady()
Enables the data-ready output.
- Returns:
error code
-
esp_err_t DisableDataReady()
Disables the data-ready output.
- Returns:
error code
-
esp_err_t IsDataReadyEnabled(bool &isEnabled)
Checks if the data-ready output is enabled.
- Parameters:
isReady – true if the data-ready output is enabled
- Returns:
error code
-
esp_err_t SelfTest(Adxl355_Accelerations &accelerations)
Performs the self-test of the device.
- Parameters:
accelerations – 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)
- Returns:
error code
-
esp_err_t Reset()
Resets the device.
- Returns:
error code
Public Static Attributes
-
static constexpr uint32_t defaultSpiFrequency = 10000000
Default SPI 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.