📄 bulkloop.lst
字号:
C51 COMPILER V7.50 BULKLOOP 08/05/2008 21:19:01 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 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 RXData[26];
18 extern void my_InitnRF2401();
19 extern void ReceiveShock();
20 extern void write_leds(BYTE d);
21 extern void delay100();
22
23 BYTE Configuration; // Current configuration
24 BYTE AlternateSetting; // Alternate settings
25
26 BOOL bNewState;
27 BYTE State[26];
28
29 #define DR1 1
30 #define VR_NAKALL_ON 0xD0
31 #define VR_NAKALL_OFF 0xD1
32
33 //-----------------------------------------------------------------------------
34 // Task Dispatcher hooks
35 // The following hooks are called by the task dispatcher.
36 //-----------------------------------------------------------------------------
37
38 void TD_Init(void) // Called once at startup
39 {
40 1 int i;
41 1
42 1 // set the CPU clock to 48MHz
43 1 CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
44 1
45 1 // set the slave FIFO interface to 48MHz
46 1 IFCONFIG |= 0x40;
47 1
48 1 // Registers which require a synchronization delay, see section 15.14
49 1 // FIFORESET FIFOPINPOLAR
50 1 // INPKTEND OUTPKTEND
51 1 // EPxBCH:L REVCTL
52 1 // GPIFTCB3 GPIFTCB2
53 1 // GPIFTCB1 GPIFTCB0
54 1 // EPxFIFOPFH:L EPxAUTOINLENH:L
55 1 // EPxFIFOCFG EPxGPIFFLGSEL
C51 COMPILER V7.50 BULKLOOP 08/05/2008 21:19:01 PAGE 2
56 1 // PINFLAGSxx EPxFIFOIRQ
57 1 // EPxFIFOIE GPIFIRQ
58 1 // GPIFIE GPIFADRH:L
59 1 // UDMACRCH:L EPxGPIFTRIG
60 1 // GPIFTRIG
61 1
62 1 // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
63 1 // ...these have been replaced by GPIFTC[B3:B0] registers
64 1
65 1 // default: all endpoints have their VALID bit set
66 1 // default: TYPE1 = 1 and TYPE0 = 0 --> BULK
67 1 // default: EP2 and EP4 DIR bits are 0 (OUT direction)
68 1 // default: EP6 and EP8 DIR bits are 1 (IN direction)
69 1 // default: EP2, EP4, EP6, and EP8 are double buffered
70 1
71 1 // we are just using the default values, yes this is not necessary...
72 1 SYNCDELAY; // see TRM section 15.14
73 1 EP4CFG = 0xD0;
74 1
75 1 // enable dual autopointer feature
76 1 AUTOPTRSETUP |= 0x01;
77 1
78 1 Rwuen = TRUE; // Enable remote-wakeup
79 1 my_InitnRF2401();
80 1 bNewState=FALSE;
81 1 for(i=0;i<26;i++)
82 1 State[i]=0;
83 1 // write_leds(1);
84 1 }
85
86
87 void TD_Poll(void) // Called repeatedly while the device is idle
88 {
89 1 int i;
90 1
91 1 if(IOA&(1<<DR1))
92 1 {
93 2 ReceiveShock();
94 2 for(i=0;i<26;i++)
95 2 {
96 3 State[i]=RXData[i];
97 3
98 3 }
99 2 bNewState=TRUE;
100 2 }
101 1
102 1 if(!(EP2468STAT & bmEP4EMPTY))//ENDPOINT2非空,则开始接收数据
103 1 {
104 2
105 2 if(bNewState==TRUE)
106 2 {
107 3 //EP1INBUF[0]=0x00;
108 3 for(i=0;i<26;i++)
109 3 {
110 4 EP4FIFOBUF[i]=State[i];
111 4 //delay100();
112 4 write_leds(EP4FIFOBUF[i]);
113 4 //delay100();
114 4 }
115 3
116 3 bNewState=FALSE;
117 3 }
C51 COMPILER V7.50 BULKLOOP 08/05/2008 21:19:01 PAGE 3
118 2
119 2 //根据端点2缓冲区数目多少来确定装载端点计数器的次数
120 2 SYNCDELAY;
121 2 EP4BCH = 0x00; // re(arm) EP2OUT
122 2 SYNCDELAY;
123 2 EP4BCL = 0x40; // re(arm) EP2OUT
124 2
125 2 }
126 1 }
127
128 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
129 {
130 1 return(TRUE);
131 1 }
132
133 BOOL TD_Resume(void) // Called after the device resumes
134 {
135 1 return(TRUE);
136 1 }
137
138 //-----------------------------------------------------------------------------
139 // Device Request hooks
140 // The following hooks are called by the end point 0 device request parser.
141 //-----------------------------------------------------------------------------
142
143 BOOL DR_GetDescriptor(void)
144 {
145 1 return(TRUE);
146 1 }
147
148 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
149 {
150 1 Configuration = SETUPDAT[2];
151 1 return(TRUE); // Handled by user code
152 1 }
153
154 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
155 {
156 1 EP0BUF[0] = Configuration;
157 1 EP0BCH = 0;
158 1 EP0BCL = 1;
159 1 return(TRUE); // Handled by user code
160 1 }
161
162 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
163 {
164 1 AlternateSetting = SETUPDAT[2];
165 1 return(TRUE); // Handled by user code
166 1 }
167
168 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
169 {
170 1 EP0BUF[0] = AlternateSetting;
171 1 EP0BCH = 0;
172 1 EP0BCL = 1;
173 1 return(TRUE); // Handled by user code
174 1 }
175
176 BOOL DR_GetStatus(void)
177 {
178 1 return(TRUE);
179 1 }
C51 COMPILER V7.50 BULKLOOP 08/05/2008 21:19:01 PAGE 4
180
181 BOOL DR_ClearFeature(void)
182 {
183 1 return(TRUE);
184 1 }
185
186 BOOL DR_SetFeature(void)
187 {
188 1 return(TRUE);
189 1 }
190
191 BOOL DR_VendorCmnd(void)
192 {
193 1 BYTE tmp;
194 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -