void bsp_tof_init(void)
{
uint32_t Id;
/* reset XSHUT (XSDN) pin */
HAL_GPIO_WritePin(VL53L4A3_XSHUT_C_PORT, VL53L4A3_XSHUT_C_PIN, GPIO_PIN_RESET);
HAL_Delay(2);
HAL_GPIO_WritePin(VL53L4A3_XSHUT_C_PORT, VL53L4A3_XSHUT_C_PIN, GPIO_PIN_SET);
HAL_Delay(2);
printf("53L4A3 Simple Ranging demo application\r\n");
status = VL53L4A3_RANGING_SENSOR_Init(VL53L4A3_DEV_CENTER);
if (status != BSP_ERROR_NONE)
{
printf("VL53L4A3_RANGING_SENSOR_Init failed\r\n");
while (1);
}
/*- 读取传感器ID -*/
VL53L4A3_RANGING_SENSOR_ReadID(VL53L4A3_DEV_CENTER, &Id);
VL53L4A3_RANGING_SENSOR_GetCapabilities(VL53L4A3_DEV_CENTER, &Cap);
/*-- 测量模式 --*/
Profile.RangingProfile = VL53L4ED_PROFILE_CONTINUOUS;
/*-- 测量时间 10 ms < TimingBudget < 200 ms --*/
Profile.TimingBudget = TIMING_BUDGET;
Profile.Frequency = 0; /* Induces intermeasurement period, NOT USED for normal ranging */
/*-- 测量噪声输出使能 --*/
Profile.EnableAmbient = 1; /* Enable: 1, Disable: 0 */
/*-- 测量信号强度输出使能 --*/
Profile.EnableSignal = 1; /* Enable: 1, Disable: 0 */
/* set the profile if different from default one */
VL53L4A3_RANGING_SENSOR_ConfigProfile(VL53L4A3_DEV_CENTER, &Profile);
/* 阻塞模式 */
// status = VL53L4A3_RANGING_SENSOR_Start(VL53L4A3_DEV_CENTER, RS_MODE_BLOCKING_CONTINUOUS);
/* 同步模式 */
status = VL53L4A3_RANGING_SENSOR_Start(VL53L4A3_DEV_CENTER, RS_MODE_ASYNC_CONTINUOUS);
if (status != BSP_ERROR_NONE)
{
printf("VL53L4A3_RANGING_SENSOR_Start failed\r\n");
while (1);
}
}
int main(void)
{
int32_t i = 0, status;
RANGING_SENSOR_Result_t Result;
bsp_init();
init_cycle_counter(true);
bsp_tof_init();
while(1)
{
// int64_t time_stamp = get_system_ms();
VL53L4A3_RANGING_SENSOR_GetDistance(VL53L4A3_DEV_CENTER, &Result);
/* polling mode status = */
while(ToF_EventDetected == 0)
{
}
// printf("time_stamp = %lldms\r\n", get_system_ms() - time_stamp);
ToF_EventDetected = 0;
ano_send_custom1(Result.ZoneResult[0].Distance[0],
Result.ZoneResult[0].Status[0],
Result.ZoneResult[0].Ambient[0],
Result.ZoneResult[0].Signal[0]);
}
}
引用: 秦天qintian0303 发表于 2024-11-9 08:39 这次带的开发板不是可以直接下载使用吗?
上位机不好用,看波形不灵活