16 #ifndef __LSM9DS1_IMU_SENSOR_H__ // Prevents duplicate 17 #define __LSM9DS1_IMU_SENSOR_H__ // declarations 19 #if defined(__cplusplus) // If compiling for C++ 28 #define INT_GEN_CFG_XL 0x06 29 #define INT_GEN_THS_X_XL 0x07 30 #define INT_GEN_THS_Y_XL 0x08 31 #define INT_GEN_THS_Z_XL 0x09 32 #define INT_GEN_DUR_XL 0x0A 33 #define REFERENCE_G 0x0B 34 #define INT1_CTRL 0x0C 35 #define INT2_CTRL 0x0D 36 #define WHO_AM_I_XG 0x0F 37 #define CTRL_REG1_G 0x10 38 #define CTRL_REG2_G 0x11 39 #define CTRL_REG3_G 0x12 40 #define ORIENT_CFG_G 0x13 41 #define INT_GEN_SRC_G 0x14 42 #define OUT_TEMP_L 0x15 43 #define OUT_TEMP_H 0x16 44 #define STATUS_REG_0 0x17 45 #define OUT_X_L_G 0x18 46 #define OUT_X_H_G 0x19 47 #define OUT_Y_L_G 0x1A 48 #define OUT_Y_H_G 0x1B 49 #define OUT_Z_L_G 0x1C 50 #define OUT_Z_H_G 0x1D 51 #define CTRL_REG4 0x1E 52 #define CTRL_REG5_XL 0x1F 53 #define CTRL_REG6_XL 0x20 54 #define CTRL_REG7_XL 0x21 55 #define CTRL_REG8 0x22 56 #define CTRL_REG9 0x23 57 #define CTRL_REG10 0x24 58 #define INT_GEN_SRC_XL 0x26 59 #define STATUS_REG_1 0x27 60 #define OUT_X_L_XL 0x28 61 #define OUT_X_H_XL 0x29 62 #define OUT_Y_L_XL 0x2A 63 #define OUT_Y_H_XL 0x2B 64 #define OUT_Z_L_XL 0x2C 65 #define OUT_Z_H_XL 0x2D 66 #define FIFO_CTRL 0x2E 68 #define INT_GEN_CFG_G 0x30 69 #define INT_GEN_THS_XH_G 0x31 70 #define INT_GEN_THS_XL_G 0x32 71 #define INT_GEN_THS_YH_G 0x33 72 #define INT_GEN_THS_YL_G 0x34 73 #define INT_GEN_THS_ZH_G 0x35 74 #define INT_GEN_THS_ZL_G 0x36 75 #define INT_GEN_DUR_G 0x37 78 #define OFFSET_X_REG_L_M 0x05 79 #define OFFSET_X_REG_H_M 0x06 80 #define OFFSET_Y_REG_L_M 0x07 81 #define OFFSET_Y_REG_H_M 0x08 82 #define OFFSET_Z_REG_L_M 0x09 83 #define OFFSET_Z_REG_H_M 0x0A 84 #define WHO_AM_I_M 0x0F 85 #define CTRL_REG1_M 0x20 86 #define CTRL_REG2_M 0x21 87 #define CTRL_REG3_M 0x22 88 #define CTRL_REG4_M 0x23 89 #define CTRL_REG5_M 0x24 90 #define STATUS_REG_M 0x27 91 #define OUT_X_L_M 0x28 92 #define OUT_X_H_M 0x29 93 #define OUT_Y_L_M 0x2A 94 #define OUT_Y_H_M 0x2B 95 #define OUT_Z_L_M 0x2C 96 #define OUT_Z_H_M 0x2D 97 #define INT_CFG_M 0x30 98 #define INT_SRC_M 0x30 99 #define INT_THS_L_M 0x32 100 #define INT_THS_H_M 0x33 103 #define WHO_AM_I_AG_RSP 0x68 104 #define WHO_AM_I_M_RSP 0x3D 110 #define FIFO_CONT_TRIGGER 3 111 #define FIFO_OFF_TRIGGER 4 147 int imu_init(
int pinSCL,
int pinSDIO,
int pinAG,
int pinM);
581 void imu_setGyroInterrupt(
char axis,
float threshold,
char duration,
char overUnder,
char andOr);
605 void imu_setMagInterrupt(
char axis,
float threshold,
char overPos,
char underNeg,
char lowHigh);
612 void imu_SPIwriteByte(
unsigned char csPin,
unsigned char subAddress,
unsigned char data);
618 void imu_SPIreadBytes(
unsigned char csPin,
unsigned char subAddress,
unsigned char *dest,
unsigned char count);
622 #if defined(__cplusplus) 627 #endif // End prevent duplicate forward unsigned char imu_gyroAvailable()
Polls the Gyroscope status register to check if new data is available.
Definition: imu_gryoAvailable.c:22
void imu_setAccelInterrupt(char axis, float threshold, char duration, char overUnder, char andOr)
Configures the Accelerometer interrupt output to the INT_A/G pin.
Definition: imu_setAccelInterrupt.c:7
void imu_clearMagInterrupt()
Clears out any interrupts set up on the Magnetometer and resets all Magnetometer interrupt registers ...
Definition: imu_clearInterrupt.c:38
void imu_getAccelCalibration(int *axBias, int *ayBias, int *azBias)
Retrieves the Accelreometer's calibration biases.
Definition: imu_getCalibration.c:30
void imu_calibrateAG()
Calibrates the Accelerometer and Gyroscope on the LSM9DS1 IMU module.
Definition: imu_calibrateAG.c:30
unsigned char imu_magAvailable()
Polls the Magnetometer status register to check if new data is available.
Definition: imu_magAvailable.c:23
int imu_getGyroScale()
Retrieves the full-scale range of the Gyroscope.
Definition: imu_getScale.c:24
void imu_calibrateMag()
Calibrates the Magnetometer on the LSM9DS1 IMU module.
Definition: imu_calibrateMag.c:25
void imu_setAccelScale(unsigned char aScl)
Sets the full-scale range of the Accelerometer.
Definition: imu_setAccelScale.c:26
void imu_readMagCalculated(float *mx, float *my, float *mz)
Reads the Magnetometer output registers and scales the outputs to gauss'.
Definition: imu_readMag.c:40
void imu_readTempCalculated(float *temperature, char tempUnit)
Reads the Thermometer output registers and scales the outputs to degrees Celsius, Fahrenheit...
void imu_setAccelCalibration(int axBias, int ayBias, int azBias)
Sets the Accelerometer's calibration biases.
Definition: imu_setCalibration.c:40
void imu_SPIreadBytes(unsigned char csPin, unsigned char subAddress, unsigned char *dest, unsigned char count)
Reads a specified number of bytes from the specified LSM9DS1 register.
Definition: imu_SPIread.c:22
void imu_setGyroInterrupt(char axis, float threshold, char duration, char overUnder, char andOr)
Configures the Gyroscope interrupt output to the INT_A/G pin.
Definition: imu_setGyroInterrupt.c:7
void imu_setGyroScale(unsigned int gScl)
Sets the full-scale range of the Gyroscope.
Definition: imu_setGyroScale.c:26
void imu_readMag(int *mx, int *my, int *mz)
Reads the Magnetometer output registers.
Definition: imu_readMag.c:24
void imu_readTemp(int *temperature)
Reads the Temperature output registers.
Definition: imu_readTemp.c:21
void imu_readGyroCalculated(float *gx, float *gy, float *gz)
Reads the Gyroscope output registers and scales the outputs to degrees of rotation per second (DPS)...
Definition: imu_readGyro.c:49
void imu_getMagCalibration(int *mxBias, int *myBias, int *mzBias)
Retrieves the Magnetometer's calibration biases.
Definition: imu_getCalibration.c:23
unsigned char imu_accelAvailable()
Polls the Accelerometer status register to check if new data is available.
Definition: imu_accelAvailable.c:21
int imu_init(int pinSCL, int pinSDIO, int pinAG, int pinM)
Initializes the LSM9DS1 IMU module.
Definition: imu_init.c:23
void imu_getGyroCalibration(int *gxBias, int *gyBias, int *gzBias)
Retrieves the Gyroscope's calibration biases.
Definition: imu_getCalibration.c:37
void imu_SPIwriteByte(unsigned char csPin, unsigned char subAddress, unsigned char data)
Writes a byte to the specified LSM9DS1 register.
Definition: imu_SPIwrite.c:23
void imu_clearAccelInterrupt()
Clears out any interrupts set up on the Accelerometer and resets all Accelerometer interrupt register...
Definition: imu_clearInterrupt.c:5
void imu_readAccelCalculated(float *ax, float *ay, float *az)
Reads the Accelerometer output registers and scales the outputs to g's (1 g = 9.8 m/s/s)...
Definition: imu_readAccel.c:50
int imu_getMagScale()
Retrieves the full-scale range of the Magnetometer.
Definition: imu_getScale.c:34
void imu_clearGyroInterrupt()
Clears out any interrupts set up on the Gyroscope and resets all Gyroscope interrupt registers to the...
Definition: imu_clearInterrupt.c:20
int imu_getAccelScale()
Retrieves the full-scale range of the Accelerometer.
Definition: imu_getScale.c:29
void imu_readGyro(int *gx, int *gy, int *gz)
Reads the Gyroscope output registers.
Definition: imu_readGyro.c:27
void imu_readAccel(int *ax, int *ay, int *az)
Reads the Accelerometer output registers.
Definition: imu_readAccel.c:28
void imu_setGyroCalibration(int gxBias, int gyBias, int gzBias)
Sets the Gyroscope's calibration biases.
Definition: imu_setCalibration.c:47
void imu_setMagScale(unsigned char mScl)
Sets the full-scale range of the Magnetometer.
Definition: imu_setMagScale.c:25
unsigned char imu_tempAvailable()
Polls the Thermometer status register to check if new data is available.
Definition: imu_tempAvailable.c:22
void imu_setMagCalibration(int mxBias, int myBias, int mzBias)
Sets the Magnetometer's calibration biases.
Definition: imu_setCalibration.c:24
void imu_setMagInterrupt(char axis, float threshold, char overPos, char underNeg, char lowHigh)
Configures the Magnetometer interrupt output to the INT_M pin.
Definition: imu_setMagInterrupt.c:8