Skip to content

Commit

Permalink
apollo_fpga.gateware: convert request handler to new interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mndza committed Dec 4, 2023
1 parent 54c018d commit ac6ac1c
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions apollo_fpga/gateware/advertiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def __init__(self, if_number, stop_pin):
self.if_number = if_number
self.stop_pin = stop_pin

def handled(self, setup):
return (setup.type == USBRequestType.VENDOR) & \
(setup.recipient == USBRequestRecipient.INTERFACE) & \
(setup.index == self.if_number)

def elaborate(self, platform):
m = Module()

Expand All @@ -84,9 +89,7 @@ def elaborate(self, platform):
(setup.recipient == USBRequestRecipient.INTERFACE) & \
(setup.index == self.if_number)):

with m.Switch(setup.request):

with m.Case(self.REQUEST_APOLLO_ADV_STOP):
with m.If(setup.request == self.REQUEST_APOLLO_ADV_STOP):

# Once the receive is complete, respond with an ACK.
with m.If(interface.rx_ready_for_response):
Expand All @@ -97,12 +100,4 @@ def elaborate(self, platform):
m.d.comb += self.send_zlp()
m.d.usb += self.stop_pin.eq(1)

with m.Case():

#
# Stall unhandled requests.
#
with m.If(interface.status_requested | interface.data_requested):
m.d.comb += interface.handshakes_out.stall.eq(1)

return m
return m

0 comments on commit ac6ac1c

Please sign in to comment.