📄 timer.c
字号:
/*
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -