OpenEndpoint for now takes an address - a device can have two endpoints

with the same number...
This commit is contained in:
Sebastian Zagrodzki
2017-04-09 19:08:42 +02:00
parent c44b5b7307
commit f668df87df
4 changed files with 15 additions and 13 deletions

View File

@@ -27,6 +27,8 @@ type EndpointInfo struct {
// Number represents the endpoint number. Note that the endpoint number is different from the
// address field in the descriptor - address 0x82 means endpoint number 2,
// with endpoint direction IN.
// The device can have up to two endpoints with the same number but with
// different directions.
Number uint8
// Direction defines whether the data is flowing IN or OUT from the host perspective.
Direction EndpointDirection
@@ -44,9 +46,9 @@ type EndpointInfo struct {
UsageType UsageType
}
func (e EndpointInfo) addr() uint8 {
addr := e.Number
if e.Direction == EndpointDirectionIn {
func endpointAddr(n uint8, d EndpointDirection) uint8 {
addr := n
if d == EndpointDirectionIn {
addr |= 0x80
}
return addr
@@ -55,7 +57,7 @@ func (e EndpointInfo) addr() uint8 {
// String returns the human-readable description of the endpoint.
func (e EndpointInfo) String() string {
ret := make([]string, 0, 3)
ret = append(ret, fmt.Sprintf("Endpoint #%d %s (address 0x%02x) %s", e.Number, e.Direction, e.addr(), e.TransferType))
ret = append(ret, fmt.Sprintf("Endpoint #%d %s (address 0x%02x) %s", e.Number, e.Direction, endpointAddr(e.Number, e.Direction), e.TransferType))
switch e.TransferType {
case TransferTypeIsochronous:
ret = append(ret, fmt.Sprintf("- %s %s", e.IsoSyncType, e.UsageType))