1
0
mirror of https://github.com/whowechina/chu_pico.git synced 2024-09-23 18:48:23 +02:00

Fix USB failure due to VL53L0x wait

This commit is contained in:
whowechina 2023-11-19 16:55:47 +08:00
parent 505ac4e24c
commit 273d05d625

View File

@ -773,16 +773,14 @@ void vl53l0x_stop_continuous()
// single-shot range measurement)
uint16_t readRangeContinuousMillimeters()
{
uint32_t start = time_us_32();
while ((read_reg(RESULT_INTERRUPT_STATUS) & 0x07) == 0) {
if (time_us_32() - start > IO_TIMEOUT_US) {
return 65535;
}
static uint16_t range = 65535;
if ((read_reg(RESULT_INTERRUPT_STATUS) & 0x07) == 0) {
return range; // use last result
}
// assumptions: Linearity Corrective Gain is 1000 (default);
// fractional ranging is not enabled
uint16_t range = read_reg16(RESULT_RANGE_STATUS + 10);
range = read_reg16(RESULT_RANGE_STATUS + 10);
write_reg(SYSTEM_INTERRUPT_CLEAR, 0x01);