EFR32 Blue Gecko 13 Software Documentation  efr32bg13-doc-5.1.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu.h File Reference

Detailed Description

Inertial Measurement Unit DCM matrix related routines.

Version
5.1.1

License

Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com

This file is licensed under the Silicon Labs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.

Definition in file imu.h.

#include <stdint.h>
#include "em_gpio.h"
#include "i2cspm.h"
#include "thunderboard/board_pic_regs.h"
#include "thunderboard/board_rgbled_profiles.h"

Go to the source code of this file.

Data Structures

struct  _IMU_SensorFusion
 Structure to store the sensor fusion data. More...
 

Macros

#define IMU_DEG_TO_RAD(ang)    (ang * IMU_DEG_TO_RAD_FACTOR)
 
#define IMU_DEG_TO_RAD_FACTOR   ( (2.0*IMU_PI) / 360.0 )
 
#define IMU_MAX_ACCEL_FOR_ANGLE   0.9848
 
#define IMU_OK   0
 
#define IMU_PI   3.14159265358979323
 
#define IMU_RAD_TO_DEG(ang)    (ang * IMU_RAD_TO_DEG_FACTOR)
 
#define IMU_RAD_TO_DEG_FACTOR   ( 360.0 / (2.0*IMU_PI) )
 
#define IMU_STATE_CALIBRATING   0x03
 
#define IMU_STATE_DISABLED   0x00
 
#define IMU_STATE_INITIALIZING   0x02
 
#define IMU_STATE_READY   0x01
 

Typedefs

typedef struct _IMU_SensorFusion IMU_SensorFusion
 Structure to store the sensor fusion data.
 

Functions

void IMU_accelerationGet (int16_t avec[3])
 Retrieves the processed acceleration data. More...
 
void IMU_clearDataReadyFlag (void)
 Clears the IMU data ready flag. In case of ver 0.3.0 and older of the PIC firmware the interrupt register also needs to be cleared. More...
 
void IMU_config (float sampleRate)
 Configures the IMU. More...
 
void IMU_dcmGetAngles (float dcm[3][3], float angle[3])
 Calculates the Euler angles (roll, pitch, yaw) from the DCM matrix. More...
 
void IMU_dcmNormalize (float dcm[3][3])
 Normalizes the DCM matrix. More...
 
void IMU_dcmReset (float dcm[3][3])
 Sets the elements of the DCM matrixto the corresponding elements of the identity matrix. More...
 
void IMU_dcmResetZ (float dcm[3][3])
 DCM reset, Z direction. More...
 
void IMU_dcmRotate (float dcm[3][3], float angle[3])
 Rotates the DCM matrix by a given angle. More...
 
uint32_t IMU_deInit (void)
 De-initializes the IMU chip. More...
 
void IMU_fuseAccelerometerSetSampleRate (IMU_SensorFusion *f, float rate)
 Sets the accelerometer sample rate in the IMU_SensorFusion structure. More...
 
void IMU_fuseAccelerometerUpdateFilter (IMU_SensorFusion *f, float avec[3])
 The current accelerometer data is added to the accumulator. More...
 
void IMU_fuseGyroCorrection (IMU_SensorFusion *f, bool accValid, bool dirValid, float dirZ)
 Calculates the gyro correction vector. More...
 
void IMU_fuseGyroCorrectionClear (IMU_SensorFusion *f)
 Clears the gyro correction vector. More...
 
void IMU_fuseGyroSetSampleRate (IMU_SensorFusion *f, float rate)
 Sets the gyro sample rate and related values in the IMU_SensorFusion structure. More...
 
void IMU_fuseGyroUpdate (IMU_SensorFusion *f, float gvec[3])
 Updates the fusion calculation with a new gyro data. More...
 
void IMU_fuseNew (IMU_SensorFusion *f)
 Initializes a new IMU_SensorFusion structure. More...
 
void IMU_fuseReset (IMU_SensorFusion *f)
 Clears the values of the sensor fusion object. More...
 
void IMU_fuseUpdate (IMU_SensorFusion *f)
 Updates the fusion calculation. More...
 
void IMU_getAccelerometerData (float avec[3])
 Retrieves the raw acceleration data from the IMU. More...
 
void IMU_getGyroCorrectionAngles (float acorr[3])
 Retrieves the processed gyroscope correction angles. More...
 
void IMU_getGyroData (float gvec[3])
 Retrieves the raw gyroscope data from the IMU. More...
 
uint8_t IMU_getState (void)
 Returns IMU state. More...
 
uint32_t IMU_gyroCalibrate (void)
 Performs gyroscope calibration to cancel gyro bias. More...
 
void IMU_gyroGet (int16_t gvec[3])
 Retrieves the processed gyroscope data. More...
 
uint32_t IMU_init (void)
 Initializes and calibrates the IMU. More...
 
bool IMU_isDataReady (void)
 Checks if there is new accel/gyro data available for read. More...
 
bool IMU_isDataReadyFlag (void)
 Checks if there is new accel/gyro data available for read. In case of ver 0.3.0 and older of the PIC firmware the state of the PIC_INT_WAKE needs to be read to determinte if the IMU interrupt is valid. More...
 
void IMU_matrixMultiply (float c[3][3], float a[3][3], float b[3][3])
 Multiplies two 3x3 matrices. More...
 
void IMU_normalizeAngle (float *a)
 Normalizes the angle ( -PI < angle <= PI ) More...
 
void IMU_orientationGet (int16_t ovec[3])
 Retrieves the processed orientation data. More...
 
void IMU_reset (void)
 Resets the fusion calculation. More...
 
void IMU_update (void)
 Gets a new set of data from the accel and gyro sensor and updates the fusion calculation. More...
 
void IMU_vectorAdd (float r[3], float a[3], float b[3])
 Adds two vectors. More...
 
void IMU_vectorCrossProduct (float r[3], float a[3], float b[3])
 Calculates the cross product of two vectors. More...
 
float IMU_vectorDotProduct (float a[3], float b[3])
 Calculates the dot product of two vectors. More...
 
void IMU_vectorNormalizeAngle (float v[3])
 Normalizes the angle of a vector. More...
 
void IMU_vectorScalarMultiplication (float r[3], float v[3], float scale)
 Multiplies a vector by a scalar. More...
 
void IMU_vectorScale (float v[3], float scale)
 Scales a vector by a factor. More...
 
void IMU_vectorSubtract (float r[3], float a[3], float b[3])
 Subtracts vector b from vector a. More...
 
void IMU_vectorZero (float v[3])
 Sets all elements of a vector to 0. More...