Skip to content

Commit

Permalink
Merge pull request #172 from zyp/fix_control_ping
Browse files Browse the repository at this point in the history
usb2.control: Support PING protocol in data OUT and status OUT stages.
  • Loading branch information
miek committed Jul 18, 2022
2 parents b518a97 + fa3769d commit 4bc5899
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion luna/gateware/usb/usb2/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def elaborate(self, platform):
m.d.comb += request_handler.data_requested.eq(1)

# Once we get an OUT token, we should move on to the STATUS stage. [USB2, 8.5.3]
with m.If(endpoint_targeted & interface.tokenizer.new_token & interface.tokenizer.is_out):
with m.If(endpoint_targeted & interface.tokenizer.new_token & (interface.tokenizer.is_out | interface.tokenizer.is_ping)):
m.next = 'STATUS_OUT'


Expand All @@ -267,6 +267,10 @@ def elaborate(self, platform):
with m.If(endpoint_targeted & interface.tokenizer.new_token & interface.tokenizer.is_in):
m.next = 'STATUS_IN'

# Respond to PING token [USB2.0: 8.5.1]
with m.If(endpoint_targeted & interface.tokenizer.ready_for_response & interface.tokenizer.is_ping):
m.d.comb += interface.handshakes_out.ack.eq(1)


# STATUS_IN -- We're currently in the status stage, and we're expecting an IN token.
# We'll wait for that token.
Expand All @@ -292,6 +296,10 @@ def elaborate(self, platform):
with m.If(allowed_to_respond & interface.tokenizer.is_out):
m.d.comb += request_handler.status_requested.eq(1)

# Respond to PING token [USB2.0: 8.5.1]
with m.If(endpoint_targeted & interface.tokenizer.ready_for_response & interface.tokenizer.is_ping):
m.d.comb += interface.handshakes_out.ack.eq(1)

return m


Expand Down

0 comments on commit 4bc5899

Please sign in to comment.