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

lis2mdl: fix read (#14227)

* lis2mdl: revert reading status register, use measure/collect paradigm

* Update src/main/drivers/compass/compass_lis2mdl.c

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

* fix typo

* fixed borked logic

---------

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
This commit is contained in:
Jacob Dahl 2025-02-04 10:00:11 -09:00 committed by GitHub
parent f2e9dac322
commit 896bf03b4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -77,20 +77,15 @@ static bool lis2mdlInit(magDev_t *mag)
static bool lis2mdlRead(magDev_t *mag, int16_t *magData) static bool lis2mdlRead(magDev_t *mag, int16_t *magData)
{ {
uint8_t status = 0; static uint8_t buf[6];
uint8_t buf[6]; static bool pendingRead = true;
extDevice_t *dev = &mag->dev; extDevice_t *dev = &mag->dev;
if (!busReadRegisterBuffer(dev, LIS2MDL_ADDR_STATUS_REG, &status, sizeof(status))) { if (pendingRead) {
return false; if (busReadRegisterBufferStart(dev, LIS2MDL_ADDR_OUTX_L_REG, (uint8_t *)buf, sizeof(buf))) {
} pendingRead = false;
}
if (!(status & LIS2MDL_STATUS_REG_READY)) {
return false;
}
if (!busReadRegisterBuffer(dev, LIS2MDL_ADDR_OUTX_L_REG, (uint8_t *)&buf, sizeof(buf))) {
return false; return false;
} }
@ -107,6 +102,8 @@ static bool lis2mdlRead(magDev_t *mag, int16_t *magData)
magData[Y] = y; magData[Y] = y;
magData[Z] = z; magData[Z] = z;
pendingRead = true;
return true; return true;
} }