Resolved conflicts

This commit is contained in:
dario
2024-07-05 10:35:25 +02:00
parent 44f7099c4f
commit 5c00355a25
3 changed files with 125 additions and 13 deletions

View File

@@ -1,10 +1,14 @@
#ifndef STA_DRIVERS_BMI088_HPP
#define STA_DRIVERS_BMI088_HPP
<<<<<<< HEAD
//#include <sta/devices/stm32/bus/spi.hpp>
//#include <sta/devices/stm32/bus/i2c.hpp>
#include <sta/bus/spi/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>
@@ -77,7 +81,7 @@ namespace sta
};
public:
BMI088(Device* gyro_device, Device* accel_device);
BMI088(SPIDevice* gyro_device, SPIDevice* accel_device);
bool init();
@@ -100,8 +104,8 @@ namespace sta
void convertRawToActual(uint16_t* i, float* f, float f_range);
Device* gyro_device;
Device* accel_device;
SPIDevice* gyro_device;
SPIDevice* accel_device;
float f_gyro_range = 0;
float f_accel_range = 0;

View File

@@ -2,9 +2,12 @@
#include <sta/debug/assert.hpp>
#include <sta/config.hpp>
#ifndef STA_SPATZ_ENABLED
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)
{
STA_ASSERT(gyro_device != nullptr);
@@ -143,7 +146,7 @@ namespace sta
void BMI088::getAcceleration(float* x, float* y, float* 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_y, y, f_accel_range);
convertRawToActual(&i_z, z, f_accel_range);
@@ -204,3 +207,5 @@ namespace sta
}
}
} // namespace sta
#endif // STA_SPATZ_ENABLED

103
src/mock.cpp Normal file
View 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