📄 ultrasound.h
字号:
#ifndef _Ultrasound_h_
#define _Ultrasound_h_
#define Open_Ultrasound DDRB|=_BV(P3) //开启超声波发射
#define Close_Ultrasound DDRB&=~_BV(P3) //关闭超声波发射
#define Start_T1 TCCR1B|=_BV(CS11);SFIOR|=_BV(PSR10)//复位预计分频器并开启定时器T1
#define Stop_T1 TCCR1B&=~_BV(CS11) //关闭定时器T1
#define Start_INT0 GIFR|=_BV(INTF0);GICR|=_BV(INT0) //清除中断位并开启外部中断
#define Stop_INT0 GICR&=~_BV(INT0) //关闭外部中断
float GetTemperature(void); //获取温度
float GetUltrasoundSpeed(void); //获取超声波速度
uint Calculate_Distant(void); //距离计算
uint GetImmediateDistance(void); //获得一个距离的方法
uint GetValuableDistant(void); //获得经过抽样判决的距离的方法
#define Sample 5 // 获取最优值所需要的采样次数
volatile ulong Valuable_Distance; //经过采样判决的距离最优值
volatile float Valuable_Speed; //当前测距超声波有效速度
volatile uchar Ultrasound_TimeOut_Flag; //超声波接收超时标志
volatile uchar Ultrasound_Receive_Flag; //超声波接收有效标志
volatile uchar Timer1_Counter_H;// T1 高位 用于超声波测距
volatile uchar Timer1_Counter_L;// T1 低位 用于超声波测距
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -