diff --git a/Makefile.stk525 b/Makefile.stk525 new file mode 100644 index 0000000..8cad8c4 --- /dev/null +++ b/Makefile.stk525 @@ -0,0 +1,44 @@ +CC=avr-gcc +AS=$(CC) +LD=$(CC) + +PROGNAME=n64 +OBJDIR=objs-$(PROGNAME) +CPU=at90usb1287 +CFLAGS=-Wall -mmcu=$(CPU) -DF_CPU=16000000L -Os -DUART1_STDOUT -DSTK525 +LDFLAGS=-mmcu=$(CPU) -Wl,-Map=$(PROGNAME).map +HEXFILE=$(PROGNAME).hex + +OBJS=main.o n64.o gcn64_protocol.o usart1.o usb.o bootloader.o + +all: $(HEXFILE) + +clean: + rm -f $(PROGNAME).elf $(PROGNAME).hex $(PROGNAME).map $(OBJS) + +%.o: %.S + $(CC) $(CFLAGS) -c $< -o $@ + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +%.o: %.c %.h + $(CC) $(CFLAGS) -c $< -o $@ + +$(PROGNAME).elf: $(OBJS) + $(LD) $(OBJS) $(LDFLAGS) -o $(PROGNAME).elf + +$(PROGNAME).hex: $(PROGNAME).elf + avr-objcopy -j .data -j .text -O ihex $(PROGNAME).elf $(PROGNAME).hex + avr-size $(PROGNAME).elf + +fuse: + +flash: $(HEXFILE) + ./wait_then_flash.sh $(CPU) $(HEXFILE) + +chip_erase: + dfu-programmer atmega32u2 erase + +reset: + dfu-programmer atmega32u2 reset diff --git a/gcn64_protocol.c b/gcn64_protocol.c index b479c01..cea1356 100644 --- a/gcn64_protocol.c +++ b/gcn64_protocol.c @@ -26,13 +26,23 @@ static volatile unsigned char gcn64_workbuf[GCN64_BUF_SIZE]; /******** IO port definitions and options **************/ -#define GCN64_DATA_PORT PORTD -#define GCN64_DATA_DDR DDRD -#define GCN64_DATA_PIN PIND -#define GCN64_DATA_BIT (1<<0) -#define GCN64_BIT_NUM_S "0" // for asm -#define FREQ_IS_16MHZ -#define DISABLE_INTS_DURING_COMM +#ifndef STK525 + #define GCN64_DATA_PORT PORTD + #define GCN64_DATA_DDR DDRD + #define GCN64_DATA_PIN PIND + #define GCN64_DATA_BIT (1<<0) + #define GCN64_BIT_NUM_S "0" // for asm + #define FREQ_IS_16MHZ + #define DISABLE_INTS_DURING_COMM +#else + #define GCN64_DATA_PORT PORTA + #define GCN64_DATA_DDR DDRA + #define GCN64_DATA_PIN PINA + #define GCN64_DATA_BIT (1<<0) + #define GCN64_BIT_NUM_S "0" // for asm + #define FREQ_IS_16MHZ + #define DISABLE_INTS_DURING_COMM +#endif /* * \brief Explode bytes to bits