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

Subversion Repositories usb_fpga_2_13

[/] [usb_fpga_2_13/] [trunk/] [examples/] [usb-fpga-2.13/] [2.13d/] [memfifo/] [memfifo.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
/*!
2
   memfifo -- implementation of EZ-USB slave FIFO's (input and output) a FIFO using the DDR3 SDRAM for ZTEX USB-FPGA Modules 2.13
3
   Copyright (C) 2009-2014 ZTEX GmbH.
4
   http://www.ztex.de
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License version 3 as
8
   published by the Free Software Foundation.
9
 
10
   This program is distributed in the hope that it will be useful, but
11
   WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
   General Public License for more details.
14
 
15
   You should have received a copy of the GNU General Public License
16
   along with this program; if not, see http://www.gnu.org/licenses/.
17
!*/
18
#include[ztex-conf.h]   // Loads the configuration macros, see ztex-conf.h for the available macros
19
#include[ztex-utils.h]  // include basic functions
20
 
21
// configure endpoint 2, in, quad buffered, 512 bytes, interface 0
22
EP_CONFIG(2,0,BULK,IN,512,4);
23
 
24
// configure endpoint 6, out, double buffered, 512 bytes, interface 0
25
EP_CONFIG(6,0,BULK,OUT,512,4);
26
 
27
// select ZTEX USB FPGA Module 1.15 as target  (required for FPGA configuration)
28
IDENTITY_UFM_2_13(10.17.0.0,0);
29
 
30
// this product string is also used for identification by the host software
31
#define[PRODUCT_STRING]["memfifo for UFM 2.13"]
32
 
33
// enables high speed FPGA configuration via EP6
34
ENABLE_HS_FPGA_CONF(6);
35
 
36
// enable Flash support
37
ENABLE_FLASH;
38
 
39
#define[MT_RESET][IOA7]
40
#define[MT_MODE0][IOA0]
41
#define[MT_MODE1][IOA1]
42
 
43
// this is called automatically after FPGA configuration
44
#define[POST_FPGA_CONFIG][POST_FPGA_CONFIG
45
    reset ();
46
]
47
 
48
// set mode
49
ADD_EP0_VENDOR_COMMAND((0x80,,
50
        IOA = SETUPDAT[2] & 3;
51
,,
52
        NOP;
53
));;
54
 
55
// reset
56
ADD_EP0_VENDOR_COMMAND((0x81,,
57
        reset();
58
,,
59
        NOP;
60
));;
61
 
62
void reset () {
63
        OEA = bmBIT0 | bmBIT1 | bmBIT7;
64
        OEB = 0;
65
        OED = 0;
66
        MT_RESET = 1;
67
        MT_MODE0 = 0;
68
        MT_MODE1 = 0;
69
 
70
        EP2CS &= ~bmBIT0;                       // clear stall bit
71
        EP6CS &= ~bmBIT0;                       // clear stall bit
72
 
73
        IFCONFIG = bmBIT7 | bmBIT6 | bmBIT5 | 3;  // internal 48MHz clock, drive IFCLK output, slave FIFO interface
74
//      IFCONFIG = bmBIT7 | bmBIT5 | 3;           // internal 30MHz clock, drive IFCLK output, slave FIFO interface
75
        SYNCDELAY;
76
 
77
        REVCTL = 0x1;
78
        SYNCDELAY;
79
 
80
        FIFORESET = 0x80;                       // reset FIFO ...
81
        SYNCDELAY;
82
        FIFORESET = 2;                          // ... for EP 2
83
        SYNCDELAY;
84
        FIFORESET = 0x00;
85
        SYNCDELAY;
86
        FIFORESET = 6;                          // ... for EP 6
87
        SYNCDELAY;
88
        FIFORESET = 0x00;
89
        SYNCDELAY;
90
 
91
        EP2FIFOCFG = bmBIT0;
92
        SYNCDELAY;
93
        EP2FIFOCFG = bmBIT3 | bmBIT0;           // EP2: AUTOIN, WORDWIDE
94
        SYNCDELAY;
95
        EP2AUTOINLENH = 2;                      // 512 bytes 
96
        SYNCDELAY;
97
        EP2AUTOINLENL = 0;
98
        SYNCDELAY;
99
 
100
        EP6FIFOCFG = bmBIT0;
101
        SYNCDELAY;
102
        EP6FIFOCFG = bmBIT4 | bmBIT0;           // EP6: 0 -> 1 transition of AUTOOUT bit arms the FIFO, WORDWIDE
103
        SYNCDELAY;
104
 
105
        FIFOPINPOLAR = 0;
106
        SYNCDELAY;
107
        PINFLAGSAB = 0xca;                      // FLAGA: EP6: EF; FLAGB: EP2 FF
108
        SYNCDELAY;
109
 
110
        wait(2);
111
        MT_RESET = 0;
112
}
113
 
114
 
115
// include the main part of the firmware kit, define the descriptors, ...
116
#include[ztex.h]
117
 
118
void main(void)
119
{
120
    init_USB();
121
 
122
    while (1) {
123
    }
124
}
125
 
126
 

powered by: WebSVN 2.1.0

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