📄 kisr.lst
字号:
165 =2
166 =2 /*------------------------------------------------
167 =2 IP Bit Registers
168 =2 ------------------------------------------------*/
169 =2 sbit PX0 = 0xB8;
170 =2 sbit PT0 = 0xB9;
171 =2 sbit PX1 = 0xBA;
172 =2 sbit PT1 = 0xBB;
173 =2 sbit PS = 0xBC;
174 =2 sbit PT2 = 0xBD;
175 =2
176 =2 /*------------------------------------------------
177 =2 T2CON Bit Registers
178 =2 ------------------------------------------------*/
179 =2 sbit CP_RL2= 0xC8; /* 0=Reload, 1=Capture select */
180 =2 sbit C_T2 = 0xC9; /* 0=Timer, 1=Counter */
181 =2 sbit TR2 = 0xCA; /* 0=Stop timer, 1=Start timer */
182 =2 sbit EXEN2= 0xCB; /* Timer 2 external enable */
183 =2 sbit TCLK = 0xCC; /* 0=Serial clock uses Timer 1 overflow, 1=Timer 2 */
184 =2 sbit RCLK = 0xCD; /* 0=Serial clock uses Timer 1 overflow, 1=Timer 2 */
185 =2 sbit EXF2 = 0xCE; /* Timer 2 external flag */
186 =2 sbit TF2 = 0xCF; /* Timer 2 overflow flag */
187 =2
188 =2 /*------------------------------------------------
189 =2 T2MOD Bit Values
190 =2 ------------------------------------------------*/
191 =2 #define DCEN_ 0x01 /* 1=Timer 2 can be configured as up/down counter */
192 =2 #define T2OE_ 0x02 /* Timer 2 output enable */
193 =2
194 =2 /*------------------------------------------------
195 =2 PSW Bit Registers
196 =2 ------------------------------------------------*/
197 =2 sbit P = 0xD0;
198 =2 sbit FL = 0xD1;
199 =2 sbit OV = 0xD2;
C51 COMPILER V7.06 KISR 11/11/2003 20:11:03 PAGE 6
200 =2 sbit RS0 = 0xD3;
201 =2 sbit RS1 = 0xD4;
202 =2 sbit F0 = 0xD5;
203 =2 sbit AC = 0xD6;
204 =2 sbit CY = 0xD7;
205 =2
206 =2 /*------------------------------------------------
207 =2 Interrupt Vectors:
208 =2 Interrupt Address = (Number * 8) + 3
209 =2 ------------------------------------------------*/
210 =2 #define IE0_VECTOR 0 /* 0x03 External Interrupt 0 */
211 =2 #define TF0_VECTOR 1 /* 0x0B Timer 0 */
212 =2 #define IE1_VECTOR 2 /* 0x13 External Interrupt 1 */
213 =2 #define TF1_VECTOR 3 /* 0x1B Timer 1 */
214 =2 #define SIO_VECTOR 4 /* 0x23 Serial port */
215 =2
216 =2 #define TF2_VECTOR 5 /* 0x2B Timer 2 */
217 =2 #define EX2_VECTOR 5 /* 0x2B External Interrupt 2 */
218 =2
219 =2 #endif
220 =2
221 =2
2 =1
3 =1 #define EPP_PORT P1
4 =1 #define DATA_BUS P0
5 =1
6 =1 sbit MCU_SWM0 = P1^0;
7 =1 sbit MCU_SWM1 = P1^1;
8 =1 sbit MCU_LED0 = P1^2;
9 =1 sbit MCU_LED1 = P1^3;
10 =1
11 =1 sbit MCU_D12CS = P1^6;
12 =1 sbit MCU_D12RST = P1^7;
13 =1
14 =1 sbit D12SUSPD = P3^3;
15 =1
16 =1 #define DISABLE EA=0
17 =1 #define ENABLE EA=1
18 =1
6 #include "kd12ci.h"
1 =1 #define D12_NOLAZYCLOCK 0x02
2 =1 #define D12_CLOCKRUNNING 0x04
3 =1 #define D12_INTERRUPTMODE 0x08
4 =1 #define D12_SOFTCONNECT 0x10
5 =1 #define D12_ENDP_NONISO 0x00
6 =1 #define D12_ENDP_ISOOUT 0x40
7 =1 #define D12_ENDP_ISOIN 0x80
8 =1 #define D12_ENDP_ISOIO 0xC0
9 =1
10 =1 #define D12_CLOCK_12M 0x03
11 =1 #define D12_CLOCK_4M 0x0b
12 =1 #define D12_SETTOONE 0x40
13 =1 #define D12_SOFONLY 0x80
14 =1
15 =1 #define D12_DMASINGLE 0x00
16 =1 #define D12_BURST_4 0x01
17 =1 #define D12_BURST_8 0x02
18 =1 #define D12_BURST_16 0x03
19 =1 #define D12_DMAENABLE 0x04
20 =1 #define D12_DMA_INTOKEN 0x08
21 =1 #define D12_AUTOLOAD 0x10
22 =1
C51 COMPILER V7.06 KISR 11/11/2003 20:11:03 PAGE 7
23 =1 //==============================================
24 =1 #define D12_NORMALPLUSSOF 0x20
25 =1 #define D12_ENDP4INTENABLE 0x40
26 =1 #define D12_ENDP5INTENABLE 0x80 // bug fixed in V2.1
27 =1
28 =1 #define D12_INT_ENDP0OUT 0x01
29 =1 #define D12_INT_ENDP0IN 0x02
30 =1 #define D12_INT_ENDP1OUT 0x04
31 =1 #define D12_INT_ENDP1IN 0x08
32 =1 #define D12_INT_ENDP2OUT 0x10
33 =1 #define D12_INT_ENDP2IN 0x20
34 =1 #define D12_INT_BUSRESET 0x40
35 =1 #define D12_INT_SUSPENDCHANGE 0x80
36 =1 #define D12_INT_EOT 0x0100
37 =1
38 =1 #define D12_SETUPPACKET 0x20
39 =1
40 =1 #define D12_BUFFER0FULL 0x20
41 =1 #define D12_BUFFER1FULL 0x40
42 =1
43 =1 #define D12_FULLEMPTY 0x01
44 =1 #define D12_STALL 0x02
45 =1
46 =1
47 =1 //#define D12_COMMAND XBYTE[0xFF03]
48 =1 //#define D12_DATA XBYTE[0xFF02]
49 =1 #define D12_COMMAND 0x0ff03
50 =1 #define D12_DATA 0x0ff02
51 =1
52 =1 //-----------------------------------------------------
53 =1 void D12_SetEndpointEnable(unsigned char bEnable);
54 =1 void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable);void D12_SetAddressEnable(unsigne
-d char bAddress, unsigned char bEnable);void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable);
55 =1 void D12_SetMode(unsigned char bConfig, unsigned char bClkDiv);
56 =1 void D12_SetDMA(unsigned char bMode);
57 =1 unsigned char D12_GetDMA(void);
58 =1 unsigned short D12_ReadInterruptRegister(void);
59 =1 unsigned char D12_SelectEndpoint(unsigned char bEndp);
60 =1 unsigned char D12_ReadLastTransactionStatus(unsigned char bEndp);
61 =1 unsigned char D12_ReadEndpointStatus(unsigned char bEndp);
62 =1 void D12_SetEndpointStatus(unsigned char bEndp, unsigned char bStalled);
63 =1 void D12_SendResume(void);
64 =1
65 =1 unsigned char D12_ReadEndpoint(unsigned char endp, unsigned char len, unsigned char * buf);
66 =1 unsigned char D12_WriteEndpoint(unsigned char endp, unsigned char len, unsigned char * buf);
67 =1 void D12_AcknowledgeEndpoint(unsigned char endp);
68 =1
69 =1
70 =1
7 #include "kmain.h"
1 =1 /*
2 =1 //*************************************************************************
3 =1 // basic #defines
4 =1 //*************************************************************************
5 =1 */
6 =1 #define MAX_ENDPOINTS (unsigned char)0x3
7 =1
8 =1 //#define EP0_TX_FIFO_SIZE 16
9 =1 //#define EP0_RX_FIFO_SIZE 16
10 =1 #define EP0_PACKET_SIZE 16
11 =1
12 =1 //#define EP1_TX_FIFO_SIZE 4
C51 COMPILER V7.06 KISR 11/11/2003 20:11:03 PAGE 8
13 =1 //#define EP1_RX_FIFO_SIZE 4
14 =1 #define EP1_PACKET_SIZE 4
15 =1
16 =1 //#define EP2_TX_FIFO_SIZE 64
17 =1 //#define EP2_RX_FIFO_SIZE 64
18 =1 #define EP2_PACKET_SIZE 64
19 =1
20 =1
21 =1 #define USB_IDLE 0
22 =1 #define USB_TRANSMIT 1
23 =1 #define USB_RECEIVE 2
24 =1
25 =1 #define USB_CLASS_CODE_TEST_CLASS_DEVICE 0xdc
26 =1 #define USB_SUBCLASS_CODE_TEST_CLASS_D12 0xA0
27 =1 #define USB_PROTOCOL_CODE_TEST_CLASS_D12 0xB0
28 =1
29 =1 /*
30 =1 //*************************************************************************
31 =1 // masks
32 =1 //*************************************************************************
33 =1 */
34 =1
35 =1 #define USB_RECIPIENT (unsigned char)0x1F
36 =1 #define USB_RECIPIENT_DEVICE (unsigned char)0x00
37 =1 #define USB_RECIPIENT_INTERFACE (unsigned char)0x01
38 =1 #define USB_RECIPIENT_ENDPOINT (unsigned char)0x02
39 =1
40 =1 #define USB_REQUEST_TYPE_MASK (unsigned char)0x60
41 =1 #define USB_STANDARD_REQUEST (unsigned char)0x00
42 =1 //#define USB_CLASS_REQUEST (unsigned char)0x20
43 =1 #define USB_VENDOR_REQUEST (unsigned char)0x40
44 =1
45 =1 #define USB_REQUEST_MASK (unsigned char)0x0F
46 =1
47 =1 #define DEVICE_ADDRESS_MASK 0x7F
48 =1
49 =1 /*
50 =1 //*************************************************************************
51 =1 // macros
52 =1 //*************************************************************************
53 =1 */
54 =1 #define SWAP(x) ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
55 =1
56 =1 #define MSB(x) (((x) >> 8) & 0xFF)
57 =1 #define LSB(x) ((x) & 0xFF)
58 =1
59 =1 #define FALSE 0
60 =1 #define TRUE (!FALSE)
61 =1
62 =1 /*
63 =1 //*************************************************************************
64 =1 // basic typedefs
65 =1 //*************************************************************************
66 =1 */
67 =1 typedef unsigned char UCHAR;
68 =1 typedef unsigned short USHORT;
69 =1 typedef unsigned long ULONG;
70 =1 typedef unsigned char BOOL;
71 =1
72 =1 /*
73 =1 //*************************************************************************
74 =1 // structure and union definitions
C51 COMPILER V7.06 KISR 11/11/2003 20:11:03 PAGE 9
75 =1 //*************************************************************************
76 =1 */
77 =1 typedef union _epp_flags
78 =1 {
79 =1 struct _flags
80 =1 {
81 =1 unsigned char timer : 1;
82 =1 unsigned char bus_reset : 1;
83 =1 unsigned char suspend : 1;
84 =1 unsigned char setup_packet : 1;
85 =1 unsigned char remote_wakeup : 1;
86 =1 unsigned char in_isr : 1;
87 =1 unsigned char control_state : 2;
88 =1
89 =1 unsigned char configuration : 1;
90 =1 unsigned char verbose : 1;
91 =1 unsigned char ep1_rxdone : 1;
92 =1 unsigned char setup_dma : 2; // V2.3
93 =1 unsigned char dma_state : 2;
94 =1 unsigned char power_down : 1; // Smart Board
95 =1 } bits;
96 =1 unsigned short value;
97 =1 } EPPFLAGS;
98 =1
99 =1 typedef struct _device_request
100 =1 {
101 =1 unsigned char bmRequestType;
102 =1 unsigned char bRequest;
103 =1 unsigned short wValue;
104 =1 unsigned short wIndex;
105 =1 unsigned short wLength;
106 =1 } DEVICE_REQUEST;
107 =1
108 =1 typedef struct _IO_REQUEST {
109 =1 unsigned short uAddressL;
110 =1 unsigned char bAddressH;
111 =1 unsigned short uSize;
112 =1 unsigned char bCommand;
113 =1 } IO_REQUEST, *PIO_REQUEST;
114 =1
115 =1 #define MAX_CONTROLDATA_SIZE 8
116 =1
117 =1 typedef struct _control_xfer
118 =1 {
119 =1 DEVICE_REQUEST DeviceRequest;
120 =1 unsigned short wLength;
121 =1 unsigned short wCount;
122 =1 unsigned char * pData;
123 =1 unsigned char dataBuffer[MAX_CONTROLDATA_SIZE];
124 =1 } CONTROL_XFER;
125 =1
126 =1 /*
127 =1 //*************************************************************************
128 =1 // USB utility functions
129 =1 //*************************************************************************
130 =1 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -