wpi-32u4-library
Data Structures | Public Types | Public Member Functions | Data Fields | Private Member Functions | Private Attributes
LSM6 Class Reference

#include <LSM6.h>

Data Structures

struct  vector
 

Public Types

enum  deviceType { device_DS33 , device_auto }
 
enum  sa0State { sa0_low , sa0_high , sa0_auto }
 
enum  ACC_FS { ACC_FS2 , ACC_FS4 , ACC_FS8 , ACC_FS16 }
 
enum  GYRO_FS { GYRO_FS245 , GYRO_FS500 , GYRO_FS1000 , GYRO_FS2000 }
 
enum  ODR {
  ODR13 = 0x1 , ODR26 = 0x2 , ODR52 = 0x3 , ODR104 = 0x4 ,
  ODR208 = 0x5 , ODR416 = 0x6 , ODR833 = 0x7 , ODR166k = 0x8
}
 
enum  regAddr {
  FUNC_CFG_ACCESS = 0x01 , FIFO_CTRL1 = 0x06 , FIFO_CTRL2 = 0x07 , FIFO_CTRL3 = 0x08 ,
  FIFO_CTRL4 = 0x09 , FIFO_CTRL5 = 0x0A , ORIENT_CFG_G = 0x0B , 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 ,
  WAKE_UP_SRC = 0x1B , TAP_SRC = 0x1C , D6D_SRC = 0x1D , STATUS_REG = 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_XL = 0x28 , OUTX_H_XL = 0x29 , OUTY_L_XL = 0x2A , OUTY_H_XL = 0x2B ,
  OUTZ_L_XL = 0x2C , OUTZ_H_XL = 0x2D , FIFO_STATUS1 = 0x3A , FIFO_STATUS2 = 0x3B ,
  FIFO_STATUS3 = 0x3C , FIFO_STATUS4 = 0x3D , FIFO_DATA_OUT_L = 0x3E , FIFO_DATA_OUT_H = 0x3F ,
  TIMESTAMP0_REG = 0x40 , TIMESTAMP1_REG = 0x41 , TIMESTAMP2_REG = 0x42 , STEP_TIMESTAMP_L = 0x49 ,
  STEP_TIMESTAMP_H = 0x4A , STEP_COUNTER_L = 0x4B , STEP_COUNTER_H = 0x4C , FUNC_SRC = 0x53 ,
  TAP_CFG = 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
}
 

Public Member Functions

 LSM6 (void)
 
bool init (deviceType device=device_auto, sa0State sa0=sa0_auto)
 
deviceType getDeviceType (void)
 
void enableDefault (void)
 
void writeReg (uint8_t reg, uint8_t value)
 
uint8_t readReg (uint8_t reg)
 
void readAcc (void)
 
void readGyro (void)
 
void read (void)
 
void setFullScaleGyro (GYRO_FS gfs)
 
void setFullScaleAcc (ACC_FS afs)
 
void setGyroDataOutputRate (ODR)
 
void setAccDataOutputRate (ODR)
 
void setTimeout (uint16_t timeout)
 
uint16_t getTimeout (void)
 
bool timeoutOccurred (void)
 
uint8_t getStatus (void)
 

Data Fields

vector< int16_t > a
 
vector< int16_t > g
 
vector< float > dps
 
float mdps = 0
 
float mg = 0
 
uint8_t last_status
 

Private Member Functions

int16_t testReg (uint8_t address, regAddr reg)
 

Private Attributes

deviceType _device
 
uint8_t address
 
uint16_t io_timeout
 
bool did_timeout
 

Detailed Description

The LSM6 IMU

Definition at line 9 of file LSM6.h.

Member Enumeration Documentation

◆ ACC_FS

Enumerator
ACC_FS2 
ACC_FS4 
ACC_FS8 
ACC_FS16 

Definition at line 20 of file LSM6.h.

◆ deviceType

Enumerator
device_DS33 
device_auto 

Definition at line 17 of file LSM6.h.

◆ GYRO_FS

Enumerator
GYRO_FS245 
GYRO_FS500 
GYRO_FS1000 
GYRO_FS2000 

Definition at line 21 of file LSM6.h.

◆ ODR

enum LSM6::ODR
Enumerator
ODR13 
ODR26 
ODR52 
ODR104 
ODR208 
ODR416 
ODR833 
ODR166k 

Definition at line 22 of file LSM6.h.

◆ regAddr

Enumerator
FUNC_CFG_ACCESS 
FIFO_CTRL1 
FIFO_CTRL2 
FIFO_CTRL3 
FIFO_CTRL4 
FIFO_CTRL5 
ORIENT_CFG_G 
INT1_CTRL 
INT2_CTRL 
WHO_AM_I 
CTRL1_XL 
CTRL2_G 
CTRL3_C 
CTRL4_C 
CTRL5_C 
CTRL6_C 
CTRL7_G 
CTRL8_XL 
CTRL9_XL 
CTRL10_C 
WAKE_UP_SRC 
TAP_SRC 
D6D_SRC 
STATUS_REG 
OUT_TEMP_L 
OUT_TEMP_H 
OUTX_L_G 
OUTX_H_G 
OUTY_L_G 
OUTY_H_G 
OUTZ_L_G 
OUTZ_H_G 
OUTX_L_XL 
OUTX_H_XL 
OUTY_L_XL 
OUTY_H_XL 
OUTZ_L_XL 
OUTZ_H_XL 
FIFO_STATUS1 
FIFO_STATUS2 
FIFO_STATUS3 
FIFO_STATUS4 
FIFO_DATA_OUT_L 
FIFO_DATA_OUT_H 
TIMESTAMP0_REG 
TIMESTAMP1_REG 
TIMESTAMP2_REG 
STEP_TIMESTAMP_L 
STEP_TIMESTAMP_H 
STEP_COUNTER_L 
STEP_COUNTER_H 
FUNC_SRC 
TAP_CFG 
TAP_THS_6D 
INT_DUR2 
WAKE_UP_THS 
WAKE_UP_DUR 
FREE_FALL 
MD1_CFG 
MD2_CFG 

Definition at line 35 of file LSM6.h.

◆ sa0State

Enumerator
sa0_low 
sa0_high 
sa0_auto 

Definition at line 18 of file LSM6.h.

Constructor & Destructor Documentation

◆ LSM6()

LSM6::LSM6 ( void  )

Definition at line 18 of file LSM6.cpp.

References _device, device_auto, did_timeout, and io_timeout.

Member Function Documentation

◆ enableDefault()

void LSM6::enableDefault ( void  )

◆ getDeviceType()

deviceType LSM6::getDeviceType ( void  )
inline

Definition at line 121 of file LSM6.h.

References _device.

◆ getStatus()

uint8_t LSM6::getStatus ( void  )
inline

Definition at line 143 of file LSM6.h.

References readReg(), and STATUS_REG.

◆ getTimeout()

uint16_t LSM6::getTimeout ( void  )

Definition at line 41 of file LSM6.cpp.

References io_timeout.

◆ init()

bool LSM6::init ( deviceType  device = device_auto,
sa0State  sa0 = sa0_auto 
)

◆ read()

void LSM6::read ( void  )

Definition at line 300 of file LSM6.cpp.

References readAcc(), and readGyro().

◆ readAcc()

void LSM6::readAcc ( void  )

Definition at line 232 of file LSM6.cpp.

References a, address, did_timeout, io_timeout, OUTX_L_XL, LSM6::vector< T >::x, LSM6::vector< T >::y, and LSM6::vector< T >::z.

Referenced by read().

◆ readGyro()

void LSM6::readGyro ( void  )

Definition at line 264 of file LSM6.cpp.

References address, did_timeout, dps, g, io_timeout, mdps, OUTX_L_G, LSM6::vector< T >::x, LSM6::vector< T >::y, and LSM6::vector< T >::z.

Referenced by read().

◆ readReg()

uint8_t LSM6::readReg ( uint8_t  reg)

◆ setAccDataOutputRate()

void LSM6::setAccDataOutputRate ( ODR  rate)

Definition at line 112 of file LSM6.cpp.

References CTRL1_XL, ODR166k, readReg(), and writeReg().

◆ setFullScaleAcc()

void LSM6::setFullScaleAcc ( ACC_FS  afs)

Definition at line 73 of file LSM6.cpp.

References ACC_FS16, ACC_FS2, ACC_FS4, ACC_FS8, CTRL1_XL, mg, readReg(), and writeReg().

Referenced by enableDefault().

◆ setFullScaleGyro()

void LSM6::setFullScaleGyro ( GYRO_FS  gfs)

Definition at line 46 of file LSM6.cpp.

References CTRL2_G, GYRO_FS1000, GYRO_FS2000, GYRO_FS245, GYRO_FS500, mdps, readReg(), and writeReg().

Referenced by enableDefault().

◆ setGyroDataOutputRate()

void LSM6::setGyroDataOutputRate ( ODR  rate)

Definition at line 100 of file LSM6.cpp.

References CTRL2_G, ODR166k, readReg(), and writeReg().

◆ setTimeout()

void LSM6::setTimeout ( uint16_t  timeout)

Definition at line 36 of file LSM6.cpp.

References io_timeout.

◆ testReg()

int16_t LSM6::testReg ( uint8_t  address,
regAddr  reg 
)
private

Definition at line 316 of file LSM6.cpp.

References address, and TEST_REG_ERROR.

Referenced by init().

◆ timeoutOccurred()

bool LSM6::timeoutOccurred ( void  )

Definition at line 29 of file LSM6.cpp.

References did_timeout.

◆ writeReg()

void LSM6::writeReg ( uint8_t  reg,
uint8_t  value 
)

Field Documentation

◆ _device

deviceType LSM6::_device
private

Definition at line 146 of file LSM6.h.

Referenced by enableDefault(), getDeviceType(), init(), and LSM6().

◆ a

vector<int16_t> LSM6::a

Definition at line 107 of file LSM6.h.

Referenced by readAcc().

◆ address

uint8_t LSM6::address
private

Definition at line 147 of file LSM6.h.

Referenced by init(), readAcc(), readGyro(), readReg(), testReg(), and writeReg().

◆ did_timeout

bool LSM6::did_timeout
private

Definition at line 150 of file LSM6.h.

Referenced by LSM6(), readAcc(), readGyro(), and timeoutOccurred().

◆ dps

vector<float> LSM6::dps

Definition at line 109 of file LSM6.h.

Referenced by readGyro().

◆ g

vector<int16_t> LSM6::g

Definition at line 108 of file LSM6.h.

Referenced by readGyro().

◆ io_timeout

uint16_t LSM6::io_timeout
private

Definition at line 149 of file LSM6.h.

Referenced by getTimeout(), LSM6(), readAcc(), readGyro(), and setTimeout().

◆ last_status

uint8_t LSM6::last_status

Definition at line 116 of file LSM6.h.

Referenced by readReg(), and writeReg().

◆ mdps

float LSM6::mdps = 0

Definition at line 112 of file LSM6.h.

Referenced by readGyro(), and setFullScaleGyro().

◆ mg

float LSM6::mg = 0

Definition at line 113 of file LSM6.h.

Referenced by setFullScaleAcc().


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