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.04/] [2.04b/] [memtest/] [memtest.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
/*!
2
   memtest -- DDR SDRAM FIFO for testing memory on ZTEX USB-FPGA Module 2.04b
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
 
19
#include[ztex-conf.h]   // Loads the configuration macros, see ztex-conf.h for the available macros
20
#include[ztex-utils.h]  // include basic functions
21
 
22
// 1024 (instead of 512) byte bulk transferns. 
23
// According to USB standard they are invalid but usually supported and 25% faster.
24
//#define[fastmode]
25
 
26
#ifdef[fastmode]
27
// configure endpoint 2, in, quad buffered, 1024 bytes, interface 0
28
EP_CONFIG(2,0,BULK,IN,1024,4);
29
#else
30
// configure endpoint 2, in, quad buffered, 512 bytes, interface 0
31
EP_CONFIG(2,0,BULK,IN,512,4);
32
#endif
33
 
34
// select ZTEX USB FPGA Module 2.04 as target  (required for FPGA configuration)
35
IDENTITY_UFM_2_04(10.19.0.0,0);
36
 
37
// this product string is also used for identification by the host software
38
#define[PRODUCT_STRING]["memtest example for UFM 2.04"]
39
 
40
// 0 : counter mode; 1: shift pattern mode 
41
__xdata BYTE mode = 0;
42
 
43
// this is called automatically after FPGA configuration
44
#define[POST_FPGA_CONFIG][POST_FPGA_CONFIG
45
        IOA0 = 1;                               // reset on
46
        OEA |= bmBIT0 | bmBIT3;
47
        if ( mode ) IOA3 = 1;
48
 
49
        EP2CS &= ~bmBIT0;                       // clear stall bit
50
 
51
        REVCTL = 0x3;
52
        SYNCDELAY;
53
 
54
        IFCONFIG = bmBIT7 | bmBIT5 | 3;         // internel 30MHz clock, drive IFCLK ouput, slave FIFO interface
55
        SYNCDELAY;
56
        EP2FIFOCFG = bmBIT3 | bmBIT0;           // AOTUOIN, WORDWIDE
57
        SYNCDELAY;
58
 
59
#ifdef[fastmode]
60
        EP2AUTOINLENH = 4;                      // 1024 bytes 
61
#else   
62
        EP2AUTOINLENH = 2;                      // 512 bytes 
63
#endif  
64
        SYNCDELAY;
65
        EP2AUTOINLENL = 0;
66
        SYNCDELAY;
67
 
68
        FIFORESET = 0x80;                       // reset FIFO
69
        SYNCDELAY;
70
        FIFORESET = 2;
71
        SYNCDELAY;
72
        FIFORESET = 0x00;
73
        SYNCDELAY;
74
 
75
        FIFOPINPOLAR = 0;
76
        SYNCDELAY;
77
        PINFLAGSAB = 0;
78
        SYNCDELAY;
79
        PINFLAGSCD = 0;
80
        SYNCDELAY;
81
 
82
        IOA0 = 0;                                // reset off
83
]
84
 
85
// set the test pattern
86
ADD_EP0_VENDOR_COMMAND((0x60,,
87
        mode = SETUPDAT[2];
88
,,
89
        NOP;
90
));;
91
 
92
// include the main part of the firmware kit, define the descriptors, ...
93
#include[ztex.h]
94
 
95
void main(void)
96
{
97
    init_USB();
98
 
99
    while (1) {
100
    }
101
}
102
 

powered by: WebSVN 2.1.0

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