Adjustments for board rev.B

This commit is contained in:
ikari
2009-10-22 11:25:52 +02:00
parent c14d25f6e2
commit 677233c0d7
11 changed files with 64 additions and 51 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -27,7 +27,7 @@
CONFIG_MCU=atmega644 CONFIG_MCU=atmega644
CONFIG_LINKER_RELAX=n CONFIG_LINKER_RELAX=n
CONFIG_MCU_FREQ=13500000 CONFIG_MCU_FREQ=12288000
CONFIG_BOOTLOADER=y CONFIG_BOOTLOADER=y
CONFIG_BOOT_DEVID=0x4e534453 CONFIG_BOOT_DEVID=0x4e534453
CONFIG_UART_DEBUG=y CONFIG_UART_DEBUG=y
@@ -35,7 +35,7 @@ CONFIG_UART_BAUDRATE=38400
CONFIG_UART_BUF_SHIFT=7 CONFIG_UART_BUF_SHIFT=7
CONFIG_HARDWARE_NAME=sd2snes CONFIG_HARDWARE_NAME=sd2snes
CONFIG_SD_AUTO_RETRIES=10 CONFIG_SD_AUTO_RETRIES=10
#CONFIG_SD_DATACRC=y CONFIG_SD_DATACRC=y
CONFIG_EEPROM_SIZE=512 CONFIG_EEPROM_SIZE=512
CONFIG_EEPROM_OFFSET=512 CONFIG_EEPROM_OFFSET=512
CONFIG_MAX_PARTITIONS=1 CONFIG_MAX_PARTITIONS=1

View File

@@ -62,8 +62,8 @@
# error Unknown chip! # error Unknown chip!
# endif # endif
# define SD_CHANGE_VECT INT0_vect # define SD_CHANGE_VECT INT0_vect
# define SDCARD_WP (PINB & _BV(PB3)) # define SDCARD_WP (PINB & _BV(PB1))
# define SDCARD_WP_SETUP() do { DDRB &= ~ _BV(PB3); PORTB |= _BV(PB3); } while(0) # define SDCARD_WP_SETUP() do { DDRB &= ~ _BV(PB1); PORTB |= _BV(PB1); } while(0)
# define SD_CHANGE_ICR MCUCR # define SD_CHANGE_ICR MCUCR
# define SD_SUPPLY_VOLTAGE (1L<<21) # define SD_SUPPLY_VOLTAGE (1L<<21)
# define DEVICE_SELECT (8+!(PINA & _BV(PA2))+2*!(PINA & _BV(PA3))) # define DEVICE_SELECT (8+!(PINA & _BV(PA2))+2*!(PINA & _BV(PA3)))

View File

@@ -31,9 +31,11 @@
CCLK PD4 OUT CCLK PD4 OUT
INIT_B PD7 IN INIT_B PD7 IN
DIN PC7 OUT DIN PC7 OUT
DONE PA3 IN
*/ */
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <util/delay.h>
#include "fpga.h" #include "fpga.h"
#include "config.h" #include "config.h"
#include "uart.h" #include "uart.h"
@@ -89,11 +91,13 @@ void fpga_init() {
DDRC = _BV(PC7); // for FPGA config, PC7 is output DDRC = _BV(PC7); // for FPGA config, PC7 is output
DDRD |= _BV(PD3) | _BV(PD4); // PD3, PD4 are outputs DDRD |= _BV(PD3) | _BV(PD4); // PD3, PD4 are outputs
DDRA = ~_BV(PA3); // PA3 is input <- DONE
set_cclk(0); // initial clk=0 set_cclk(0); // initial clk=0
} }
int fpga_get_done(void) { int fpga_get_done(void) {
return 0; return PINA & _BV(PA3);
} }
void fpga_postinit() { void fpga_postinit() {
@@ -103,43 +107,45 @@ void fpga_postinit() {
} }
void fpga_pgm(char* filename) { void fpga_pgm(char* filename) {
set_prog_b(0); int MAXRETRIES = 10;
uart_putc('P'); // int retries = MAXRETRIES;
set_prog_b(1); do {
loop_until_bit_is_set(PIND, PD7); set_prog_b(0);
uart_putc('p'); uart_putc('P');
set_prog_b(1);
// FIL in; loop_until_bit_is_set(PIND, PD7);
// FRESULT res; uart_putc('p');
UINT bytes_read;
UINT bytes_read;
// open configware file // open configware file
// res=f_open(&in, filename, FA_READ); file_open(filename, FA_READ);
file_open(filename, FA_READ); if(file_res) {
if(file_res) { uart_putc('?');
uart_putc('?'); uart_putc(0x30+file_res);
uart_putc(0x30+file_res); return;
return;
}
// file open successful
set_cs_b(0);
set_rdwr_b(0);
for (;;) {
// res = f_read(&in, file_buf, sizeof(file_buf), &bytes_read);
bytes_read = file_read();
if (file_res || bytes_read == 0) break; // error or eof
for(int i=0; i<bytes_read; i++) {
//FPGA_SEND_BYTE(file_buf[i]);
FPGA_SEND_BYTE_SERIAL(file_buf[i]);
} }
} // file open successful
set_cs_b(0);
file_close(); set_rdwr_b(0);
for (;;) {
bytes_read = file_read();
if (file_res || bytes_read == 0) break; // error or eof
for(int i=0; i<bytes_read; i++) {
FPGA_SEND_BYTE_SERIAL(file_buf[i]);
}
}
file_close();
_delay_ms(10);
} while (0); //(!fpga_get_done() && retries--);
if(!fpga_get_done()) {
dprintf("FPGA failed to configure after %d tries.\n", MAXRETRIES);
_delay_ms(50);
}
fpga_postinit(); fpga_postinit();
} }
void set_avr_read(uint8_t val) { void set_avr_read(uint8_t val) {
if(val) { if(val) {
PORTB |= _BV(PB3); PORTB |= _BV(PB3);
@@ -210,3 +216,4 @@ void set_avr_bank(uint8_t val) {
FPGA_SS_HIGH(); FPGA_SS_HIGH();
SPI_SS_LOW(); SPI_SS_LOW();
} }

View File

@@ -43,15 +43,24 @@ void update_leds(void) {
} }
void toggle_busy_led(void) { void toggle_busy_led(void) {
PORTB &= ~_BV(PB1); PORTB &= ~_BV(PB3);
DDRB ^= _BV(PB1); DDRB ^= _BV(PB3);
} }
void set_busy_led(uint8_t state) { void set_busy_led(uint8_t state) {
PORTB &= ~_BV(PB1); PORTB &= ~_BV(PB3);
if(state) { if(state) {
DDRB |= _BV(PB1); DDRB |= _BV(PB3);
} else { } else {
DDRB &= ~_BV(PB1); DDRB &= ~_BV(PB3);
}
}
void set_pwr_led(uint8_t state) {
PORTB &= ~_BV(PB0);
if(state) {
DDRB |= _BV(PB0);
} else {
DDRB &= ~_BV(PB0);
} }
} }

View File

@@ -41,6 +41,7 @@ extern volatile uint8_t led_state;
void update_leds(void); void update_leds(void);
void toggle_busy_led(void); void toggle_busy_led(void);
void set_busy_led(uint8_t); void set_busy_led(uint8_t);
void set_pwr_led(uint8_t);
#endif #endif

View File

@@ -131,6 +131,7 @@ int main(void) {
snes_reset(1); snes_reset(1);
uart_init(); uart_init();
sei(); // suspected to reset the AVR when inserting an SD card sei(); // suspected to reset the AVR when inserting an SD card
set_busy_led(0);
_delay_ms(100); _delay_ms(100);
disk_init(); disk_init();
snes_init(); snes_init();
@@ -141,11 +142,11 @@ int main(void) {
file_init(); file_init();
FATFS fatfs; FATFS fatfs;
f_mount(0,&fatfs); f_mount(0,&fatfs);
set_busy_led(1);
uart_putc('W'); uart_putc('W');
fpga_init(); fpga_init();
fpga_pgm("/sd2snes/main.bit"); fpga_pgm("/sd2snes/main.bit");
_delay_ms(100); _delay_ms(100);
set_pwr_led(1);
fpga_spi_init(); fpga_spi_init();
uart_putc('!'); uart_putc('!');
_delay_ms(100); _delay_ms(100);

View File

@@ -120,8 +120,8 @@ NET "SRAM_ADDR[10]" LOC = P60;
NET "SRAM_ADDR[11]" LOC = P59; NET "SRAM_ADDR[11]" LOC = P59;
NET "SRAM_ADDR[12]" LOC = P57; NET "SRAM_ADDR[12]" LOC = P57;
NET "SRAM_ADDR[13]" LOC = P56; NET "SRAM_ADDR[13]" LOC = P56;
NET "SRAM_ADDR[14]" LOC = P53; NET "SRAM_ADDR[14]" LOC = P51;
NET "SRAM_ADDR[15]" LOC = P52; NET "SRAM_ADDR[15]" LOC = P50;
NET "SRAM_ADDR[19]" LOC = P69; NET "SRAM_ADDR[19]" LOC = P69;
NET "SRAM_ADDR[8]" LOC = P68; NET "SRAM_ADDR[8]" LOC = P68;
NET "SRAM_ADDR[9]" LOC = P63; NET "SRAM_ADDR[9]" LOC = P63;
@@ -233,9 +233,5 @@ NET "CLKIN" IOSTANDARD = LVCMOS33;
NET "CLKIN" PULLUP; NET "CLKIN" PULLUP;
NET "SPI_SS" IOSTANDARD = LVCMOS33; NET "SPI_SS" IOSTANDARD = LVCMOS33;
NET "SPI_SS" PULLUP; NET "SPI_SS" PULLUP;
NET "DCM_FX_STOPPED" LOC = P44;
NET "DCM_FX_STOPPED" IOSTANDARD = LVCMOS33;
NET "DCM_IN_STOPPED" LOC = P41;
NET "DCM_IN_STOPPED" IOSTANDARD = LVCMOS33;
//NET "DCM_RST" LOC = P46; //NET "DCM_RST" LOC = P46;
//NET "DCM_RST" IOSTANDARD = LVCMOS33; //NET "DCM_RST" IOSTANDARD = LVCMOS33;

View File

@@ -110,8 +110,6 @@ avr_cmd snes_avr_cmd(
); );
wire [7:0] DCM_STATUS; wire [7:0] DCM_STATUS;
assign DCM_FX_STOPPED = DCM_STATUS[2];
assign DCM_IN_STOPPED = DCM_STATUS[1];
my_dcm snes_dcm(.CLKIN(CLKIN), my_dcm snes_dcm(.CLKIN(CLKIN),
.CLKFX(CLK2), .CLKFX(CLK2),
.LOCKED(DCM_LOCKED), .LOCKED(DCM_LOCKED),

View File

@@ -73,6 +73,7 @@
<property xil_pn:name="Constraints Entry" xil_pn:value="Constraints Editor"/> <property xil_pn:name="Constraints Entry" xil_pn:value="Constraints Editor"/>
<property xil_pn:name="Device" xil_pn:value="xc3s200"/> <property xil_pn:name="Device" xil_pn:value="xc3s200"/>
<property xil_pn:name="Device Family" xil_pn:value="Spartan3"/> <property xil_pn:name="Device Family" xil_pn:value="Spartan3"/>
<property xil_pn:name="Drive Done Pin High" xil_pn:value="true"/>
<property xil_pn:name="Extra Effort" xil_pn:value="Normal"/> <property xil_pn:name="Extra Effort" xil_pn:value="Normal"/>
<property xil_pn:name="Extra Effort (Highest PAR level only)" xil_pn:value="Normal"/> <property xil_pn:name="Extra Effort (Highest PAR level only)" xil_pn:value="Normal"/>
<property xil_pn:name="Fitter Report Format" xil_pn:value="HTML"/> <property xil_pn:name="Fitter Report Format" xil_pn:value="HTML"/>