LSM9DS1 the other library
Fork of LSM9DS1 by
LSM9DS1 Class Reference
LSM9DS1 Class - driver for the 9 DoF IMU. More...
#include <LSM9DS1.h>
Public Types | |
enum | gyro_scale |
gyro_scale defines the possible full-scale ranges of the gyroscope: More... | |
enum | gyro_odr |
gyro_odr defines all possible data rate/bandwidth combos of the gyro: More... | |
enum | accel_scale |
accel_scale defines all possible FSR's of the accelerometer: More... | |
enum | accel_odr |
accel_oder defines all possible output data rates of the accelerometer: More... | |
enum | mag_scale |
mag_scale defines all possible FSR's of the magnetometer: More... | |
enum | mag_odr |
mag_odr defines all possible output data rates of the magnetometer: More... | |
Public Member Functions | |
LSM9DS1 (PinName sda, PinName scl, uint8_t xgAddr=LSM9DS1_AG_I2C_ADDR(1), uint8_t mAddr=LSM9DS1_M_I2C_ADDR(1)) | |
LSM9DS1 -- LSM9DS1 class constructor The constructor will set up a handful of private variables, and set the communication mode as well. | |
bool | begin (gyro_scale gScl=G_SCALE_2000DPS, accel_scale aScl=A_SCALE_8G, mag_scale mScl=M_SCALE_4GS, gyro_odr gODR=G_ODR_119_BW_31, accel_odr aODR=A_ODR_119, mag_odr mODR=M_ODR_80) |
begin() -- Initialize the gyro, accelerometer, and magnetometer. | |
void | readGyro () |
readGyro() -- Read the gyroscope output registers. | |
void | readAccel () |
readAccel() -- Read the accelerometer output registers. | |
void | readMag () |
readMag() -- Read the magnetometer output registers. | |
void | readIntr () |
Read Interrupt. | |
void | readTemp () |
readTemp() -- Read the temperature output register. | |
void | calibration () |
calibration() -- Calibrate Accel and Gyro sensor | |
void | setGyroScale (gyro_scale gScl) |
setGyroScale() -- Set the full-scale range of the gyroscope. | |
void | setAccelScale (accel_scale aScl) |
setAccelScale() -- Set the full-scale range of the accelerometer. | |
void | setMagScale (mag_scale mScl) |
setMagScale() -- Set the full-scale range of the magnetometer. | |
void | setGyroODR (gyro_odr gRate) |
setGyroODR() -- Set the output data rate and bandwidth of the gyroscope Input:
| |
void | setAccelODR (accel_odr aRate) |
setAccelODR() -- Set the output data rate of the accelerometer Input:
| |
void | setMagODR (mag_odr mRate) |
setMagODR() -- Set the output data rate of the magnetometer Input:
| |
void | enableXgFIFO (bool enable) |
enableFIFO() -- Turn on FIFO state (CTRL_REG9) Input:
| |
void | setXgFIFO (uint8_t fifoMode, uint8_t fifoThs) |
setFIFO() -- Set FIFO mode and FIFO threshold(FIFO_CTRL) Input:
|
Detailed Description
LSM9DS1 Class - driver for the 9 DoF IMU.
Definition at line 102 of file LSM9DS1.h.
Member Enumeration Documentation
enum accel_odr |
enum accel_scale |
enum gyro_odr |
enum gyro_scale |
enum mag_odr |
enum mag_scale |
Constructor & Destructor Documentation
LSM9DS1 | ( | PinName | sda, |
PinName | scl, | ||
uint8_t | xgAddr = LSM9DS1_AG_I2C_ADDR(1) , |
||
uint8_t | mAddr = LSM9DS1_M_I2C_ADDR(1) |
||
) |
LSM9DS1 -- LSM9DS1 class constructor The constructor will set up a handful of private variables, and set the communication mode as well.
Input:
- interface = Either MODE_SPI or MODE_I2C, whichever you're using to talk to the IC.
- xgAddr = If MODE_I2C, this is the I2C address of the accel/gyro. If MODE_SPI, this is the chip select pin of the accel/gyro (CS_A/G)
- mAddr = If MODE_I2C, this is the I2C address of the mag. If MODE_SPI, this is the cs pin of the mag (CS_M)
Definition at line 3 of file LSM9DS1.cpp.
Member Function Documentation
bool begin | ( | gyro_scale | gScl = G_SCALE_2000DPS , |
accel_scale | aScl = A_SCALE_8G , |
||
mag_scale | mScl = M_SCALE_4GS , |
||
gyro_odr | gODR = G_ODR_119_BW_31 , |
||
accel_odr | aODR = A_ODR_119 , |
||
mag_odr | mODR = M_ODR_80 |
||
) |
begin() -- Initialize the gyro, accelerometer, and magnetometer.
This will set up the scale and output rate of each sensor. It'll also "turn on" every sensor and every axis of every sensor. Input:
- gScl = The scale of the gyroscope. This should be a gyro_scale value.
- aScl = The scale of the accelerometer. Should be a accel_scale value.
- mScl = The scale of the magnetometer. Should be a mag_scale value.
- gODR = Output data rate of the gyroscope. gyro_odr value.
- aODR = Output data rate of the accelerometer. accel_odr value.
- mODR = Output data rate of the magnetometer. mag_odr value. Output: The function will return an unsigned 16-bit value. The most-sig bytes of the output are the WHO_AM_I reading of the accel/gyro. The least significant two bytes are the WHO_AM_I reading of the mag. All parameters have a defaulted value, so you can call just "begin()". Default values are FSR's of: +/- 245DPS, 4g, 2Gs; ODRs of 119 Hz for gyro, 119 Hz for accelerometer, 80 Hz for magnetometer. Use the return value of this function to verify communication.
Definition at line 10 of file LSM9DS1.cpp.
void calibration | ( | ) |
calibration() -- Calibrate Accel and Gyro sensor
Definition at line 196 of file LSM9DS1.cpp.
void enableXgFIFO | ( | bool | enable ) |
enableFIFO() -- Turn on FIFO state (CTRL_REG9) Input:
- enable = true - turn on FIFO false - turn off FIFO
void readAccel | ( | ) |
readAccel() -- Read the accelerometer output registers.
This function will read all six accelerometer output registers. The readings are stored in the class' ax_raw, ay_raw, and az_raw variables. Read those _after_ calling readAccel().
Definition at line 270 of file LSM9DS1.cpp.
void readGyro | ( | ) |
readGyro() -- Read the gyroscope output registers.
This function will read all six gyroscope output registers. The readings are stored in the class' gx_raw, gy_raw, and gz_raw variables. Read those _after_ calling readGyro().
Definition at line 354 of file LSM9DS1.cpp.
void readIntr | ( | ) |
Read Interrupt.
Definition at line 323 of file LSM9DS1.cpp.
void readMag | ( | ) |
readMag() -- Read the magnetometer output registers.
This function will read all six magnetometer output registers. The readings are stored in the class' mx_raw, my_raw, and mz_raw variables. Read those _after_ calling readMag().
Definition at line 301 of file LSM9DS1.cpp.
void readTemp | ( | ) |
readTemp() -- Read the temperature output register.
This function will read two temperature output registers. The combined readings are stored in the class' temperature variables. Read those _after_ calling readTemp().
Definition at line 334 of file LSM9DS1.cpp.
void setAccelODR | ( | accel_odr | aRate ) |
setAccelODR() -- Set the output data rate of the accelerometer Input:
- aRate = The desired output rate of the accel.
Must be a value from the accel_odr enum (check above).
Definition at line 502 of file LSM9DS1.cpp.
void setAccelScale | ( | accel_scale | aScl ) |
setAccelScale() -- Set the full-scale range of the accelerometer.
This function can be called to set the scale of the accelerometer to 2, 4, 8, or 16 g's. Input:
- aScl = The desired accelerometer scale. Must be one of five possible values from the accel_scale enum.
Definition at line 415 of file LSM9DS1.cpp.
void setGyroODR | ( | gyro_odr | gRate ) |
setGyroODR() -- Set the output data rate and bandwidth of the gyroscope Input:
- gRate = The desired output rate and cutoff frequency of the gyro.
Must be a value from the gyro_odr enum (check above).
Definition at line 471 of file LSM9DS1.cpp.
void setGyroScale | ( | gyro_scale | gScl ) |
setGyroScale() -- Set the full-scale range of the gyroscope.
This function can be called to set the scale of the gyroscope to 245, 500, or 2000 degrees per second. Input:
- gScl = The desired gyroscope scale. Must be one of three possible values from the gyro_scale enum.
Definition at line 387 of file LSM9DS1.cpp.
void setMagODR | ( | mag_odr | mRate ) |
setMagODR() -- Set the output data rate of the magnetometer Input:
- mRate = The desired output rate of the mag.
Must be a value from the mag_odr enum (check above).
Definition at line 524 of file LSM9DS1.cpp.
void setMagScale | ( | mag_scale | mScl ) |
setMagScale() -- Set the full-scale range of the magnetometer.
This function can be called to set the scale of the magnetometer to 4, 8, 12, or 16 Gs. Input:
- mScl = The desired magnetometer scale. Must be one of four possible values from the mag_scale enum.
Definition at line 443 of file LSM9DS1.cpp.
void setXgFIFO | ( | uint8_t | fifoMode, |
uint8_t | fifoThs | ||
) |
setFIFO() -- Set FIFO mode and FIFO threshold(FIFO_CTRL) Input:
- fifoMode = 0: Bypass mode.
FIFO turned off 1: FIFO mode. Stops collecting data when FIFO is full
- fifoThs = maximum threshold is 0x1F(31)
Generated on Wed Jul 13 2022 15:51:31 by
