add support for ATmega16
authorStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Sun, 31 Mar 2013 15:18:53 +0000 (17:18 +0200)
committerStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Sun, 31 Mar 2013 23:04:38 +0000 (23:04 +0000)
Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Makefile.inc
firmware/main.c
firmware/spminterface.h

index fd52381..6aa6611 100644 (file)
@@ -39,6 +39,12 @@ LOCKOPT = -U lock:w:0x3f:m
 #some features may be deactivated to fit into bootloader section
 #ATTANTION: CONFIG_NO... feature deactivation may not be optimal!
 
+FUSEOPT_16              = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m
+BOOTLOADER_ADDRESS_16   = 0x3800
+DEFINES_16              = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP
+
+
+
 FUSEOPT_88              = -U lfuse:w:0xd7:m -U hfuse:w:0xd4:m -U efuse:w:0xf8:m
 BOOTLOADER_ADDRESS_88   = 0x1800
 DEFINES_88              = -DCONFIG_NO__FLASH_BYTE_READACCESS -DCONFIG_NO__HAVE_READ_LOCK_FUSE
@@ -74,7 +80,7 @@ DEFINES_8            = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCH
 
 
 
-FUSEOPT_32              = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m
+FUSEOPT_32              = $(FUSEOPT_16)
 BOOTLOADER_ADDRESS_32   = 0x7000
 DEFINES_32              = #-DEMPTY
 
@@ -118,6 +124,11 @@ ifeq ($(DEVICE), atmega8)
   BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_8) 
   MCUARCH            = avr4
   DEFINES           += $(DEFINES_8)
+else ifeq ($(DEVICE), atmega16)
+  FUSEOPT            = $(FUSEOPT_16)
+  BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_16)
+  MCUARCH            = avr5
+  DEFINES           += $(DEFINES_16)
 else ifeq ($(DEVICE), atmega32)
   FUSEOPT            = $(FUSEOPT_32)
   BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_32)
index 91127ef..4c612d6 100644 (file)
@@ -131,6 +131,8 @@ static const uchar  signatureBytes[4] = {
     SIGNATURE_BYTES
 #elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)
     0x1e, 0x93, 0x07, 0
+#elif defined (__AVR_ATmega16__)
+    0x1e, 0x94, 0x03, 0
 #elif defined (__AVR_ATmega32__)
     0x1e, 0x95, 0x02, 0
 #elif defined (__AVR_ATmega48__) || defined (__AVR_ATmega48A__) || defined (__AVR_ATmega48P__)
@@ -266,7 +268,7 @@ uchar usbFunctionSetup_USBASP_FUNC_TRANSMIT(usbRequest_t *rq) {
     rval = rq->wIndex.bytes[0] & 3;
     rval = signatureBytes[rval];
 #if HAVE_READ_LOCK_FUSE
-#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega32__)
+#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__)
   }else if(rq->wValue.bytes[0] == 0x58 && rq->wValue.bytes[1] == 0x00){  /* read lock bits */
       rval = boot_lock_fuse_bits_get(GET_LOCK_BITS);
   }else if(rq->wValue.bytes[0] == 0x50 && rq->wValue.bytes[1] == 0x00){  /* read lfuse bits */
index 66fcd39..6338f03 100644 (file)
@@ -112,6 +112,8 @@ ret
   #else
     #if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)
       #define  funcaddr___bootloader__do_spm 0x1826
+    #elif defined (__AVR_ATmega16__)
+      #define  funcaddr___bootloader__do_spm 0x3854
     #elif defined (__AVR_ATmega32__)
       #define  funcaddr___bootloader__do_spm 0x7054
     #elif defined (__AVR_ATmega88__) || defined (__AVR_ATmega88P__) || defined (__AVR_ATmega88A__) || defined (__AVR_ATmega88PA__)  
@@ -285,12 +287,16 @@ void do_spm(const uint32_t flash_byteaddress, const uint8_t spmcrval, const uint
  * try to make this array as big as possible
  * (so bootloader always uses 2kbytes flash)
  */
-#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__) || defined (__AVR_ATmega32__)
+#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__)
 
 #if 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__)
+  #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
 #elif defined (__AVR_ATmega32__)
   #if (BOOTLOADER_ADDRESS != 0x7000)
     #error BOOTLOADER_ADDRESS!=0x7000, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use