📄 ch375prt.lst
字号:
C51 COMPILER V6.12 CH375PRT 07/10/2006 13:52:42 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE CH375PRT
OBJECT MODULE PLACED IN .\CH375PRT.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\CH375PRT.C DEBUG OBJECTEXTEND
stmt level source
1 /* 2004.03.05, 2004.8.18, 2005.12.29
2 ****************************************
3 ** Copyright (C) W.ch 1999-2005 **
4 ** Web: http://www.winchiphead.com **
5 ****************************************
6 ** USB 1.1 Host Examples for CH375 **
7 ** KC7.0@MCS-51 **
8 ****************************************
9 */
10 /* 单片机通过CH375控制USB打印机 */
11 /* 程序示例,C语言,CH375中断为查询方式,只负责数据传输,不涉及打印格式及打印描述语言 */
12 /* 另可提供多台计算机共享一台USB打印机的方案 */
13
14 /* 以下定义适用于MCS-51单片机,其它单片机参照修改,为了提供C语言的速度需要对本程序进行优化 */
15 #include <reg52.h>
16 #include<intrins.h>
17 #include <string.h>
18 #include <stdio.h>
19
20
21
22 unsigned char volatile xdata CH375_CMD_PORT _at_ 0x7fff; /* CH375命令端口的I/O地址 */
23 unsigned char volatile xdata CH375_DAT_PORT _at_ 0x3fff; /* CH375数据端口的I/O地址 */
24 sbit CH375_INT_WIRE = 0xB0^2; /* P3.2, INT0, 连接CH375的INT#引脚,用于查询中断状态 */
25 typedef unsigned char BOOL1; /* typedef bit BOOL1; */
26
27 #include"tu.h"
28 /* 定义CH375命令代码及返回状态 */
29 #include "CH375INC.H"
30
31
32 #define dot 0x2e
33 #define hpstart 0x1b
34 #define true 1
35 #define false 0
36
37
38 sbit SDA=P1^2;
39 sbit SCL=P1^3;
40 sbit led1=P2^0;
41 sbit led2=P2^1;
42
43
44
45 sfr t2mod=0xc9;
46 sfr sbuf1=0xc1;
47 sfr scon1=0xc0;
48 sfr scon0=0x98;
49 sfr rcap2h=0xcb;
50 sfr rcap2l=0xca;
51 sfr t2con=0xc8;
52 sfr CKCON=0x8E;
53 sfr EIE=0xE8;
54 sfr TA=0xC7;
55 sfr WDCON=0xD8;
C51 COMPILER V6.12 CH375PRT 07/10/2006 13:52:42 PAGE 2
56 sfr PMR=0xC4;
57 sfr DPH1=0x85;
58 sfr DPL1=0x84;
59 sbit ti_1=scon1^1;
60 sbit ri_1=scon1^0;
61 sbit tr2=t2con^2;
62 sbit es1=IE^6;// ; 有效电平
63
64
65
66
67 typedef unsigned char UCHAR;
68 typedef unsigned int UINT;
69 typedef unsigned short USHORT;
70
71 UCHAR data1,data2,data3,data4;
72 UCHAR date[7]; //日期数组
73 /*date[0]=year,date[1]=month,date[2]=day,date[3]=week,
74 date[4]=hour,date[5]=minute,date[6]=second*/
75
76 void I2CReadDate();
77 void SendTime();
78 void I2CWriteTime();
79 void I2CWriteStatus();
80
81 typedef struct _USB_DEVICE_DESCRIPTOR {
82 UCHAR bLength;
83 UCHAR bDescriptorType;
84 USHORT bcdUSB;
85 UCHAR bDeviceClass;
86 UCHAR bDeviceSubClass;
87 UCHAR bDeviceProtocol;
88 UCHAR bMaxPacketSize0;
89 USHORT idVendor;
90 USHORT idProduct;
91 USHORT bcdDevice;
92 UCHAR iManufacturer;
93 UCHAR iProduct;
94 UCHAR iSerialNumber;
95 UCHAR bNumConfigurations;
96 } USB_DEV_DESCR, *PUSB_DEV_DESCR;
97
98 typedef struct _USB_CONFIG_DESCRIPTOR {
99 UCHAR bLength;
100 UCHAR bDescriptorType;
101 USHORT wTotalLength;
102 UCHAR bNumInterfaces;
103 UCHAR bConfigurationValue;
104 UCHAR iConfiguration;
105 UCHAR bmAttributes;
106 UCHAR MaxPower;
107 } USB_CFG_DESCR, *PUSB_CFG_DESCR;
108
109 typedef struct _USB_INTERF_DESCRIPTOR {
110 UCHAR bLength;
111 UCHAR bDescriptorType;
112 UCHAR bInterfaceNumber;
113 UCHAR bAlternateSetting;
114 UCHAR bNumEndpoints;
115 UCHAR bInterfaceClass;
116 UCHAR bInterfaceSubClass;
117 UCHAR bInterfaceProtocol;
C51 COMPILER V6.12 CH375PRT 07/10/2006 13:52:42 PAGE 3
118 UCHAR iInterface;
119 } USB_ITF_DESCR, *PUSB_ITF_DESCR;
120
121 typedef struct _USB_ENDPOINT_DESCRIPTOR {
122 UCHAR bLength;
123 UCHAR bDescriptorType;
124 UCHAR bEndpointAddress;
125 UCHAR bmAttributes;
126 UCHAR wMaxPacketSize;
127 UCHAR wMaxPacketSize1;
128 UCHAR bInterval;
129 } USB_ENDP_DESCR, *PUSB_ENDP_DESCR;
130
131 typedef struct _USB_CONFIG_DESCRIPTOR_LONG {
132 USB_CFG_DESCR cfg_descr;
133 USB_ITF_DESCR itf_descr;
134 USB_ENDP_DESCR endp_descr[4];
135 } USB_CFG_DESCR_LONG, *PUSB_CFG_DESCR_LONG;
136
137
138 unsigned char idata buffer[124]; /* 公用缓冲区 100~154用于接收串口数据*/
139
140
141 unsigned int RecvCount,RecvStart,RecvFlage=0;
142
143 /*120cm-210cm,水标准范围值,小值在前,大值在后*/
144 unsigned char code twb_m[]={
145 0x01,0x24,0x01,0x51,0x01,0x26,0x01,0x54,0x01,0x29,0x01,0x57,0x01,0x31,0x01,0x60,0x01,0x34,0x01,0x64,//100
-~104
146 0x01,0x36,0x01,0x67,0x01,0x39,0x01,0x70,0x01,0x42,0x01,0x73,0x01,0x44,0x01,0x76,0x01,0x47,0x01,0x80,//105
-~109
147 0x01,0x50,0x01,0x83,0x01,0x52,0x01,0x86,0x01,0x55,0x01,0x90,0x01,0x58,0x01,0x93,0x01,0x61,0x01,0x96,//110
-~114
148 0x01,0x64,0x02,0x00,0x01,0x66,0x02,0x03,0x01,0x69,0x02,0x07,0x01,0x72,0x02,0x11,0x01,0x75,0x02,0x14,//110
-~119
149 0x01,0x78,0x02,0x18,0x01,0x81,0x02,0x21,0x01,0x84,0x02,0x25,0x01,0x87,0x02,0x29,0x01,0x90,0x02,0x32,//120
-~124
150 0x01,0x93,0x02,0x36,0x01,0x96,0x02,0x40,0x02,0x00,0x02,0x44,0x02,0x03,0x02,0x48,0x02,0x06,0x02,0x52,//125
-~129
151 0x02,0x09,0x02,0x56,0x02,0x12,0x02,0x59,0x02,0x16,0x02,0x63,0x02,0x19,0x02,0x67,0x02,0x22,0x02,0x71,//130
-~134
152 0x02,0x25,0x02,0x76,0x02,0x29,0x02,0x80,0x02,0x32,0x02,0x84,0x02,0x36,0x02,0x88,0x02,0x39,0x02,0x92,//135
-~139
153 0x02,0x42,0x02,0x96,0x02,0x46,0x03,0x01,0x02,0x49,0x03,0x05,0x02,0x53,0x03,0x09,0x02,0x57,0x03,0x14,//140
-~144
154 0x02,0x60,0x03,0x18,0x02,0x64,0x03,0x22,0x02,0x67,0x03,0x27,0x02,0x71,0x03,0x31,0x02,0x75,0x03,0x36,//145
-~149
155 0x02,0x78,0x03,0x40,0x02,0x82,0x03,0x45,0x02,0x86,0x03,0x49,0x02,0x90,0x03,0x54,0x02,0x93,0x03,0x59,//150
-~154
156 0x02,0x97,0x03,0x63,0x03,0x01,0x03,0x68,0x03,0x05,0x03,0x73,0x03,0x09,0x03,0x77,0x03,0x13,0x03,0x82,//155
-~159
157 0x03,0x17,0x03,0x87,0x03,0x21,0x03,0x92,0x03,0x25,0x03,0x97,0x03,0x29,0x04,0x02,0x03,0x33,0x04,0x07,//160
-~164
158 0x03,0x37,0x04,0x12,0x03,0x41,0x04,0x17,0x03,0x45,0x04,0x22,0x03,0x49,0x04,0x27,0x03,0x53,0x04,0x32,//165
-~169
159 0x03,0x57,0x04,0x37,0x03,0x62,0x04,0x42,0x03,0x66,0x04,0x47,0x03,0x70,0x04,0x52,0x03,0x75,0x04,0x58,//170
-~174
160 0x03,0x79,0x04,0x63,0x03,0x83,0x04,0x68,0x03,0x88,0x04,0x74,0x03,0x92,0x04,0x79,0x03,0x96,0x04,0x84,//175
-~179
161 0x04,0x01,0x04,0x90,0x04,0x05,0x04,0x95,0x04,0x10,0x05,0x01,0x04,0x14,0x05,0x06,0x04,0x19,0x05,0x12,//180
-~184
162 0x04,0x23,0x05,0x17,0x04,0x28,0x05,0x23,0x04,0x33,0x05,0x29,0x04,0x37,0x05,0x34,0x04,0x42,0x05,0x40,//185
C51 COMPILER V6.12 CH375PRT 07/10/2006 13:52:42 PAGE 4
-~189
163 0x04,0x47,0x05,0x46,0x04,0x51,0x05,0x52,0x04,0x56,0x05,0x57,0x04,0x61,0x05,0x63,0x04,0x66,0x05,0x69,//190
-~194
164 0x04,0x70,0x05,0x75,0x04,0x75,0x05,0x81,0x04,0x80,0x05,0x87,0x04,0x85,0x05,0x93,0x04,0x90,0x05,0x99,//195
-~199
165 0x04,0x95,0x06,0x05,//200cm~
166 };
167 unsigned char code twb_f[]={
168 0x01,0x07,0x01,0x31,0x01,0x09,0x01,0x33,0x01,0x11,0x01,0x36,0x01,0x13,0x01,0x39,0x01,0x16,0x01,0x41,//
-100~104
169 0x01,0x18,0x01,0x44,0x01,0x20,0x01,0x47,0x01,0x22,0x01,0x50,0x01,0x25,0x01,0x52,0x01,0x27,0x01,0x55,//
-105~109
170 0x01,0x29,0x01,0x58,0x01,0x32,0x01,0x61,0x01,0x34,0x01,0x64,0x01,0x37,0x01,0x67,0x01,0x39,0x01,0x70,//
-110~114
171 0x01,0x41,0x01,0x73,0x01,0x44,0x01,0x76,0x01,0x46,0x01,0x79,0x01,0x49,0x01,0x82,0x01,0x51,0x01,0x85,//
-115~119
172 0x01,0x54,0x01,0x88,0x01,0x57,0x01,0x91,0x01,0x59,0x01,0x95,0x01,0x62,0x01,0x98,0x01,0x64,0x02,0x01,//
-120~124
173 0x01,0x67,0x02,0x04,0x01,0x70,0x02,0x08,0x01,0x73,0x02,0x11,0x01,0x75,0x02,0x14,0x01,0x78,0x02,0x18,//
-125~129
174 0x01,0x81,0x02,0x21,0x01,0x84,0x02,0x24,0x01,0x86,0x02,0x28,0x01,0x89,0x02,0x31,0x01,0x92,0x02,0x35,//
-130~134
175 0x01,0x95,0x02,0x38,0x01,0x98,0x02,0x42,0x02,0x01,0x02,0x45,0x02,0x04,0x02,0x49,0x02,0x07,0x02,0x53,//
-135~139
176 0x02,0x10,0x02,0x56,0x02,0x13,0x02,0x60,0x02,0x16,0x02,0x64,0x02,0x19,0x02,0x67,0x02,0x22,0x02,0x71,//
-140~144
177 0x02,0x25,0x02,0x75,0x02,0x28,0x02,0x79,0x02,0x31,0x02,0x83,0x02,0x34,0x02,0x86,0x02,0x37,0x02,0x90,//
-145~149
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -