Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LSM6DS3 Class Reference
LSM6DS3 Class - driver for the 9 DoF IMU. More...
#include <LSM6DS3.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... | |
Public Member Functions | |
LSM6DS3 (PinName sda, PinName scl, uint8_t xgAddr=LSM6DS3_AG_I2C_ADDR(1)) | |
LSM6DS3 -- LSM6DS3 class constructor The constructor will set up a handful of private variables, and set the communication mode as well. | |
uint16_t | begin (gyro_scale gScl=G_SCALE_245DPS, accel_scale aScl=A_SCALE_2G, gyro_odr gODR=G_ODR_104, accel_odr aODR=A_ODR_104) |
begin() -- Initialize the gyro, and accelerometer. | |
void | readGyro () |
readGyro() -- Read the gyroscope output registers. | |
void | readAccel () |
readAccel() -- Read the accelerometer output registers. | |
void | readTemp () |
readTemp() -- Read the temperature output register. | |
void | readIntr () |
Read Interrupt. | |
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 | 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:
|
Detailed Description
LSM6DS3 Class - driver for the 9 DoF IMU.
Definition at line 92 of file LSM6DS3.h.
Member Enumeration Documentation
enum accel_odr |
enum accel_scale |
enum gyro_odr |
enum gyro_scale |
Constructor & Destructor Documentation
LSM6DS3 | ( | PinName | sda, |
PinName | scl, | ||
uint8_t | xgAddr = LSM6DS3_AG_I2C_ADDR(1) |
||
) |
LSM6DS3 -- LSM6DS3 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)
Definition at line 3 of file LSM6DS3.cpp.
Member Function Documentation
uint16_t begin | ( | gyro_scale | gScl = G_SCALE_245DPS , |
accel_scale | aScl = A_SCALE_2G , |
||
gyro_odr | gODR = G_ODR_104 , |
||
accel_odr | aODR = A_ODR_104 |
||
) |
begin() -- Initialize the gyro, and accelerometer.
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.
- gODR = Output data rate of the gyroscope. gyro_odr value.
- aODR = Output data rate of the accelerometer. accel_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. 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. Use the return value of this function to verify communication.
Definition at line 10 of file LSM6DS3.cpp.
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 102 of file LSM6DS3.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 176 of file LSM6DS3.cpp.
void readIntr | ( | ) |
Read Interrupt.
Definition at line 140 of file LSM6DS3.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 151 of file LSM6DS3.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 310 of file LSM6DS3.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 242 of file LSM6DS3.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 270 of file LSM6DS3.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 214 of file LSM6DS3.cpp.
Generated on Tue Jul 12 2022 17:55:36 by
