Skip to content

Commit

Permalink
Merge pull request #51 from mndza/rename-honor-req
Browse files Browse the repository at this point in the history
rename `honor_fpga_adv` to `allow_fpga_takeover_usb`
  • Loading branch information
mossmann authored May 16, 2024
2 parents 87b5f53 + bc1eeae commit 93470ec
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
14 changes: 7 additions & 7 deletions apollo_fpga/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class ApolloDebugger:
if os.getenv("LUNA_USB_IDS"):
LUNA_USB_IDS += [tuple([int(x, 16) for x in os.getenv("LUNA_USB_IDS").split(":")])]

REQUEST_SET_LED_PATTERN = 0xa1
REQUEST_RECONFIGURE = 0xc0
REQUEST_FORCE_FPGA_OFFLINE = 0xc1
REQUEST_HONOR_FPGA_ADV = 0xc2
REQUEST_SET_LED_PATTERN = 0xa1
REQUEST_RECONFIGURE = 0xc0
REQUEST_FORCE_FPGA_OFFLINE = 0xc1
REQUEST_ALLOW_FPGA_TAKEOVER_USB = 0xc2

LED_PATTERN_IDLE = 500
LED_PATTERN_UPLOAD = 50
Expand Down Expand Up @@ -294,9 +294,9 @@ def force_fpga_offline(self):
""" Resets the target (FPGA/etc) connected to the debug controller. """
self.out_request(self.REQUEST_FORCE_FPGA_OFFLINE)

def honor_fpga_adv(self):
""" Tell Apollo to honor requests from FPGA_ADV again. Useful after reconfiguration. """
self.out_request(self.REQUEST_HONOR_FPGA_ADV)
def allow_fpga_takeover_usb(self):
""" Request Apollo to allow FPGA takeover of the USB port. Useful after reconfiguration. """
self.out_request(self.REQUEST_ALLOW_FPGA_TAKEOVER_USB)

def close(self):
""" Closes the USB device so it can be reused, possibly by another ApolloDebugger """
Expand Down
6 changes: 3 additions & 3 deletions apollo_fpga/commands/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def configure_fpga(device, args):
programmer.configure(bitstream)

# Let the LUNA gateware take over in devices with shared USB port
device.honor_fpga_adv()
device.allow_fpga_takeover_usb()


def ensure_unconfigured(device):
Expand Down Expand Up @@ -194,7 +194,7 @@ def program_flash_fast(device, args):
programmer.configure(products.get("top.bit"))

# Let the LUNA gateware take over in devices with shared USB port
device.honor_fpga_adv()
device.allow_fpga_takeover_usb()

# Wait for flash bridge enumeration
time.sleep(2)
Expand Down Expand Up @@ -260,7 +260,7 @@ def reconfigure_fpga(device, args):
device.soft_reset()

# Let the LUNA gateware take over in devices with shared USB port
device.honor_fpga_adv()
device.allow_fpga_takeover_usb()


def force_fpga_offline(device, args):
Expand Down
4 changes: 2 additions & 2 deletions firmware/src/boards/cynthion_d11/fpga_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ void fpga_adv_task(void)
}

/**
* Honor requests from FPGA_ADV again
* Allow FPGA takeover of the USB port
*/
void honor_fpga_adv(void)
void allow_fpga_takeover_usb(void)
{
#ifdef BOARD_HAS_USB_SWITCH
if (fpga_requesting_port()) {
Expand Down
4 changes: 2 additions & 2 deletions firmware/src/boards/cynthion_d21/fpga_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ void fpga_adv_task(void)
}

/**
* Honor requests from FPGA_ADV again
* Allow FPGA takeover of the USB port
*/
void honor_fpga_adv(void)
void allow_fpga_takeover_usb(void)
{
}

Expand Down
4 changes: 2 additions & 2 deletions firmware/src/boards/daisho/fpga_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ void fpga_adv_task(void)
}

/**
* Honor requests from FPGA_ADV again
* Allow FPGA takeover of the USB port
*/
void honor_fpga_adv(void)
void allow_fpga_takeover_usb(void)
{
}

Expand Down
4 changes: 2 additions & 2 deletions firmware/src/boards/qtpy/fpga_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ void fpga_adv_task(void)
}

/**
* Honor requests from FPGA_ADV again
* Allow FPGA takeover of the USB port
*/
void honor_fpga_adv(void)
void allow_fpga_takeover_usb(void)
{
}

Expand Down
4 changes: 2 additions & 2 deletions firmware/src/boards/samd11_xplained/fpga_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ void fpga_adv_task(void)
}

/**
* Honor requests from FPGA_ADV again
* Allow FPGA takeover of the USB port
*/
void honor_fpga_adv(void)
void allow_fpga_takeover_usb(void)
{
}

Expand Down
4 changes: 2 additions & 2 deletions firmware/src/fpga_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ void fpga_adv_init(void);
void fpga_adv_task(void);

/**
* Honor requests from FPGA_ADV again
* Allow FPGA takeover of the USB port
*/
void honor_fpga_adv(void);
void allow_fpga_takeover_usb(void);

/**
* True if we received an advertisement message within the last time window.
Expand Down
18 changes: 9 additions & 9 deletions firmware/src/vendor.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ enum {
// General programming requests.
VENDOR_REQUEST_TRIGGER_RECONFIGURATION = 0xc0,
VENDOR_REQUEST_FORCE_FPGA_OFFLINE = 0xc1,
VENDOR_REQUEST_HONOR_FPGA_ADV = 0xc2,
VENDOR_REQUEST_ALLOW_FPGA_TAKEOVER_USB = 0xc2,


//
Expand Down Expand Up @@ -142,16 +142,16 @@ bool handle_force_fpga_offline(uint8_t rhport, tusb_control_request_t const* req


/**
* Request Apollo to honor FPGA advertisement messages.
* Request Apollo to allow FPGA takeover of the USB port.
*/
bool handle_honor_fpga_adv(uint8_t rhport, tusb_control_request_t const* request)
bool handle_allow_fpga_takeover_usb(uint8_t rhport, tusb_control_request_t const* request)
{
return tud_control_xfer(rhport, request, NULL, 0);
}

bool handle_honor_fpga_adv_finish(uint8_t rhport, tusb_control_request_t const* request)
bool handle_allow_fpga_takeover_usb_finish(uint8_t rhport, tusb_control_request_t const* request)
{
honor_fpga_adv();
allow_fpga_takeover_usb();
return true;
}

Expand All @@ -169,8 +169,8 @@ static bool handle_vendor_request_setup(uint8_t rhport, tusb_control_request_t c
return handle_trigger_fpga_reconfiguration(rhport, request);
case VENDOR_REQUEST_FORCE_FPGA_OFFLINE:
return handle_force_fpga_offline(rhport, request);
case VENDOR_REQUEST_HONOR_FPGA_ADV:
return handle_honor_fpga_adv(rhport, request);
case VENDOR_REQUEST_ALLOW_FPGA_TAKEOVER_USB:
return handle_allow_fpga_takeover_usb(rhport, request);

// JTAG requests
case VENDOR_REQUEST_JTAG_CLEAR_OUT_BUFFER:
Expand Down Expand Up @@ -250,8 +250,8 @@ static bool handle_vendor_request_complete(uint8_t rhport, tusb_control_request_
static bool handle_vendor_request_finish(uint8_t rhport, tusb_control_request_t const * request)
{
switch (request->bRequest) {
case VENDOR_REQUEST_HONOR_FPGA_ADV:
return handle_honor_fpga_adv_finish(rhport, request);
case VENDOR_REQUEST_ALLOW_FPGA_TAKEOVER_USB:
return handle_allow_fpga_takeover_usb_finish(rhport, request);
default:
return true;
}
Expand Down

0 comments on commit 93470ec

Please sign in to comment.