diff --git a/firmware/src/boards/cynthion_d11/fpga.c b/firmware/src/boards/cynthion_d11/fpga.c index 968951a..31162d8 100644 --- a/firmware/src/boards/cynthion_d11/fpga.c +++ b/firmware/src/boards/cynthion_d11/fpga.c @@ -14,18 +14,8 @@ #include -/** - * Sets up the I/O pins needed to configure the FPGA. - */ -void fpga_io_init(void) -{ - // By default, keep PROGRAM_N from being driven. - gpio_set_pin_level(FPGA_PROGRAM, true); - gpio_set_pin_direction(FPGA_PROGRAM, GPIO_DIRECTION_IN); -} - /* - * Allows or disallows the FPGA from configuring from flash. When disallowed, + * Allows or disallows the FPGA from configuring. When disallowed, * initialization (erasing of configuration memory) takes place, but the FPGA * does not proceed to the configuration phase. */ @@ -45,12 +35,22 @@ void permit_fpga_configuration(bool enable) } /** - * Requests that the FPGA clear its configuration and try to reconfigure. + * Sets up the I/O pins needed to configure the FPGA. */ -void trigger_fpga_reconfiguration(void) +void fpga_io_init(void) { + // By default, keep PROGRAM_N from being driven. + gpio_set_pin_level(FPGA_PROGRAM, true); + gpio_set_pin_direction(FPGA_PROGRAM, GPIO_DIRECTION_IN); + permit_fpga_configuration(true); +} +/** + * Requests that the FPGA clear its configuration and try to reconfigure. + */ +void trigger_fpga_reconfiguration(void) +{ gpio_set_pin_direction(FPGA_PROGRAM, GPIO_DIRECTION_OUT); gpio_set_pin_level(FPGA_PROGRAM, false); @@ -65,8 +65,6 @@ void trigger_fpga_reconfiguration(void) */ void force_fpga_offline(void) { - permit_fpga_configuration(false); - gpio_set_pin_direction(FPGA_PROGRAM, GPIO_DIRECTION_OUT); gpio_set_pin_level(FPGA_PROGRAM, false); } diff --git a/firmware/src/boards/cynthion_d11/usb_switch.c b/firmware/src/boards/cynthion_d11/usb_switch.c index c800b90..1456dfa 100644 --- a/firmware/src/boards/cynthion_d11/usb_switch.c +++ b/firmware/src/boards/cynthion_d11/usb_switch.c @@ -40,7 +40,6 @@ void take_over_usb(void) void switch_control_task(void) { if (gpio_get_pin_level(PROGRAM_BUTTON) == false) { - force_fpga_offline(); take_over_usb(); } } diff --git a/firmware/src/main.c b/firmware/src/main.c index 00f6e31..ceef060 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -58,10 +58,12 @@ int main(void) // Trigger an FPGA reconfiguration; so the FPGA automatically // configures itself from its SPI ROM on reset. This effectively // makes the RESET button reset both the uC and the FPGA. - // Only reconfigure the FPGA if the PROGRAM button is not being - // pressed. if (gpio_get_pin_level(PROGRAM_BUTTON) == true) { trigger_fpga_reconfiguration(); + } else { + // If PROGRAM button is held down at start-up, halt the FPGA + // instead of configuring it. + force_fpga_offline(); } while (1) {