微型打印机的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();
}
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部0条评论
快来发表一下你的评论吧 !