Browse Source

beeter check for AK09916 sensor

Juraj Ďuďák 2 years ago
parent
commit
b0b7c616fa
1 changed files with 12 additions and 7 deletions
  1. 12 7
      src/icm20948.cpp

+ 12 - 7
src/icm20948.cpp

@@ -259,15 +259,20 @@ void Icm20948::ak09916_init(Config_Mag_t *config)
 	this->icm20948_i2c_master_enable();
 	this->icm20948_i2c_master_clk_frq(7);
 
-	while(!this->ak09916_who_am_i());
+	this->_ak09916_enable = false;
+	if(this->ak09916_who_am_i()){
+		this->_ak09916_enable = true;
+	}
 
-	this->ak09916_soft_reset();
-	this->ak09916_operation_mode_setting(config->mode);
+	if(this->_ak09916_enable == true){
+		this->ak09916_soft_reset();
+		this->ak09916_operation_mode_setting(config->mode);
 
-	if (config->mode == mag_mode_power_down) {
-		this->_ak09916_enable = false;
-	} else {
-		this->_ak09916_enable = true;
+		if (config->mode == mag_mode_power_down) {
+			this->_ak09916_enable = false;
+		} else {
+			this->_ak09916_enable = true;
+		}
 	}
 }