modm API documentation
modm::adis16470< SpiMaster, Cs > Class Template Reference

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

Inheritance diagram for modm::adis16470< SpiMaster, Cs >:
modm::SpiDevice< SpiMaster > modm::NestedResumable< 2 >

Public Typedefs

using SyncFunction_t = Configuration< MscCtrl_t, SyncFunction, 0b111, 2 >
 

Public Types

enum  Register : uint8_t {
  DIAG_STAT = 0x02, X_GYRO_LOW = 0x04, X_GYRO_OUT = 0x06, Y_GYRO_LOW = 0x08,
  Y_GYRO_OUT = 0x0A, Z_GYRO_LOW = 0x0C, Z_GYRO_OUT = 0x0E, X_ACCL_LOW = 0x10,
  X_ACCL_OUT = 0x12, Y_ACCL_LOW = 0x14, Y_ACCL_OUT = 0x16, Z_ACCL_LOW = 0x18,
  Z_ACCL_OUT = 0x1A, TEMP_OUT = 0x1C, TIME_STAMP = 0x1E, DATA_CNTR = 0x22,
  X_DELTANG_LOW = 0x24, X_DELTANG_OUT = 0x26, Y_DELTANG_LOW = 0x28, Y_DELTANG_OUT = 0x2A,
  Z_DELTANG_LOW = 0x2C, Z_DELTANG_OUT = 0x2E, X_DELTVEL_LOW = 0x30, X_DELTVEL_OUT = 0x32,
  Y_DELTVEL_LOW = 0x34, Y_DELTVEL_OUT = 0x36, Z_DELTVEL_LOW = 0x38, Z_DELTVEL_OUT = 0x3A,
  XG_BIAS_LOW = 0x40, XG_BIAS_HIGH = 0x42, YG_BIAS_LOW = 0x44, YG_BIAS_HIGH = 0x46,
  ZG_BIAS_LOW = 0x48, ZG_BIAS_HIGH = 0x4A, XA_BIAS_LOW = 0x4C, XA_BIAS_HIGH = 0x4E,
  YA_BIAS_LOW = 0x50, YA_BIAS_HIGH = 0x52, ZA_BIAS_LOW = 0x54, ZA_BIAS_HIGH = 0x56,
  FILT_CTRL = 0x5C, MSC_CTRL = 0x60, UP_SCALE = 0x62, DEC_RATE = 0x64,
  NULL_CNFG = 0x66, GLOB_CMD = 0x68, FIRM_REV = 0x6C, FIRM_DM = 0x6E,
  FIRM_Y = 0x70, PROD_ID = 0x72, SERIAL_NUM = 0x74, USER_SCR1 = 0x76,
  USER_SCR2 = 0x78, USER_SCR3 = 0x7A, FLSHCNT_LOW = 0x7C, FLSHCNT_HIGH = 0x7E
}
 Available registers.
 
enum  AccessMethod : uint8_t { Read = 0b01, Write = 0b10, ReadWrite = 0b11 }
 
enum  DiagStat : uint16_t {
  DiagStat::ClockError = Bit7, DiagStat::MemoryFailure = Bit6, DiagStat::SensorFailure = Bit5, DiagStat::StandbyMode = Bit4,
  DiagStat::SpiCommunicationError = Bit3, DiagStat::FlashUpdateFailure = Bit2, DiagStat::DataPathOverrun = Bit1
}
 
enum  MscCtrl : uint16_t {
  MscCtrl::LinearGCompensationGyro = Bit7, MscCtrl::PointOfPercussionAlign = Bit6, MscCtrl::SyncFunction2 = Bit4, MscCtrl::SyncFunction1 = Bit3,
  MscCtrl::SyncFunction0 = Bit2, MscCtrl::SyncPolarity = Bit1, MscCtrl::DrPolarity = Bit0
}
 
enum  SyncFunction : uint16_t {
  PulseSync = 0b101, OutputSync = 0b011, ScaledSync = 0b010, DirectSync = 0b001,
  SyncFunction::InternalClock = 0b000
}
 
enum  GlobCmd : uint16_t {
  GlobCmd::SoftwareReset = Bit7, GlobCmd::FlashMemoryTest = Bit4, GlobCmd::FlashMemoryUpdate = Bit3, GlobCmd::SensorSelfTest = Bit2,
  GlobCmd::FactoryCalibrationRestore = Bit1, GlobCmd::BiasCorrectionUpdate = Bit0
}
 

Public Member Functions

constexpr AccessMethod getRegisterAccess (Register r)
 Get the allowed register access modes for a given Register.
 
 MODM_FLAGS16 (DiagStat)
 
 MODM_FLAGS16 (MscCtrl)
 
 MODM_FLAGS16 (GlobCmd)
 
modm::ResumableResult< void > initialize ()
 Initialize. More...
 
modm::ResumableResult< std::optional< uint16_t > > readRegister (Register reg)
 Read a single register. More...
 
modm::ResumableResult< modm::adis16470::DiagStat_t > readDiagStat ()
 Read the DIAG_STAT register. More...
 
modm::ResumableResult< modm::adis16470::MscCtrl_t > readMscCtrl ()
 Read the MSC_CTRL register. More...
 
modm::ResumableResult< bool > writeRegister (Register reg, uint16_t value)
 Write a single register. More...
 
modm::ResumableResult< void > writeMscCtrl (modm::adis16470::MscCtrl_t value)
 Write the MSC_CTRL register. More...
 
modm::ResumableResult< void > writeGlobCmd (modm::adis16470::GlobCmd_t value)
 Write the MSC_CTRL register. More...
 
template<frequency_t frequency, percent_t tolerance = pct(1)>
modm::ResumableResult< void > setDataOutputFrequency ()
 Set the desired data output frequency from 1Hz to 2kHz. More...
 
modm::ResumableResult< bool > readRegisterSequence (std::span< const Register > sequence, std::span< uint16_t > values)
 Read a sequence of registers. Improves SPI usage efficiency by 100% compared to accessRegister(...). More...
 
modm::ResumableResult< bool > readRegisterBurst (std::array< uint16_t, 11 > &data)
 Read all output data registers using burst mode. More...
 
void attachConfigurationHandler (Spi::ConfigurationHandler handler)
 

Protected Member Functions

bool acquireMaster ()
 
bool releaseMaster ()
 
modm::ResumableResult< ReturnType > resumable function (...)
 
int8_t getResumableDepth () const
 
bool isResumableRunning () const
 
void stopResumable ()
 Force all resumable functions to stop running at the current nesting level.
 

Detailed Description

template<class SpiMaster, class Cs>
class modm::adis16470< SpiMaster, Cs >

Author
Raphael Lehmann

Member Enumeration Documentation

template<class SpiMaster , class Cs >
enum modm::adis16470::DiagStat : uint16_t
strong

Status/Error Flag Indicators DIAG_STAT register (address 0x02, 0x03) reset value is 0x0000

Enum ValuesDocumentation
ClockError 

Indicates that the internal data sampling clock does not synchronize with the external clock, which only applies when using scale sync mode.

MemoryFailure 

Indicates a failure in the flash memory test.

SensorFailure 

Indicates failure of at least one sensor, at the conclusion of the self test.

StandbyMode 

Indicates that the voltage across VDD and GND is <2.8 V, which causes data processing to stop.

SpiCommunicationError 

Indicates that the total number of SCLK cycles is not equal to an integer multiple of 16.

FlashUpdateFailure 

Indicates that the most recent flash memory update failed.

DataPathOverrun 

Indicates that one of the data paths have experienced an overrun condition.

template<class SpiMaster , class Cs >
enum modm::adis16470::GlobCmd : uint16_t
strong

Global Commands GLOB_CMD register (address 0x68, 0x69) is write only

Enum ValuesDocumentation
SoftwareReset 

This reset clears all data, and then restarts data sampling and processing. Software alternative to toggling the RST pin.

FlashMemoryTest 

Triggers flash memory test; result can be read from DIAG_STAT register.

FlashMemoryUpdate 

Backups all applicable registers in the flash memory.

SensorSelfTest 

Triggers a self test. Motion during the execution of this test can indicate a false failure.

FactoryCalibrationRestore 

Triggers a factory calibration restore.

BiasCorrectionUpdate 

Triggers a bias correction update.

template<class SpiMaster , class Cs >
enum modm::adis16470::MscCtrl : uint16_t
strong

Miscellaneous Control Register MSC_CTRL register (address 0x60, 0x61) reset value is 0x00C1

Enum ValuesDocumentation
LinearGCompensationGyro 

Linear g compensation for gyroscopes (enabled if bit is set)

PointOfPercussionAlign 

Point of percussion alignment (enabled if bit is set)

SyncFunction2 

See SyncFunction_t.

SyncFunction1 

See SyncFunction_t.

SyncFunction0 

See SyncFunction_t.

SyncPolarity 

Rising edge triggers sampling if this bit is set, falling edge otherwise.

DrPolarity 

DR pins is active high when data is valid if this bit is set, DR is actice low otherwise.

template<class SpiMaster , class Cs >
enum modm::adis16470::SyncFunction : uint16_t
strong
Enum ValuesDocumentation
InternalClock 

InternalClock is default mode.

Member Function Documentation

modm::ResumableResult< ReturnType > resumable modm::NestedResumable< 1 >::function (   ...)
inherited

Run the resumable function.

You need to implement this method in you subclass yourself.

Returns
>NestingError if still running, <=NestingError if it has finished.
int8_t modm::NestedResumable< 1 >::getResumableDepth ( ) const
inheritedinline
Returns
the nesting depth in the current resumable function, or -1 if called outside any resumable function
template<class SpiMaster , class Cs >
modm::ResumableResult<void> modm::adis16470< SpiMaster, Cs >::initialize ( )

Initialize.

Sets used pins as output.

SPI must be initialized by the user!

Warning
The SPI frequency must not exceed 2 MHz for this chip, or 1 MHz with burst mode.
bool modm::NestedResumable< 1 >::isResumableRunning ( ) const
inheritedinline
Returns
true if a resumable function is running at the current nesting level, else false
template<class SpiMaster , class Cs >
modm::ResumableResult<modm::adis16470::DiagStat_t> modm::adis16470< SpiMaster, Cs >::readDiagStat ( )

Read the DIAG_STAT register.

Returns
The register value
template<class SpiMaster , class Cs >
modm::ResumableResult<modm::adis16470::MscCtrl_t> modm::adis16470< SpiMaster, Cs >::readMscCtrl ( )

Read the MSC_CTRL register.

Returns
The register value
template<class SpiMaster , class Cs >
modm::ResumableResult<std::optional<uint16_t> > modm::adis16470< SpiMaster, Cs >::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, e.g. if some register access is not permitted.
template<class SpiMaster , class Cs >
modm::ResumableResult<bool> modm::adis16470< SpiMaster, Cs >::readRegisterBurst ( std::array< uint16_t, 11 > &  data)

Read all output data registers using burst mode.

In all clock modes, except when operating in scaled sync mode (Register MSC_CTRL, Bits[4:2] = 010), the burst read response includes the following registers and checksum value: DIAG_STAT, X_GYRO_OUT, Y_GYRO_OUT, Z_GYRO_OUT, X_ACCL_OUT, Y_ACCL_OUT, Z_ACCL_OUT, TEMP_OUT, DATA_CNTR, and checksum.

When operating in scaled sync mode (Register MSC_CTRL, Bits[4:2] = 010), the burst read response includes the following registers and value: DIAG_STAT, X_GYRO_OUT, Y_GYRO_OUT, Z_GYRO_OUT, X_ACCL_OUT, Y_ACCL_OUT, Z_ACCL_OUT, TEMP_OUT, TIME_STMP, and checksum.

This is useful with DMA accelerated SPI to retrieve the measurement data, because it only triggers a single SPI transfer.

Warning
The SPI frequency must not exceed 1 MHz for this mode.
Parameters
dataReference to a array of 11 uint16_t entries, the read register values are written here. data[0] is empty and the last entry (data[10]) contains a checksum which has already been checked by this driver.
Returns
False in case of a checksum mismatch.
template<class SpiMaster , class Cs >
modm::ResumableResult<bool> modm::adis16470< SpiMaster, Cs >::readRegisterSequence ( std::span< const Register sequence,
std::span< uint16_t >  values 
)

Read a sequence of registers. Improves SPI usage efficiency by 100% compared to accessRegister(...).

Parameters
sequenceAll registers in the std::span will be read and the results will be stored in values.
valuesResults of the read operations
Returns
False in case of any error, e.g. if some register access is not permitted.
template<class SpiMaster , class Cs >
template<frequency_t frequency, percent_t tolerance = pct(1)>
modm::ResumableResult<void> modm::adis16470< SpiMaster, Cs >::setDataOutputFrequency ( )

Set the desired data output frequency from 1Hz to 2kHz.

Template Parameters
frequencydesired frequency
toleranceacceptable tolerance, default 1%
template<class SpiMaster , class Cs >
modm::ResumableResult<void> modm::adis16470< SpiMaster, Cs >::writeGlobCmd ( modm::adis16470< SpiMaster, Cs >::GlobCmd_t  value)

Write the MSC_CTRL register.

Parameters
valueThe value to be written to the MSC_CTRL register.
template<class SpiMaster , class Cs >
modm::ResumableResult<void> modm::adis16470< SpiMaster, Cs >::writeMscCtrl ( modm::adis16470< SpiMaster, Cs >::MscCtrl_t  value)

Write the MSC_CTRL register.

Parameters
valueThe value to be written to the MSC_CTRL register.
template<class SpiMaster , class Cs >
modm::ResumableResult<bool> modm::adis16470< SpiMaster, Cs >::writeRegister ( Register  reg,
uint16_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, e.g. if some register acces is not permitted.

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