comparison 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
comparison
equal deleted inserted replaced
513:0680975c39b8 514:d9dbfa496f7e
258 } 258 }
259 259
260 /* No compass identified => Retry */ 260 /* No compass identified => Retry */
261 if(hardwareCompass == 0) 261 if(hardwareCompass == 0)
262 { 262 {
263 I2C_DeInit();
264 HAL_Delay(100);
265 MX_I2C1_Init();
266 HAL_Delay(100);
263 uint8_t data = WHO_AM_I; 267 uint8_t data = WHO_AM_I;
264 I2C_Master_Transmit( DEVICE_COMPASS_303D, &data, 1); 268 I2C_Master_Transmit( DEVICE_COMPASS_303D, &data, 1);
265 I2C_Master_Receive( DEVICE_COMPASS_303D, &data, 1); 269 I2C_Master_Receive( DEVICE_COMPASS_303D, &data, 1);
266 if(data == WHOIAM_VALUE_LSM303D) 270 if(data == WHOIAM_VALUE_LSM303D)
267 hardwareCompass = compass_generation2; //LSM303D; 271 hardwareCompass = compass_generation2; //LSM303D;
352 // compass_sleep 356 // compass_sleep
353 /// @brief low power mode 357 /// @brief low power mode
354 // =============================================================================== 358 // ===============================================================================
355 void compass_sleep(void) 359 void compass_sleep(void)
356 { 360 {
357 if(hardwareCompass == compass_generation2) //LSM303D) 361 if(hardwareCompass == compass_generation2) //LSM303D
358 {
359 compass_sleep_LSM303D(); 362 compass_sleep_LSM303D();
360 } 363 if(hardwareCompass == compass_generation1) //HMC5883L
361 else
362 if(hardwareCompass == compass_generation1) //HMC5883L)
363 {
364 compass_sleep_HMC5883L(); 364 compass_sleep_HMC5883L();
365 } 365 if(hardwareCompass == compass_generation3) //LSM303AGR
366 compass_sleep_LSM303AGR();
366 } 367 }
367 368
368 369
369 // =============================================================================== 370 // ===============================================================================
370 // compass_read 371 // compass_read
376 if(hardwareCompass == compass_generation2) //LSM303D) 377 if(hardwareCompass == compass_generation2) //LSM303D)
377 compass_read_LSM303D(); 378 compass_read_LSM303D();
378 if(hardwareCompass == compass_generation1) //HMC5883L) 379 if(hardwareCompass == compass_generation1) //HMC5883L)
379 compass_read_HMC5883L(); 380 compass_read_HMC5883L();
380 if(hardwareCompass == compass_generation3) //LSM303AGR) 381 if(hardwareCompass == compass_generation3) //LSM303AGR)
381 compass_read_LSM303AGR(); 382 compass_read_LSM303AGR();
382 383
383 } 384 }
384 385
385 386
386 // =============================================================================== 387 // ===============================================================================