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/] [libusbJava-src/] [ch/] [ntb/] [usb/] [Usb_Endpoint_Descriptor.java] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
/*
2
 * Java libusb wrapper
3
 * Copyright (c) 2005-2006 Andreas Schläpfer <spandi at users.sourceforge.net>
4
 *
5
 * http://libusbjava.sourceforge.net
6
 * This library is covered by the LGPL, read LGPL.txt for details.
7
 */
8
package ch.ntb.usb;
9
 
10
/**
11
 * Represents the descriptor of an USB endpoint.<br>
12
 * Endpoint descriptors are used to describe endpoints other than endpoint zero.
13
 * Endpoint zero is always assumed to be a control endpoint and is configured
14
 * before any descriptors are even requested. The host will use the information
15
 * returned from these descriptors to determine the bandwidth requirements of
16
 * the bus.<br>
17
 * <br>
18
 * The length of the configuration descriptor is
19
 * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_ENDPOINT_SIZE} and the type is
20
 * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_ENDPOINT}.
21
 *
22
 */
23
public class Usb_Endpoint_Descriptor extends Usb_Descriptor {
24
 
25
        /**
26
         * Maximum number of endpoints
27
         */
28
        public static final int USB_MAXENDPOINTS = 32;
29
 
30
        /**
31
         * Endpoint address mask (in bEndpointAddress).
32
         */
33
        public static final int USB_ENDPOINT_ADDRESS_MASK = 0x0f,
34
                        USB_ENDPOINT_DIR_MASK = 0x80;
35
 
36
        /**
37
         * Endpoint type mask (in bmAttributes).
38
         */
39
        public static final int USB_ENDPOINT_TYPE_MASK = 0x03;
40
 
41
        /**
42
         * Possible endpoint types (in bmAttributes).
43
         */
44
        public static final int USB_ENDPOINT_TYPE_CONTROL = 0,
45
                        USB_ENDPOINT_TYPE_ISOCHRONOUS = 1, USB_ENDPOINT_TYPE_BULK = 2,
46
                        USB_ENDPOINT_TYPE_INTERRUPT = 3;
47
 
48
        private byte bEndpointAddress;
49
 
50
        private byte bmAttributes;
51
 
52
        private short wMaxPacketSize;
53
 
54
        private byte bInterval;
55
 
56
        private byte bRefresh;
57
 
58
        private byte bSynchAddress;
59
 
60
        private byte[] extra; /* Extra descriptors */
61
 
62
        private int extralen;
63
 
64
        /**
65
         * Returns the endpoint address.<br>
66
         * <br>
67
         * Bits 3..0: Endpoint number <br>
68
         * Bits 6..4: Reserved. Set to zero <br>
69
         * Bit 7: Direction. 0 = Out, 1 = In (ignored for control endpoints)<br>
70
         *
71
         * @return the endpoint address
72
         */
73
        public byte getBEndpointAddress() {
74
                return bEndpointAddress;
75
        }
76
 
77
        /**
78
         * Returns the intervall for polling endpoint data transfers.<br>
79
         * Value in frame counts. Ignored for Bulk & Control eEndpoints. Isochronous
80
         * endpoints must equal 1 and field may range from 1 to 255 for interrupt
81
         * endpoints.
82
         *
83
         * @return the intervall for polling endpoint data transfers
84
         */
85
        public byte getBInterval() {
86
                return bInterval;
87
        }
88
 
89
        /**
90
         * Returns the attributes of this endpoint.<br>
91
         *
92
         * Bits 1..0: Transfer Type (see <i>USB_ENDPOINT_TYPE_XXX</i>).<br>
93
         * Bits 7..2: Reserved.<br>
94
         *
95
         * <pre>
96
         *      If isochronous endpoint:
97
         *              Bits 3..2: Synchronisation type
98
         *              00 = No synchronisation
99
         *                      01 = Asynchronous
100
         *          10 = Adaptive
101
         *          11 = Synchronous
102
         *      Bits 5..4: Usage Type
103
         *              00 = Data endpoint
104
         *              01 = Feedback endpoint
105
         *              10 = Explicit feedback data endpoint
106
         *              11 = Reserved
107
         * </pre>
108
         *
109
         * @return the attributes of this endpoint
110
         */
111
        public byte getBmAttributes() {
112
                return bmAttributes;
113
        }
114
 
115
        public byte getBRefresh() {
116
                return bRefresh;
117
        }
118
 
119
        public byte getBSynchAddress() {
120
                return bSynchAddress;
121
        }
122
 
123
        /**
124
         * Returns the data of extra descriptor(s) if available.<br>
125
         *
126
         * @return null or a byte array with the extra descriptor data
127
         */
128
        public byte[] getExtra() {
129
                return extra;
130
        }
131
 
132
        /**
133
         * Returns the number of bytes of the extra descriptor.<br>
134
         *
135
         * @return the number of bytes of the extra descriptor
136
         */
137
        public int getExtralen() {
138
                return extralen;
139
        }
140
 
141
        /**
142
         * Returns the maximum packet size of this endpoint is capable of sending or
143
         * receiving.<br>
144
         *
145
         * @return the maximum packet size
146
         */
147
        public short getWMaxPacketSize() {
148
                return wMaxPacketSize;
149
        }
150
 
151
        @Override
152
        public String toString() {
153
                return "Usb_Endpoint_Descriptor bEndpointAddress: 0x"
154
                                + Integer.toHexString(bEndpointAddress & 0xFF);
155
        }
156
}

powered by: WebSVN 2.1.0

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