#ifndef __ULTRASOUND_H #define __ULTRASOUND_H #include "headfile.h" #define HCSR_TEST 1 #define EVENT_ECHO_DONE 0x01 extern volatile uint8_t obstacle_level; extern volatile uint32_t distance_cm; void DWT_Init(void); /******** delay_us() 函数实现 (使用DWT) 待确认 *********/ void delay_us(uint32_t us); /****** Trig 触发 You only need to supply a short 10uS pulse to the trigger input to start the ranging 尤其在周期性测距中,如果前一个测距周期残留了 Trig 为高电平,可能导致错误测距或模块死机。因此加上 HAL_GPIO_WritePin(..., RESET); HAL_Delay(); 是一种保险写法。 ******/ void HCSR04_Trigger(void); void ultrasonic_task_entry(ULONG thread_input); #endif