📄 sensor.c.svn-base
字号:
/* ****ROBOCON 2009 | BUPT TEAM******* * ------------------------------------------------------------------------ * FileName : sensor.c * Version : 1.0 * Brief : * Code by : Leaf * Date : Tue Mar 31 00:05:13 2009 * Note : * * * ------------------------------------------------------------------------ */
#include "lib_bupt.h"
#ifdef SENSOR_H_INCLUDED
static UINT8 judgeTimes = 4;void setJudgeTimes( UINT8 t){ judgeTimes = t;}/* * 1ms采样一次,采样若干次,若这几次都为所需,则判断成功, 之所以时间控制器要用传入参数,是为了维持可重入性 *//*所需的是低电平*/
Bool judgeSensorLow(volatile UINT8 *p, UINT8 b, pTimerControlBlock tmr){
UINT8 i;
Bool res = True;
for(i = 0; i < judgeTimes; ++i){
if(bit_is_set(*p, b)){
res = False; break;
}
AvrXDelay(tmr, 1);
}
return res;
}
/*所需的是高电平*/
Bool judgeSensorHigh(volatile UINT8 *p, UINT8 b, pTimerControlBlock tmr){
UINT8 i;
Bool res = True;
for(i = 0; i < judgeTimes; ++i){
if(bit_is_clear(*p, b)){
res = False;
break;
}
AvrXDelay(tmr, 1);
}
return res;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -