modm API documentation
modm::lsm6dso< Transport > Class Template Reference

#include <modm/driver/inertial/lsm6dso.hpp>

Inheritance diagram for modm::lsm6dso< Transport >:

Public Types

enum  Register : uint8_t {
  FUNC_CFG_ACCESS = 0x01, PIN_CTRL = 0x02, FIFO_CTRL1 = 0x07, FIFO_CTRL2 = 0x08,
  FIFO_CTRL3 = 0x09, FIFO_CTRL4 = 0x0A, COUNTER_BDR_REG1 = 0x0B, COUNTER_BDR_REG2 = 0x0C,
  INT1_CTRL = 0x0D, INT2_CTRL = 0x0E, WHO_AM_I = 0x0F, CTRL1_XL = 0x10,
  CTRL2_G = 0x11, CTRL3_C = 0x12, CTRL4_C = 0x13, CTRL5_C = 0x14,
  CTRL6_C = 0x15, CTRL7_G = 0x16, CTRL8_XL = 0x17, CTRL9_XL = 0x18,
  CTRL10_C = 0x19, ALL_INT_SRC = 0x1A, WAKE_UP_SRC = 0x1B, TAP_SRC = 0x1C,
  D6D_SRC = 0x1D, STATUS_REG = 0x1E, STATUS_SPIAux = 0x1E, OUT_TEMP_L = 0x20,
  OUT_TEMP_H = 0x21, OUTX_L_G = 0x22, OUTX_H_G = 0x23, OUTY_L_G = 0x24,
  OUTY_H_G = 0x25, OUTZ_L_G = 0x26, OUTZ_H_G = 0x27, OUTX_L_A = 0x28,
  OUTX_H_A = 0x29, OUTY_L_A = 0x2A, OUTY_H_A = 0x2B, OUTZ_L_A = 0x2C,
  OUTZ_H_A = 0x2D, EMB_FUNC_STATUS_MAINPAGE = 0x35, FSM_STATUS_A_MAINPAGE = 0x36, FSM_STATUS_B_MAINPAGE = 0x37,
  STATUS_MASTER_MAINPAGE = 0x39, FIFO_STATUS1 = 0x3A, FIFO_STATUS2 = 0x3B, TIMESTAMP0 = 0x40,
  TIMESTAMP1 = 0x41, TIMESTAMP2 = 0x42, TIMESTAMP3 = 0x43, TAP_CFG0 = 0x56,
  TAP_CFG1 = 0x57, TAP_CFG2 = 0x58, TAP_THS_6D = 0x59, INT_DUR2 = 0x5A,
  WAKE_UP_THS = 0x5B, WAKE_UP_DUR = 0x5C, FREE_FALL = 0x5D, MD1_CFG = 0x5E,
  MD2_CFG = 0x5F, I3C_BUS_AVB = 0x62, INTERNAL_FREQ_FINE = 0x63, INT_OIS = 0x6F,
  CTRL1_OIS = 0x70, CTRL2_OIS = 0x71, CTRL3_OIS = 0x72, X_OFS_USR = 0x73,
  Y_OFS_USR = 0x74, Z_OFS_USR = 0x75, FIFO_DATA_OUT_TAG = 0x78, FIFO_DATA_OUT_X_L = 0x79,
  FIFO_DATA_OUT_X_H = 0x7A, FIFO_DATA_OUT_Y_L = 0x7B, FIFO_DATA_OUT_Y_H = 0x7C, FIFO_DATA_OUT_Z_L = 0x7D,
  FIFO_DATA_OUT_Z_H = 0x7E
}
 
enum  LinearRange : uint8_t { G2 = (0b00 << 2), G4 = (0b10 << 2), G8 = (0b11 << 2), G16 = (0b01 << 2) }
 
enum  AngularRange : uint8_t {
  dps125 = (0b001 << 1), dps250 = (0b000 << 1), dps500 = (0b010 << 1), dps1000 = (0b100 << 1),
  dps2000 = (0b110 << 1)
}
 

Public Member Functions

 Lsm6dso (uint8_t address=0x6a)
 Constructor. More...
 
modm::ResumableResult< bool > initialize ()
 Initializes the device and driver. More...
 
modm::ResumableResult< std::optional< uint8_t > > readRegister (Register reg)
 Read a single register. More...
 
modm::ResumableResult< bool > readRegisters (Register reg, std::span< uint8_t > values)
 Read multiple consecutive registers. More...
 
modm::ResumableResult< bool > writeRegister (Register reg, uint8_t value)
 Write a single register. More...
 
template<frequency_t frequency, percent_t tolerance = pct(1)>
modm::ResumableResult< bool > setOutputDataRate ()
 Set the desired output data rate from 12.5Hz to 6.7kHz. More...
 
modm::ResumableResult< bool > setRange (LinearRange lr, AngularRange ar)
 Set the measurement range. More...
 
template<frequency_t frequency, percent_t tolerance = pct(1)>
modm::ResumableResult< bool > setOutputDataRateAndRange (LinearRange lr, AngularRange ar)
 Set the desired output data rate from 12.5Hz to 6.7kHz and the measurement range simultanously. More...
 

Detailed Description

template<class Transport>
class modm::lsm6dso< Transport >

Template Parameters
TransportEither the I2C or SPI Transport Layer.
See also
Lsm6TransportI2c
Lsm6TransportSpi
Author
Raphael Lehmann

Member Function Documentation

template<class Transport >
modm::ResumableResult<bool> modm::lsm6dso< Transport >::initialize ( )

Initializes the device and driver.

SPI/I2C must be initialized by the user!

Returns
False in case of any error
template<class Transport >
modm::lsm6dso< Transport >::Lsm6dso ( uint8_t  address = 0x6a)
explicit

Constructor.

For I2c this also sets the address to 0x6a (alternative: 0x6b with pin SA0 high).

template<class Transport >
modm::ResumableResult<std::optional<uint8_t> > modm::lsm6dso< Transport >::readRegister ( Register  reg)

Read a single register.

Parameters
regThe register to be read
Returns
The register value in case of a read access, or std::nullopt if an error occured
template<class Transport >
modm::ResumableResult<bool> modm::lsm6dso< Transport >::readRegisters ( Register  reg,
std::span< uint8_t >  values 
)

Read multiple consecutive registers.

Parameters
regThe first register to be read
valuesResults of the read operations
Returns
False in case of any error
template<class Transport >
template<frequency_t frequency, percent_t tolerance = pct(1)>
modm::ResumableResult<bool> modm::lsm6dso< Transport >::setOutputDataRate ( )

Set the desired output data rate from 12.5Hz to 6.7kHz.

Use 0 Hz to disable the IMU (power down).

Template Parameters
frequencydesired frequency
toleranceacceptable tolerance, default 1%
Returns
False in case of any error
template<class Transport >
template<frequency_t frequency, percent_t tolerance = pct(1)>
modm::ResumableResult<bool> modm::lsm6dso< Transport >::setOutputDataRateAndRange ( LinearRange  lr,
AngularRange  ar 
)

Set the desired output data rate from 12.5Hz to 6.7kHz and the measurement range simultanously.

Use frequency==0 to disable the IMU (power down).

Template Parameters
frequencydesired frequency
toleranceacceptable tolerance, default 1%
Parameters
lrLinear acceleration measurement range (±2G, ±4G, ±8G, ±16G)
arAngular rate measurement range (±125dps, ±250dps, ±500dps, ±1000dps, ±2000dps)
Returns
False in case of any error
template<class Transport >
modm::ResumableResult<bool> modm::lsm6dso< Transport >::setRange ( LinearRange  lr,
AngularRange  ar 
)

Set the measurement range.

Parameters
lrLinear acceleration measurement range (±2G, ±4G, ±8G, ±16G)
arAngular rate measurement range (±125dps, ±250dps, ±500dps, ±1000dps, ±2000dps)
Returns
False in case of any error
template<class Transport >
modm::ResumableResult<bool> modm::lsm6dso< Transport >::writeRegister ( Register  reg,
uint8_t  value 
)

Write a single register.

Parameters
regThe register to be written
valueThe value to be written to the register.
Returns
False in case of any error

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