微型打印机的C语言源程序:微型打印机的C51源程序#define uchar unsigned char#define uint unsigned int#include
#include #include #include #include #include #include #define PIN XBYTE[0x8000]#define POUT XBYTE[0x9000]sbit PRINTSTB =P1^6;sbit DOG=P1^7;bdata char pin&#118alue;sbit PRINTBUSY=pin&#118alue^7;sbit PRINTSEL =pin&#118alue^6;sbit PRINTERR =pin&#118alue^5;sbit PRINTACK =pin&#118alue^4; void PrintString(uchar *String1,uchar *String2);void initprint(void);void print(uchar a); void initprint(void) //打印机初始化子程序 { pin&#118alue=PIN; if((PRINTSEL==1)&&(PRINTERR==1)) { print(0x1b); print(0x40); print(0x1b); print(0x38); print(0x4); }}void print(uchar a) //打印字符a{ pin&#118alue=PIN; if((PRINTSEL==0)||(PRINTERR==0)) return; for(;;) { DOG=~DOG; pin&#118alue=PIN; if(PRINTBUSY==0) break; } DOG=~DOG; POUT=a; PRINTSTB=1; PRINTSTB=1; PRINTSTB=1; PRINTSTB=1; PRINTSTB=0; PRINTSTB=0; PRINTSTB=0; PRINTSTB=0; PRINTSTB=1;}void PrintString(uchar *String) //打印字符串后回车{ uchar CH; for (;;) { DOG=~DOG; CH=*String; if (CH==0) { print(0x0d); break; } print(CH); String++; } initprint();}