Enable SPI for icm20948
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ build_flags =
|
|||||||
-D USE_BMP180=0
|
-D USE_BMP180=0
|
||||||
-D USE_MPU6050=0
|
-D USE_MPU6050=0
|
||||||
-D USE_ICM20948=1
|
-D USE_ICM20948=1
|
||||||
-D USE_ICM20948_SPIMODE=0
|
-D USE_ICM20948_SPIMODE=1
|
||||||
-D USE_WS2812=1
|
-D USE_WS2812=1
|
||||||
-D USE_BNO055=0
|
-D USE_BNO055=0
|
||||||
-D USE_USS=0
|
-D USE_USS=0
|
||||||
|
|||||||
@@ -87,7 +87,10 @@ class IMU : public SensorBase<IMUAnglesMsg> {
|
|||||||
_imu.setExtCrystalUse(true);
|
_imu.setExtCrystalUse(true);
|
||||||
#endif
|
#endif
|
||||||
#if FT_ENABLED(USE_ICM20948)
|
#if FT_ENABLED(USE_ICM20948)
|
||||||
#if USE_ICM20948_SPIMODE > 0
|
#if FT_ENABLED(USE_ICM20948_SPIMODE) > 0
|
||||||
|
#define SPI_PORT SPI
|
||||||
|
#define CS_PIN 2
|
||||||
|
SPI_PORT.begin(41U, 19U, 20U, -1);
|
||||||
_imu = (ICM_20948_SPI*)_arg;
|
_imu = (ICM_20948_SPI*)_arg;
|
||||||
if (true || !_imu->isConnected()) { _imu->begin(CS_PIN, SPI_PORT); ESP_LOGI("IMU", "Beginning ICM20948 in SPI mode"); }
|
if (true || !_imu->isConnected()) { _imu->begin(CS_PIN, SPI_PORT); ESP_LOGI("IMU", "Beginning ICM20948 in SPI mode"); }
|
||||||
#else
|
#else
|
||||||
@@ -95,16 +98,16 @@ class IMU : public SensorBase<IMUAnglesMsg> {
|
|||||||
if (true || !_imu->isConnected()) { _imu->begin(Wire, 1, 0xFF); ESP_LOGI("IMU", "Beginning ICM20948 in I2C mode"); }
|
if (true || !_imu->isConnected()) { _imu->begin(Wire, 1, 0xFF); ESP_LOGI("IMU", "Beginning ICM20948 in I2C mode"); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (_imu->status != ICM_20948_Stat_Ok){ return false; }
|
if (_imu->status != ICM_20948_Stat_Ok){ ESP_LOGW("IMU", "Failed to start ICM20948: begin failed"); return false; }
|
||||||
|
|
||||||
_imu->setSampleMode((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), ICM_20948_Sample_Mode_Continuous);
|
_imu->setSampleMode((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), ICM_20948_Sample_Mode_Continuous);
|
||||||
if (_imu->status != ICM_20948_Stat_Ok){ return false; }
|
if (_imu->status != ICM_20948_Stat_Ok){ ESP_LOGW("IMU", "Failed to start ICM20948: set sample failed"); return false; }
|
||||||
|
|
||||||
ICM_20948_fss_t myFSS;
|
ICM_20948_fss_t myFSS;
|
||||||
myFSS.a = gpm2;
|
myFSS.a = gpm2;
|
||||||
myFSS.g = dps250;
|
myFSS.g = dps250;
|
||||||
_imu->setFullScale((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), myFSS);
|
_imu->setFullScale((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), myFSS);
|
||||||
if (_imu->status != ICM_20948_Stat_Ok){ return false; }
|
if (_imu->status != ICM_20948_Stat_Ok){ ESP_LOGW("IMU", "Failed to start ICM20948: set full scale failed"); return false; }
|
||||||
// TODO: Setup low pass filter config
|
// TODO: Setup low pass filter config
|
||||||
_msg.success = true;
|
_msg.success = true;
|
||||||
#endif
|
#endif
|
||||||
@@ -148,8 +151,6 @@ class IMU : public SensorBase<IMUAnglesMsg> {
|
|||||||
#endif
|
#endif
|
||||||
#if FT_ENABLED(USE_ICM20948)
|
#if FT_ENABLED(USE_ICM20948)
|
||||||
#if FT_ENABLED(USE_ICM20948_SPIMODE) > 0
|
#if FT_ENABLED(USE_ICM20948_SPIMODE) > 0
|
||||||
#define SPI_PORT SPI // TODO in periphearals_seetings.h
|
|
||||||
#define CS_PIN 2
|
|
||||||
ICM_20948_SPI _imu;
|
ICM_20948_SPI _imu;
|
||||||
#else
|
#else
|
||||||
//#define WIRE_PORT Wire
|
//#define WIRE_PORT Wire
|
||||||
@@ -180,8 +181,6 @@ class IMU : public SensorBase<IMUAnglesMsg> {
|
|||||||
#endif
|
#endif
|
||||||
#if FT_ENABLED(USE_ICM20948)
|
#if FT_ENABLED(USE_ICM20948)
|
||||||
#if FT_ENABLED(USE_ICM20948_SPIMODE) > 0
|
#if FT_ENABLED(USE_ICM20948_SPIMODE) > 0
|
||||||
#define SPI_PORT SPI // TODO in periphearals_seetings.h
|
|
||||||
#define CS_PIN 2
|
|
||||||
ICM_20948_SPI* _imu;
|
ICM_20948_SPI* _imu;
|
||||||
#else
|
#else
|
||||||
//#define WIRE_PORT Wire
|
//#define WIRE_PORT Wire
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class Magnetometer : public SensorBase<MagnetometerMsg> {
|
|||||||
public:
|
public:
|
||||||
bool initialize(void* _arg) override {
|
bool initialize(void* _arg) override {
|
||||||
#if FT_ENABLED(USE_ICM20948)
|
#if FT_ENABLED(USE_ICM20948)
|
||||||
#if USE_ICM20948_SPIMODE > 0
|
#if FT_ENABLED(USE_ICM20948_SPIMODE) > 0
|
||||||
_mag = (ICM_20948_SPI*)_arg;
|
_mag = (ICM_20948_SPI*)_arg;
|
||||||
if (true || !_mag->isConnected()) { _mag->begin(CS_PIN, SPI_PORT); ESP_LOGI("Magnetometer", "Beginning ICM20948 in SPI mode"); }
|
if (true || !_mag->isConnected()) { _mag->begin(CS_PIN, SPI_PORT); ESP_LOGI("Magnetometer", "Beginning ICM20948 in SPI mode"); }
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ void Peripherals::begin() {
|
|||||||
updatePins();
|
updatePins();
|
||||||
|
|
||||||
#if FT_ENABLED(USE_ICM20948)
|
#if FT_ENABLED(USE_ICM20948)
|
||||||
#if USE_ICM20948_SPIMODE > 0
|
#if FT_ENABLED(USE_ICM20948_SPIMODE) > 0
|
||||||
ICM_20948_SPI* icm20948 = new ICM_20948_SPI;
|
ICM_20948_SPI* icm20948 = new ICM_20948_SPI;
|
||||||
#else
|
#else
|
||||||
ICM_20948_I2C* icm20948 = new ICM_20948_I2C;
|
ICM_20948_I2C* icm20948 = new ICM_20948_I2C;
|
||||||
|
|||||||
Reference in New Issue
Block a user