1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Use Naze hardware revision when initialising adxl345 - this now allows

the driver to be used by any target with an hse_value of 12Mhz.
This commit is contained in:
Dominic Clifton 2014-10-15 21:16:52 +01:00
parent a4879cc2e3
commit 6162f609ea
2 changed files with 11 additions and 7 deletions

View file

@ -65,10 +65,6 @@ bool adxl345Detect(drv_adxl345_config_t *init, acc_t *acc)
bool ack = false; bool ack = false;
uint8_t sig = 0; uint8_t sig = 0;
// Not supported with this frequency
if (hse_value == 12000000)
return false;
ack = i2cRead(ADXL345_ADDRESS, 0x00, 1, &sig); ack = i2cRead(ADXL345_ADDRESS, 0x00, 1, &sig);
if (!ack || sig != 0xE5) if (!ack || sig != 0xE5)
return false; return false;

View file

@ -56,6 +56,10 @@
#include "sensors/compass.h" #include "sensors/compass.h"
#include "sensors/sonar.h" #include "sensors/sonar.h"
#ifdef NAZE
#include "hardware_revision.h"
#endif
extern float magneticDeclination; extern float magneticDeclination;
extern gyro_t gyro; extern gyro_t gyro;
@ -191,12 +195,16 @@ retry:
case ACC_ADXL345: // ADXL345 case ACC_ADXL345: // ADXL345
acc_params.useFifo = false; acc_params.useFifo = false;
acc_params.dataRate = 800; // unused currently acc_params.dataRate = 800; // unused currently
#ifdef NAZE
if (hardwareRevision < NAZE32_REV5 && adxl345Detect(&acc_params, &acc)) {
accHardware = ACC_ADXL345;
accAlign = CW270_DEG;
}
#else
if (adxl345Detect(&acc_params, &acc)) { if (adxl345Detect(&acc_params, &acc)) {
accHardware = ACC_ADXL345; accHardware = ACC_ADXL345;
#ifdef NAZE
accAlign = CW270_DEG;
#endif
} }
#endif
if (accHardwareToUse == ACC_ADXL345) if (accHardwareToUse == ACC_ADXL345)
break; break;
; // fallthrough ; // fallthrough