#include #include #include #include #include #define RELAY2 P01 #define RELAY1 P13 #define IN1 P05 #define IN2 P15 #define MAXCMD 64 unsigned char crc; unsigned char getchar1(void) { UINT8 c; while (!RI); c = SBUF; RI = 0; return (c); } int putchar1 (unsigned char c) { crc += c; TI = 0; SBUF = c; while(TI==0); return 0; } void sendpkt(unsigned char cmd, unsigned int len, unsigned char *buffer) { unsigned int i; crc = 0; putchar1(0x55); putchar1(0xAA); putchar1(0x03); putchar1(cmd); putchar1(len >> 8); putchar1(len & 0xFF); for (i=0; i