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_Config_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 configuration.<br>
12
 * A USB device can have several different configuration.<br>
13
 * <br>
14
 * The length of the configuration descriptor is
15
 * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_CONFIG_SIZE} and the type is
16
 * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_CONFIG}.
17
 *
18
 */
19
public class Usb_Config_Descriptor extends Usb_Descriptor {
20
 
21
        /**
22
         * Maximum number of configurations per device
23
         */
24
        public static final int USB_MAXCONFIG = 8;
25
 
26
        private short wTotalLength;
27
 
28
        private byte bNumInterfaces;
29
 
30
        private byte bConfigurationValue;
31
 
32
        private byte iConfiguration;
33
 
34
        private byte bmAttributes;
35
 
36
        private byte MaxPower;
37
 
38
        private Usb_Interface[] interface_;
39
 
40
        private byte[] extra; /* Extra descriptors */
41
 
42
        private int extralen;
43
 
44
        /**
45
         * Returns the value to use as an argument to select this configuration ({@link LibusbJava#usb_set_configuration(long, int)}).
46
         *
47
         * @return the value to use as an argument to select this configuration
48
         */
49
        public byte getBConfigurationValue() {
50
                return bConfigurationValue;
51
        }
52
 
53
        /**
54
         * Returns the power parameters for this configuration.<br>
55
         * <br>
56
         * Bit 7: Reserved, set to 1 (USB 1.0 Bus Powered)<br>
57
         * Bit 6: Self Powered<br>
58
         * Bit 5: Remote Wakeup<br>
59
         * Bit 4..0: Reserved, set to 0
60
         *
61
         * @return the power parameters for this configuration
62
         */
63
        public byte getBmAttributes() {
64
                return bmAttributes;
65
        }
66
 
67
        /**
68
         * Returns the number of interfaces.<br>
69
         *
70
         * @return the number of interfaces
71
         */
72
        public byte getBNumInterfaces() {
73
                return bNumInterfaces;
74
        }
75
 
76
        /**
77
         * Returns the data of extra descriptor(s) if available.<br>
78
         *
79
         * @return null or a byte array with the extra descriptor data
80
         */
81
        public byte[] getExtra() {
82
                return extra;
83
        }
84
 
85
        /**
86
         * Returns the number of bytes of the extra descriptor.<br>
87
         *
88
         * @return the number of bytes of the extra descriptor
89
         */
90
        public int getExtralen() {
91
                return extralen;
92
        }
93
 
94
        /**
95
         * Returns the index of the String descriptor describing this configuration.<br>
96
         *
97
         * @return the index of the String descriptor
98
         */
99
        public byte getIConfiguration() {
100
                return iConfiguration;
101
        }
102
 
103
        /**
104
         * Returns the USB interface descriptors.<br>
105
         *
106
         * @return the USB interface descriptors
107
         */
108
        public Usb_Interface[] getInterface() {
109
                return interface_;
110
        }
111
 
112
        /**
113
         * Returns the maximum power consumption in 2mA units.<br>
114
         *
115
         * @return the maximum power consumption in 2mA units
116
         */
117
        public byte getMaxPower() {
118
                return MaxPower;
119
        }
120
 
121
        /**
122
         * Returns the total length in bytes of all descriptors.<br>
123
         * When the configuration descriptor is read, it returns the entire
124
         * configuration hierarchy which includes all related interface and endpoint
125
         * descriptors. The <code>wTotalLength</code> field reflects the number of
126
         * bytes in the hierarchy.
127
         *
128
         * @return the total length in bytes of all descriptors
129
         */
130
        public short getWTotalLength() {
131
                return wTotalLength;
132
        }
133
 
134
        @Override
135
        public String toString() {
136
                return "Usb_Config_Descriptor bNumInterfaces: 0x"
137
                                + Integer.toHexString(bNumInterfaces);
138
        }
139
}

powered by: WebSVN 2.1.0

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