mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Merge pull request #11056 from SteveCEvans/mpu6000_bmi270
This commit is contained in:
commit
ac2dede3e2
3 changed files with 10 additions and 16 deletions
|
@ -115,7 +115,7 @@ static void mpu6050FindRevision(gyroDev_t *gyro)
|
||||||
// Gyro read has just completed
|
// Gyro read has just completed
|
||||||
busStatus_e mpuIntcallback(uint32_t arg)
|
busStatus_e mpuIntcallback(uint32_t arg)
|
||||||
{
|
{
|
||||||
volatile gyroDev_t *gyro = (gyroDev_t *)arg;
|
gyroDev_t *gyro = (gyroDev_t *)arg;
|
||||||
int32_t gyroDmaDuration = cmpTimeCycles(getCycleCounter(), gyro->gyroLastEXTI);
|
int32_t gyroDmaDuration = cmpTimeCycles(getCycleCounter(), gyro->gyroLastEXTI);
|
||||||
|
|
||||||
if (gyroDmaDuration > gyro->gyroDmaMaxDuration) {
|
if (gyroDmaDuration > gyro->gyroDmaMaxDuration) {
|
||||||
|
|
|
@ -260,7 +260,7 @@ extiCallbackRec_t bmi270IntCallbackRec;
|
||||||
// Gyro read has just completed
|
// Gyro read has just completed
|
||||||
busStatus_e bmi270Intcallback(uint32_t arg)
|
busStatus_e bmi270Intcallback(uint32_t arg)
|
||||||
{
|
{
|
||||||
volatile gyroDev_t *gyro = (gyroDev_t *)arg;
|
gyroDev_t *gyro = (gyroDev_t *)arg;
|
||||||
int32_t gyroDmaDuration = cmpTimeCycles(getCycleCounter(), gyro->gyroLastEXTI);
|
int32_t gyroDmaDuration = cmpTimeCycles(getCycleCounter(), gyro->gyroLastEXTI);
|
||||||
|
|
||||||
if (gyroDmaDuration > gyro->gyroDmaMaxDuration) {
|
if (gyroDmaDuration > gyro->gyroDmaMaxDuration) {
|
||||||
|
@ -274,12 +274,6 @@ busStatus_e bmi270Intcallback(uint32_t arg)
|
||||||
|
|
||||||
void bmi270ExtiHandler(extiCallbackRec_t *cb)
|
void bmi270ExtiHandler(extiCallbackRec_t *cb)
|
||||||
{
|
{
|
||||||
// Non-blocking, so this needs to be static
|
|
||||||
static busSegment_t segments[] = {
|
|
||||||
{NULL, NULL, 14, true, bmi270Intcallback},
|
|
||||||
{NULL, NULL, 0, true, NULL},
|
|
||||||
};
|
|
||||||
|
|
||||||
gyroDev_t *gyro = container_of(cb, gyroDev_t, exti);
|
gyroDev_t *gyro = container_of(cb, gyroDev_t, exti);
|
||||||
// Ideally we'd use a time to capture such information, but unfortunately the port used for EXTI interrupt does
|
// Ideally we'd use a time to capture such information, but unfortunately the port used for EXTI interrupt does
|
||||||
// not have an associated timer
|
// not have an associated timer
|
||||||
|
@ -288,12 +282,7 @@ void bmi270ExtiHandler(extiCallbackRec_t *cb)
|
||||||
gyro->gyroLastEXTI = nowCycles;
|
gyro->gyroLastEXTI = nowCycles;
|
||||||
|
|
||||||
if (gyro->gyroModeSPI == GYRO_EXTI_INT_DMA) {
|
if (gyro->gyroModeSPI == GYRO_EXTI_INT_DMA) {
|
||||||
segments[0].txData = gyro->dev.txBuf;
|
spiSequence(&gyro->dev, gyro->segments);
|
||||||
segments[0].rxData = gyro->dev.rxBuf;
|
|
||||||
|
|
||||||
if (!spiIsBusy(&gyro->dev)) {
|
|
||||||
spiSequence(&gyro->dev, &segments[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gyro->detectedEXTI++;
|
gyro->detectedEXTI++;
|
||||||
|
@ -387,9 +376,14 @@ static bool bmi270GyroReadRegister(gyroDev_t *gyro)
|
||||||
if (spiUseDMA(&gyro->dev)) {
|
if (spiUseDMA(&gyro->dev)) {
|
||||||
// Indicate that the bus on which this device resides may initiate DMA transfers from interrupt context
|
// Indicate that the bus on which this device resides may initiate DMA transfers from interrupt context
|
||||||
spiSetAtomicWait(&gyro->dev);
|
spiSetAtomicWait(&gyro->dev);
|
||||||
gyro->gyroModeSPI = GYRO_EXTI_INT_DMA;
|
|
||||||
gyro->dev.callbackArg = (uint32_t)gyro;
|
gyro->dev.callbackArg = (uint32_t)gyro;
|
||||||
gyro->dev.txBuf[0] = BMI270_REG_ACC_DATA_X_LSB | 0x80;
|
gyro->dev.txBuf[0] = BMI270_REG_ACC_DATA_X_LSB | 0x80;
|
||||||
|
gyro->segments[0].len = 14;
|
||||||
|
gyro->segments[0].callback = bmi270Intcallback;
|
||||||
|
gyro->segments[0].txData = gyro->dev.txBuf;
|
||||||
|
gyro->segments[0].rxData = gyro->dev.rxBuf;
|
||||||
|
gyro->segments[0].negateCS = true;
|
||||||
|
gyro->gyroModeSPI = GYRO_EXTI_INT_DMA;
|
||||||
} else {
|
} else {
|
||||||
// Interrupts are present, but no DMA
|
// Interrupts are present, but no DMA
|
||||||
gyro->gyroModeSPI = GYRO_EXTI_INT;
|
gyro->gyroModeSPI = GYRO_EXTI_INT;
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#define TASK_AGE_EXPEDITE_SCALE 0.9 // By scaling their expected execution time
|
#define TASK_AGE_EXPEDITE_SCALE 0.9 // By scaling their expected execution time
|
||||||
|
|
||||||
// Gyro interrupt counts over which to measure loop time and skew
|
// Gyro interrupt counts over which to measure loop time and skew
|
||||||
#define GYRO_RATE_COUNT 32000
|
#define GYRO_RATE_COUNT 25000
|
||||||
#define GYRO_LOCK_COUNT 400
|
#define GYRO_LOCK_COUNT 400
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue