|
最近在研究做一个关于超声波测距的小demo,亲测,好用(非常准)- void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
- {
- if(GPIO_Pin == GPIO_PIN_5)
- {
- if(HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_5) == 1)
- {
- TIM1->CNT = 0;Count_Up = 0;
- }
- if(HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_5) == 0)
- {
- Count = TIM1->CNT;
- Time = (Count_Up*65536+Count)*0.017;
- printf("%d cm\n",Time);
- }
- }
- }
复制代码
|
评分
-
查看全部评分
|