endpointdescriptor.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 125 行
JAVA
125 行
/*
* $Id: EndPointDescriptor.java,v 1.1 2003/11/25 11:41:20 epr Exp $
*/
package org.jnode.driver.usb;
/**
* @author Ewout Prangsma (epr@users.sourceforge.net)
*/
public final class EndPointDescriptor extends AbstractDescriptor {
/**
* Initialize this instance.
*/
public EndPointDescriptor() {
super(USB_DT_ENDPOINT_SIZE);
}
/**
* @param data
* @param ofs
* @param len
*/
public EndPointDescriptor(byte[] data, int ofs, int len) {
super(data, ofs, len);
}
/**
* Gets the address of this endpoint.
* This is a combination of address and direction.
*/
public final int getEndPointAddress() {
return getByte(2);
}
/**
* Gets the number of this endpoint.
*/
public final int getEndPointNumber() {
return getByte(2) & USB_ENDPOINT_NUMBER_MASK;
}
/**
* Gets the direction of this endpoint.
*/
public final boolean isDirIn() {
return ((getByte(2) & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
}
/**
* Gets the direction of this endpoint.
*/
public final boolean isDirOut() {
return ((getByte(2) & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
}
/**
* Gets the attributes of this endpoint.
* This is a combination of tranfer type, synchronization type and usage type.
*/
public final int getAttributes() {
return getByte(3);
}
/**
* Gets the transfer type of this endpoint.
*/
public final int getTransferType() {
return getByte(3) & USB_ENDPOINT_XFERTYPE_MASK;
}
/**
* Is the transfer type of this endpoint control.
*/
public final boolean isControlTransfer() {
return ((getByte(3) & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_CONTROL);
}
/**
* Is the transfer type of this endpoint interrupt.
*/
public final boolean isIntTransfer() {
return ((getByte(3) & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT);
}
/**
* Is the transfer type of this endpoint bulk.
*/
public final boolean isBulkTransfer() {
return ((getByte(3) & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK);
}
/**
* Is the transfer type of this endpoint isochronous.
*/
public final boolean isIsochronousTransfer() {
return ((getByte(3) & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_ISOC);
}
/**
* Gets the maximum size of packets
*/
public final int getMaxPacketSize() {
return getShort(4) & USB_ENDPOINT_MAXPS_MASK;
}
/**
* Gets the interval for polling
*/
public final int getInterval() {
return getByte(6);
}
/**
* Convert to a String representation
* @see java.lang.Object#toString()
*/
public final String toString() {
return "EP[epnum:" + getEndPointNumber() +
", dir:" + (isDirIn() ? "IN" : "OUT") +
", xfertype:" + USB_ENDPOINT_XFER_NAMES[getTransferType()] +
", mpsize:" + getMaxPacketSize() +
", intval:" + getInterval() + "]";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?