Fix cache crosstalk

This commit is contained in:
whowechina 2024-09-26 19:15:55 +08:00
parent c4cedde58b
commit 5c6411c847

View File

@ -1821,10 +1821,8 @@ static bool dataReady()
// measurement) // measurement)
uint16_t vl53l1x_readContinuousMillimeters() uint16_t vl53l1x_readContinuousMillimeters()
{ {
static uint16_t cached = 0;
while (!dataReady()) { while (!dataReady()) {
return cached; return INSTANCE.result.range_mm;
} }
readResults(); readResults();
@ -1838,8 +1836,7 @@ uint16_t vl53l1x_readContinuousMillimeters()
getRangingData(); getRangingData();
write_reg(SYSTEM__INTERRUPT_CLEAR, 0x01); // sys_interrupt_clear_range write_reg(SYSTEM__INTERRUPT_CLEAR, 0x01); // sys_interrupt_clear_range
cached = INSTANCE.result.range_mm; return INSTANCE.result.range_mm;
return cached;
} }
// "Setup ranges after the first one in low power auto mode by turning off // "Setup ranges after the first one in low power auto mode by turning off