mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-bmi088.git
synced 2025-09-29 00:37:33 +00:00
Resolved conflicts
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
#ifndef STA_DRIVERS_BMI088_HPP
|
#ifndef STA_DRIVERS_BMI088_HPP
|
||||||
#define STA_DRIVERS_BMI088_HPP
|
#define STA_DRIVERS_BMI088_HPP
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
//#include <sta/devices/stm32/bus/spi.hpp>
|
//#include <sta/devices/stm32/bus/spi.hpp>
|
||||||
//#include <sta/devices/stm32/bus/i2c.hpp>
|
//#include <sta/devices/stm32/bus/i2c.hpp>
|
||||||
#include <sta/bus/spi/device.hpp>
|
#include <sta/bus/spi/device.hpp>
|
||||||
#include <sta/bus/i2c/device.hpp>
|
#include <sta/bus/i2c/device.hpp>
|
||||||
|
=======
|
||||||
|
#include <sta/bus/spi/device.hpp>
|
||||||
|
>>>>>>> 2e8b075 (Added mock driver; renamed enums and fixed a bug)
|
||||||
|
|
||||||
#include <sta/drivers/bmi088_defs.hpp>
|
#include <sta/drivers/bmi088_defs.hpp>
|
||||||
|
|
||||||
@@ -15,9 +19,9 @@ namespace sta
|
|||||||
public:
|
public:
|
||||||
enum GyroMode
|
enum GyroMode
|
||||||
{
|
{
|
||||||
NORMAL_AWAKE = 0x00,
|
NORMAL_AWAKE = 0x00,
|
||||||
SUSPEND = 0x80,
|
SUSPEND = 0x80,
|
||||||
DEEP_SUSPEND = 0x20
|
DEEP_SUSPEND = 0x20
|
||||||
};
|
};
|
||||||
enum GyroRange
|
enum GyroRange
|
||||||
{
|
{
|
||||||
@@ -41,8 +45,8 @@ namespace sta
|
|||||||
|
|
||||||
enum AccelMode
|
enum AccelMode
|
||||||
{
|
{
|
||||||
OFF = 0x00,
|
OFF = 0x00,
|
||||||
ON = 0x04
|
ON = 0x04
|
||||||
};
|
};
|
||||||
enum AccelRange
|
enum AccelRange
|
||||||
{
|
{
|
||||||
@@ -53,9 +57,9 @@ namespace sta
|
|||||||
};
|
};
|
||||||
enum AccelBandwidth
|
enum AccelBandwidth
|
||||||
{
|
{
|
||||||
OSR4 = 0x08,
|
OSR4 = 0x08,
|
||||||
OSR2 = 0x09,
|
OSR2 = 0x09,
|
||||||
NORMAL_BANDWIDTH = 0x0A
|
NORMAL_BANDWIDTH = 0x0A
|
||||||
};
|
};
|
||||||
enum AccelODR
|
enum AccelODR
|
||||||
{
|
{
|
||||||
@@ -77,7 +81,7 @@ namespace sta
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BMI088(Device* gyro_device, Device* accel_device);
|
BMI088(SPIDevice* gyro_device, SPIDevice* accel_device);
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
@@ -100,8 +104,8 @@ namespace sta
|
|||||||
|
|
||||||
void convertRawToActual(uint16_t* i, float* f, float f_range);
|
void convertRawToActual(uint16_t* i, float* f, float f_range);
|
||||||
|
|
||||||
Device* gyro_device;
|
SPIDevice* gyro_device;
|
||||||
Device* accel_device;
|
SPIDevice* accel_device;
|
||||||
|
|
||||||
float f_gyro_range = 0;
|
float f_gyro_range = 0;
|
||||||
float f_accel_range = 0;
|
float f_accel_range = 0;
|
||||||
|
@@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
#include <sta/debug/assert.hpp>
|
#include <sta/debug/assert.hpp>
|
||||||
|
|
||||||
|
#include <sta/config.hpp>
|
||||||
|
#ifndef STA_SPATZ_ENABLED
|
||||||
|
|
||||||
namespace sta
|
namespace sta
|
||||||
{
|
{
|
||||||
BMI088::BMI088(Device* gyro_device, Device* accel_device)
|
BMI088::BMI088(SPIDevice* gyro_device, SPIDevice* accel_device)
|
||||||
: gyro_device{gyro_device}, accel_device(accel_device)
|
: gyro_device{gyro_device}, accel_device(accel_device)
|
||||||
{
|
{
|
||||||
STA_ASSERT(gyro_device != nullptr);
|
STA_ASSERT(gyro_device != nullptr);
|
||||||
@@ -143,7 +146,7 @@ namespace sta
|
|||||||
void BMI088::getAcceleration(float* x, float* y, float* z)
|
void BMI088::getAcceleration(float* x, float* y, float* z)
|
||||||
{
|
{
|
||||||
uint16_t i_x,i_y,i_z;
|
uint16_t i_x,i_y,i_z;
|
||||||
getRawRotation(&i_x, &i_y, &i_z);
|
getRawAcceleration(&i_x, &i_y, &i_z);
|
||||||
convertRawToActual(&i_x, x, f_accel_range);
|
convertRawToActual(&i_x, x, f_accel_range);
|
||||||
convertRawToActual(&i_y, y, f_accel_range);
|
convertRawToActual(&i_y, y, f_accel_range);
|
||||||
convertRawToActual(&i_z, z, f_accel_range);
|
convertRawToActual(&i_z, z, f_accel_range);
|
||||||
@@ -204,3 +207,5 @@ namespace sta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
|
#endif // STA_SPATZ_ENABLED
|
103
src/mock.cpp
Normal file
103
src/mock.cpp
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
#include <sta/config.hpp>
|
||||||
|
#ifdef STA_SPATZ_ENABLED
|
||||||
|
|
||||||
|
#include <sta/drivers/bmi088.hpp>
|
||||||
|
#include <sta/debug/spatz.hpp>
|
||||||
|
#include <sta/debug/assert.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#define STA_BMI088_ACC_SPATZ_ID 3
|
||||||
|
#define STA_BMI088_GYRO_SPATZ_ID 4
|
||||||
|
|
||||||
|
namespace sta
|
||||||
|
{
|
||||||
|
BMI088::BMI088(SPIDevice* gyro_device, SPIDevice* accel_device)
|
||||||
|
: gyro_device{gyro_device}, accel_device(accel_device)
|
||||||
|
{
|
||||||
|
STA_ASSERT(gyro_device != nullptr);
|
||||||
|
STA_ASSERT(accel_device != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMI088::init()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::setGyroscopeMode(GyroMode mode)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::setGyroscopeRange(GyroRange range)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::setGyroscopeBandwidth(GyroBandwidth bandwidth)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::getRawRotation(uint16_t* x, uint16_t* y, uint16_t* z)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::getRotation(float* x, float* y, float* z)
|
||||||
|
{
|
||||||
|
float omegas[3];
|
||||||
|
spatz::request(STA_BMI088_GYRO_SPATZ_ID, omegas, 3);
|
||||||
|
|
||||||
|
*x = omegas[0];
|
||||||
|
*y = omegas[1];
|
||||||
|
*z = omegas[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BMI088::setAccelerometerMode(AccelMode mode)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::setAccelerometerRange(AccelRange range)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::setAccelerometerBandwidth(AccelBandwidth bandwidth, AccelODR odr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::getRawAcceleration(uint16_t* x, uint16_t* y, uint16_t* z)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::getAcceleration(float* x, float* y, float* z)
|
||||||
|
{
|
||||||
|
float acc[3];
|
||||||
|
spatz::request(STA_BMI088_ACC_SPATZ_ID, acc, 3);
|
||||||
|
|
||||||
|
*x = acc[0];
|
||||||
|
*y = acc[1];
|
||||||
|
*z = acc[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMI088::busRead(Part part, uint8_t reg, uint8_t * buffer)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMI088::busWrite(Part part, uint8_t reg, uint8_t value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMI088::convertRawToActual(uint16_t* i, float* f, float f_range)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
} // namespace sta
|
||||||
|
|
||||||
|
#endif // STA_SPATZ_ENABLED
|
Reference in New Issue
Block a user