actually configure I2C bus for MPU
This commit is contained in:
parent
3d67aaab48
commit
91b017c27d
@ -9,6 +9,8 @@
|
|||||||
namespace ugv {
|
namespace ugv {
|
||||||
namespace io {
|
namespace io {
|
||||||
|
|
||||||
|
static constexpr gpio_num_t MPU_SDA = GPIO_NUM_2;
|
||||||
|
static constexpr gpio_num_t MPU_SCL = GPIO_NUM_3;
|
||||||
static constexpr mpud::accel_fs_t MPU_ACCEL_FS = mpud::ACCEL_FS_2G;
|
static constexpr mpud::accel_fs_t MPU_ACCEL_FS = mpud::ACCEL_FS_2G;
|
||||||
static constexpr mpud::gyro_fs_t MPU_GYRO_FS = mpud::GYRO_FS_500DPS;
|
static constexpr mpud::gyro_fs_t MPU_GYRO_FS = mpud::GYRO_FS_500DPS;
|
||||||
static constexpr float MPU_MAG_TO_FLUX = (4912.f) / (32760.f);
|
static constexpr float MPU_MAG_TO_FLUX = (4912.f) / (32760.f);
|
||||||
@ -20,7 +22,7 @@ Vec3f::Vec3f(float x, float y, float z) : x(x), y(y), z(z) {}
|
|||||||
Vec3f::Vec3f(const mpud::float_axes_t &axes)
|
Vec3f::Vec3f(const mpud::float_axes_t &axes)
|
||||||
: x(axes.x), y(axes.y), z(axes.z) {}
|
: x(axes.x), y(axes.y), z(axes.z) {}
|
||||||
|
|
||||||
MPU::MPU() { mpu_ = new mpud::MPU(); }
|
MPU::MPU() : mpu_(nullptr), mpu_data_() {}
|
||||||
|
|
||||||
MPU::~MPU() { delete mpu_; }
|
MPU::~MPU() { delete mpu_; }
|
||||||
|
|
||||||
@ -28,6 +30,10 @@ void MPU::Init() {
|
|||||||
mutex_ = xSemaphoreCreateMutex();
|
mutex_ = xSemaphoreCreateMutex();
|
||||||
mpu_data_ = MpuData{};
|
mpu_data_ = MpuData{};
|
||||||
|
|
||||||
|
mpu_bus_ = &i2c0;
|
||||||
|
mpu_bus_->begin(MPU_SDA, MPU_SCL);
|
||||||
|
mpu_ = new mpud::MPU(*mpu_bus_);
|
||||||
|
|
||||||
esp_err_t ret;
|
esp_err_t ret;
|
||||||
ret = mpu_->testConnection();
|
ret = mpu_->testConnection();
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
|
@ -36,6 +36,7 @@ class MPU {
|
|||||||
void GetData(MpuData &data);
|
void GetData(MpuData &data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
mpud::mpu_bus_t *mpu_bus_;
|
||||||
mpud::MPU * mpu_;
|
mpud::MPU * mpu_;
|
||||||
mpud::raw_axes_t accel_, gyro_, mag_;
|
mpud::raw_axes_t accel_, gyro_, mag_;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user