电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

c语言串口通信范例

c语言串口通信范例_第1页
1/13
c语言串口通信范例_第2页
2/13
c语言串口通信范例_第3页
3/13
一个 c 语言的串口通信程序范例标签:分类:技术笔记c 语言串口通信通信程序it最近接触一个项目,用 HL-C1C 激光位移传感器+易控组态软件完成生产线高度跳变检测,好久没有接触 cc#,一些资料,找来做个记录,也许大家用的着#include#include#include#include#defineCOM2320x2f8#defineCOMINT0x0b#defineMaxBufLen500#definePort82590x20#defineEofInt0x20staticintcomportaddr;staticcharintvectnum;staticunsignedcharmaskb;staticunsignedcharBuffer[MaxBufLen];staticintCharsInBuf,CircIn,CircOut;staticvoid(interruptfar*OldAsyncInt)();outp(ComPortAddr+4,0x0a);staticvoidinterruptfarAsyncInt(void);voidInit_COM(intComPortAddr,unsignedcharIntVectNum,intBaud,unsignedcharData,unsignedcharStop,unsignedcharParity){unsignedcharHigh,Low;intf;comportaddr=ComPortAddr;intvectnum=IntVectNum;CharsInBuf=0;CircIn=0;CircOut=0;f=(Baud/100);f=1152/f;High=f/256;Low=f-High*256;outp(ComPortAddr+3,0x80);outp(ComPortAddr,Low);outp(ComPortAddr+1,High);Data=(Data-5)|((Stop-1)*4);if(Parity==2)Data=Data|0x18;elseif(Parity==1)Data=Data|0x8;outp(ComPortAddr+3,Data);outp(ComPortAddr+1,0x01);outp(ComPortAddr+4,0x0a);disable();OldAsyncInt=getvect(IntVectNum);setvect(IntVectNum,AsyncInt);enable();maskb=inp(Port8259+1);if(IntVectNum==0x0c)outp(Port8259+1,maskb&0xef);elseoutp(Port8259+1,maskb&0xf7);}staticvoidinterruptfarAsyncInt(void){disable();if(CharsInBuf0){(*Char)=Buffer[CircOut];if(CircOut

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

c语言串口通信范例

确认删除?
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群