diff Small_CPU/Src/compass.c @ 514:d9dbfa496f7e

Properly send compass 3 into sleepmode (end-2019 hardware)
author heinrichsweikamp
date Wed, 16 Sep 2020 10:30:28 +0200
parents 9eeab3fead8f
children 573a2bc796c8
line wrap: on
line diff
--- a/Small_CPU/Src/compass.c	Mon Aug 31 20:06:59 2020 +0200
+++ b/Small_CPU/Src/compass.c	Wed Sep 16 10:30:28 2020 +0200
@@ -260,6 +260,10 @@
 /* No compass identified => Retry */
 	if(hardwareCompass == 0)
 	{
+		I2C_DeInit();
+		HAL_Delay(100);
+		MX_I2C1_Init();
+		HAL_Delay(100);
 		uint8_t data = WHO_AM_I;
 		I2C_Master_Transmit( DEVICE_COMPASS_303D, &data, 1);
 		I2C_Master_Receive(  DEVICE_COMPASS_303D, &data, 1);
@@ -354,15 +358,12 @@
 //  ===============================================================================
 void compass_sleep(void)
 {
-	if(hardwareCompass == compass_generation2)			//LSM303D)
-	{
+	if(hardwareCompass == compass_generation2)			//LSM303D
 		compass_sleep_LSM303D();
-	}
-	else
-	if(hardwareCompass == compass_generation1)			//HMC5883L)
-	{
+	if(hardwareCompass == compass_generation1)			//HMC5883L
 		compass_sleep_HMC5883L();
-	}
+	if(hardwareCompass == compass_generation3)			//LSM303AGR
+		compass_sleep_LSM303AGR();
 }
 
 
@@ -378,7 +379,7 @@
 	if(hardwareCompass == compass_generation1)			//HMC5883L)
 		compass_read_HMC5883L();
 	if(hardwareCompass == compass_generation3)			//LSM303AGR)
-			compass_read_LSM303AGR();
+		compass_read_LSM303AGR();
 
 }