C语言串口通信-源代码
int outcount=0; void interrupt(*vect_com)(...); void putb(unsigned char ch)//write a char to the recvbuf 将中断得到的数据写到缓冲区 { int temp; temp=buffin; if(++buffin==BUFFLEN) buffin=0; if(buffin!=buffout) {buffer[buffin]=ch; // printf("bufferin[%d]=%c",buffer[buffin]); // getch(); } else buffin=temp; }; unsigned char getb()//read a char from the recvbuf { if(buffout!=buffin) { if(++buffout==BUFFLEN) buffout=0; //printf("bufferout[%d]=%c",buffout,buffer[buffout]); return(buffer[buffout]); } else return(0xff); }; /*unsigned char sender( unsigned char ch) { outportb(portaddr2+TXD,ch); printf("\nsender outportdata=%c\n",ch); outcount++; return(1); }; */ void interrupt receiver(...) { unsigned char ch; ch=inportb(portaddr+RXD); putb(ch); incount++; //记录接收了多少个数据。 outportb(ICREG,EOI);
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库C语言串口通信-源代码(5)在线全文阅读。
相关推荐: