Firmware: timeouts for FPGA configuration; LED flash codes for various FPGA related errors

This commit is contained in:
Maximilian Rehkopf 2013-10-18 14:43:02 +02:00
parent 28949ac307
commit f7d393451a
4 changed files with 44 additions and 29 deletions

View File

@ -98,37 +98,43 @@ void fpga_pgm(uint8_t* filename) {
uint8_t data;
int i;
tick_t timeout;
/* open configware file */
file_open(filename, FA_READ);
if(file_res) {
uart_putc('?');
uart_putc(0x30+file_res);
return;
}
do {
i=0;
timeout = getticks() + 100;
timeout = getticks() + 1;
fpga_set_prog_b(0);
if(BITBAND(PROGBREG->FIOPIN, PROGBBIT)) {
printf("PROGB is stuck high!\n");
led_panic();
}
while(BITBAND(PROGBREG->FIOPIN, PROGBBIT)) {
if(getticks() > timeout) {
printf("PROGB is stuck high!\n");
led_panic(LED_PANIC_FPGA_PROGB_STUCK);
}
}
timeout = getticks() + 100;
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(LED_PANIC_FPGA_NO_INITB);
}
};
if(fpga_get_done()) {
printf("DONE is stuck high!\n");
led_panic();
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 */
file_open(filename, FA_READ);
if(file_res) {
uart_putc('?');
uart_putc(0x30+file_res);
return;
}
uart_putc('C');
for (;;) {
@ -144,7 +150,7 @@ if(BITBAND(PROGBREG->FIOPIN, PROGBBIT)) {
} while (!fpga_get_done() && retries--);
if(!fpga_get_done()) {
printf("FPGA failed to configure after %d tries.\n", MAXRETRIES);
led_panic();
led_panic(LED_PANIC_FPGA_NOCONF);
}
printf("FPGA configured\n");
fpga_postinit();
@ -165,12 +171,15 @@ void fpga_rompgm() {
while(!fpga_get_initb()){
if(getticks() > timeout) {
printf("no response from FPGA trying to initiate configuration!\n");
led_panic();
led_panic(LED_PANIC_FPGA_NO_INITB);
}
};
if(fpga_get_done()) {
printf("DONE is stuck high!\n");
led_panic();
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');
@ -190,7 +199,7 @@ void fpga_rompgm() {
} while (!fpga_get_done() && retries--);
if(!fpga_get_done()) {
printf("FPGA failed to configure after %d tries.\n", MAXRETRIES);
led_panic();
led_panic(LED_PANIC_FPGA_NOCONF);
}
printf("FPGA configured\n");
fpga_postinit();

View File

@ -85,12 +85,12 @@ void toggle_write_led() {
writeled(~led_writeledstate);
}
void led_panic() {
void led_panic(uint8_t led_states) {
led_std();
while(1) {
rdyled(1);
readled(1);
writeled(1);
rdyled((led_states >> 2) & 1);
readled((led_states >> 1) & 1);
writeled(led_states & 1);
delay_ms(100);
rdyled(0);
readled(0);

View File

@ -3,6 +3,12 @@
#ifndef _LED_H
#define _LED_H
#define LED_PANIC_FPGA_PROGB_STUCK (1)
#define LED_PANIC_FPGA_NO_INITB (2)
#define LED_PANIC_FPGA_DONE_STUCK (3)
#define LED_PANIC_FPGA_NOCONF (4)
#define LED_PANIC_FPGA_DEAD (5)
void readbright(uint8_t bright);
void writebright(uint8_t bright);
void rdybright(uint8_t bright);
@ -13,7 +19,7 @@ void led_clkout32(uint32_t val);
void toggle_rdy_led(void);
void toggle_read_led(void);
void toggle_write_led(void);
void led_panic(void);
void led_panic(uint8_t led_states);
void led_pwm(void);
void led_std(void);
void led_init(void);

View File

@ -344,7 +344,7 @@ printf("PCONP=%lx\n", LPC_SC->PCONP);
}
/* fpga test fail: panic */
if(fpga_test() != FPGA_TEST_TOKEN){
led_panic();
led_panic(LED_PANIC_FPGA_DEAD);
}
/* else reset */
}