Browse Source

Added API config. methods.

xnecas 1 month ago
parent
commit
1bdee9f8df
3 changed files with 20 additions and 2 deletions
  1. 5 0
      inc/DMP_ICM20948.h
  2. 2 2
      inc/HAL_STM32_config.h
  3. 13 0
      src/DMP_ICM20948.cpp

+ 5 - 0
inc/DMP_ICM20948.h

@@ -5,6 +5,7 @@
 
 #include "HAL_impl.h"
 #include "HAL_STM32_config.h"
+#include "SensorTypes.h"
 
 /*************************************************************************
   Defines
@@ -61,6 +62,10 @@ class DMP_ICM20948
     void init(DMP_ICM20948Settings settings);
     void task();
 
+    void setOperatingMode(uint8_t mode);
+    void enableSensor(inv_sensor_type sensor_type, bool enable);
+    void setSensorFrequency(inv_sensor_type sensor_type, uint32_t frequency_hz);
+
     bool gyroDataIsReady();
     bool accelDataIsReady();
     bool magDataIsReady();

+ 2 - 2
inc/HAL_STM32_config.h

@@ -26,8 +26,8 @@
 
 	extern SPI_HandleTypeDef hspi1;
 
-	#define CHIP_SELECT_PIN SPI_CS_Pin
-	#define CHIP_SELECT_PORT SPI_CS_GPIO_Port
+	#define CHIP_SELECT_PIN SPI_SS_Pin
+	#define CHIP_SELECT_PORT SPI_SS_GPIO_Port
 
 	#define SPI_INSTANCE hspi1
 

+ 13 - 0
src/DMP_ICM20948.cpp

@@ -510,7 +510,20 @@ void DMP_ICM20948::init(DMP_ICM20948Settings settings)
   rc = inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(INV_SENSOR_TYPE_STEP_COUNTER), settings.enable_steps);
 }
 
+void DMP_ICM20948::setOperatingMode(uint8_t mode)
+{
+	inv_icm20948_set_lowpower_or_highperformance(&icm_device, mode);
+}
 
+void DMP_ICM20948::enableSensor(inv_sensor_type sensor_type, bool enable)
+{
+	inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(sensor_type), enable);
+}
+
+void DMP_ICM20948::setSensorFrequency(inv_sensor_type sensor_type, uint32_t frequency_hz)
+{
+	inv_icm20948_set_sensor_period(&icm_device, idd_sensortype_conversion(sensor_type), 1000 / frequency_hz);
+}
 
 void DMP_ICM20948::task()
 {