📄 gpif_c.lst
字号:
C51 COMPILER V7.10 GPIF_C 10/05/2005 08:24:59 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE GPIF_C
OBJECT MODULE PLACED IN gpif_c.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE gpif_c.c BROWSE INCDIR(F:\Keil\C51\INC\Cypress\) DEBUG OBJECTEXTEND
line level source
1 //----------------------------------------------------------------------------//
2 //GPIF implement file
3 #include "fx2.h"
4 #include "fx2regs.h"
5 #include "fx2sdly.h" // SYNCDELAY macro
6 #include "gpif.h"
7
8
9 #define TESTING_GPIF // NOTE: Comment this line out for frameworks based firmware
10 // See the example GPIF Tool Utility under Application
11 // Reference Material for more advanced development info
12 #ifdef TESTING_GPIF
13 // TODO: You may add additional code below.
14 void OtherInit( void )
15 { // interface initialization
16 1 // ...see TD_Init( );
17 1 }
18
19 // Set Address GPIFADR[8:0] to PERIPHERAL
20 void Peripheral_SetAddress( WORD gaddr )
21 {
22 1 SYNCDELAY; //
23 1 GPIFADRH = gaddr >> 8;
24 1 SYNCDELAY; //
25 1 GPIFADRL = ( BYTE )gaddr; // setup GPIF address
26 1 }
27
28 // Set EP2GPIF Transaction Count
29 void Peripheral_SetEP2GPIFTC( WORD xfrcnt )
30 {
31 1 SYNCDELAY; //
32 1 EP2GPIFTCH = xfrcnt >> 8; // setup transaction count
33 1 SYNCDELAY; //
34 1 EP2GPIFTCL = ( BYTE )xfrcnt;
35 1 }
36
37 // Set EP4GPIF Transaction Count
38 void Peripheral_SetEP4GPIFTC( WORD xfrcnt )
39 {
40 1 SYNCDELAY; //
41 1 EP4GPIFTCH = xfrcnt >> 8; // setup transaction count
42 1 SYNCDELAY; //
43 1 EP4GPIFTCL = ( BYTE )xfrcnt;
44 1 }
45
46 // Set EP6GPIF Transaction Count
47
48 void Peripheral_SetEP6GPIFTC( WORD xfrcnt )
49 {
50 1 SYNCDELAY; //
51 1 EP6GPIFTCH = xfrcnt >> 8; // setup transaction count
52 1 SYNCDELAY; //
53 1 EP6GPIFTCL = ( BYTE )xfrcnt;
54 1 }
55
C51 COMPILER V7.10 GPIF_C 10/05/2005 08:24:59 PAGE 2
56
57 void Peripheral_SetEP6GPIFTCX( WORD xfrcnt )
58 {
59 1 SYNCDELAY; //
60 1 EP6GPIFTCHX = xfrcnt >> 8; // setup transaction count
61 1 SYNCDELAY; //
62 1 EP6GPIFTCLX = ( BYTE )xfrcnt;
63 1 }
64
65 // Set EP8GPIF Transaction Count
66 void Peripheral_SetEP8GPIFTC( WORD xfrcnt )
67 {
68 1 SYNCDELAY; //
69 1 EP8GPIFTCH = xfrcnt >> 8; // setup transaction count
70 1 SYNCDELAY; //
71 1 EP8GPIFTCL = ( BYTE )xfrcnt;
72 1 }
73
74 #define GPIF_FLGSELPF 0
75 #define GPIF_FLGSELEF 1
76 #define GPIF_FLGSELFF 2
77
78 // Set EP2GPIF Decision Point FIFO Flag Select (PF, EF, FF)
79 void SetEP2GPIFFLGSEL( WORD DP_FIFOFlag )
80 {
81 1 EP2GPIFFLGSEL = DP_FIFOFlag;
82 1 }
83
84 // Set EP4GPIF Decision Point FIFO Flag Select (PF, EF, FF)
85 void SetEP4GPIFFLGSEL( WORD DP_FIFOFlag )
86 {
87 1 EP4GPIFFLGSEL = DP_FIFOFlag;
88 1 }
89
90 // Set EP6GPIF Decision Point FIFO Flag Select (PF, EF, FF)
91 void SetEP6GPIFFLGSEL( WORD DP_FIFOFlag )
92 {
93 1 EP6GPIFFLGSEL = DP_FIFOFlag;
94 1 }
95
96 // Set EP8GPIF Decision Point FIFO Flag Select (PF, EF, FF)
97 void SetEP8GPIFFLGSEL( WORD DP_FIFOFlag )
98 {
99 1 EP8GPIFFLGSEL = DP_FIFOFlag;
100 1 }
101
102 // Set EP2GPIF Programmable Flag STOP, overrides Transaction Count
103 void SetEP2GPIFPFSTOP( void )
104 {
105 1 EP2GPIFPFSTOP = 0x01;
106 1 }
107
108 // Set EP4GPIF Programmable Flag STOP, overrides Transaction Count
109 void SetEP4GPIFPFSTOP( void )
110 {
111 1 EP4GPIFPFSTOP = 0x01;
112 1 }
113
114 // Set EP6GPIF Programmable Flag STOP, overrides Transaction Count
115 void SetEP6GPIFPFSTOP( void )
116 {
117 1 EP6GPIFPFSTOP = 0x01;
C51 COMPILER V7.10 GPIF_C 10/05/2005 08:24:59 PAGE 3
118 1 }
119
120 // Set EP8GPIF Programmable Flag STOP, overrides Transaction Count
121 void SetEP8GPIFPFSTOP( void )
122 {
123 1 EP8GPIFPFSTOP = 0x01;
124 1 }
125
126 // write single byte to PERIPHERAL, using GPIF
127 void Peripheral_SingleByteWrite( BYTE gdata )
128 {
129 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
130 1 {
131 2 ;
132 2 }
133 1
134 1 XGPIFSGLDATLX = gdata; // trigger GPIF
135 1 // ...single byte write transaction
136 1 }
137
138 // write single word to PERIPHERAL, using GPIF
139 void Peripheral_SingleWordWrite( WORD gdata )
140 {
141 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
142 1 {
143 2 ;
144 2 }
145 1
146 1 // using register(s) in XDATA space
147 1 XGPIFSGLDATH = gdata >> 8;
148 1 XGPIFSGLDATLX = gdata; // trigger GPIF
149 1 // ...single word write transaction
150 1 }
151
152 // read single byte from PERIPHERAL, using GPIF
153 void Peripheral_SingleByteRead( BYTE xdata *gdata )
154 {
155 1 static BYTE g_data = 0x00;
156 1
157 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
158 1 {
159 2 ;
160 2 }
161 1
162 1 // using register(s) in XDATA space, dummy read
163 1 g_data = XGPIFSGLDATLX; // trigger GPIF
164 1 // ...single byte read transaction
165 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
166 1 {
167 2 ;
168 2 }
169 1
170 1 // using register(s) in XDATA space,
171 1 *gdata = XGPIFSGLDATLNOX; // ...GPIF reads byte from PERIPHERAL
172 1 }
173
174 // read single word from PERIPHERAL, using GPIF
175 void Peripheral_SingleWordRead( WORD xdata *gdata )
176 {
177 1 BYTE g_data = 0x00;
178 1
179 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
C51 COMPILER V7.10 GPIF_C 10/05/2005 08:24:59 PAGE 4
180 1 {
181 2 ;
182 2 }
183 1
184 1 // using register(s) in XDATA space, dummy read
185 1 g_data = XGPIFSGLDATLX; // trigger GPIF
186 1 // ...single word read transaction
187 1
188 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
189 1 {
190 2 ;
191 2 }
192 1
193 1 // using register(s) in XDATA space, GPIF reads word from PERIPHERAL
194 1 *gdata = ( ( WORD )XGPIFSGLDATH << 8 ) | ( WORD )XGPIFSGLDATLNOX;
195 1 }
196
197 #define GPIFTRIGWR 0
198 #define GPIFTRIGRD 4
199
200 #define GPIF_EP2 0
201 #define GPIF_EP4 1
202 #define GPIF_EP6 2
203 #define GPIF_EP8 3
204
205 // write byte(s)/word(s) to PERIPHERAL, using GPIF and EPxFIFO
206 // if EPx WORDWIDE=0 then write byte(s)
207 // if EPx WORDWIDE=1 then write word(s)
208 void Peripheral_FIFOWrite( BYTE FIFO_EpNum )
209 {
210 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
211 1 {
212 2 ;
213 2 }
214 1
215 1 // trigger FIFO write transaction(s), using SFR
216 1 GPIFTRIG = FIFO_EpNum; // R/W=0, EP[1:0]=FIFO_EpNum for EPx write(s)
217 1 }
218
219 // read byte(s)/word(s) from PERIPHERAL, using GPIF and EPxFIFO
220 // if EPx WORDWIDE=0 then read byte(s)
221 // if EPx WORDWIDE=1 then read word(s)
222 void Peripheral_FIFORead( BYTE FIFO_EpNum )
223 {
224 1 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 GPIF Done bit
225 1 {
226 2 ;
227 2 }
228 1
229 1 // trigger FIFO read transaction(s), using SFR
230 1 GPIFTRIG = GPIFTRIGRD | FIFO_EpNum; // R/W=1, EP[1:0]=FIFO_EpNum for EPx read(s)
231 1 }
232 //---------------------------------------------------------------------------//
233 void GPIF_LOAD_SINGLE()//单通道
234 {
235 1 BYTE i;
236 1
237 1 GPIFABORT = 0xFF; // abort any waveforms pending
238 1
239 1 GPIFREADYCFG = InitData[ 0 ];
240 1 GPIFCTLCFG = InitData[ 1 ];
241 1 GPIFIDLECS = InitData[ 2 ];
C51 COMPILER V7.10 GPIF_C 10/05/2005 08:24:59 PAGE 5
242 1 GPIFIDLECTL = InitData[ 3 ];
243 1 GPIFWFSELECT = InitData[ 5 ];
244 1 GPIFREADYSTAT = InitData[ 6 ];
245 1
246 1 // use dual autopointer feature...
247 1 AUTOPTRSETUP = 0x07; // inc both pointers,
248 1 // ...warning: this introduces pdata hole(s)
249 1 // ...at E67B (XAUTODAT1) and E67C (XAUTODAT2)
250 1
251 1 // source
252 1 AUTOPTRH1 = MSB( &WaveData );
253 1 AUTOPTRL1 = LSB( &WaveData );
254 1
255 1 // destination
256 1 AUTOPTRH2 = 0xE4;
257 1 AUTOPTRL2 = 0x00;
258 1
259 1 // transfer
260 1 for ( i = 0x00; i < 128; i++ )
261 1 {
262 2 EXTAUTODAT2 = EXTAUTODAT1;
263 2 }
264 1 }
265
266 void GPIF_LOAD_DOUBLE()//双通道
267 {
268 1 BYTE i;
269 1 GPIFREADYCFG = InitData2[ 0 ];
270 1 GPIFCTLCFG = InitData2[ 1 ];
271 1 GPIFIDLECS = InitData2[ 2 ];
272 1 GPIFIDLECTL = InitData2[ 3 ];
273 1 GPIFWFSELECT = InitData2[ 5 ];
274 1 GPIFREADYSTAT = InitData2[ 6 ];
275 1
276 1 // use dual autopointer feature...
277 1 AUTOPTRSETUP = 0x07; // inc both pointers,
278 1 // ...warning: this introduces pdata hole(s)
279 1 // ...at E67B (XAUTODAT1) and E67C (XAUTODAT2)
280 1
281 1 // source
282 1 AUTOPTRH1 = MSB( &WaveData2 );
283 1 AUTOPTRL1 = LSB( &WaveData2 );
284 1
285 1 // destination
286 1 AUTOPTRH2 = 0xE4;
287 1 AUTOPTRL2 = 0x00;
288 1
289 1 // transfer
290 1 for ( i = 0x00; i < 128; i++ )
291 1 {
292 2 EXTAUTODAT2 = EXTAUTODAT1;
293 2 }
294 1
295 1 }
296
297 void GPIF_LOAD_TRI() //三通道
298 {
299 1
300 1 }
301 void GPIF_LOAD_QUAD() //四通道
302 {
303 1
C51 COMPILER V7.10 GPIF_C 10/05/2005 08:24:59 PAGE 6
304 1 }
305 void GPIF_LOAD_PWDW() //AD 掉电模式
306 {
307 1
308 1 }
309 #endif
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 452 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 306 ----
PDATA SIZE = ---- ----
DATA SIZE = 1 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -