upm
0.8.0
Sensor/Actuator repository for libmraa (v1.1.1)
|
API for the BMI055 6-axis Sensor Module. More...
The BMI055 is an inertial measurement unit (IMU) for the detection of movements and rotations in 6 degrees of freedom (6DoF). It reflects the full functionality of a triaxial, low-g acceleration sensor and at the same time it is capable to measure angular rates. Both – acceleration and angular rate – in three perpendicular room dimensions, the x-, y- and z-axis.
The BMI055 is essentially 2 separate devices in one: the BMA250E Accelerometer and the BMG160 Gyroscope. They are completely independant of each other.
This driver provides a very simple interface to these two devices. If finer control is desired, you should just use the separate BMA25E and BMG160 device classes directly. This driver simply initializes both devices, and provides a mechanism to read accelerometer and gyroscope data from them.
Public Member Functions | |
BMI055 (int accelBus=BMA250E_I2C_BUS, int accelAddr=BMA250E_DEFAULT_ADDR, int accelCS=-1, int gyroBus=BMG160_I2C_BUS, int gyroAddr=BMG160_DEFAULT_ADDR, int gyroCS=-1) | |
~BMI055 () | |
void | update () |
void | initAccelerometer (BMA250E::POWER_MODE_T pwr=BMA250E::POWER_MODE_NORMAL, BMA250E::RANGE_T range=BMA250E::RANGE_2G, BMA250E::BW_T bw=BMA250E::BW_250) |
void | initGyroscope (BMG160::POWER_MODE_T pwr=BMG160::POWER_MODE_NORMAL, BMG160::RANGE_T range=BMG160::RANGE_250, BMG160::BW_T bw=BMG160::BW_400_47) |
void | getAccelerometer (float *x, float *y, float *z) |
float * | getAccelerometer () |
void | getGyroscope (float *x, float *y, float *z) |
float * | getGyroscope () |
Protected Attributes | |
BMA250E * | m_accel |
BMG160 * | m_gyro |
BMI055 | ( | int | accelBus = BMA250E_I2C_BUS , |
int | accelAddr = BMA250E_DEFAULT_ADDR , |
||
int | accelCS = -1 , |
||
int | gyroBus = BMG160_I2C_BUS , |
||
int | gyroAddr = BMG160_DEFAULT_ADDR , |
||
int | gyroCS = -1 |
||
) |
BMI055 constructor.
This device can support both I2C and SPI. For SPI, set the addr to -1, and specify a positive integer representing the Chip Select (CS) pin for the cs argument. If you are using a hardware CS pin (like edison with arduino breakout), then you can connect the proper pin to the hardware CS pin on your MCU and supply -1 for cs. The default operating mode is I2C.
accelBus | I2C or SPI bus to use. -1 to skip initializing this device. |
accelAddr | The address for this device. -1 for SPI. |
accelCS | The gpio pin to use for the SPI Chip Select. -1 for I2C or for SPI with a hardware controlled pin. |
gyroBus | I2C or SPI bus to use. -1 to skip initializing this device. |
gyroAddr | The address for this device. -1 for SPI. |
gyroCS | The gpio pin to use for the SPI Chip Select. -1 for I2C or for SPI with a hardware controlled pin. |
void update | ( | void | ) |
Update the internal stored values from sensor data.
void initAccelerometer | ( | BMA250E::POWER_MODE_T | pwr = BMA250E::POWER_MODE_NORMAL , |
BMA250E::RANGE_T | range = BMA250E::RANGE_2G , |
||
BMA250E::BW_T | bw = BMA250E::BW_250 |
||
) |
Initialize the accelerometer and start operation. This function is called from the constructor so will not typically need to be called by a user unless the device is reset or you want to change these values.
pwr | One of the BMA250E::POWER_MODE_T values. The default is BMA250E::POWER_MODE_NORMAL. |
range | One of the BMA250E::RANGE_T values. The default is BMA250E::RANGE_2G. |
bw | One of the filtering BMA250E::BW_T values. The default is BMA250E::BW_250. |
void initGyroscope | ( | BMG160::POWER_MODE_T | pwr = BMG160::POWER_MODE_NORMAL , |
BMG160::RANGE_T | range = BMG160::RANGE_250 , |
||
BMG160::BW_T | bw = BMG160::BW_400_47 |
||
) |
Initialize the gyroscope and start operation. This function is called from the constructor so will not typically need to be called by a user unless the device is reset or you want to change these values.
pwr | One of the BMG160::POWER_MODE_T values. The default is BMG160::POWER_MODE_NORMAL. |
range | One of the BMG160::RANGE_T values. The default is BMG160::RANGE_250. |
bw | One of the filtering BMG160::BW_T values. The default is BMG160::BW_400_47. |
void getAccelerometer | ( | float * | x, |
float * | y, | ||
float * | z | ||
) |
Return accelerometer data in gravities. update() must have been called prior to calling this method.
x | Pointer to a floating point value that will have the current x component placed into it. |
y | Pointer to a floating point value that will have the current y component placed into it. |
z | Pointer to a floating point value that will have the current z component placed into it. |
float * getAccelerometer | ( | ) |
Return accelerometer data in gravities in the form of a floating point array. The pointer returned by this function is statically allocated and will be rewritten on each call. update() must have been called prior to calling this method.
void getGyroscope | ( | float * | x, |
float * | y, | ||
float * | z | ||
) |
Return gyroscope data in degrees per second. update() must have been called prior to calling this method.
x | Pointer to a floating point value that will have the current x component placed into it. |
y | Pointer to a floating point value that will have the current y component placed into it. |
z | Pointer to a floating point value that will have the current z component placed into it. |
float * getGyroscope | ( | ) |
Return gyroscope data in degrees per second in the form of a floating point array. The pointer returned by this function is statically allocated and will be rewritten on each call. update() must have been called prior to calling this method.