Merge pull request #8 from Mcharlsto/master

Fix & Improve ATmega32u4 support
This commit is contained in:
Raphaël Assenat 2021-11-12 10:13:57 +09:00 committed by GitHub
commit c681f648a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 2 deletions

64
Makefile.32u4 Normal file
View File

@ -0,0 +1,64 @@
CC=avr-gcc
AS=$(CC)
LD=$(CC)
include Makefile.inc
PROGNAME=gcn64usb
OBJDIR=objs-$(PROGNAME)
CPU=atmega32u4
CFLAGS=-Wall -mmcu=$(CPU) -DF_CPU=16000000L -Os -DUART1_STDOUT -DVERSIONSTR=$(VERSIONSTR) -DVERSIONSTR_SHORT=$(VERSIONSTR_SHORT) -DVERSIONBCD=$(VERSIONBCD) -std=gnu99
LDFLAGS=-mmcu=$(CPU) -Wl,-Map=$(PROGNAME).map
HEXFILE=$(PROGNAME).hex
all: $(HEXFILE)
clean:
rm -f $(PROGNAME).elf $(PROGNAME).hex $(PROGNAME).map $(OBJS)
gcn64txrx0.o: gcn64txrx.S
$(CC) $(CFLAGS) -c $< -o $@ -DSUFFIX=0 -DGCN64_DATA_BIT=0
gcn64txrx1.o: gcn64txrx.S
$(CC) $(CFLAGS) -c $< -o $@ -DSUFFIX=1 -DGCN64_DATA_BIT=2
gcn64txrx2.o: gcn64txrx.S
$(CC) $(CFLAGS) -c $< -o $@ -DSUFFIX=2 -DGCN64_DATA_BIT=1
gcn64txrx3.o: gcn64txrx.S
$(CC) $(CFLAGS) -c $< -o $@ -DSUFFIX=3 -DGCN64_DATA_BIT=3
%.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 -C --mcu=$(CPU)
fuse:
flash: $(HEXFILE)
- ./scripts/enter_bootloader.sh
./scripts/wait_then_flash.sh $(CPU) $(HEXFILE)
justflash: $(HEXFILE)
./scripts/wait_then_flash.sh $(CPU) $(HEXFILE)
chip_erase:
dfu-programmer $(CPU) erase
reset:
dfu-programmer $(CPU) reset
restart:
- ./scripts/enter_bootloader.sh
./scripts/start.sh $(CPU)

View File

@ -18,6 +18,7 @@ The project is released under the General Public License version 3.
You will need a working avr-gcc toolchain with avr-libc and standard utilities such as make. Just
type 'make' and it should build just fine. Under Linux at least.
If you are compiling for a custom board or Arduino running on an ATmega32u4, then run 'make -f Makefile.32u4' instead.
## Programming the firmware

View File

@ -26,7 +26,7 @@ void enterBootLoader(void)
usb_shutdown();
_delay_ms(10);
#if defined(__AVR_ATmega32U2__)
#if defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega32U4__)
// ATmega32u2 : 0x3800
asm volatile(
"cli \n"

View File

@ -1,6 +1,5 @@
- Future ideas / TODO
- Add very basic N64 mouse support (detect and treat it like a controller)
- Add support for Atmega32u4 MCU
- March 5, 2021 : Version 3.6.1
- Alter timing so the brawler64 wireless gamepad will work. Those will now