# HG changeset patch # User heinrichsweikamp # Date 1600245028 -7200 # Node ID d9dbfa496f7e15bdde84b1745bf8922b1f14d680 # Parent 0680975c39b8194b44007950ed2f8a2ca2e0a8d4 Properly send compass 3 into sleepmode (end-2019 hardware) diff -r 0680975c39b8 -r d9dbfa496f7e Small_CPU/Src/compass.c --- 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(); }