fpga_io: reboot ASAP if USB Blaster loading is detected.
This commit is contained in:
16
fpga_io.cpp
16
fpga_io.cpp
@@ -657,6 +657,20 @@ void fpga_spi_en(uint32_t mask, uint32_t en)
|
||||
fpga_gpo_write(en ? gpo | mask : gpo & ~mask);
|
||||
}
|
||||
|
||||
void fpga_wait_to_reset()
|
||||
{
|
||||
printf("FPGA is not ready. JTAG uploading?\n");
|
||||
printf("Waiting for FPGA to be ready...\n");
|
||||
|
||||
fpga_core_reset(1);
|
||||
|
||||
while (!is_fpga_ready(0))
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
reboot(0);
|
||||
}
|
||||
|
||||
uint16_t fpga_spi(uint16_t word)
|
||||
{
|
||||
uint32_t gpo = (fpga_gpo_read() & ~(0xFFFF | SSPI_STROBE)) | word;
|
||||
@@ -671,6 +685,7 @@ uint16_t fpga_spi(uint16_t word)
|
||||
if (gpi < 0)
|
||||
{
|
||||
printf("GPI[31]==1. FPGA is uninitialized?\n");
|
||||
fpga_wait_to_reset();
|
||||
return 0;
|
||||
}
|
||||
} while (!(gpi & SSPI_ACK));
|
||||
@@ -683,6 +698,7 @@ uint16_t fpga_spi(uint16_t word)
|
||||
if (gpi < 0)
|
||||
{
|
||||
printf("GPI[31]==1. FPGA is uninitialized?\n");
|
||||
fpga_wait_to_reset();
|
||||
return 0;
|
||||
}
|
||||
} while (gpi & SSPI_ACK);
|
||||
|
||||
@@ -39,4 +39,6 @@ void reboot(int cold);
|
||||
void app_restart(const char *path, const char *xml = 0);
|
||||
char *getappname();
|
||||
|
||||
void fpga_wait_to_reset();
|
||||
|
||||
#endif
|
||||
|
||||
8
main.cpp
8
main.cpp
@@ -76,13 +76,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (!is_fpga_ready(1))
|
||||
{
|
||||
printf("FPGA is not ready. JTAG uploading?\n");
|
||||
printf("Waiting for FPGA to be ready...\n");
|
||||
//enable reset in advance
|
||||
fpga_core_reset(1);
|
||||
|
||||
while (!is_fpga_ready(0)) sleep(1);
|
||||
reboot(0);
|
||||
fpga_wait_to_reset();
|
||||
}
|
||||
|
||||
user_io_poll();
|
||||
|
||||
@@ -16,17 +16,7 @@ static void scheduler_wait_fpga_ready(void)
|
||||
{
|
||||
while (!is_fpga_ready(1))
|
||||
{
|
||||
printf("FPGA is not ready. JTAG uploading?\n");
|
||||
printf("Waiting for FPGA to be ready...\n");
|
||||
|
||||
//enable reset in advance
|
||||
fpga_core_reset(1);
|
||||
|
||||
while (!is_fpga_ready(0))
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
reboot(0);
|
||||
fpga_wait_to_reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user