📄 periph.lst
字号:
C51 COMPILER V7.10 PERIPH 10/26/2005 09:28:03 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE PERIPH
OBJECT MODULE PLACED IN periph.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE periph.c BROWSE INCDIR(F:\Keil\C51\INC\Cypress\) DEBUG OBJECTEXTEND
line level source
1 #pragma NOIV // Do not generate interrupt vectors
2 //-----------------------------------------------------------------------------
3 // File: periph.c
4 // Contents: Hooks required to implement USB peripheral function.
5 //
6 // Copyright (c) 1997 AnchorChips, Inc. All rights reserved
7 //-----------------------------------------------------------------------------
8 #include "fx2.h"
9 #include "fx2regs.h"
10 #include "fx2sdly.h"
11 #include "io.h"
12 #include "gpif.h"
13 #include "ad.h"
14
15 extern BOOL GotSUD; // Received setup data flag
16 extern BOOL Sleep;
17 extern BOOL Rwuen;
18 extern BOOL Selfpwr;
19
20 BYTE data Configuration; // Current configuration
21 BYTE data AlternateSetting; // Alternate settings
22 BYTE data GpifReadWriteFlag; //gpif read write flag
23 BYTE data GpifFinishFlag;
24 BYTE data High_Full_Flag;
25 BYTE data PowerDown_Flag; //AD Power Down Mode
26
27 BYTE data Ad_complete_Flag;
28
29 #define bmEP1OUTBSY 0x02
30 #define bmEP1INBSY 0x04
31
32 //-----------------------------------------------------------------------------
33 // Task Dispatcher hooks
34 // The following hooks are called by the task dispatcher.
35 //-----------------------------------------------------------------------------
36
37 void TD_Init(void) // Called once at startup
38 {
39 1 BREAKPT &= ~bmBPEN; // to see BKPT LED go out TGE
40 1 Rwuen = TRUE; // Enable remote-wakeup
41 1 ////////////////////////////////////////////////////////////////////
42 1 //将GPIF初试化用在收到控制通道命令字来重新动态调用
43 1 GpifInit();
44 1
45 1 SYNCDELAY;
46 1 EP1OUTCFG = 0xA0; // always OUT, valid, bulk
47 1 EP1INCFG = 0xA0; // always IN, valid, bulk
48 1 // EP2 512 BULK OUT 4x
49 1 SYNCDELAY; // see TRM section 15.14
50 1 EP2CFG = 0xA0; //512PACKET; // BUF[1:0]=00 for 4x buffering
51 1
52 1 // EP4 and EP6 and EP8 are not used in this implementation...
53 1 SYNCDELAY; //
54 1 EP4CFG = 0x20; // clear valid bit
55 1 SYNCDELAY; //
C51 COMPILER V7.10 PERIPH 10/26/2005 09:28:03 PAGE 2
56 1 EP6CFG = 0xE0; //
57 1 SYNCDELAY; //
58 1 EP8CFG = 0x60; // clear valid bit
59 1 SYNCDELAY;
60 1 EP1OUTBC = 0x80;
61 1
62 1 SYNCDELAY; //
63 1 FIFORESET = 0x80; // activate NAK-ALL to avoid race conditions
64 1 SYNCDELAY; //
65 1 FIFORESET = 0x02; // reset, FIFO 2
66 1 SYNCDELAY; //
67 1 FIFORESET = 0x04; // reset, FIFO 4
68 1 SYNCDELAY; //
69 1 FIFORESET = 0x06; // reset, FIFO 6
70 1 SYNCDELAY; //
71 1 FIFORESET = 0x08; // reset, FIFO 8
72 1 SYNCDELAY; //
73 1 FIFORESET = 0x00; // deactivate NAK-ALL
74 1 SYNCDELAY;
75 1
76 1 // 8-bit bus (WORDWIDE=1)...
77 1 EP2FIFOCFG = 0x00;//AUTO OUT 8-BIT BUS
78 1 SYNCDELAY;
79 1 EP6FIFOCFG = 0x09;//AUTO IN 8-BIT BUS
80 1 SYNCDELAY;
81 1
82 1 EP2BCL = 0x80;
83 1 SYNCDELAY;
84 1 EP2BCL = 0x80;
85 1 SYNCDELAY;
86 1 EP2BCL = 0x80;
87 1 SYNCDELAY;
88 1 EP2BCL = 0x80;
89 1 SYNCDELAY;
90 1
91 1 // setup INT4 as internal source for GPIF interrupts
92 1 // using INT4CLR (SFR), automatically enabled
93 1 SYNCDELAY;
94 1 INTSETUP |= 0x03; // Enable INT4 FIFO/GPIF Autovectoring
95 1 SYNCDELAY; // used here as "delay"
96 1 EXIF &= ~0x40; // just in case one was pending...
97 1 SYNCDELAY; // used here as "delay"
98 1 GPIFIRQ = 0x01;
99 1 SYNCDELAY; //
100 1 GPIFIE = 0x01; // Enable GPIFDONE interrupt
101 1 SYNCDELAY; //
102 1 EIE |= 0x04; // Enable INT4 ISR, EIE.2(EIEX4=1)
103 1
104 1 GpifReadWriteFlag = 0; //write
105 1 GpifFinishFlag = 0;
106 1 High_Full_Flag = 0;
107 1 PowerDown_Flag = 0; //AD Power Down Mode
108 1 }
109
110
111
112 void TD_Poll(void) // Called repeatedly while the device is idle
113 {
114 1
115 1 WORD data MyNumber;
116 1 BYTE data My_EP6GPIFBCHX;
117 1 BYTE data My_EP6GPIFBCLX; //高16位
C51 COMPILER V7.10 PERIPH 10/26/2005 09:28:03 PAGE 3
118 1 BYTE data My_EP6GPIFBCH;
119 1 BYTE data My_EP6GPIFBCL; //低16位
120 1 WORD data My_EP6GPIFNOX;
121 1 WORD data My_EP6GPIFNO;
122 1 BYTE data My_OUT1_Temp1;
123 1 BYTE data My_OUT1_Temp2;
124 1 BYTE data My_OUT1_Channel;//
125 1 WORD data My_Channel_Word;//通道控制字
126 1 //-----------------------------------------------------------------------------------------------
127 1 //handle OUT1 Control Word
128 1 //-----------------------------------------------------------------------------------------------
129 1 if(!(EP01STAT & bmEP1OUTBSY))
130 1 {
131 2 // handle OUTs to EP1OUT
132 2 MyNumber = EP1OUTBC;
133 2 My_OUT1_Temp1 = EP1OUTBUF[0];
134 2 switch(My_OUT1_Temp1)
135 2 {
136 3 case SetAdDen: //设置采样深度0x01
137 3
138 3 My_EP6GPIFBCHX = EP1OUTBUF[1];
139 3 My_EP6GPIFBCLX = EP1OUTBUF[2];
140 3 My_EP6GPIFBCH = EP1OUTBUF[3];
141 3 My_EP6GPIFBCL = EP1OUTBUF[4];
142 3 My_EP6GPIFNOX = (My_EP6GPIFBCHX <<8 ) + My_EP6GPIFBCLX;
143 3 My_EP6GPIFNO = (My_EP6GPIFBCH <<8 ) + My_EP6GPIFBCL;
144 3 break;
145 3 case StartAd://应该增加启动失败的功能0x02
146 3 My_OUT1_Temp2 = EP1OUTBUF[1];
147 3 if(My_OUT1_Temp2 == OUT1_START_AD)
148 3 {
149 4 Peripheral_SingleWordWrite(0);//start ad
150 4 // Peripheral_SingleWordWrite(My_Channel_Word);//start ad
151 4 GpifReadWriteFlag = 0;
152 4 }
153 3 break;
154 3 case EndAd: //Stop AD 0x03
155 3 My_OUT1_Temp2 = EP1OUTBUF[1];
156 3 if(My_OUT1_Temp2 == OUT1_END_AD)
157 3 {
158 4 WORD xdata *pTemp_gpif;
159 4 Peripheral_SingleWordRead(pTemp_gpif);
160 4 SetEP6GPIFPFSTOP();
161 4 }
162 3 break;
163 3 /*case SelectADCh: //Select AD Channel 0x04 装载波形
164 3 My_OUT1_Channel = EP1OUTBUF[1];
165 3
166 3 My_Channel_Word = ((WORD)(My_OUT1_Channel<<8))+0x00;
167 3 if(My_OUT1_Channel == 0x00)
168 3 {
169 3 GPIF_LOAD_SINGLE(); //默认状态装载波形
170 3 }
171 3 if(My_OUT1_Channel == 0x01)
172 3 {
173 3 GPIF_LOAD_DOUBLE();//双通道
174 3 }
175 3 if(My_OUT1_Channel == 0x02)
176 3 {
177 3 GPIF_LOAD_TRI();
178 3 }
179 3 if(My_OUT1_Channel == 0x03)
C51 COMPILER V7.10 PERIPH 10/26/2005 09:28:03 PAGE 4
180 3 {
181 3 GPIF_LOAD_QUAD();
182 3 }
183 3 if((0x04<=My_OUT1_Channel)&&(My_OUT1_Channel < 0x08))
184 3 {
185 3 ;
186 3 }
187 3 if(My_OUT1_Channel >= 0x08)
188 3 {
189 3 PowerDown_Flag = 1;
190 3 GPIF_LOAD_PWDW();
191 3 }
192 3 break;*/
193 3 default:
194 3 break;
195 3 }
196 2 SYNCDELAY;
197 2 EP1OUTBC = 0x80;
198 2 }
199 1 //-----------------------------------------------------------------------------------------------
200 1 //Handle EP6 FIFO Read
201 1 //-----------------------------------------------------------------------------------------------
202 1 if(GpifFinishFlag == 1)
203 1 {
204 2 GpifFinishFlag = 0; //每次中断完成就切换读和写
205 2
206 2 if(GpifReadWriteFlag == 0)
207 2 {
208 3 SYNCDELAY; //
209 3 EP6GPIFTCHX = My_EP6GPIFNOX >> 8; // setup transaction count
210 3 SYNCDELAY; //
211 3 EP6GPIFTCLX = ( BYTE )My_EP6GPIFNOX;
212 3 Peripheral_SetEP6GPIFTC(My_EP6GPIFNO); //read 512 byte data from gipf 底16位
213 3 Peripheral_FIFORead(2);
214 3 // i++;
215 3 // if(i > My_EP6GPIFNO1) //如果采样深度没有达到跳出
216 3 GpifReadWriteFlag = 1; //read
217 3 }
218 2 }
219 1 }
*** WARNING C280 IN LINE 124 OF PERIPH.C: 'My_OUT1_Channel': unreferenced local variable
*** WARNING C280 IN LINE 125 OF PERIPH.C: 'My_Channel_Word': unreferenced local variable
220
221 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
222 {
223 1 return(TRUE);
224 1 }
225
226 BOOL TD_Resume(void) // Called after the device resumes
227 {
228 1 return(TRUE);
229 1 }
230
231 //-----------------------------------------------------------------------------
232 // Device Request hooks
233 // The following hooks are called by the end point 0 device request parser.
234 //-----------------------------------------------------------------------------
235
236 BOOL DR_GetDescriptor(void)
237 {
238 1 return(TRUE);
239 1 }
C51 COMPILER V7.10 PERIPH 10/26/2005 09:28:03 PAGE 5
240
241 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
242 {
243 1 Configuration = SETUPDAT[2];
244 1 if(High_Full_Flag == 1)
245 1 {
246 2 SYNCDELAY; //
247 2 EP2AUTOINLENH = 0x02; //ep2 auto commit length 512
248 2 SYNCDELAY;
249 2 EP2AUTOINLENL = 0x00;
250 2 SYNCDELAY;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -