Hi All,
in chirp driver ch_driver.c the fucntion chdrv_wait_for_lock() :
int chdrv_wait_for_lock(ch_dev_t *dev_ptr, uint16_t timeout_ms) {
uint32_t start_time = chbsp_timestamp_ms();
int ch_err = !(dev_ptr->sensor_connected); while (!ch_err && !(dev_ptr->get_locked_state(dev_ptr))) {
chbsp_delay_ms(10);
ch_err = ((chbsp_timestamp_ms() - start_time) > timeout_ms);
}
#ifdef CHDRV_DEBUG
if (ch_err) {
char cbuf[80];
snprintf(cbuf, sizeof(cbuf), "Sensor %hhu initialization timed out or missing\n", dev_ptr->io_index);
chbsp_print_str(cbuf);
}
#endif
return ch_err;
}
the function use chbsp_timestamp_ms() however this call is marked as RECOMMENDED instead of REQUIRED, so it's not necessary available.
I proposed to use alternative way for timeout purpose ex:
uint8_t locked = 0;
uint32_t cnt = 0;
while (cnt <= timeout_ms) {
locked = dev_ptr->get_locked_state(dev_ptr);
// DBG_OUT("get_locked_state:%d\n", locked);
if (locked > 0 ) {
break;
}
chbsp_delay_ms(10);
cnt += 10; }
to avoid chbsp_timestamp_ms() call.