📄 bulkloop.lst
字号:
C51 COMPILER V7.50 BULKLOOP 08/10/2005 08:48:14 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 BYTE Configuration; // Current configuration
18 BYTE AlternateSetting; // Alternate settings
19
20 #define VR_NAKALL_ON 0xD0
21 #define VR_NAKALL_OFF 0xD1
22
23 //-----------------------------------------------------------------------------
24 // Task Dispatcher hooks
25 // The following hooks are called by the task dispatcher.
26 //-----------------------------------------------------------------------------
27
28 void TD_Init(void) // Called once at startup
29 {
30 1 // set the CPU clock to 48MHz
31 1 CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
32 1
33 1 // set the slave FIFO interface to 48MHz
34 1 IFCONFIG |= 0x40;
35 1
36 1 // Registers which require a synchronization delay, see section 15.14
37 1 // FIFORESET FIFOPINPOLAR
38 1 // INPKTEND OUTPKTEND
39 1 // EPxBCH:L REVCTL
40 1 // GPIFTCB3 GPIFTCB2
41 1 // GPIFTCB1 GPIFTCB0
42 1 // EPxFIFOPFH:L EPxAUTOINLENH:L
43 1 // EPxFIFOCFG EPxGPIFFLGSEL
44 1 // PINFLAGSxx EPxFIFOIRQ
45 1 // EPxFIFOIE GPIFIRQ
46 1 // GPIFIE GPIFADRH:L
47 1 // UDMACRCH:L EPxGPIFTRIG
48 1 // GPIFTRIG
49 1
50 1 // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
51 1 // ...these have been replaced by GPIFTC[B3:B0] registers
52 1
53 1 // default: all endpoints have their VALID bit set
54 1 // default: TYPE1 = 1 and TYPE0 = 0 --> BULK
55 1 // default: EP2 and EP4 DIR bits are 0 (OUT direction)
C51 COMPILER V7.50 BULKLOOP 08/10/2005 08:48:14 PAGE 2
56 1 // default: EP6 and EP8 DIR bits are 1 (IN direction)
57 1 // default: EP2, EP4, EP6, and EP8 are double buffered
58 1 //
59 1 // we are just using the default values, yes this is not necessary...
60 1 EP1OUTCFG = 0xA0;
61 1 // SYNCDELAY;
62 1 EP1INCFG = 0xA3;
63 1 // SYNCDELAY; // see TRM section 15.14
64 1 //EP2CFG Endpoint 2 Configuration VALID DIR TYPE1 TYPE0 SIZE 0 BUF1 BUF0
65 1 //端点2配置,OUT,双缓冲,BULK
66 1 //0xA0 四缓冲
67 1 //0xA2 双缓冲
68 1 //0xA3 三缓冲
69 1 SYNCDELAY;
70 1 EP2CFG = 0xA2; // EP2OUT, bulk, size 512, 2x buffered
71 1 SYNCDELAY;
72 1 EP4CFG = 0x00; // EP4 not valid
73 1 SYNCDELAY;
74 1 EP6CFG = 0x00; // EP6 not valid
75 1 SYNCDELAY;
76 1 EP8CFG = 0x00; // EP8 not valid
77 1
78 1
79 1 //根据端点2缓冲区数目多少来确定装载端点计数器的次数
80 1 SYNCDELAY;
81 1 EP2BCL = 0x80;
82 1 SYNCDELAY;
83 1 EP2BCL = 0x80;
84 1 // SYNCDELAY;
85 1 // EP2BCL = 0x80;
86 1 // SYNCDELAY;
87 1 // EP2BCL = 0x80;
88 1
89 1
90 1 // enable dual autopointer feature
91 1 AUTOPTRSETUP |= 0x01;
92 1
93 1 Rwuen = TRUE; // Enable remote-wakeup
94 1 }
95
96
97 void TD_Poll(void) // Called repeatedly while the device is idle
98 {
99 1
100 1 WORD count;
101 1 unsigned char temp;
102 1 WORD i;
103 1 if(!(EP2468STAT & bmEP2EMPTY))//ENDPOINT2非空,则开始接收数据
104 1 {
105 2 /* *///////////////////////////////////////////
106 2 APTR1H = MSB( &EP2FIFOBUF );
107 2 APTR1L = LSB( &EP2FIFOBUF );
108 2
109 2 count = (EP2BCH << 8) + EP2BCL;
110 2
111 2 // 循环将端点2中的数据取出,因为单片机指令慢,会影响测试速度
112 2 for( i = 0x0000; i < count; i++ )
113 2 {
114 3 // setup to transfer EP2OUT buffer to EP6IN buffer using AUTOPOINTER(s)
115 3 temp = EXTAUTODAT1;
116 3
117 3 }
C51 COMPILER V7.50 BULKLOOP 08/10/2005 08:48:14 PAGE 3
118 2 ////////////////////////////////////本来没有
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -