📄 protodma.lst
字号:
60 =1 sbit MCU_WHICH_PW = P2^3;
61 =1 sbit MCU_DMARD_WR = P2^4;
62 =1 sbit MCU_SWM1 = P2^5;
63 =1 sbit MCU_SWM2 = P2^6;
64 =1 sbit MCU_ALE1 = P2^7;
65 =1
66 =1 sbit EPP_WRITE = P1^0;
67 =1 sbit EPP_DSTROBE = P1^1;
68 =1 sbit EPP_ASTROBE = P1^2;
69 =1 sbit EPP_WAIT = P1^3;
70 =1 sbit EPP_INTR = P1^4;
71 =1 sbit EPP_PE = P1^5;
72 =1 sbit EPP_ERROR = P1^6;
73 =1 sbit EPP_SELECT = P1^7;
74 =1
75 =1 sbit MCU_LED0 = P3^4;
76 =1 sbit MCU_LED1 = P3^5;
77 =1
78 =1 #define DISABLE EA=0
79 =1 #define ENABLE EA=1
80 =1
81 =1 void outportb(unsigned char port, unsigned char val);
82 =1 unsigned char inportb(unsigned char port);
83 =1
84 =1 #endif
85 =1
86 =1 #endif
24 #else
#include <dos.h>
#endif
27
28 #include "d12ci.h"
1 =1 /*
C51 COMPILER V8.02 PROTODMA 07/27/2007 11:10:49 PAGE 6
2 =1 //*************************************************************************
3 =1 //
4 =1 // P H I L I P S P R O P R I E T A R Y
5 =1 //
6 =1 // COPYRIGHT (c) 1997 BY PHILIPS SINGAPORE.
7 =1 // -- ALL RIGHTS RESERVED --
8 =1 //
9 =1 // File Name: D12CI.H
10 =1 // Author: Wenkai Du
11 =1 // Created: 8 Jun 98
12 =1 // Modified:
13 =1 // Revision: 2.2
14 =1 //
15 =1 //*************************************************************************
16 =1 //
17 =1 // 98/11/26 Bug fix: D12_ENDP5INTENABLE (WK)
18 =1 // 98/12/2 Added D12_ReadMainEndpoint to support double buffer (WK)
19 =1 //*************************************************************************
20 =1 */
21 =1 #ifndef __D12CI_H__
22 =1 #define __D12CI_H__
23 =1
24 =1 #define D12_NOLAZYCLOCK 0x02
25 =1 #define D12_CLOCKRUNNING 0x04
26 =1 #define D12_INTERRUPTMODE 0x08
27 =1 #define D12_SOFTCONNECT 0x10
28 =1 #define D12_ENDP_NONISO 0x00
29 =1 #define D12_ENDP_ISOOUT 0x40
30 =1 #define D12_ENDP_ISOIN 0x80
31 =1 #define D12_ENDP_ISOIO 0xC0
32 =1
33 =1 #define D12_CLOCK_12M 0x03
34 =1 #define D12_CLOCK_4M 0x0b
35 =1 #define D12_SETTOONE 0x40
36 =1 #define D12_SOFONLY 0x80
37 =1
38 =1 #define D12_DMASINGLE 0x00
39 =1 #define D12_BURST_4 0x01
40 =1 #define D12_BURST_8 0x02
41 =1 #define D12_BURST_16 0x03
42 =1 #define D12_DMAENABLE 0x04
43 =1 #define D12_DMA_INTOKEN 0x08
44 =1 #define D12_AUTOLOAD 0x10
45 =1 #define D12_NORMALPLUSSOF 0x20
46 =1 #define D12_ENDP4INTENABLE 0x40
47 =1 #define D12_ENDP5INTENABLE 0x80 // bug fixed in V2.1
48 =1
49 =1 #define D12_INT_ENDP0OUT 0x01
50 =1 #define D12_INT_ENDP0IN 0x02
51 =1 #define D12_INT_ENDP1OUT 0x04
52 =1 #define D12_INT_ENDP1IN 0x08
53 =1 #define D12_INT_ENDP2OUT 0x10
54 =1 #define D12_INT_ENDP2IN 0x20
55 =1 #define D12_INT_BUSRESET 0x40
56 =1 #define D12_INT_SUSPENDCHANGE 0x80
57 =1 #define D12_INT_EOT 0x0100
58 =1
59 =1 #define D12_SETUPPACKET 0x20
60 =1
61 =1 #define D12_BUFFER0FULL 0x20
62 =1 #define D12_BUFFER1FULL 0x40
63 =1
C51 COMPILER V8.02 PROTODMA 07/27/2007 11:10:49 PAGE 7
64 =1 #define D12_FULLEMPTY 0x01
65 =1 #define D12_STALL 0x02
66 =1
67 =1 void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable);
68 =1 void D12_SetEndpointEnable(unsigned char bEnable);
69 =1 void D12_SetMode(unsigned char bConfig, unsigned char bClkDiv);
70 =1 void D12_SetDMA(unsigned char bMode);
71 =1 unsigned short D12_ReadInterruptRegister(void);
72 =1 unsigned char D12_SelectEndpoint(unsigned char bEndp);
73 =1 unsigned char D12_ReadLastTransactionStatus(unsigned char bEndp);
74 =1 unsigned char D12_ReadEndpointStatus(unsigned char bEndp);
75 =1 void D12_SetEndpointStatus(unsigned char bEndp, unsigned char bStalled);
76 =1 void D12_SendResume(void);
77 =1 unsigned short D12_ReadCurrentFrameNumber(void);
78 =1 unsigned short D12_ReadChipID(void);
79 =1
80 =1 unsigned char D12_ReadEndpoint(unsigned char endp, unsigned char * buf, unsigned char len);
81 =1 unsigned char D12_WriteEndpoint(unsigned char endp, unsigned char * buf, unsigned char len);
82 =1 void D12_AcknowledgeEndpoint(unsigned char endp);
83 =1
84 =1 unsigned char D12_ReadMainEndpoint(unsigned char * buf); // V2.2
85 =1
86 =1 unsigned char D12Eval_inportb(void);
87 =1 void D12Eval_outportb(unsigned char val, unsigned char mask);
88 =1
89 =1 #endif
29 #include "mainloop.h"
1 =1 /*
2 =1 //*************************************************************************
3 =1 //
4 =1 // P H I L I P S P R O P R I E T A R Y
5 =1 //
6 =1 // COPYRIGHT (c) 1997 BY PHILIPS SINGAPORE.
7 =1 // -- ALL RIGHTS RESERVED --
8 =1 //
9 =1 // File Name: MAINLOOP.H
10 =1 // Author: Wenkai Du
11 =1 // Created: 19 Dec 97
12 =1 // Modified:
13 =1 // Revision: 2.1
14 =1 //
15 =1 //*************************************************************************
16 =1 //
17 =1 // 98/11/25 Added DMA disable bit. (WK)
18 =1 //*************************************************************************
19 =1 */
20 =1
21 =1
22 =1 #ifndef __MAINLOOP_H__
23 =1 #define __MAINLOOP_H__
24 =1
25 =1
26 =1 /*
27 =1 //*************************************************************************
28 =1 // basic #defines
29 =1 //*************************************************************************
30 =1 */
31 =1 #define MAX_ENDPOINTS (unsigned char)0x3
32 =1
33 =1 #define EP0_TX_FIFO_SIZE 16
34 =1 #define EP0_RX_FIFO_SIZE 16
35 =1 #define EP0_PACKET_SIZE 16
C51 COMPILER V8.02 PROTODMA 07/27/2007 11:10:49 PAGE 8
36 =1
37 =1 #define EP1_TX_FIFO_SIZE 16
38 =1 #define EP1_RX_FIFO_SIZE 16
39 =1 #define EP1_PACKET_SIZE 16
40 =1
41 =1 #define EP2_TX_FIFO_SIZE 64
42 =1 #define EP2_RX_FIFO_SIZE 64
43 =1 #define EP2_PACKET_SIZE 64
44 =1
45 =1
46 =1 #define USB_IDLE 0
47 =1 #define USB_TRANSMIT 1
48 =1 #define USB_RECEIVE 2
49 =1
50 =1 #define USB_CLASS_CODE_TEST_CLASS_DEVICE 0xdc
51 =1 #define USB_SUBCLASS_CODE_TEST_CLASS_D12 0xA0
52 =1 #define USB_PROTOCOL_CODE_TEST_CLASS_D12 0xB0
53 =1
54 =1 /*
55 =1 //*************************************************************************
56 =1 // masks
57 =1 //*************************************************************************
58 =1 */
59 =1
60 =1 #define USB_RECIPIENT (unsigned char)0x1F
61 =1 #define USB_RECIPIENT_DEVICE (unsigned char)0x00
62 =1 #define USB_RECIPIENT_INTERFACE (unsigned char)0x01
63 =1 #define USB_RECIPIENT_ENDPOINT (unsigned char)0x02
64 =1
65 =1 #define USB_REQUEST_TYPE_MASK (unsigned char)0x60
66 =1 #define USB_STANDARD_REQUEST (unsigned char)0x00
67 =1 #define USB_CLASS_REQUEST (unsigned char)0x20
68 =1 #define USB_VENDOR_REQUEST (unsigned char)0x40
69 =1
70 =1 #define USB_REQUEST_MASK (unsigned char)0x0F
71 =1
72 =1 #define DEVICE_ADDRESS_MASK 0x7F
73 =1
74 =1 /*
75 =1 //*************************************************************************
76 =1 // macros
77 =1 //*************************************************************************
78 =1 */
79 =1 #ifdef __C51__
80 =1 #define SWAP(x) ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
81 =1 #else
=1 #define SWAP(x) (x)
=1 #define code
=1 #define idata
=1 #endif
86 =1
87 =1 #define MSB(x) (((x) >> 8) & 0xFF)
88 =1 #define LSB(x) ((x) & 0xFF)
89 =1
90 =1 #define FALSE 0
91 =1 #define TRUE (!FALSE)
92 =1
93 =1 /*
94 =1 //*************************************************************************
95 =1 // basic typedefs
96 =1 //*************************************************************************
97 =1 */
C51 COMPILER V8.02 PROTODMA 07/27/2007 11:10:49 PAGE 9
98 =1 typedef unsigned char UCHAR;
99 =1 typedef unsigned short USHORT;
100 =1 typedef unsigned long ULONG;
101 =1 typedef unsigned char BOOL;
102 =1
103 =1 /*
104 =1 //*************************************************************************
105 =1 // structure and union definitions
106 =1 //*************************************************************************
107 =1 */
108 =1 typedef union _epp_flags
109 =1 {
110 =1 struct _flags
111 =1 {
112 =1 unsigned char timer : 1;
113 =1 unsigned char bus_reset : 1;
114 =1 unsigned char suspend : 1;
115 =1 unsigned char setup_packet : 1;
116 =1 unsigned char remote_wakeup : 1;
117 =1 unsigned char in_isr : 1;
118 =1 unsigned char control_state : 2;
119 =1
120 =1 unsigned char configuration : 1;
121 =1 unsigned char verbose : 1;
122 =1 unsigned char ep1_rxdone : 1;
123 =1 unsigned char setup_dma : 1;
124 =1 unsigned char dma_state : 2;
125 =1 unsigned char dma_disable : 1; // V2.1
126 =1 } bits;
127 =1 unsigned short value;
128 =1 } EPPFLAGS;
129 =1
130 =1 typedef struct _device_request
131 =1 {
132 =1 unsigned char bmRequestType;
133 =1 unsigned char bRequest;
134 =1 unsigned short wValue;
135 =1 unsigned short wIndex;
136 =1 unsigned short wLength;
137 =1 } DEVICE_REQUEST;
138 =1
139 =1 typedef struct _IO_REQUEST {
140 =1 unsigned short uAddressL;
141 =1 unsigned char bAddressH;
142 =1 unsigned short uSize;
143 =1 unsigned char bCommand;
144 =1 } IO_REQUEST, *PIO_REQUEST;
145 =1
146 =1 #define MAX_CONTROLDATA_SIZE 8
147 =1
148 =1 typedef struct _control_xfer
149 =1 {
150 =1 DEVICE_REQUEST DeviceRequest;
151 =1 unsigned short wLength;
152 =1 unsigned short wCount;
153 =1 unsigned char * pData;
154 =1 unsigned char dataBuffer[MAX_CONTROLDATA_SIZE];
155 =1 } CONTROL_XFER;
156 =1
157 =1 /*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -