void fpga_rompgm() { int MAXRETRIES = 10; int retries = MAXRETRIES; uint8_t data; int i; tick_t timeout; do { i=0; timeout = getticks() + 100; fpga_set_prog_b(0); uart_putc('P'); fpga_set_prog_b(1); while(!fpga_get_initb()){ if(getticks() > timeout) { printf("no response from FPGA trying to initiate configuration!\n"); led_panic(LED_PANIC_FPGA_NO_INITB); } }; timeout = getticks() + 100; while(fpga_get_done()) { if(getticks() > timeout) { printf("DONE is stuck high!\n"); led_panic(LED_PANIC_FPGA_DONE_STUCK); } } LPC_GPIO2->FIOMASK1 = ~(BV(0)); uart_putc('p'); /* open configware file */ rle_mem_init(cfgware, sizeof(cfgware)); printf("sizeof(cfgware) = %d\n", sizeof(cfgware)); for (;;) { data = rle_mem_getc(); if(rle_state) break; i++; FPGA_SEND_BYTE_SERIAL(data); } uart_putc('c'); printf("fpga_rompgm: %d bytes programmed\n", i); delay_ms(1); } while (!fpga_get_done() && retries--); if(!fpga_get_done()) { printf("FPGA failed to configure after %d tries.\n", MAXRETRIES); led_panic(LED_PANIC_FPGA_NOCONF); } printf("FPGA configured\n"); fpga_config = FPGA_ROM; fpga_postinit(); }
uint32_t load_bootrle(uint32_t base_addr) { uint8_t data; set_mcu_addr(base_addr); DWORD filesize = 0; rle_mem_init(bootrle, sizeof(bootrle)); FPGA_SELECT(); FPGA_TX_BYTE(0x98); for(;;) { data = rle_mem_getc(); if(rle_state) break; FPGA_TX_BYTE(data); FPGA_WAIT_RDY(); filesize++; } FPGA_DESELECT(); return (uint32_t)filesize; }