def set_response(self, ep, response): if (EndpointType.epdir(ep) == EndpointType.IN and response == EndpointResponse.ACK): yield self.write(self.csrs['usb_in_ctrl'], EndpointType.epnum(ep)) elif (EndpointType.epdir(ep) == EndpointType.OUT and response == EndpointResponse.ACK): yield self.write(self.csrs['usb_out_ctrl'], 0x10 | EndpointType.epnum(ep))
def pending(self, ep): if EndpointType.epdir(ep) == EndpointType.IN: val = yield self.read(self.csrs['usb_in_status']) raise ReturnValue(val & (1 << 4)) else: val = yield self.read(self.csrs['usb_out_status']) raise ReturnValue((val & (1 << 5) | (1 << 4)) and (EndpointType.epnum(ep) == (val & 0x0f)))
def clear_pending(self, epaddr): if EndpointType.epdir(epaddr) == EndpointType.IN: # Reset endpoint self.dut._log.info("Clearing IN_EV_PENDING") yield self.write(self.csrs['usb_in_ctrl'], 0x20) yield self.write(self.csrs['usb_in_ev_pending'], 0xff) else: self.dut._log.info("Clearing OUT_EV_PENDING") yield self.write(self.csrs['usb_out_ev_pending'], 0xff) yield self.write(self.csrs['usb_out_ctrl'], 0x20)
def transaction_status_out(self, addr, ep): epnum = EndpointType.epnum(ep) assert EndpointType.epdir(ep) == EndpointType.OUT xmit = cocotb.fork(self.host_send(PID.DATA1, addr, epnum, [])) yield xmit.join()
def print_ep(self, epaddr, msg, *args): self.dut._log.info("ep(%i, %s): %s" % (EndpointType.epnum(epaddr), EndpointType.epdir(epaddr).name, msg) % args)