📄 bulkloop.lst
字号:
C51 COMPILER V7.50 BULKLOOP 08/06/2008 16:10:34 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE BULKLOOP
OBJECT MODULE PLACED IN bulkloop.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE bulkloop.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #pragma NOIV // Do not generate interrupt vectors
2 //-----------------------------------------------------------------------------
3 // File: bulkloop.c
4 // Contents: Hooks required to implement USB peripheral function.
5 //
6 // Copyright (c) 2000 Cypress Semiconductor All rights reserved
7 //-----------------------------------------------------------------------------
8 #include "fx2.h"
9 #include "fx2regs.h"
10 #include "fx2sdly.h" // SYNCDELAY macro
11
12 extern BOOL GotSUD; // Received setup data flag
13 extern BOOL Sleep;
14 extern BOOL Rwuen;
15 extern BOOL Selfpwr;
16
17 extern BYTE TXData[30];
18 extern void my_InitnRF2401();
19 extern void ShockBurst();
20 extern void write_leds(BYTE d);
21
22 BYTE Configuration; // Current configuration
23 BYTE AlternateSetting; // Alternate settings
24
25 #define DR1 1
26 #define VR_NAKALL_ON 0xD0
27 #define VR_NAKALL_OFF 0xD1
28
29 extern void delay100();
30 //-----------------------------------------------------------------------------
31 // Task Dispatcher hooks
32 // The following hooks are called by the task dispatcher.
33 //-----------------------------------------------------------------------------
34
35 void TD_Init(void) // Called once at startup
36 {
37 1 // set the CPU clock to 48MHz
38 1 CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
39 1
40 1 // set the slave FIFO interface to 48MHz
41 1 IFCONFIG |= 0x40;
42 1
43 1 // Registers which require a synchronization delay, see section 15.14
44 1 // FIFORESET FIFOPINPOLAR
45 1 // INPKTEND OUTPKTEND
46 1 // EPxBCH:L REVCTL
47 1 // GPIFTCB3 GPIFTCB2
48 1 // GPIFTCB1 GPIFTCB0
49 1 // EPxFIFOPFH:L EPxAUTOINLENH:L
50 1 // EPxFIFOCFG EPxGPIFFLGSEL
51 1 // PINFLAGSxx EPxFIFOIRQ
52 1 // EPxFIFOIE GPIFIRQ
53 1 // GPIFIE GPIFADRH:L
54 1 // UDMACRCH:L EPxGPIFTRIG
55 1 // GPIFTRIG
C51 COMPILER V7.50 BULKLOOP 08/06/2008 16:10:34 PAGE 2
56 1
57 1 // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
58 1 // ...these have been replaced by GPIFTC[B3:B0] registers
59 1
60 1 // default: all endpoints have their VALID bit set
61 1 // default: TYPE1 = 1 and TYPE0 = 0 --> BULK
62 1 // default: EP2 and EP4 DIR bits are 0 (OUT direction)
63 1 // default: EP6 and EP8 DIR bits are 1 (IN direction)
64 1 // default: EP2, EP4, EP6, and EP8 are double buffered
65 1
66 1 // we are just using the default values, yes this is not necessary...
67 1 SYNCDELAY; // see TRM section 15.14
68 1 EP4CFG = 0x90;
69 1 // out endpoints do not come up armed
70 1
71 1 // since the defaults are double buffered we must write dummy byte counts twice
72 1 SYNCDELAY;
73 1 EP4BCH = 0x02;
74 1 SYNCDELAY;
75 1 EP4BCL = 0x00; // arm EP2OUT by writing byte count w/skip.
76 1 SYNCDELAY;
77 1 EP4BCH = 0x02;
78 1 SYNCDELAY;
79 1 EP4BCL = 0x00; // arm EP2OUT by writing byte count w/skip.
80 1 SYNCDELAY;
81 1
82 1 // enable dual autopointer feature
83 1 AUTOPTRSETUP |= 0x01;
84 1
85 1 Rwuen = TRUE; // Enable remote-wakeup
86 1 my_InitnRF2401();
87 1
88 1 }
89
90
91 void TD_Poll(void) // Called repeatedly while the device is idle
92 {
93 1 int i;
94 1
95 1 if(!(EP2468STAT & bmEP4FULL))//ENDPOINT2非满,则开始发送数据
96 1 {
97 2 APTR1H = MSB( &EP4FIFOBUF );
98 2 APTR1L = LSB( &EP4FIFOBUF );
99 2
100 2 AUTOPTRH2 = MSB( &(TXData+4) );
101 2 AUTOPTRL2 = LSB( &(TXData+4) );
102 2
103 2 for(i=0;i<26;i++)
104 2 {
105 3 EXTAUTODAT2 = EXTAUTODAT1;
106 3 }
107 2 write_leds(EP4FIFOBUF[0]);
108 2 ShockBurst();
109 2 delay100();
110 2
111 2 //根据端点2缓冲区数目多少来确定装载端点计数器的次数
112 2 SYNCDELAY;
113 2 EP4BCH = 0x02;
114 2 SYNCDELAY;
115 2 EP4BCL = 0x00; // re(arm) EP2IN
116 2 }
117 1 }
C51 COMPILER V7.50 BULKLOOP 08/06/2008 16:10:34 PAGE 3
118
119 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
120 {
121 1 return(TRUE);
122 1 }
123
124 BOOL TD_Resume(void) // Called after the device resumes
125 {
126 1 return(TRUE);
127 1 }
128
129 //-----------------------------------------------------------------------------
130 // Device Request hooks
131 // The following hooks are called by the end point 0 device request parser.
132 //-----------------------------------------------------------------------------
133
134 BOOL DR_GetDescriptor(void)
135 {
136 1 return(TRUE);
137 1 }
138
139 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
140 {
141 1 Configuration = SETUPDAT[2];
142 1 return(TRUE); // Handled by user code
143 1 }
144
145 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
146 {
147 1 EP0BUF[0] = Configuration;
148 1 EP0BCH = 0;
149 1 EP0BCL = 1;
150 1 return(TRUE); // Handled by user code
151 1 }
152
153 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
154 {
155 1 AlternateSetting = SETUPDAT[2];
156 1 return(TRUE); // Handled by user code
157 1 }
158
159 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
160 {
161 1 EP0BUF[0] = AlternateSetting;
162 1 EP0BCH = 0;
163 1 EP0BCL = 1;
164 1 return(TRUE); // Handled by user code
165 1 }
166
167 BOOL DR_GetStatus(void)
168 {
169 1 return(TRUE);
170 1 }
171
172 BOOL DR_ClearFeature(void)
173 {
174 1 return(TRUE);
175 1 }
176
177 BOOL DR_SetFeature(void)
178 {
179 1 return(TRUE);
C51 COMPILER V7.50 BULKLOOP 08/06/2008 16:10:34 PAGE 4
180 1 }
181
182 BOOL DR_VendorCmnd(void)
183 {
184 1 BYTE tmp;
185 1
186 1 switch (SETUPDAT[1])
187 1 {
188 2 case VR_NAKALL_ON:
189 2 tmp = FIFORESET;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -