Skip to content

Commit

Permalink
Merge pull request #256 from martinling/wcid-request-fixes
Browse files Browse the repository at this point in the history
Fixes for Microsoft OS 1.0 descriptor request handler
  • Loading branch information
mossmann authored May 19, 2024
2 parents 1c2eece + ba8634f commit e8bbfac
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions luna/gateware/usb/request/windows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ def elaborate(self, platform):
#
with m.If(
(setup.type == USBRequestType.VENDOR) &
(setup.recipient == USBRequestRecipient.DEVICE) &
((setup.index == 4) | (setup.index == 5))
(setup.request == self._request_code) & (
((setup.recipient == USBRequestRecipient.DEVICE) & (setup.index == 4)) |
((setup.recipient == USBRequestRecipient.INTERFACE) & (setup.index == 5)))
):
m.d.comb += interface.claim.eq(1)

Expand All @@ -75,13 +76,7 @@ def elaborate(self, platform):

# If we've received a new setup packet, handle it.
with m.If(setup.received):

with m.Switch(setup.request):

with m.Case(self._request_code):
m.next = 'GET_MS_DESCRIPTOR'
with m.Default():
m.next = 'UNHANDLED'
m.next = 'GET_MS_DESCRIPTOR'


# GET_MS_DESCRIPTOR -- The host is trying to request a OS Feature descriptor set
Expand Down Expand Up @@ -125,14 +120,4 @@ def elaborate(self, platform):
m.d.usb += expecting_ack.eq(0)
m.next = 'IDLE'


# UNHANDLED -- we've received a request we're not prepared to handle
with m.State('UNHANDLED'):

# When we next have an opportunity to stall, do so,
# and then return to idle.
with m.If(interface.data_requested | interface.status_requested):
m.d.comb += handshake_generator.stall.eq(1)
m.next = 'IDLE'

return m

0 comments on commit e8bbfac

Please sign in to comment.