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

powered by: WebSVN 2.1.0

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