OpenCores
URL https://opencores.org/ocsvn/gecko3/gecko3/trunk

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-fw/] [firmware/] [gpif-design/] [gecko3main_gpif.c] - Blame information for rev 19

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 nussgipfel
// This program configures the General Programmable Interface (GPIF) for FX2.     
2
// Please do not modify sections of text which are marked as "DO NOT EDIT ...". 
3
//                                                                                
4
// DO NOT EDIT ...                  
5
// GPIF Initialization              
6
// Interface Timing      Sync         
7
// Internal Ready Init   IntRdy=1     
8
// CTL Out Tristate-able Binary       
9
// SingleWrite WF Select     1     
10
// SingleRead WF Select      0     
11
// FifoWrite WF Select       3     
12
// FifoRead WF Select        2     
13
// Data Bus Idle Drive   Tristate     
14
// END DO NOT EDIT                  
15
 
16
// DO NOT EDIT ...       
17
// GPIF Wave Names       
18
// Wave 0   = Single R     
19
// Wave 1   = Single W     
20
// Wave 2   = FIFO Rea     
21
// Wave 3   = FIFO Wri     
22
 
23
// GPIF Ctrl Outputs   Level   
24
// CTL 0    = RDYU     CMOS        
25
// CTL 1    = WRU      CMOS        
26
// CTL 2    = RDYU     CMOS        
27 18 nussgipfel
// CTL 3    = X2U_ex   CMOS        
28
// CTL 4    = U2X_th   CMOS        
29 9 nussgipfel
// CTL 5    = unused   CMOS        
30
 
31
// GPIF Rdy Inputs         
32
// RDY0     = WRX            
33
// RDY1     = RDYX           
34
// RDY2     = unused         
35
// RDY3     = unused         
36
// RDY4     = unused         
37
// RDY5     = TCXpire        
38
// FIFOFlag = FIFOFlag       
39
// IntReady = IntReady       
40
// END DO NOT EDIT         
41
// DO NOT EDIT ...                                                                         
42
//                                                                                         
43
// GPIF Waveform 0: Single R                                                                
44
//                                                                                         
45
// Interval     0         1         2         3         4         5         6     Idle (7) 
46
//          _________ _________ _________ _________ _________ _________ _________ _________
47
//                                                                                         
48
// AddrMode Same Val  Same Val  Same Val  Same Val  Same Val  Same Val  Same Val           
49
// DataMode NO Data   NO Data   Activate  Activate  Activate  Activate  Activate           
50
// NextData SameData  SameData  SameData  SameData  SameData  SameData  SameData           
51
// Int Trig No Int    No Int    No Int    No Int    No Int    No Int    No Int             
52
// IF/Wait  IF        Wait 1    IF        Wait 1    Wait 1    Wait 1    Wait 1             
53
//   Term A WRX                 WRX                                                        
54
//   LFunc  AND                 AND                                                        
55
//   Term B WRX                 WRX                                                        
56
// Branch1  Then 1              ThenIdle                                                   
57
// Branch0  ElseIdle            ElseIdle                                                   
58
// Re-Exec  Yes                 Yes                                                        
59
// Sngl/CRC Default   Default   Default   Default   Default   Default   Default            
60
// RDYU         0         0         0         0         0         0         0         0    
61
// WRU          0         0         0         0         0         0         0         0    
62
// RDYU         0         1         1         1         1         1         1         0    
63 18 nussgipfel
// X2U_ex       0         0         0         0         0         0         0         0    
64
// U2X_th       0         0         0         0         0         0         0         0    
65 9 nussgipfel
// unused       0         0         0         0         0         0         0         0    
66
//                     
67
// END DO NOT EDIT     
68
// DO NOT EDIT ...                                                                         
69
//                                                                                         
70
// GPIF Waveform 1: Single W                                                                
71
//                                                                                         
72
// Interval     0         1         2         3         4         5         6     Idle (7) 
73
//          _________ _________ _________ _________ _________ _________ _________ _________
74
//                                                                                         
75
// AddrMode Same Val  Same Val  Same Val  Same Val  Same Val  Same Val  Same Val           
76
// DataMode NO Data   NO Data   Activate  NO Data   NO Data   NO Data   NO Data            
77
// NextData SameData  SameData  SameData  SameData  SameData  SameData  SameData           
78
// Int Trig No Int    No Int    No Int    No Int    No Int    No Int    No Int             
79
// IF/Wait  IF        IF        IF        IF        Wait 1    Wait 1    Wait 1             
80
//   Term A WRX       RDYX      RDYX      RDYX                                             
81
//   LFunc  OR        AND       AND       AND                                              
82
//   Term B WRX       RDYX      IntReady  RDYX                                             
83
// Branch1  ThenIdle  Then 2    ThenIdle  Then 3                                           
84
// Branch0  Else 1    Else 1    Else 3    ElseIdle                                         
85
// Re-Exec  No        No        Yes       No                                               
86
// Sngl/CRC Default   Default   Default   Default   Default   Default   Default            
87
// RDYU         0         0         0         0         0         0         0         0    
88
// WRU          0         1         1         1         1         1         1         0    
89
// RDYU         0         0         0         1         1         1         1         0    
90 18 nussgipfel
// X2U_ex       0         0         0         0         0         0         0         0    
91
// U2X_th       0         0         0         0         0         0         0         0    
92 9 nussgipfel
// unused       0         0         0         0         0         0         0         0    
93
//                     
94
// END DO NOT EDIT     
95
// DO NOT EDIT ...                                                                         
96
//                                                                                         
97
// GPIF Waveform 2: FIFO Rea                                                                
98
//                                                                                         
99
// Interval     0         1         2         3         4         5         6     Idle (7) 
100
//          _________ _________ _________ _________ _________ _________ _________ _________
101
//                                                                                         
102
// AddrMode Same Val  Same Val  Same Val  Same Val  Same Val  Same Val  Same Val           
103
// DataMode NO Data   NO Data   NO Data   Activate  Activate  NO Data   NO Data            
104
// NextData SameData  SameData  SameData  SameData  NextData  SameData  SameData           
105
// Int Trig No Int    No Int    No Int    No Int    Trig Int  No Int    No Int             
106 19 nussgipfel
// IF/Wait  IF        IF        Wait 1    IF        Wait 1    IF        IF                 
107
//   Term A WRX       WRX                 RDYX                WRX       WRX                
108
//   LFunc  AND       AND                 !A AND B            AND       AND                
109
//   Term B WRX       RDYX                WRX                 WRX       WRX                
110
// Branch1  Then 1    Then 0              Then 3              ThenIdle  ThenIdle           
111
// Branch0  Else 0    Else 2              Else 4              ElseIdle  ElseIdle           
112
// Re-Exec  No        Yes                 Yes                 No        Yes                
113 9 nussgipfel
// Sngl/CRC Default   Default   Default   Default   Default   Default   Default            
114
// RDYU         0         0         0         0         0         0         0         0    
115
// WRU          0         0         0         0         0         0         0         0    
116
// RDYU         0         0         1         1         1         0         0         0    
117 19 nussgipfel
// X2U_ex       0         0         1         1         1         0         0         0    
118 18 nussgipfel
// U2X_th       0         0         0         0         0         0         0         0    
119 9 nussgipfel
// unused       0         0         0         0         0         0         0         0    
120
//                     
121
// END DO NOT EDIT     
122
// DO NOT EDIT ...                                                                         
123
//                                                                                         
124
// GPIF Waveform 3: FIFO Wri                                                                
125
//                                                                                         
126
// Interval     0         1         2         3         4         5         6     Idle (7) 
127
//          _________ _________ _________ _________ _________ _________ _________ _________
128
//                                                                                         
129
// AddrMode Same Val  Same Val  Same Val  Same Val  Same Val  Same Val  Same Val           
130
// DataMode NO Data   NO Data   NO Data   Activate  Activate  Activate  NO Data            
131 18 nussgipfel
// NextData SameData  SameData  SameData  SameData  NextData  NextData  SameData           
132 9 nussgipfel
// Int Trig No Int    No Int    No Int    No Int    No Int    Trig Int  No Int             
133 19 nussgipfel
// IF/Wait  IF        Wait 1    IF        IF        IF        IF        IF                 
134
//   Term A WRX                 WRX       RDYX      FIFOFlag  RDYX      WRX                
135
//   LFunc  AND                 AND       AND       AND       AND       AND                
136
//   Term B WRX                 WRX       RDYX      FIFOFlag  RDYX      WRX                
137
// Branch1  ThenIdle            Then 2    Then 4    Then 4    Then 5    ThenIdle           
138
// Branch0  Else 1              Else 3    Else 3    Else 5    ElseIdle  ElseIdle           
139
// Re-Exec  No                  No        No        Yes       No        No                 
140 9 nussgipfel
// Sngl/CRC Default   Default   Default   Default   Default   Default   Default            
141
// RDYU         0         0         0         0         0         0         0         0    
142
// WRU          0         1         1         1         1         0         0         0    
143
// RDYU         0         0         0         0         0         0         0         0    
144 18 nussgipfel
// X2U_ex       0         0         0         0         0         0         0         0    
145
// U2X_th       0         0         0         0         0         0         0         0    
146 9 nussgipfel
// unused       0         0         0         0         0         0         0         0    
147
//                     
148
// END DO NOT EDIT     
149
 
150
// GPIF Program Code                          
151
 
152
// DO NOT EDIT ...                            
153
#include "fx2.h"                            
154
#include "fx2regs.h"                        
155
#include "fx2sdly.h"     // SYNCDELAY macro 
156
// END DO NOT EDIT                            
157
 
158
// DO NOT EDIT ...                     
159
const char xdata WaveData[128] =
160
{
161
// Wave 0 
162
/* LenBr */ 0x8F,     0x01,     0xBF,     0x01,     0x01,     0x01,     0x01,     0x07,
163
/* Opcode*/ 0x01,     0x00,     0x03,     0x02,     0x02,     0x02,     0x02,     0x00,
164
/* Output*/ 0x00,     0x04,     0x04,     0x04,     0x04,     0x04,     0x04,     0x00,
165
/* LFun  */ 0x00,     0x00,     0x00,     0x00,     0x00,     0x00,     0x00,     0x3F,
166
// Wave 1 
167
/* LenBr */ 0x39,     0x11,     0xBB,     0x1F,     0x01,     0x01,     0x01,     0x07,
168
/* Opcode*/ 0x01,     0x01,     0x03,     0x01,     0x00,     0x00,     0x00,     0x00,
169
/* Output*/ 0x00,     0x02,     0x02,     0x06,     0x06,     0x06,     0x06,     0x00,
170
/* LFun  */ 0x40,     0x09,     0x0F,     0x09,     0x00,     0x00,     0x00,     0x3F,
171
// Wave 2 
172 19 nussgipfel
/* LenBr */ 0x08,     0x82,     0x01,     0x9C,     0x01,     0x3F,     0xBF,     0x07,
173
/* Opcode*/ 0x01,     0x01,     0x00,     0x03,     0x16,     0x01,     0x01,     0x00,
174
/* Output*/ 0x00,     0x00,     0x0C,     0x0C,     0x0C,     0x00,     0x00,     0x00,
175
/* LFun  */ 0x00,     0x01,     0x00,     0xC8,     0x00,     0x00,     0x00,     0x3F,
176 9 nussgipfel
// Wave 3 
177 19 nussgipfel
/* LenBr */ 0x39,     0x01,     0x13,     0x23,     0xA5,     0x2F,     0x3F,     0x07,
178
/* Opcode*/ 0x01,     0x00,     0x01,     0x03,     0x07,     0x17,     0x01,     0x00,
179 9 nussgipfel
/* Output*/ 0x00,     0x02,     0x02,     0x02,     0x02,     0x00,     0x00,     0x00,
180 19 nussgipfel
/* LFun  */ 0x00,     0x00,     0x00,     0x09,     0x36,     0x09,     0x00,     0x3F,
181 9 nussgipfel
};
182
// END DO NOT EDIT     
183
 
184
// DO NOT EDIT ...                     
185
const char xdata FlowStates[36] =
186
{
187
/* Wave 0 FlowStates */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
188
/* Wave 1 FlowStates */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
189
/* Wave 2 FlowStates */ 0x83,0x36,0x04,0x00,0x03,0x23,0x03,0x02,0x00,
190 19 nussgipfel
/* Wave 3 FlowStates */ 0x84,0x09,0x02,0x02,0x04,0x24,0x03,0x02,0x00,
191 9 nussgipfel
};
192
// END DO NOT EDIT     
193
 
194
// DO NOT EDIT ...                                               
195
const char xdata InitData[7] =
196
{
197
/* Regs  */ 0xE0,0x00,0x00,0x00,0xEE,0x4E,0x00
198
};
199
// END DO NOT EDIT                                               
200
 
201
// TO DO: You may add additional code below.
202
 
203
void GpifInit( void )
204
{
205
  BYTE i;
206
 
207
  // Registers which require a synchronization delay, see section 15.14
208
  // FIFORESET        FIFOPINPOLAR
209
  // INPKTEND         OUTPKTEND
210
  // EPxBCH:L         REVCTL
211
  // GPIFTCB3         GPIFTCB2
212
  // GPIFTCB1         GPIFTCB0
213
  // EPxFIFOPFH:L     EPxAUTOINLENH:L
214
  // EPxFIFOCFG       EPxGPIFFLGSEL
215
  // PINFLAGSxx       EPxFIFOIRQ
216
  // EPxFIFOIE        GPIFIRQ
217
  // GPIFIE           GPIFADRH:L
218
  // UDMACRCH:L       EPxGPIFTRIG
219
  // GPIFTRIG
220
 
221
  // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
222
  //      ...these have been replaced by GPIFTC[B3:B0] registers
223
 
224
  // 8051 doesn't have access to waveform memories 'til
225
  // the part is in GPIF mode.
226
 
227
  IFCONFIG = 0xEE;
228
  // IFCLKSRC=1   , FIFOs executes on internal clk source
229
  // xMHz=1       , 48MHz internal clk rate
230
  // IFCLKOE=0    , Don't drive IFCLK pin signal at 48MHz
231
  // IFCLKPOL=0   , Don't invert IFCLK pin signal from internal clk
232
  // ASYNC=1      , master samples asynchronous
233
  // GSTATE=1     , Drive GPIF states out on PORTE[2:0], debug WF
234
  // IFCFG[1:0]=10, FX2 in GPIF master mode
235
 
236
  GPIFABORT = 0xFF;  // abort any waveforms pending
237
 
238
  GPIFREADYCFG = InitData[ 0 ];
239
  GPIFCTLCFG = InitData[ 1 ];
240
  GPIFIDLECS = InitData[ 2 ];
241
  GPIFIDLECTL = InitData[ 3 ];
242
  GPIFWFSELECT = InitData[ 5 ];
243
  GPIFREADYSTAT = InitData[ 6 ];
244
 
245
  // use dual autopointer feature... 
246
  AUTOPTRSETUP = 0x07;          // inc both pointers, 
247
                                // ...warning: this introduces pdata hole(s)
248
                                // ...at E67B (XAUTODAT1) and E67C (XAUTODAT2)
249
 
250
  // source
251
  AUTOPTRH1 = MSB( &WaveData );
252
  AUTOPTRL1 = LSB( &WaveData );
253
 
254
  // destination
255
  AUTOPTRH2 = 0xE4;
256
  AUTOPTRL2 = 0x00;
257
 
258
  // transfer
259
  for ( i = 0x00; i < 128; i++ )
260
  {
261
    EXTAUTODAT2 = EXTAUTODAT1;
262
  }
263
 
264
// Configure GPIF Address pins, output initial value,
265
  PORTCCFG = 0xFF;    // [7:0] as alt. func. GPIFADR[7:0]
266
  OEC = 0xFF;         // and as outputs
267
  PORTECFG |= 0x80;   // [8] as alt. func. GPIFADR[8]
268
  OEE |= 0x80;        // and as output
269
 
270
// ...OR... tri-state GPIFADR[8:0] pins
271
//  PORTCCFG = 0x00;  // [7:0] as port I/O
272
//  OEC = 0x00;       // and as inputs
273
//  PORTECFG &= 0x7F; // [8] as port I/O
274
//  OEE &= 0x7F;      // and as input
275
 
276
// GPIF address pins update when GPIFADRH/L written
277
  SYNCDELAY;                    // 
278
  GPIFADRH = 0x00;    // bits[7:1] always 0
279
  SYNCDELAY;                    // 
280
  GPIFADRL = 0x00;    // point to PERIPHERAL address 0x0000
281
 
282
// Configure GPIF FlowStates registers for Wave 0 of WaveData
283
  FLOWSTATE = FlowStates[ 0 ];
284
  FLOWLOGIC = FlowStates[ 1 ];
285
  FLOWEQ0CTL = FlowStates[ 2 ];
286
  FLOWEQ1CTL = FlowStates[ 3 ];
287
  FLOWHOLDOFF = FlowStates[ 4 ];
288
  FLOWSTB = FlowStates[ 5 ];
289
  FLOWSTBEDGE = FlowStates[ 6 ];
290
  FLOWSTBHPERIOD = FlowStates[ 7 ];
291
}
292
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.