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/] [libusbJava-src/] [ch/] [ntb/] [usb/] [Usb_Device_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 a USB device.<br>
12
 * A USB device can only have one device descriptor. It specifies some basic,
13
 * yet important information about the device.<br>
14
 * <br>
15
 * The length of the device descriptor is
16
 * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_DEVICE_SIZE} and the type is
17
 * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_DEVICE}.
18
 *
19
 */
20
public class Usb_Device_Descriptor extends Usb_Descriptor {
21
        /**
22
         * Device and/or interface class codes.
23
         */
24
        public static final int USB_CLASS_PER_INTERFACE = 0, USB_CLASS_AUDIO = 1,
25
                        USB_CLASS_COMM = 2, USB_CLASS_HID = 3, USB_CLASS_PRINTER = 7,
26
                        USB_CLASS_MASS_STORAGE = 8, USB_CLASS_HUB = 9, USB_CLASS_DATA = 10,
27
                        USB_CLASS_VENDOR_SPEC = 0xff;
28
 
29
        private short bcdUSB;
30
 
31
        private byte bDeviceClass;
32
 
33
        private byte bDeviceSubClass;
34
 
35
        private byte bDeviceProtocol;
36
 
37
        private byte bMaxPacketSize0;
38
 
39
        private short idVendor;
40
 
41
        private short idProduct;
42
 
43
        private short bcdDevice;
44
 
45
        private byte iManufacturer;
46
 
47
        private byte iProduct;
48
 
49
        private byte iSerialNumber;
50
 
51
        private byte bNumConfigurations;
52
 
53
        /**
54
         * Returns the device release number.<br>
55
         * Assigned by the manufacturer of the device.
56
         *
57
         * @return the device release number
58
         */
59
        public short getBcdDevice() {
60
                return bcdDevice;
61
        }
62
 
63
        /**
64
         * Returns the USB specification number to which the device complies to.<br>
65
         * This field reports the highest version of USB the device supports. The
66
         * value is in binary coded decimal with a format of 0xJJMN where JJ is the
67
         * major version number, M is the minor version number and N is the sub
68
         * minor version number.<br>
69
         * Examples: USB 2.0 is reported as 0x0200, USB 1.1 as 0x0110 and USB 1.0 as
70
         * 0x100
71
         *
72
         * @return the USB specification number to which the device complies to
73
         */
74
        public short getBcdUSB() {
75
                return bcdUSB;
76
        }
77
 
78
        /**
79
         * Returns the class code (Assigned by <a
80
         * href="http://www.usb.org">www.usb.org</a>)<br>
81
         * If equal to zero, each interface specifies it's own class code. If equal
82
         * to 0xFF, the class code is vendor specified. Otherwise the field is a
83
         * valid class code.
84
         *
85
         * @return the class code
86
         */
87
        public byte getBDeviceClass() {
88
                return bDeviceClass;
89
        }
90
 
91
        /**
92
         * Returns the protocol code (Assigned by <a
93
         * href="http://www.usb.org">www.usb.org</a>)<br>
94
         *
95
         * @return the protocol code
96
         */
97
        public byte getBDeviceProtocol() {
98
                return bDeviceProtocol;
99
        }
100
 
101
        /**
102
         * Returns the subclass code (Assigned by <a
103
         * href="http://www.usb.org">www.usb.org</a>)<br>
104
         *
105
         * @return the subclass code
106
         */
107
        public byte getBDeviceSubClass() {
108
                return bDeviceSubClass;
109
        }
110
 
111
        /**
112
         * Returns the maximum packet size for endpoint zero.<br>
113
         * Valid sizes are 8, 16, 32, 64.
114
         *
115
         * @return the maximum packet size for endpoint zero
116
         */
117
        public byte getBMaxPacketSize0() {
118
                return bMaxPacketSize0;
119
        }
120
 
121
        /**
122
         * Returns the number of possible configurations supported at its current
123
         * speed.<br>
124
         *
125
         * @return the number of possible configurations supported at its current
126
         *         speed
127
         */
128
        public byte getBNumConfigurations() {
129
                return bNumConfigurations;
130
        }
131
 
132
        /**
133
         * Returns the product ID (Assigned by <a
134
         * href="http://www.usb.org">www.usb.org</a>)<br>
135
         *
136
         * @return the product ID
137
         */
138
        public short getIdProduct() {
139
                return idProduct;
140
        }
141
 
142
        /**
143
         * Returns the Vendor ID (Assigned by <a
144
         * href="http://www.usb.org">www.usb.org</a>)<br>
145
         *
146
         * @return the Vendor ID
147
         */
148
        public short getIdVendor() {
149
                return idVendor;
150
        }
151
 
152
        /**
153
         * Returns the index of the manufacturer string descriptor.<br>
154
         * If this value is 0, no string descriptor is used.
155
         *
156
         * @return the index of the manufacturer string descriptor
157
         */
158
        public byte getIManufacturer() {
159
                return iManufacturer;
160
        }
161
 
162
        /**
163
         * Returns the index of the product string descriptor.<br>
164
         * If this value is 0, no string descriptor is used.
165
         *
166
         * @return the index of the product string descriptor
167
         */
168
        public byte getIProduct() {
169
                return iProduct;
170
        }
171
 
172
        /**
173
         * Returns the index of serial number string descriptor.<br>
174
         * If this value is 0, no string descriptor is used.
175
         *
176
         * @return the index of serial number string descriptor
177
         */
178
        public byte getISerialNumber() {
179
                return iSerialNumber;
180
        }
181
 
182
        @Override
183
        public String toString() {
184
                StringBuffer sb = new StringBuffer();
185
                sb.append("Usb_Device_Descriptor idVendor: 0x"
186
                                + Integer.toHexString(idVendor & 0xFFFF) + ", idProduct: 0x"
187
                                + Integer.toHexString(idProduct & 0xFFFF));
188
                return sb.toString();
189
        }
190
}

powered by: WebSVN 2.1.0

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