diff --git a/avr/usbload/Makefile b/avr/usbload/Makefile index fe26c9d..25a11b5 100644 --- a/avr/usbload/Makefile +++ b/avr/usbload/Makefile @@ -2,8 +2,7 @@ TTY = /dev/tty.PL2303-00002126 DEVICE = atmega644 F_CPU = 20000000 # in Hz -FUSE_L = 0xf7 -FUSE_H = 0xdd + AVRDUDE = avrdude -c usbasp -p $(DEVICE) CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0 @@ -16,12 +15,8 @@ COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE) # Fuse values for particular devices ############################################################################## # http://www.engbedded.com/fusecalc/ -################################## ATMega644 ################################## -# ATMega644 FUSE_L (Fuse low byte): -# 0xf7 = 1 1 1 1 0 1 1 1 -# ATMega644 FUSE_H (Fuse high byte): -# 0xdd = 1 1 0 1 1 1 0 0 - +FUSE_L = 0xf7 +FUSE_H = 0xda # symbolic targets: @@ -76,7 +71,7 @@ usbdrv: cp -r ../../../usbdrv . main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it - $(COMPILE) -o main.elf $(OBJECTS) -Wl,-u,vfprintf -lprintf_flt + $(COMPILE) -o main.elf $(OBJECTS) -Wl,-u,vfprintf -lprintf_flt main.hex: main.elf rm -f main.hex main.eep.hex diff --git a/avr/usbload/main.c b/avr/usbload/main.c index 9fc5ea1..628e0e3 100644 --- a/avr/usbload/main.c +++ b/avr/usbload/main.c @@ -405,24 +405,41 @@ int main(void) while (req_state != REQ_STATUS_AVR){ usbPoll(); -#if 0 +#if 0 i = 20; while (--i) { /* fake USB disconnect for > 250 ms */ - _delay_ms(100); + _delay_ms(500); + printf("Wait to switch to avr mode %i\n", i); } printf("Send IRQ\n"); - snes_irq_lo(); - snes_irq_on(); - _delay_ms(1); + //snes_irq_lo(); + //snes_irq_on(); + //_delay_ms(1); - //avr_bus_active(); - //c = sram_bulk_read(); - //snes_bus_active(); + avr_bus_active(); - snes_irq_off(); + sram_bulk_read_start(0x003000); + c = sram_bulk_read(); + i = 5; + while (--i) { /* fake USB disconnect for > 250 ms */ + _delay_ms(500); + printf("Wait to switch to snes mode %i\n", i); + } - //sram_bulk_read_start(0x003000); - //printf("Read 0x3000=%c\n",c); + if (req_bank_size == 0x8000){ + snes_lorom(); + printf("Set Snes lowrom \n"); + } else { + snes_hirom(); + printf("Set Snes hirom \n"); + } + snes_wr_disable(); + printf("Disable snes WR\n"); + + snes_bus_active(); + printf("Activate Snes bus\n"); + + printf("Read 0x3000=%c\n",c); #endif } }