feat(VL53L4CD): 添加VL53L4CD测距驱动、I2C 16位寄存器支持与项目文档

This commit is contained in:
2026-08-06 00:52:32 +08:00
parent 6eb9f304d3
commit 782fe2b2b0
9 changed files with 774 additions and 362 deletions
+24
View File
@@ -41,6 +41,7 @@ OF SUCH DAMAGE.
#include <stdio.h>
#include "i2c.h"
#include "board_config.h"
#include "VL53L4CD_Driver.h"
/*!
\brief main function
@@ -76,12 +77,35 @@ int main(void)
i2c_bus_reset();
#endif
if (vl53l4cd_init()) {
vl53l4cd_start_ranging();
printf("VL53L4CD ready\r\n");
} else {
printf("VL53L4CD init failed\r\n");
}
/* ========== Command Testing ========== */
/* ========== */
while(1){
command_process(); /* Process UART commands */
if (vl53l4cd_data_ready()) {
vl53l4cd_result_t result;
vl53l4cd_clear_interrupt();
if (vl53l4cd_get_result(&result)) {
printf("Distance: %u mm | status: %u | signal: %lu kcps | ambient: %lu kcps | sigma: %u mm\r\n",
result.distance_mm,
result.range_status,
(unsigned long)result.signal_rate_kcps,
(unsigned long)result.ambient_rate_kcps,
result.sigma_mm);
}
delay_ms(500);
}
delay_ms(10);
}
}