这是一个周界报警的报警控制程序,采用89C52芯片,KEIL 51开发!
源代码在线查看: input.c
//scan the Alarm input
#include "reg52.h"
#include "main.h"
unsigned char data in_buf = 0;
unsigned char data i;
unsigned char data in_status = 0;
unsigned char data P0_status;
extern P0_buf;
extern P2_buf;
extern bit Ysd_flag;
extern void delay50us(unsigned char count);
extern void input(void)
{
LE = 0;
for(i=0;i {
P0 = 0xFF & (0xFF-i);
delay50us(1);
if(com_input == 0)
{
in_status = 0x01 P0_buf = P0_buf | in_status;
}
else
{
in_status = 0x01 in_status = ~in_status;
P0_buf = P0_buf & in_status;
}
}
delay50us(1);
P0 = ~P0_buf;
P2_buf = P0_buf;
P0_buf = P0;
LE = 1;
}