From: Stephan Baerwolf Date: Fri, 14 Mar 2014 00:46:29 +0000 (+0100) Subject: add support for ATmega162 X-Git-Tag: testing-head~2 X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/commitdiff_plain/31e49de4348d9ce27211f08e0a58346ef8f85394 add support for ATmega162 Signed-off-by: Stephan Baerwolf --- diff --git a/Makefile.inc b/Makefile.inc index b0de713..dd9526a 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -64,6 +64,7 @@ DEFINES_16 += -DCONFIG_NO__HAVE_READ_LOCK_FUSE endif + FUSEOPT_88 = -U lfuse:w:0xd7:m -U hfuse:w:0xd4:m -U efuse:w:0xf8:m BOOTLOADER_ADDRESS_88 = 0x1800 DEFINES_88 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP @@ -73,6 +74,15 @@ endif +FUSEOPT_162 = -U lfuse:w:0xff:m -U hfuse:w:0x90:m -U efuse:w:0xf9:m +BOOTLOADER_ADDRESS_162 = 0x3800 +DEFINES_162 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP -DCONFIG_NO__HAVE_READ_LOCK_FUSE +ifeq ($(F_CPU), 12000000) +DEFINES_162 += -DCONFIG_NO__BOOTLOADER_CAN_EXIT +endif + + + FUSEOPT_164 = -U lfuse:w:0xd7:m -U hfuse:w:0xd0:m -U efuse:w:0xfc:m BOOTLOADER_ADDRESS_164 = 0x3800 DEFINES_164 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP -DCONFIG_NO__FLASH_BYTE_READACCESS -DCONFIG_NO__HAVE_READ_LOCK_FUSE @@ -213,6 +223,11 @@ else ifeq ($(DEVICE), atmega88pa) BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_88) MCUARCH = avr4 DEFINES += $(DEFINES_88) +else ifeq ($(DEVICE), atmega162) + FUSEOPT = $(FUSEOPT_162) + BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_162) + MCUARCH = avr5 + DEFINES += $(DEFINES_162) else ifeq ($(DEVICE), atmega164a) FUSEOPT = $(FUSEOPT_164) BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_164) diff --git a/firmware/main.c b/firmware/main.c index e4a2104..fccec56 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -165,6 +165,8 @@ static const uchar signatureBytes[4] = { 0x1e, 0x93, 0x0a, 0 #elif defined (__AVR_ATmega88PA__) 0x1e, 0x93, 0x0F, 0 +#elif defined (__AVR_ATmega162__) + 0x1e, 0x94, 0x04, 0 #elif defined (__AVR_ATmega164A__) 0x1e, 0x94, 0x0f, 0 #elif defined (__AVR_ATmega164P__) || defined (__AVR_ATmega164PA__) @@ -364,6 +366,7 @@ uchar usbFunctionSetup_USBASP_FUNC_TRANSMIT(usbRequest_t *rq) { #elif defined (__AVR_ATmega48__) || defined (__AVR_ATmega48A__) || defined (__AVR_ATmega48P__) || defined (__AVR_ATmega48PA__) || \ defined (__AVR_ATmega88__) || defined (__AVR_ATmega88A__) || defined (__AVR_ATmega88P__) || defined (__AVR_ATmega88PA__) || \ +defined (__AVR_ATmega162__) || \ defined (__AVR_ATmega164A__) || defined (__AVR_ATmega164P__) || \ defined (__AVR_ATmega168__) || defined (__AVR_ATmega168A__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega168PA__) || \ defined (__AVR_ATmega324A__) || defined (__AVR_ATmega324P__) || \ diff --git a/firmware/spminterface.h b/firmware/spminterface.h index b80163c..290998c 100644 --- a/firmware/spminterface.h +++ b/firmware/spminterface.h @@ -122,6 +122,8 @@ ret #define funcaddr___bootloader__do_spm 0x7054 #elif defined (__AVR_ATmega88__) || defined (__AVR_ATmega88P__) || defined (__AVR_ATmega88A__) || defined (__AVR_ATmega88PA__) #define funcaddr___bootloader__do_spm 0x1834 + #elif defined (__AVR_ATmega162__) + #define funcaddr___bootloader__do_spm 0x3870 #elif defined (__AVR_ATmega164A__) || defined (__AVR_ATmega164P__) || defined (__AVR_ATmega164PA__) #define funcaddr___bootloader__do_spm 0x387c #elif defined (__AVR_ATmega168__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega168A__) || defined (__AVR_ATmega168PA__) @@ -436,13 +438,13 @@ void do_spm(const uint32_t flash_byteaddress, const uint8_t spmcrval, const uint /* * insert architecture dependend "bootloader_do_spm"-code */ -#if defined (__AVR_ATmega8535__) || defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__) +#if defined (__AVR_ATmega8535__) || defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega162__) || defined (__AVR_ATmega32__) #if defined (__AVR_ATmega8535__) || defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__) #if (BOOTLOADER_ADDRESS != 0x1800) #error BOOTLOADER_ADDRESS!=0x1800, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use #endif -#elif defined (__AVR_ATmega16__) +#elif defined (__AVR_ATmega16__) || defined (__AVR_ATmega162__) #if (BOOTLOADER_ADDRESS != 0x3800) #error BOOTLOADER_ADDRESS!=0x3800, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use #endif