mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
MPU6050 MPU DATA READY // gyro sync activated
MPU6050 gets DATA READY pin based interrupt instad of i2c SPI targets are still getting interrupt from SPI
This commit is contained in:
parent
60053d5ea5
commit
c45d3e1fdd
3 changed files with 35 additions and 17 deletions
|
@ -92,7 +92,7 @@ enum {
|
|||
#define VBATINTERVAL (6 * 3500)
|
||||
/* IBat monitoring interval (in microseconds) - 6 default looptimes */
|
||||
#define IBATINTERVAL (6 * 3500)
|
||||
#define GYRO_WATCHDOG_DELAY 150 // Watchdog for boards without interrupt for gyro
|
||||
#define GYRO_WATCHDOG_DELAY 100 // Watchdog for boards without interrupt for gyro
|
||||
|
||||
uint32_t currentTime = 0;
|
||||
uint32_t previousTime = 0;
|
||||
|
@ -738,6 +738,21 @@ void filterRc(void){
|
|||
}
|
||||
}
|
||||
|
||||
// Function for loop trigger
|
||||
bool runLoop(uint32_t loopTime) {
|
||||
bool loopTrigger = false;
|
||||
|
||||
if (masterConfig.syncGyroToLoop) {
|
||||
if (gyroSyncCheckUpdate() || (int32_t)(currentTime - (loopTime + GYRO_WATCHDOG_DELAY)) >= 0) {
|
||||
loopTrigger = true;
|
||||
}
|
||||
} else if ((int32_t)(currentTime - loopTime) >= 0){
|
||||
loopTrigger = true;
|
||||
}
|
||||
|
||||
return loopTrigger;
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
static uint32_t loopTime;
|
||||
|
@ -784,7 +799,7 @@ void loop(void)
|
|||
}
|
||||
|
||||
currentTime = micros();
|
||||
if ((!masterConfig.syncGyroToLoop && masterConfig.looptime == 0) || ((int32_t)(currentTime - loopTime) >= 0)) {
|
||||
if (runLoop(loopTime)) {
|
||||
|
||||
loopTime = currentTime + targetLooptime;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue