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

Subversion Repositories usb_fpga_2_04

[/] [usb_fpga_2_04/] [trunk/] [examples/] [usb-fpga-2.01/] [2.01b/] [intraffic/] [intraffic.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
/*!
2
   intraffic -- example showing how the EZ-USB FIFO interface is used on ZTEX USB-FPGA Module 2.01b
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
// configure endpoint 2, in, quad buffered, 512 bytes, interface 0
23
EP_CONFIG(2,0,BULK,IN,512,4);
24
 
25
// select ZTEX USB FPGA Module 2.01 as target  (required for FPGA configuration)
26
IDENTITY_UFM_2_01(10.18.0.0,0);
27
 
28
// this product string is also used for identification by the host software
29
#define[PRODUCT_STRING]["intraffic example for UFM 2.01"]
30
 
31
// this is called automatically after FPGA configuration
32
#define[POST_FPGA_CONFIG][POST_FPGA_CONFIG
33
        IOA0 = 1;                               // reset on
34
        IOA1 = 0;                                // controlled mode
35
        OEA |= bmBIT0 | bmBIT1;
36
 
37
        EP2CS &= ~bmBIT0;                       // clear stall bit
38
 
39
        REVCTL = 0x3;
40
        SYNCDELAY;
41
 
42
        IFCONFIG = bmBIT7 | bmBIT5 | 3;         // internel 30MHz clock, drive IFCLK ouput, slave FIFO interface
43
        SYNCDELAY;
44
        EP2FIFOCFG = bmBIT3 | bmBIT0;           // AOTUOIN, WORDWIDE
45
        SYNCDELAY;
46
 
47
#ifdef[fastmode]
48
        EP2AUTOINLENH = 4;                      // 1024 bytes 
49
#else   
50
        EP2AUTOINLENH = 2;                      // 512 bytes 
51
#endif  
52
        SYNCDELAY;
53
        EP2AUTOINLENL = 0;
54
        SYNCDELAY;
55
 
56
        FIFORESET = 0x80;                       // reset FIFO
57
        SYNCDELAY;
58
        FIFORESET = 2;
59
        SYNCDELAY;
60
        FIFORESET = 0x00;
61
        SYNCDELAY;
62
 
63
        FIFOPINPOLAR = 0;
64
        SYNCDELAY;
65
        PINFLAGSAB = 0;
66
        SYNCDELAY;
67
        PINFLAGSCD = 0;
68
        SYNCDELAY;
69
 
70
        IOA0 = 0;                                // reset off
71
]
72
 
73
// set mode
74
ADD_EP0_VENDOR_COMMAND((0x60,,
75
        IOA0 = 1;                               // reset on
76
        IOA1 = SETUPDAT[2] ? 1 : 0;
77
        IOA0 = 0;                                // reset off
78
,,
79
        NOP;
80
));;
81
 
82
// include the main part of the firmware kit, define the descriptors, ...
83
#include[ztex.h]
84
 
85
void main(void)
86
{
87
    init_USB();
88
 
89
    while (1) {
90
    }
91
}
92
 

powered by: WebSVN 2.1.0

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