diff --git a/include/sta/drivers/bmi088.hpp b/include/sta/drivers/bmi088.hpp index 80e486b..4c2709b 100644 --- a/include/sta/drivers/bmi088.hpp +++ b/include/sta/drivers/bmi088.hpp @@ -1,10 +1,14 @@ #ifndef STA_DRIVERS_BMI088_HPP #define STA_DRIVERS_BMI088_HPP +<<<<<<< HEAD //#include //#include #include #include +======= +#include +>>>>>>> 2e8b075 (Added mock driver; renamed enums and fixed a bug) #include @@ -15,9 +19,9 @@ namespace sta public: enum GyroMode { - NORMAL_AWAKE = 0x00, - SUSPEND = 0x80, - DEEP_SUSPEND = 0x20 + NORMAL_AWAKE = 0x00, + SUSPEND = 0x80, + DEEP_SUSPEND = 0x20 }; enum GyroRange { @@ -41,8 +45,8 @@ namespace sta enum AccelMode { - OFF = 0x00, - ON = 0x04 + OFF = 0x00, + ON = 0x04 }; enum AccelRange { @@ -53,9 +57,9 @@ namespace sta }; enum AccelBandwidth { - OSR4 = 0x08, - OSR2 = 0x09, - NORMAL_BANDWIDTH = 0x0A + OSR4 = 0x08, + OSR2 = 0x09, + NORMAL_BANDWIDTH = 0x0A }; enum AccelODR { @@ -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; diff --git a/src/bmi088.cpp b/src/bmi088.cpp index 0a0dd03..98eab6f 100644 --- a/src/bmi088.cpp +++ b/src/bmi088.cpp @@ -2,9 +2,12 @@ #include +#include +#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 \ No newline at end of file diff --git a/src/mock.cpp b/src/mock.cpp new file mode 100644 index 0000000..c3c18ce --- /dev/null +++ b/src/mock.cpp @@ -0,0 +1,103 @@ +#include +#ifdef STA_SPATZ_ENABLED + +#include +#include +#include + + +#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 \ No newline at end of file