sensor.c.svn-base

来自「AVR单片机下」· SVN-BASE 代码 · 共 56 行

SVN-BASE
56
字号
/*                ****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 + =
减小字号Ctrl + -
显示快捷键?