From 5c6411c847e3555326dcb9330072762a5d78d4c5 Mon Sep 17 00:00:00 2001 From: whowechina Date: Thu, 26 Sep 2024 19:15:55 +0800 Subject: [PATCH] Fix cache crosstalk --- firmware/src/vl53l1x.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/firmware/src/vl53l1x.c b/firmware/src/vl53l1x.c index 41e6ab5..f255c0a 100644 --- a/firmware/src/vl53l1x.c +++ b/firmware/src/vl53l1x.c @@ -1821,10 +1821,8 @@ static bool dataReady() // measurement) uint16_t vl53l1x_readContinuousMillimeters() { - static uint16_t cached = 0; - while (!dataReady()) { - return cached; + return INSTANCE.result.range_mm; } readResults(); @@ -1838,8 +1836,7 @@ uint16_t vl53l1x_readContinuousMillimeters() getRangingData(); write_reg(SYSTEM__INTERRUPT_CLEAR, 0x01); // sys_interrupt_clear_range - cached = INSTANCE.result.range_mm; - return cached; + return INSTANCE.result.range_mm; } // "Setup ranges after the first one in low power auto mode by turning off