timer.c

来自「j dadshafdsaf dfdsafdfdsafdsafdsfd」· C语言 代码 · 共 51 行

C
51
字号
/*
	FILENAME:		drivers/timer.c
	VERSION:		1.1.0.0
	AUTHOR:			Tony Huang (cnwzhjs@gmail.com)
	RELEASE DATE:	July 27, 2007
	DESCRIPTION:	The implement of the driver of internal timer
	MODIFICATION:	Aug 1, 2007
						ADD FUNCTION: drv_timer_istimeout()
						ADD FUNCTION: drv_timer_wait_jeff()
*/
#include <reg51.h>
#include "config.h"
#include "timer.h"

#ifdef DRIVER_TIMER

void drv_timer_init(
	BOOL t1_gate,
	BOOL t1_is_counter,
	unsigned char t1_mode,
	BOOL t0_gate,
	BOOL t0_is_counter,
	unsigned char t0_mode
) {
	unsigned char command = (t1_gate << 7)
						   |(t1_is_counter << 6)
						   |(t1_mode << 4)
						   |(t0_gate << 3)
						   |(t0_is_counter << 2)
						   |(t0_mode);
						   
	TMOD = command;
}

void drv_timer_enable(unsigned char n) {
	if(n) {
		TR1 = 1;
	} else {
		TR0 = 1;
	}	
}

void drv_timer_disable(unsigned char n) {
	if(n) {
		TR1 = 0;
	} else {
		TR0 = 0;
	}	
}

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?