First Commit
authorTobias <tm@tm3d.de>
Thu, 17 Sep 2015 09:28:51 +0000 (11:28 +0200)
committerTobias <tm@tm3d.de>
Thu, 17 Sep 2015 09:28:51 +0000 (11:28 +0200)
67 files changed:
DS18B20_DS2438/DS18B20.pdf [new file with mode: 0644]
DS18B20_DS2438/DS18B20_DS2438.atsln [new file with mode: 0644]
DS18B20_DS2438/DS18B20_DS2438.c [new file with mode: 0644]
DS18B20_DS2438/DS18B20_DS2438.cproj [new file with mode: 0644]
DS18B20_DS2438/OWDS18B20_DS2438.S [new file with mode: 0644]
DS18B20_MAX44009/DS18B20.atsln [new file with mode: 0644]
DS18B20_MAX44009/DS18B20.c [new file with mode: 0644]
DS18B20_MAX44009/DS18B20.cproj [new file with mode: 0644]
DS18B20_MAX44009/DS18B20.pdf [new file with mode: 0644]
DS18B20_MAX44009/OWDS18B20.S [new file with mode: 0644]
DS18B20_Thermocouble/DS18B20.atsln [new file with mode: 0644]
DS18B20_Thermocouble/DS18B20.c [new file with mode: 0644]
DS18B20_Thermocouble/DS18B20.cproj [new file with mode: 0644]
DS18B20_Thermocouble/DS18B20.pdf [new file with mode: 0644]
DS18B20_Thermocouble/OWDS18B20.S [new file with mode: 0644]
DS18B20_Thermocouble/Typ-J.csv [new file with mode: 0644]
DS18B20_Thermocouble/convthermocouple.py [new file with mode: 0644]
DS2406/DS2406.atsln [new file with mode: 0644]
DS2406/DS2406.c [new file with mode: 0644]
DS2406/DS2406.cproj [new file with mode: 0644]
DS2406/DS2406.pdf [new file with mode: 0644]
DS2406/Makefile [new file with mode: 0644]
DS2406/OWDS2406.S [new file with mode: 0644]
DS2423/DS2423.atsln [new file with mode: 0644]
DS2423/DS2423.c [new file with mode: 0644]
DS2423/DS2423.cproj [new file with mode: 0644]
DS2423/Makefile [new file with mode: 0644]
DS2423/OWDS2423.S [new file with mode: 0644]
DS2438_DHT22/.gitignore [new file with mode: 0644]
DS2438_DHT22/DS2438_DHT22.atsln [new file with mode: 0644]
DS2438_DHT22/DS2438_DHT22.c [new file with mode: 0644]
DS2438_DHT22/DS2438_DHT22.cproj [new file with mode: 0644]
DS2438_DHT22/OWDS2438.S [new file with mode: 0644]
DS2450/DS2450.atsln [new file with mode: 0644]
DS2450/DS2450.c [new file with mode: 0644]
DS2450/DS2450.cproj [new file with mode: 0644]
DS2450/DS2450.pdf [new file with mode: 0644]
DS2450/OWDS2450.S [new file with mode: 0644]
common/I2C/BMP280.c [new file with mode: 0644]
common/I2C/BMP280.h [new file with mode: 0644]
common/I2C/MAX1164x.h [new file with mode: 0644]
common/I2C/MAX1164x.h.c [new file with mode: 0644]
common/I2C/MAX44009.c [new file with mode: 0644]
common/I2C/MAX44009.h [new file with mode: 0644]
common/I2C/SHT2x.c [new file with mode: 0644]
common/I2C/SHT2x.h [new file with mode: 0644]
common/I2C/TSL256x.c [new file with mode: 0644]
common/I2C/TSL256x.h [new file with mode: 0644]
common/I2C/USI_TWI_Master.c [new file with mode: 0644]
common/I2C/USI_TWI_Master.h [new file with mode: 0644]
common/OWCRC16.s [new file with mode: 0644]
common/OWCRC8.s [new file with mode: 0644]
common/OWConfig.s [new file with mode: 0644]
common/OWPinInterrupt.s [new file with mode: 0644]
common/OWRomFunctions.s [new file with mode: 0644]
common/OWRomFunctionsDual.s [new file with mode: 0644]
common/OWSet_ATTINYX4.s [new file with mode: 0644]
common/OWSet_ATTINYX5.s [new file with mode: 0644]
common/OWTimerInterrupt.s [new file with mode: 0644]
programmer/flash/avrdude.conf [new file with mode: 0644]
programmer/flash/avrdude.exe [new file with mode: 0644]
programmer/flash/flashp.bat [new file with mode: 0644]
programmer/owflash.py [new file with mode: 0644]
programmer/programmer.atsln [new file with mode: 0644]
programmer/programmer/programmer.asm [new file with mode: 0644]
programmer/programmer/programmer.asmproj [new file with mode: 0644]
tools/chowid.py [new file with mode: 0644]

diff --git a/DS18B20_DS2438/DS18B20.pdf b/DS18B20_DS2438/DS18B20.pdf
new file mode 100644 (file)
index 0000000..a942d79
Binary files /dev/null and b/DS18B20_DS2438/DS18B20.pdf differ
diff --git a/DS18B20_DS2438/DS18B20_DS2438.atsln b/DS18B20_DS2438/DS18B20_DS2438.atsln
new file mode 100644 (file)
index 0000000..6e68474
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Atmel Studio Solution File, Format Version 11.00
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_DS2438", "DS18B20_DS2438.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS18B20_DS2438/DS18B20_DS2438.c b/DS18B20_DS2438/DS18B20_DS2438.c
new file mode 100644 (file)
index 0000000..e668064
--- /dev/null
@@ -0,0 +1,233 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+#include <avr/pgmspace.h>
+#include "../common/I2C/USI_TWI_Master.h"
+#include "../common/I2C/MAX44009.h"
+#include "../common/I2C/SHT2x.h"
+
+
+extern void OWINIT();
+
+
+
+uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/
+uint8_t owid2[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x00, 0x01, 0x77};/**/
+       
+#if (owid>128) 
+#error "Variable not correct"
+#endif
+
+extern uint8_t mode;
+extern uint8_t gcontrol;
+extern uint8_t reset_indicator;
+extern uint8_t alarmflag;
+volatile uint8_t wdcounter;
+
+
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+ISR(WATCHDOG_vect) {
+#else
+ISR(WDT_vect) {
+#endif 
+       //sleep_disable();          // Disable Sleep on Wakeup
+       wdcounter++;
+       if (reset_indicator==1) reset_indicator++;
+       else if (reset_indicator==2) mode=0;
+/*     if (timeout==2) {
+               DIS_TIMER;
+               EN_OWINT;
+               mode=OWM_SLEEP;
+       }
+       timeout++;*/
+       //sleep_enable();           // Enable Sleep Mode
+
+}
+
+
+typedef union {
+       volatile uint8_t bytes[8];
+       struct {
+               uint16_t temp;  //0
+               uint8_t TH;  //2
+               uint8_t TL;  //3
+               uint8_t config;  //4
+               uint8_t rrFF; //5
+               uint8_t rr00; //6
+               uint8_t rr10; //7
+       };
+} pack1_t;
+volatile pack1_t pack1;
+
+
+
+typedef union {
+       #if  defined(__AVR_ATtiny25__)
+       volatile uint8_t bytes[16];
+       #else
+       volatile uint8_t bytes[64];
+       #endif
+       struct {
+               uint8_t status;  //1
+               int16_t temp;  //2
+               uint16_t voltage;  //4
+               uint16_t current;  //6
+               uint8_t threshold; //8
+               
+               uint8_t page1[8]; //9
+               #if  defined(__AVR_ATtiny25__)
+               #else
+               uint8_t page2[8]; //17
+               uint8_t page3[8]; //25
+               uint8_t page4[8];  //33
+               uint8_t page5[8];  //41
+               uint8_t page6[8];  //49
+               uint8_t page7[8];  //57
+               //uint8_t crc;  //65
+               #endif
+       };
+} pack2_t;
+volatile pack2_t pack2;
+
+
+
+
+volatile int16_t am2302_temp;
+volatile uint16_t am2302_hum;
+
+
+uint8_t userRegister[1];
+int16_t sRH,sT;
+volatile double temperatureC,humidityRH;
+volatile double l;
+
+
+int main(void){
+    PRR|=(1<<PRADC);  // adc for save Power
+       pack1.temp=0x0550;
+       pack1.config=0x7F;
+       pack1.TH=75;
+       pack1.TL=70;
+       pack1.rrFF=0xFF;
+       pack1.rr00=0;
+       pack1.rr10=0x10;
+       PORTA=0xFF;
+       PORTB=0xFF;
+       OWINIT();
+
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+       MCUCR |=(1<<BODS);
+
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt
+       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~1 seconds
+
+       MCUSR=0;
+       USI_TWI_Master_Initialise();
+       SHT2x_SoftReset();
+       SHT2x_ReadUserRegister(userRegister);
+       //(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT;
+       SHT2x_WriteUserRegister(userRegister); //write changed user reg
+       // --- measure humidity with "Hold Master Mode (HM)" ---
+       SHT2x_MeasurePoll(HUMIDITY, &sRH);
+       // --- measure temperature with "Polling Mode" (no hold master) ---
+       SHT2x_MeasurePoll(TEMP, &sT);
+       //-- calculate humidity and temperature --
+       temperatureC = SHT2x_CalcTemperatureC(sT);
+       humidityRH = SHT2x_CalcRH(sRH);
+       
+       gcontrol=1;
+       sei();
+    while(1)   {
+               if (wdcounter>0) {
+                       SHT2x_MeasurePoll(HUMIDITY, &sRH);
+                       // --- measure temperature with "Polling Mode" (no hold master) ---
+                       SHT2x_MeasurePoll(TEMP, &sT);
+                       //-- calculate humidity and temperature --
+                       temperatureC = SHT2x_CalcTemperatureC(sT)*10.0;
+                       humidityRH = SHT2x_CalcRH(sRH)*10.0;
+                       double hhum=(1.0546-0.000216*temperatureC)*(humidityRH);
+                       am2302_hum=0.318*hhum +76.0;
+                       am2302_temp=temperatureC*25.6;
+                       wdcounter=0;
+               }
+       
+               if (gcontrol==1) {
+                       l=MAX44009getlux();             
+                       if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045
+                       //double l=1000;
+                       l=log(l)*10*16;
+                       uint16_t w=l;
+                       uint8_t t8=w>>4;
+                       uint8_t af=0;
+                       if (t8>pack1.TH) af=1;
+                       if (t8<=pack1.TL) af=1; 
+                       cli();
+                       pack1.temp=w;
+                       //pack.temp++;
+                       alarmflag=af;
+                       sei();                  
+                       gcontrol=0;
+               }
+               if ((gcontrol==2)||(gcontrol==3)) {
+                       gcontrol=0;
+                       
+               }
+
+               
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))
+#endif                 
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))
+#endif
+                         {
+
+                       MCUCR|=(1<<SE)|(1<<SM1);
+                       MCUCR&=~(1<<ISC01);
+               } else {
+                       MCUCR|=(1<<SE);
+                       MCUCR&=~(1<<SM1);
+               }
+               //MCUCR&=~(1<<ISC01);
+               asm("SLEEP");
+   }
+
+
+}
\ No newline at end of file
diff --git a/DS18B20_DS2438/DS18B20_DS2438.cproj b/DS18B20_DS2438/DS18B20_DS2438.cproj
new file mode 100644 (file)
index 0000000..dec1c59
--- /dev/null
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>6.2</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>{7a5672fe-8226-4158-b931-e1f36b9a8858}</ProjectGuid>
+    <avrdevice>ATtiny84A</avrdevice>
+    <avrdeviceseries>none</avrdeviceseries>
+    <OutputType>Executable</OutputType>
+    <Language>C</Language>
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>
+    <OutputFileExtension>.elf</OutputFileExtension>
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
+    <AssemblyName>DS18B20_DS2438</AssemblyName>
+    <Name>DS18B20_DS2438</Name>
+    <RootNamespace>DS18B20_DS2438</RootNamespace>
+    <ToolchainFlavour>Native</ToolchainFlavour>
+    <KeepTimersRunning>true</KeepTimersRunning>
+    <OverrideVtor>false</OverrideVtor>
+    <CacheFlash>true</CacheFlash>
+    <ProgFlashFromRam>true</ProgFlashFromRam>
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>
+    <UncachedRange />
+    <preserveEEPROM>true</preserveEEPROM>
+    <OverrideVtorValue>exception_table</OverrideVtorValue>
+    <BootSegment>2</BootSegment>
+    <eraseonlaunchrule>1</eraseonlaunchrule>
+    <AsfFrameworkConfig>
+      <framework-data xmlns="">
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.19.0" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <com_atmel_avrdbg_tool_atmelice>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>debugWIRE</InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
+      <ToolNumber>J41800000779</ToolNumber>
+      <ToolName>Atmel-ICE</ToolName>
+    </com_atmel_avrdbg_tool_atmelice>
+    <avrtoolinterface>debugWIRE</avrtoolinterface>
+    <com_atmel_avrdbg_tool_simulator>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>
+        </InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.simulator</ToolType>
+      <ToolNumber>
+      </ToolNumber>
+      <ToolName>Simulator</ToolName>
+    </com_atmel_avrdbg_tool_simulator>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>NDEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>DEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="..\common\I2C\SHT2x.c">
+      <SubType>compile</SubType>
+      <Link>SHT2x.c</Link>
+    </Compile>
+    <Compile Include="D:\oc\dev\owSlave2\common\I2C\MAX44009.c">
+      <SubType>compile</SubType>
+      <Link>MAX44009.c</Link>
+    </Compile>
+    <Compile Include="D:\oc\dev\owSlave2\common\I2C\USI_TWI_Master.c">
+      <SubType>compile</SubType>
+      <Link>USI_TWI_Master.c</Link>
+    </Compile>
+    <Compile Include="DS18B20_DS2438.c">
+      <SubType>compile</SubType>
+    </Compile>
+    <Compile Include="OWDS18B20_DS2438.S">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
diff --git a/DS18B20_DS2438/OWDS18B20_DS2438.S b/DS18B20_DS2438/OWDS18B20_DS2438.S
new file mode 100644 (file)
index 0000000..5ffafa3
--- /dev/null
@@ -0,0 +1,345 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+#define _CHANGEABLE_ID_
+#define _ZERO_POLLING_
+
+
+#include "../common/OWConfig.s"
+#include "../common/OWCRC8.s"
+
+.extern pack1,8
+
+//.extern  am2302_temp,2
+
+#if  defined(__AVR_ATtiny25__)
+.extern pack2,16
+#else
+.extern pack2,64
+#endif
+.extern  am2302_temp,2
+.extern  am2302_hum,2
+.comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)
+
+
+.macro CHIP_INIT       
+Init_EEPROM_read:
+       sbic _SFR_IO_ADDR(EECR), EEPE
+       rjmp Init_EEPROM_read
+       ldi r_temp,0
+       out _SFR_IO_ADDR(EEARH), r_temp
+       ldi r_temp,2
+       out _SFR_IO_ADDR(EEARL), r_temp
+       sbi _SFR_IO_ADDR(EECR), EERE
+       in r_temp,_SFR_IO_ADDR(EEDR)
+       sbrs r_temp,7
+       rcall hrc_recall_eeprom_func1
+.endm
+
+.macro COMMAND_TABLE
+               rjmp h_readscratchpad1
+               rjmp h_writescratchpad1
+               rjmp h_readscratchpad_adr2
+               rjmp h_readscratchpad2
+               rjmp h_writescratchpad_adr2
+               rjmp h_writescratchpad2
+.endm
+
+#include "../common/OWRomFunctionsDual.s"
+#include "../common/OWTimerInterrupt.s"
+
+
+
+; Ab hier Geraeteabhaenging
+#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+0
+#define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+1
+#define OW_READ_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+2
+#define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+3
+#define OW_WRITE_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+4
+#define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+5
+
+
+;---------------------------------------------------
+;      READ COMMAND and start operation
+;---------------------------------------------------
+
+
+h_readcommand1:
+       clr r_bytep
+#ifndef _DIS_FLASH_
+       FLASH_COMMANDS ; muss zu erst sein....
+#endif
+       cjmp 0xBE,hrc_set_readscratchpad1
+       cjmp 0x4E,hrc_set_writescratchpad1
+       cjmp 0x44,hrc_set_convertT1
+       cjmp 0x48,hrc_copy_scratchpad1
+       cjmp 0xB8,hrc_recall_eeprom1
+#ifdef _CHANGEABLE_ID_
+       CHANGE_ID_COMMANDS
+#endif
+       ldi r_mode,OW_SLEEP
+       rjmp handle_end
+
+hrc_set_readscratchpad1:
+       ldi r_mode,OW_READ_SCRATCHPAD1
+       ldi r_sendflag,1
+       CRCInit2
+       rjmp h_readscratchpad1
+
+hrc_set_writescratchpad1:
+       ldi r_mode,OW_WRITE_SCRATCHPAD1
+       ldi r_bytep,2 ;start to write in 2
+       rjmp handle_end
+
+hrc_recall_eeprom1:
+       rcall hrc_recall_eeprom_func1
+       rjmp handle_end
+
+
+
+hrc_set_convertT1:
+       ldi r_temp,1
+       sts gcontrol,r_temp
+
+       rjmp handle_end_sleep
+
+
+hrc_copy_scratchpad1:
+       ldi r_bytep,2
+       configZ pack1,r_bytep
+       clr r_bytep
+hrc_copy_scratchpad_EEPROM_write1:
+       sbic _SFR_IO_ADDR(EECR), EEPE   
+       rjmp hrc_copy_scratchpad_EEPROM_write1
+       ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
+       out _SFR_IO_ADDR(EECR), r_temp
+       ldi r_temp,0
+       out _SFR_IO_ADDR(EEARH),r_temp
+       out _SFR_IO_ADDR(EEARL), r_bytep
+       ld  r_rwbyte,Z+
+       out _SFR_IO_ADDR(EEDR), r_rwbyte
+       sbi _SFR_IO_ADDR(EECR), EEMPE
+       sbi _SFR_IO_ADDR(EECR), EEPE
+       inc r_bytep
+       cpi r_bytep,3
+       brne hrc_copy_scratchpad_EEPROM_write1
+       rjmp handle_end
+
+
+hrc_recall_eeprom_func1:
+       ldi r_bytep,2
+       configZ pack1,r_bytep
+       clr r_bytep
+       clr r_temp
+hrc_recall_eeprom_EEPROM_read1:
+       sbic _SFR_IO_ADDR(EECR), EEPE
+       rjmp hrc_recall_eeprom_EEPROM_read1
+       out _SFR_IO_ADDR(EEARH), r_temp
+       out _SFR_IO_ADDR(EEARL), r_bytep
+       sbi _SFR_IO_ADDR(EECR), EERE
+       in r_rwbyte,_SFR_IO_ADDR(EEDR)
+       st Z+,r_rwbyte
+       inc r_bytep
+       cpi r_bytep,3
+       brne hrc_recall_eeprom_EEPROM_read1
+       ret
+
+
+
+
+
+
+;---------------------------------------------------
+;   READ SCRATCHPAD
+;---------------------------------------------------
+
+h_readscratchpad1:
+       cpi  r_bytep,8
+       breq h_readscratchpad_crc1
+       cpi  r_bytep,9
+       breq h_readscratchpad_all1
+       configZ pack1,r_bytep
+       ld   r_rwbyte,Z
+       rjmp h_readscratchpad_endc1
+h_readscratchpad_crc1:
+       lds  r_rwbyte,crc
+h_readscratchpad_endc1:
+       inc  r_bytep
+       ldi  r_bcount,1 
+       rjmp handle_end
+h_readscratchpad_all1:
+       rjmp handle_end_sleep
+
+
+
+
+
+;---------------------------------------------------
+;   WRITE SCRATCHPAD
+;---------------------------------------------------
+
+h_writescratchpad1:
+       configZ pack1,r_bytep
+       inc  r_bytep
+       cpi  r_bytep,5
+       breq h_writescratchpad_all1
+       st   Z,r_rwbyte
+       rjmp handle_end
+h_writescratchpad_all1:
+       ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1
+       st   Z,r_rwbyte
+       rjmp handle_end_sleep
+
+;*****************************************************************************************************************************************************************************************
+;*****************************************************************************************************************************************************************************************
+;*****************************************************************************************************************************************************************************************
+;*****************************************************************************************************************************************************************************************
+;*****************************************************************************************************************************************************************************************
+
+
+
+
+
+h_readcommand2:
+       clr r_bytep
+#ifndef _DIS_FLASH_
+       FLASH_COMMANDS ; muss zu erst sein....
+#endif
+       cset 0xBE,OW_READ_SCRATCHPAD_ADR2
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2
+       cjmp 0x44,hrc_set_convertT2
+       cjmp 0xB4,hrc_set_convertV2
+#ifdef _CHANGEABLE_ID_
+       CHANGE_ID_COMMANDS
+#endif
+       rjmp handle_end_sleep
+
+
+hrc_set_convertT2:
+       ldi r_temp,2
+       sts gcontrol,r_temp
+       lds r_temp,am2302_temp
+       sts pack2+1,r_temp
+       lds r_temp,am2302_temp+1
+       sts pack2+2,r_temp
+       rjmp handle_end_sleep
+hrc_set_convertV2:
+       lds r_temp,pack2
+       sbrs r_temp,3
+       rjmp hrc_set_convertVV2
+       ldi r_temp,0xF4
+       sts pack2+3,r_temp
+       ldi r_temp,0x01
+       sts pack2+4,r_temp
+       rjmp hrc_set_convertend2
+hrc_set_convertVV2:
+       ldi r_temp,3
+       sts gcontrol,r_temp
+       lds r_temp,am2302_hum
+       sts pack2+3,r_temp
+       lds r_temp,am2302_hum+1
+       sts pack2+4,r_temp
+hrc_set_convertend2:
+       rjmp handle_end_sleep
+
+
+
+;---------------------------------------------------
+;   READ SCRATCHPAD
+;---------------------------------------------------
+
+h_readscratchpad_adr2:
+       lsl r_rwbyte
+       lsl r_rwbyte
+       lsl r_rwbyte
+#if  defined(__AVR_ATtiny25__)
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
+#endif
+       sts block,r_rwbyte
+       ldi r_sendflag,1
+       ldi r_mode,OW_READ_SCRATCHPAD2
+       CRCInit2
+h_readscratchpad2:
+       cpi  r_bytep,8
+       breq h_readscratchpad_crc2
+       cpi  r_bytep,9
+       breq h_readscratchpad_all2
+       lds  r_temp,block
+       add  r_temp,r_bytep
+       configZ pack2,r_temp
+       ld   r_rwbyte,Z
+       rjmp handle_end_inc
+h_readscratchpad_crc2:
+       lds  r_rwbyte,crc
+       rjmp handle_end_inc
+h_readscratchpad_all2:
+       rjmp handle_end_sleep
+
+
+
+
+;---------------------------------------------------
+;   WRITE SCRATCHPAD
+;---------------------------------------------------
+h_writescratchpad_adr2:
+       lsl r_rwbyte
+       lsl r_rwbyte
+       lsl r_rwbyte
+#if  defined(__AVR_ATtiny25__)
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
+#endif
+       sts block,r_rwbyte
+       ldi r_mode,OW_WRITE_SCRATCHPAD2
+       ldi  r_bcount,1 
+       rjmp handle_end 
+h_writescratchpad2:
+       cpi  r_bytep,8
+       breq h_writescratchpad_all2
+       lds  r_temp,block
+       add  r_temp,r_bytep
+       configZ pack2,r_temp
+       st   Z,r_rwbyte
+       rjmp handle_end_inc
+h_writescratchpad_all2:
+       rjmp handle_end_sleep
+
+
+
+
+
+
+
+
+
+#include "../common/OWPinInterrupt.s"
+.end
\ No newline at end of file
diff --git a/DS18B20_MAX44009/DS18B20.atsln b/DS18B20_MAX44009/DS18B20.atsln
new file mode 100644 (file)
index 0000000..558a11d
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Atmel Studio Solution File, Format Version 11.00
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20", "DS18B20.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS18B20_MAX44009/DS18B20.c b/DS18B20_MAX44009/DS18B20.c
new file mode 100644 (file)
index 0000000..12e682b
--- /dev/null
@@ -0,0 +1,147 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+#include <avr/pgmspace.h>
+#include "../common/I2C/USI_TWI_Master.h"
+#include "../common/I2C/MAX44009.h"
+
+
+extern void OWINIT();
+
+
+
+
+uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/
+       
+#if (owid>128) 
+#error "Variable not correct"
+#endif
+
+extern uint8_t mode;
+extern uint8_t gcontrol;
+extern uint8_t reset_indicator;
+extern uint8_t alarmflag;
+
+
+
+
+typedef union {
+       volatile uint8_t bytes[8];
+       struct {
+               uint16_t temp;  //0
+               uint8_t TH;  //2
+               uint8_t TL;  //3
+               uint8_t config;  //4
+               uint8_t rrFF; //5
+               uint8_t rr00; //6
+               uint8_t rr10; //7
+       };
+} pack_t;
+volatile pack_t pack;
+
+
+
+
+
+
+
+
+int main(void){
+    PRR|=(1<<PRADC);  // adc for save Power
+       pack.temp=0x0550;
+       pack.config=0x7F;
+       pack.TH=75;
+       pack.TL=70;
+       pack.rrFF=0xFF;
+       pack.rr00=0;
+       pack.rr10=0x10;
+       PORTA=0xFF;
+       PORTB=0xFF;
+       OWINIT();
+
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+       MCUCR |=(1<<BODS);
+
+       MCUSR=0;
+       USI_TWI_Master_Initialise();
+       
+       
+       gcontrol=1;
+       sei();
+    while(1)   {
+       
+               if (gcontrol) {
+                       volatile double l=MAX44009getlux();             
+                       if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045
+                       //double l=1000;
+                       l=log(l)*10*16;
+                       uint16_t w=l;
+                       uint8_t t8=w>>4;
+                       uint8_t af=0;
+                       if (t8>pack.TH) af=1;
+                       if (t8<=pack.TL) af=1; 
+                       cli();
+                       pack.temp=w;
+                       //pack.temp++;
+                       alarmflag=af;
+                       sei();                  
+                       gcontrol=0;
+               }
+
+               
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))
+#endif                 
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))
+#endif
+                         {
+
+                       MCUCR|=(1<<SE)|(1<<SM1);
+                       MCUCR&=~(1<<ISC01);
+               } else {
+                       MCUCR|=(1<<SE);
+                       MCUCR&=~(1<<SM1);
+               }
+               //MCUCR&=~(1<<ISC01);
+               asm("SLEEP");
+   }
+
+
+}
\ No newline at end of file
diff --git a/DS18B20_MAX44009/DS18B20.cproj b/DS18B20_MAX44009/DS18B20.cproj
new file mode 100644 (file)
index 0000000..2220867
--- /dev/null
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>6.2</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>{7a5672fe-8226-4158-b931-e1f36b9a8858}</ProjectGuid>
+    <avrdevice>ATtiny84A</avrdevice>
+    <avrdeviceseries>none</avrdeviceseries>
+    <OutputType>Executable</OutputType>
+    <Language>C</Language>
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>
+    <OutputFileExtension>.elf</OutputFileExtension>
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
+    <AssemblyName>DS18B20</AssemblyName>
+    <Name>DS18B20</Name>
+    <RootNamespace>DS18B20</RootNamespace>
+    <ToolchainFlavour>Native</ToolchainFlavour>
+    <KeepTimersRunning>true</KeepTimersRunning>
+    <OverrideVtor>false</OverrideVtor>
+    <CacheFlash>true</CacheFlash>
+    <ProgFlashFromRam>true</ProgFlashFromRam>
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>
+    <UncachedRange />
+    <preserveEEPROM>true</preserveEEPROM>
+    <OverrideVtorValue>exception_table</OverrideVtorValue>
+    <BootSegment>2</BootSegment>
+    <eraseonlaunchrule>1</eraseonlaunchrule>
+    <AsfFrameworkConfig>
+      <framework-data xmlns="">
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.19.0" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <com_atmel_avrdbg_tool_atmelice>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>debugWIRE</InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
+      <ToolNumber>J41800000779</ToolNumber>
+      <ToolName>Atmel-ICE</ToolName>
+    </com_atmel_avrdbg_tool_atmelice>
+    <avrtoolinterface>debugWIRE</avrtoolinterface>
+    <com_atmel_avrdbg_tool_simulator>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>
+        </InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.simulator</ToolType>
+      <ToolNumber>
+      </ToolNumber>
+      <ToolName>Simulator</ToolName>
+    </com_atmel_avrdbg_tool_simulator>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>NDEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>DEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="D:\oc\dev\owSlave2\common\I2C\MAX44009.c">
+      <SubType>compile</SubType>
+      <Link>MAX44009.c</Link>
+    </Compile>
+    <Compile Include="D:\oc\dev\owSlave2\common\I2C\USI_TWI_Master.c">
+      <SubType>compile</SubType>
+      <Link>USI_TWI_Master.c</Link>
+    </Compile>
+    <Compile Include="DS18B20.c">
+      <SubType>compile</SubType>
+    </Compile>
+    <Compile Include="OWDS18B20.S">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
diff --git a/DS18B20_MAX44009/DS18B20.pdf b/DS18B20_MAX44009/DS18B20.pdf
new file mode 100644 (file)
index 0000000..a942d79
Binary files /dev/null and b/DS18B20_MAX44009/DS18B20.pdf differ
diff --git a/DS18B20_MAX44009/OWDS18B20.S b/DS18B20_MAX44009/OWDS18B20.S
new file mode 100644 (file)
index 0000000..27d7b8f
--- /dev/null
@@ -0,0 +1,235 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+#define _CHANGEABLE_ID_
+#define _ZERO_POLLING_
+
+#include "../common/OWConfig.s"
+#include "../common/OWCRC8.s"
+
+.extern pack,8
+
+//.extern  am2302_temp,2
+
+
+
+.macro CHIP_INIT       
+Init_EEPROM_read:
+       sbic _SFR_IO_ADDR(EECR), EEPE
+       rjmp Init_EEPROM_read
+       ldi r_temp,0
+       out _SFR_IO_ADDR(EEARH), r_temp
+       ldi r_temp,2
+       out _SFR_IO_ADDR(EEARL), r_temp
+       sbi _SFR_IO_ADDR(EECR), EERE
+       in r_temp,_SFR_IO_ADDR(EEDR)
+       sbrs r_temp,7
+       rcall hrc_recall_eeprom_func
+.endm
+
+.macro COMMAND_TABLE
+               rjmp h_readscratchpad
+               rjmp h_writescratchpad
+.endm
+
+#include "../common/OWRomFunctions.s"
+#include "../common/OWTimerInterrupt.s"
+
+
+
+; Ab hier Geraeteabhaenging
+#define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+0
+#define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+1
+
+
+;---------------------------------------------------
+;      READ COMMAND and start operation
+;---------------------------------------------------
+
+
+h_readcommand:
+       clr r_bytep
+#ifndef _DIS_FLASH_
+       FLASH_COMMANDS ; muss zu erst sein....
+#endif
+       cjmp 0xBE,hrc_set_readscratchpad
+       cjmp 0x4E,hrc_set_writescratchpad
+       cjmp 0x44,hrc_set_convertT
+       cjmp 0x48,hrc_copy_scratchpad
+       cjmp 0xB8,hrc_recall_eeprom
+#ifdef _CHANGEABLE_ID_
+       CHANGE_ID_COMMANDS
+#endif
+       //ldi r_mode,OW_SLEEP
+       rjmp handle_end_sleep
+
+hrc_set_readscratchpad:
+       ldi r_mode,OW_READ_SCRATCHPAD
+       ldi r_sendflag,1
+       CRCInit2
+       rjmp h_readscratchpad
+
+hrc_set_writescratchpad:
+       ldi r_mode,OW_WRITE_SCRATCHPAD
+       ldi r_bytep,2 ;start to write in 2
+       rjmp handle_end
+
+hrc_recall_eeprom:
+       rcall hrc_recall_eeprom_func
+       rjmp handle_end
+
+
+
+hrc_set_convertT:
+       ldi r_temp,1
+       sts gcontrol,r_temp
+       ;lds temp,am2302_temp
+       //sts pack+1,temp
+       ;lds temp,am2302_temp+1
+       //sts pack+2,temp
+;      ldi r_rwbyte,0
+;      lds r_temp,pack
+;      swap r_temp
+;      andi r_temp,0x0F
+;      lds r_temp2,pack+1
+;      swap r_temp2
+;      andi r_temp2,0xF0
+;      or r_temp,r_temp2
+;      lds r_temp2,pack+2
+;      cp r_temp,r_temp2  ;higher than or equal to TH
+;      brge hrc_set_convertT_set_arlarm
+;      lds r_temp2,pack+3 
+;      cp r_temp,r_temp2 ;lower than or equal to TL
+;      brlt hrc_set_convertT_set_arlarm
+;      breq hrc_set_convertT_set_arlarm
+;      rjmp hrc_set_convertT_end
+;hrc_set_convertT_set_arlarm:
+;      ldi r_rwbyte,1
+;hrc_set_convertT_end:
+;      sts alarmflag,r_rwbyte
+       rjmp handle_end_sleep
+
+
+hrc_copy_scratchpad:
+       ldi r_bytep,2
+       configZ pack,r_bytep
+       clr r_bytep
+hrc_copy_scratchpad_EEPROM_write:
+       sbic _SFR_IO_ADDR(EECR), EEPE   
+       rjmp hrc_copy_scratchpad_EEPROM_write
+       ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
+       out _SFR_IO_ADDR(EECR), r_temp
+       ldi r_temp,0
+       out _SFR_IO_ADDR(EEARH),r_temp
+       out _SFR_IO_ADDR(EEARL), r_bytep
+       ld  r_rwbyte,Z+
+       out _SFR_IO_ADDR(EEDR), r_rwbyte
+       sbi _SFR_IO_ADDR(EECR), EEMPE
+       sbi _SFR_IO_ADDR(EECR), EEPE
+       inc r_bytep
+       cpi r_bytep,3
+       brne hrc_copy_scratchpad_EEPROM_write
+       rjmp handle_end
+
+
+hrc_recall_eeprom_func:
+       ldi r_bytep,2
+       configZ pack,r_bytep
+       clr r_bytep
+       clr r_temp
+hrc_recall_eeprom_EEPROM_read:
+       sbic _SFR_IO_ADDR(EECR), EEPE
+       rjmp hrc_recall_eeprom_EEPROM_read
+       out _SFR_IO_ADDR(EEARH), r_temp
+       out _SFR_IO_ADDR(EEARL), r_bytep
+       sbi _SFR_IO_ADDR(EECR), EERE
+       in r_rwbyte,_SFR_IO_ADDR(EEDR)
+       st Z+,r_rwbyte
+       inc r_bytep
+       cpi r_bytep,3
+       brne hrc_recall_eeprom_EEPROM_read
+       ret
+
+
+
+
+
+
+;---------------------------------------------------
+;   READ SCRATCHPAD
+;---------------------------------------------------
+
+h_readscratchpad:
+       cpi  r_bytep,8
+       breq h_readscratchpad_crc
+       cpi  r_bytep,9
+       breq h_readscratchpad_all
+       configZ pack,r_bytep
+       ld   r_rwbyte,Z
+       rjmp h_readscratchpad_endc
+h_readscratchpad_crc:
+       lds  r_rwbyte,crc
+h_readscratchpad_endc:
+       inc  r_bytep
+       ldi  r_bcount,1 
+       rjmp handle_end
+h_readscratchpad_all:
+       rjmp handle_end_sleep
+
+
+
+
+
+;---------------------------------------------------
+;   WRITE SCRATCHPAD
+;---------------------------------------------------
+
+h_writescratchpad:
+       configZ pack,r_bytep
+       inc  r_bytep
+       cpi  r_bytep,5
+       breq h_writescratchpad_all
+       st   Z,r_rwbyte
+       rjmp handle_end
+h_writescratchpad_all:
+       ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1
+       st   Z,r_rwbyte
+       rjmp handle_end_sleep
+
+
+
+
+
+
+#include "../common/OWPinInterrupt.s"
+.end
\ No newline at end of file
diff --git a/DS18B20_Thermocouble/DS18B20.atsln b/DS18B20_Thermocouble/DS18B20.atsln
new file mode 100644 (file)
index 0000000..558a11d
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Atmel Studio Solution File, Format Version 11.00
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20", "DS18B20.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS18B20_Thermocouble/DS18B20.c b/DS18B20_Thermocouble/DS18B20.c
new file mode 100644 (file)
index 0000000..2ac3b11
--- /dev/null
@@ -0,0 +1,314 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+#include <avr/pgmspace.h>
+
+extern void OWINIT();
+
+//const float k_rs[54] PROGMEM ={0.000000,24.125000,48.585366,72.731707,96.829268,121.097561,145.700000,170.600000,195.650000,220.625000,245.365854,269.853659,294.119048,318.195122,342.166667,366.000000,389.761905,413.428571,437.023810,460.558140,484.047619,507.511628,530.976190,554.418605,577.883721,601.395349,624.952381,648.571429,672.285714,696.073171,719.976190,744.000000,768.146341,792.439024,816.853659,841.414634,866.125000,890.975000,916.000000,941.179487,966.525000,992.025641,1017.717949,1043.589744,1069.657895,1095.945946,1122.432432,1149.184211,1176.189189,1203.472222,1231.083333,1259.000000,1287.285714,1315.941176};
+const float j_rs[70] PROGMEM ={0, 18.302913, 34.830476, 50.783019, 70.653704, 90.505455, 110.341818, 130.165455, 149.163636, 160.791071, 180.596364, 200.398214, 220.200000, 240.000000, 250.882883, 270.603636, 290.409091, 310.216364, 330.025455, 342.472727, 360.649091, 380.461818, 400.275000, 420.087273, 435.275676, 450.703636, 470.503636, 490.298214, 510.082456, 523.486726, 540.621053, 560.370175, 580.105172, 591.979487, 610.527119, 630.213559, 644.601653, 660.534426, 680.168852, 690.787097, 710.391935, 729.123810, 740.559375, 760.126562, 770.684615, 790.235385, 800.782812, 820.331250, 834.681250, 850.446032, 870.017460, 880.600000, 900.196774, 911.099187, 930.432787, 950.073333, 960.728333, 980.396667, 1000.078333, 1010.772881, 1030.475862, 1050.187931, 1065.717241, 1080.631034, 1100.358621, 1120.089655, 1131.840000,1150.556897, 1170.294737, 1190.035088};
+       double gettemp_rs(double V) {
+               uint8_t iv=(uint8_t)(V);
+               float t0=pgm_read_float(&(j_rs[iv]));
+               float t1=pgm_read_float(&(j_rs[iv+1]));
+               return t0+(t1-t0)/1*(V-iv);
+       }
+
+
+uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0xAC};/**/
+       
+#if (owid>128) 
+#error "Variable not correct"
+#endif
+
+extern uint8_t mode;
+extern uint8_t gcontrol;
+extern uint8_t reset_indicator;
+extern uint8_t alarmflag;
+
+
+volatile uint8_t wdcounter;
+
+
+typedef union {
+       volatile uint8_t bytes[8];
+       struct {
+               uint16_t temp;  //0
+               uint8_t TH;  //2
+               uint8_t TL;  //3
+               uint8_t config;  //4
+               uint8_t rrFF; //5
+               uint8_t rr00; //6
+               uint8_t rr10; //7
+       };
+} pack_t;
+volatile pack_t pack;
+
+
+
+
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+ISR(WATCHDOG_vect) {
+#else
+ISR(WDT_vect) {
+#endif 
+       //sleep_disable();          // Disable Sleep on Wakeup
+       wdcounter++;
+       if (reset_indicator==1) reset_indicator++;
+       else if (reset_indicator==2) mode=0;
+/*     if (timeout==2) {
+               DIS_TIMER;
+               EN_OWINT;
+               mode=OWM_SLEEP;
+       }
+       timeout++;*/
+       //sleep_enable();           // Enable Sleep Mode
+
+}
+
+
+#define OWM_PORT PORTA
+#define OWM_PIN PINA
+#define OWM_PINN PINA0
+#define OWM_DD DDRA
+
+#define OWM_SET_LOW OWM_PORT&=~(1<<OWM_PINN);OWM_DD|=(1<<OWM_PINN)
+#define OWM_SET_HIGH OWM_DD&=~(1<<OWM_PINN);OWM_PORT|=(1<<OWM_PINN)
+
+#define OWM_IS_LOW ((OWM_PIN & (1<<OWM_PINN))==0)
+
+
+void owm_init() {
+       OWM_PORT|=(1<<OWM_PINN); //PULL UP
+       OWM_DD&=~(1<<OWM_PINN);
+}
+
+#define owm_delay(us1)  _delay_us(us1)
+
+uint8_t owm_reset() {
+       OWM_SET_LOW;
+       owm_delay(480);
+       OWM_SET_HIGH;
+       owm_delay(60);
+       if (OWM_IS_LOW) {owm_delay(420); return 1;} else {owm_delay(420); return 0;}
+       
+       
+}
+
+void owm_rw(uint8_t *b) {
+       uint8_t i;
+       uint8_t pp=1;
+       for(i=0;i<8;i++) {
+               if (pp&b[0]) {
+                       OWM_SET_LOW;
+                       owm_delay(6);
+                       OWM_SET_HIGH;
+                       owm_delay(9);
+                       if (OWM_IS_LOW) {
+                               b[0]&=~pp;
+                       }
+                       owm_delay(80-6-9);
+                       
+                       } else {
+                       OWM_SET_LOW;
+                       owm_delay(60);
+                       OWM_SET_HIGH;
+                       owm_delay(20);
+               }
+               pp=(pp<<1);
+       }
+}
+
+void owm_block(uint8_t count, uint8_t *buf){
+       uint8_t i;
+       for(i=0;i<count;i++) {
+               owm_rw(buf+i);
+       }
+}
+
+inline int16_t ow_fconvert(uint8_t b1, uint8_t b2) {
+       int16_t tsht;
+       tsht=b1  |((int)b2<<8);
+       if (b2 & 0x080)
+       tsht |= 0xFFFFF0000;
+       return tsht;
+}
+volatile double V,ktemp;
+
+uint16_t ADmess() {
+        ADMUX=0b10001101;
+        ADCSRA|=(1<<ADSC);
+        while ((ADCSRA&(1<<ADSC)));
+       return ADC;
+}
+
+int main(void){
+    //PRR|=(1<<PRUSI)|(1<<PRADC);  //Switch off usi and adc for save Power
+       pack.temp=0x0550;
+       pack.config=0x7F;
+       pack.TH=75;
+       pack.TL=70;
+       pack.rrFF=0xFF;
+       pack.rr00=0;
+       pack.rr10=0x10;
+       PORTA=0xFF-(1<<PINA1)-(1<<PINA2);
+       PORTB=0xFF;
+       OWINIT();
+
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+       MCUCR |=(1<<BODS);
+
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt
+       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~1 seconds
+       MCUSR=0;
+       uint8_t block[13];
+       sei();
+       ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
+       owm_init();
+       owm_reset();
+       block[0]=0xCC;
+       block[1]=0x4E;
+       block[2]=0;
+       block[3]=0;
+       block[4]=0x1F;
+       owm_block(5,block);
+       owm_reset();
+       block[0]=0x33;
+       for(uint8_t i=1;i<9;i++) {
+               block[i]=0xFF;
+       }
+       owm_block(9,block);
+       
+       if (block[1]==0x28) {  //DS18B20 angeschlossen
+               for(uint8_t i=0;i<8;i++) {
+                       owid[i]=block[i+1];
+               }
+               while(EECR & (1<<EEPE));
+               EEAR=E2END-7;
+               EECR|=(1<EERE);
+               if (EEDR!=0x28) { //Wenn keine ID im Eeprom uebernimm es
+                       for(uint8_t a=0;a<8;a++) {
+                               while(EECR & (1<<EEPE));
+                               EECR = (0<<EEPM1)|(0<<EEPM0);
+                               EEAR = E2END-7+a;
+                               EEDR = block[a+1];
+                               EECR |= (1<<EEMPE);
+                               EECR |= (1<<EEPE);
+                       }
+               }
+       }
+       
+       uint16_t ares[16],sum;
+       uint8_t par=0;
+       ares[0]=0;//ADmess();
+       for (par=1;par<16;par++) {
+               ares[par]=ares[0];
+       }
+       par=0;
+       wdcounter=0;
+       gcontrol=1;
+
+    while(1)   {
+               if (wdcounter>0) {
+                       ares[par]=ADmess();
+                       par++;
+                       if (par>15) par=0;
+                       wdcounter=0;
+               }
+               if (gcontrol) {
+                       PORTB|=(1<<PORTB0);
+                       sum=0;
+                       for(uint8_t i=0;i<16;i++) {
+                               sum+=ares[i];
+                       }
+                       V=sum/20.0/1024.0*1.174*1000.0/16.0;
+                       //V=sum/20.0/1024.0*1.01*1000.0/16.0;
+                       ktemp=gettemp_rs(V);
+                       owm_reset();
+                       block[0]=0xCC;
+                       block[1]=0x44;
+                       owm_block(2,block);
+                       _delay_ms(100);
+                       owm_reset();
+                       block[0]=0xCC;
+                       block[1]=0xBE;
+                       for(uint8_t i=0;i<9;i++) block[i+2]=0xFF;
+                       owm_block(11,block);
+                       uint16_t htemp;
+                       if (PINB&(1<<PINB0)) {
+                               htemp=(ktemp*16+(block[2]|(block[3]<<8)))/10;
+                       } else {
+                               
+                               htemp=ktemp*16+(block[2]|(block[3]<<8));
+                       }
+                       uint8_t t8=pack.temp>>4;
+                       uint8_t af=0;
+                       if (t8>pack.TH) af=1;
+                       if (t8<=pack.TL) af=1;
+                       cli();
+                       pack.temp=htemp;
+                       alarmflag=af;
+                       sei();
+                       gcontrol=0;
+                       PORTB&=~(1<<PORTB0);
+               }
+
+               
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))
+#endif                 
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))
+#endif
+                         {
+//                     CLKPR=(1<<CLKPCE);
+       //              CLKPR=(1<<CLKPS2); /*0.5Mhz*/
+//                     PORTB&=~(1<<PINB1);
+                       MCUCR|=(1<<SE)|(1<<SM1);
+                       MCUCR&=~(1<<ISC01);
+               } else {
+                       MCUCR|=(1<<SE);
+                       MCUCR&=~(1<<SM1);
+               }
+               asm("SLEEP");
+   }
+
+
+}
\ No newline at end of file
diff --git a/DS18B20_Thermocouble/DS18B20.cproj b/DS18B20_Thermocouble/DS18B20.cproj
new file mode 100644 (file)
index 0000000..b5a8073
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>6.2</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>{7a5672fe-8226-4158-b931-e1f36b9a8858}</ProjectGuid>
+    <avrdevice>ATtiny84A</avrdevice>
+    <avrdeviceseries>none</avrdeviceseries>
+    <OutputType>Executable</OutputType>
+    <Language>C</Language>
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>
+    <OutputFileExtension>.elf</OutputFileExtension>
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
+    <AssemblyName>DS18B20</AssemblyName>
+    <Name>DS18B20</Name>
+    <RootNamespace>DS18B20</RootNamespace>
+    <ToolchainFlavour>Native</ToolchainFlavour>
+    <KeepTimersRunning>true</KeepTimersRunning>
+    <OverrideVtor>false</OverrideVtor>
+    <CacheFlash>true</CacheFlash>
+    <ProgFlashFromRam>true</ProgFlashFromRam>
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>
+    <UncachedRange />
+    <preserveEEPROM>true</preserveEEPROM>
+    <OverrideVtorValue>exception_table</OverrideVtorValue>
+    <BootSegment>2</BootSegment>
+    <eraseonlaunchrule>1</eraseonlaunchrule>
+    <AsfFrameworkConfig>
+      <framework-data xmlns="">
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.19.0" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <com_atmel_avrdbg_tool_atmelice>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>debugWIRE</InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
+      <ToolNumber>J41800000779</ToolNumber>
+      <ToolName>Atmel-ICE</ToolName>
+    </com_atmel_avrdbg_tool_atmelice>
+    <avrtoolinterface>debugWIRE</avrtoolinterface>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>NDEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>DEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="DS18B20.c">
+      <SubType>compile</SubType>
+    </Compile>
+    <Compile Include="OWDS18B20.S">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
diff --git a/DS18B20_Thermocouble/DS18B20.pdf b/DS18B20_Thermocouble/DS18B20.pdf
new file mode 100644 (file)
index 0000000..a942d79
Binary files /dev/null and b/DS18B20_Thermocouble/DS18B20.pdf differ
diff --git a/DS18B20_Thermocouble/OWDS18B20.S b/DS18B20_Thermocouble/OWDS18B20.S
new file mode 100644 (file)
index 0000000..322f70f
--- /dev/null
@@ -0,0 +1,234 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+#define _CHANGEABLE_ID_
+
+#include "../common/OWConfig.s"
+#include "../common/OWCRC8.s"
+
+.extern pack,8
+
+//.extern  am2302_temp,2
+
+
+
+.macro CHIP_INIT       
+Init_EEPROM_read:
+       sbic _SFR_IO_ADDR(EECR), EEPE
+       rjmp Init_EEPROM_read
+       ldi r_temp,0
+       out _SFR_IO_ADDR(EEARH), r_temp
+       ldi r_temp,2
+       out _SFR_IO_ADDR(EEARL), r_temp
+       sbi _SFR_IO_ADDR(EECR), EERE
+       in r_temp,_SFR_IO_ADDR(EEDR)
+       sbrs r_temp,7
+       rcall hrc_recall_eeprom_func
+.endm
+
+.macro COMMAND_TABLE
+               rjmp h_readscratchpad
+               rjmp h_writescratchpad
+.endm
+
+#include "../common/OWRomFunctions.s"
+#include "../common/OWTimerInterrupt.s"
+
+
+
+; Ab hier Geraeteabhaenging
+#define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+0
+#define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+1
+
+
+;---------------------------------------------------
+;      READ COMMAND and start operation
+;---------------------------------------------------
+
+
+h_readcommand:
+       clr r_bytep
+#ifndef _DIS_FLASH_
+       FLASH_COMMANDS ; muss zu erst sein....
+#endif
+       cjmp 0xBE,hrc_set_readscratchpad
+       cjmp 0x4E,hrc_set_writescratchpad
+       cjmp 0x44,hrc_set_convertT
+       cjmp 0x48,hrc_copy_scratchpad
+       cjmp 0xB8,hrc_recall_eeprom
+#ifdef _CHANGEABLE_ID_
+       CHANGE_ID_COMMANDS
+#endif
+       ldi r_mode,OW_SLEEP
+       rjmp handle_end
+
+hrc_set_readscratchpad:
+       ldi r_mode,OW_READ_SCRATCHPAD
+       ldi r_sendflag,1
+       CRCInit2
+       rjmp h_readscratchpad
+
+hrc_set_writescratchpad:
+       ldi r_mode,OW_WRITE_SCRATCHPAD
+       ldi r_bytep,2 ;start to write in 2
+       rjmp handle_end
+
+hrc_recall_eeprom:
+       rcall hrc_recall_eeprom_func
+       rjmp handle_end
+
+
+
+hrc_set_convertT:
+       ldi r_temp,1
+       sts gcontrol,r_temp
+       ;lds temp,am2302_temp
+       //sts pack+1,temp
+       ;lds temp,am2302_temp+1
+       //sts pack+2,temp
+;      ldi r_rwbyte,0
+;      lds r_temp,pack
+;      swap r_temp
+;      andi r_temp,0x0F
+;      lds r_temp2,pack+1
+;      swap r_temp2
+;      andi r_temp2,0xF0
+;      or r_temp,r_temp2
+;      lds r_temp2,pack+2
+;      cp r_temp,r_temp2  ;higher than or equal to TH
+;      brge hrc_set_convertT_set_arlarm
+;      lds r_temp2,pack+3 
+;      cp r_temp,r_temp2 ;lower than or equal to TL
+;      brlt hrc_set_convertT_set_arlarm
+;      breq hrc_set_convertT_set_arlarm
+;      rjmp hrc_set_convertT_end
+;hrc_set_convertT_set_arlarm:
+;      ldi r_rwbyte,1
+;hrc_set_convertT_end:
+;      sts alarmflag,r_rwbyte
+       rjmp handle_end_sleep
+
+
+hrc_copy_scratchpad:
+       ldi r_bytep,2
+       configZ pack,r_bytep
+       clr r_bytep
+hrc_copy_scratchpad_EEPROM_write:
+       sbic _SFR_IO_ADDR(EECR), EEPE   
+       rjmp hrc_copy_scratchpad_EEPROM_write
+       ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
+       out _SFR_IO_ADDR(EECR), r_temp
+       ldi r_temp,0
+       out _SFR_IO_ADDR(EEARH),r_temp
+       out _SFR_IO_ADDR(EEARL), r_bytep
+       ld  r_rwbyte,Z+
+       out _SFR_IO_ADDR(EEDR), r_rwbyte
+       sbi _SFR_IO_ADDR(EECR), EEMPE
+       sbi _SFR_IO_ADDR(EECR), EEPE
+       inc r_bytep
+       cpi r_bytep,3
+       brne hrc_copy_scratchpad_EEPROM_write
+       rjmp handle_end
+
+
+hrc_recall_eeprom_func:
+       ldi r_bytep,2
+       configZ pack,r_bytep
+       clr r_bytep
+       clr r_temp
+hrc_recall_eeprom_EEPROM_read:
+       sbic _SFR_IO_ADDR(EECR), EEPE
+       rjmp hrc_recall_eeprom_EEPROM_read
+       out _SFR_IO_ADDR(EEARH), r_temp
+       out _SFR_IO_ADDR(EEARL), r_bytep
+       sbi _SFR_IO_ADDR(EECR), EERE
+       in r_rwbyte,_SFR_IO_ADDR(EEDR)
+       st Z+,r_rwbyte
+       inc r_bytep
+       cpi r_bytep,3
+       brne hrc_recall_eeprom_EEPROM_read
+       ret
+
+
+
+
+
+
+;---------------------------------------------------
+;   READ SCRATCHPAD
+;---------------------------------------------------
+
+h_readscratchpad:
+       cpi  r_bytep,8
+       breq h_readscratchpad_crc
+       cpi  r_bytep,9
+       breq h_readscratchpad_all
+       configZ pack,r_bytep
+       ld   r_rwbyte,Z
+       rjmp h_readscratchpad_endc
+h_readscratchpad_crc:
+       lds  r_rwbyte,crc
+h_readscratchpad_endc:
+       inc  r_bytep
+       ldi  r_bcount,1 
+       rjmp handle_end
+h_readscratchpad_all:
+       rjmp handle_end_sleep
+
+
+
+
+
+;---------------------------------------------------
+;   WRITE SCRATCHPAD
+;---------------------------------------------------
+
+h_writescratchpad:
+       configZ pack,r_bytep
+       inc  r_bytep
+       cpi  r_bytep,5
+       breq h_writescratchpad_all
+       st   Z,r_rwbyte
+       rjmp handle_end
+h_writescratchpad_all:
+       ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1
+       st   Z,r_rwbyte
+       rjmp handle_end_sleep
+
+
+
+
+
+
+#include "../common/OWPinInterrupt.s"
+.end
\ No newline at end of file
diff --git a/DS18B20_Thermocouble/Typ-J.csv b/DS18B20_Thermocouble/Typ-J.csv
new file mode 100644 (file)
index 0000000..ca48831
--- /dev/null
@@ -0,0 +1,141 @@
+-210;-8.095;-8.076;-8.057;-8.037;-8.017;-7.996;-7.976;-7.955;-7.934;-7.912;-7.890
+-200;-7.890;-7.868;-7.846;-7.824;-7.801;-7.778;-7.755;-7.731;-7.707;-7.683;-7.659
+-190;-7.659;-7.634;-7.610;-7.585;-7.559;-7.534;-7.508;-7.482;-7.456;-7.429;-7.403
+-180;-7.403;-7.376;-7.348;-7.321;-7.293;-7.265;-7.237;-7.209;-7.181;-7.152;-7.123
+-170;-7.123;-7.094;-7.064;-7.035;-7.005;-6.975;-6.944;-6.914;-6.883;-6.853;-6.821
+-160;-6.821;-6.790;-6.759;-6.727;-6.695;-6.663;-6.631;-6.598;-6.566;-6.533;-6.500
+-150;-6.500;-6.467;-6.433;-6.400;-6.366;-6.332;-6.298;-6.263;-6.229;-6.194;-6.159
+-140;-6.159;-6.124;-6.089;-6.054;-6.018;-5.982;-5.946;-5.910;-5.874;-5.838;-5.801
+-130;-5.801;-5.764;-5.727;-5.690;-5.653;-5.616;-5.578;-5.541;-5.503;-5.465;-5.426
+-120;-5.426;-5.388;-5.350;-5.311;-5.272;-5.233;-5.194;-5.155;-5.116;-5.076;-5.037
+-110;-5.037;-4.997;-4.957;-4.917;-4.877;-4.836;-4.796;-4.755;-4.714;-4.674;-4.633
+-100;-4.633;-4.591;-4.550;-4.509;-4.467;-4.425;-4.384;-4.342;-4.300;-4.257;-4.215
+-90;-4.215;-4.173;-4.130;-4.088;-4.045;-4.002;-3.959;-3.916;-3.872;-3.829;-3.786
+-80;-3.786;-3.742;-3.698;-3.654;-3.610;-3.566;-3.522;-3.478;-3.434;-3.389;-3.344
+-70;-3.344;-3.300;-3.255;-3.210;-3.165;-3.120;-3.075;-3.029;-2.984;-2.938;-2.893
+-60;-2.893;-2.847;-2.801;-2.755;-2.709;-2.663;-2.617;-2.571;-2.524;-2.478;-2.431
+-50;-2.431;-2.385;-2.338;-2.291;-2.244;-2.197;-2.150;-2.103;-2.055;-2.008;-1.961
+-40;-1.961;-1.913;-1.865;-1.818;-1.770;-1.722;-1.674;-1.626;-1.578;-1.530;-1.482
+-30;-1.482;-1.433;-1.385;-1.336;-1.288;-1.239;-1.190;-1.142;-1.093;-1.044;-0.995
+-20;-0.995;-0.946;-0.896;-0.847;-0.798;-0.749;-0.699;-0.650;-0.600;-0.550;-0.501
+-10;-0.501;-0.451;-0.401;-0.351;-0.301;-0.251;-0.201;-0.151;-0.101;-0.050;0.000
+0;0.000;0.050;0.101;0.151;0.202;0.253;0.303;0.354;0.405;0.456;0.507
+10;0.507;0.558;0.609;0.660;0.711;0.762;0.814;0.865;0.916;0.968;1.019
+20;1.019;1.071;1.122;1.174;1.226;1.277;1.329;1.381;1.433;1.485;1.537
+30;1.537;1.589;1.641;1.693;1.745;1.797;1.849;1.902;1.954;2.006;2.059
+40;2.059;2.111;2.164;2.216;2.269;2.322;2.374;2.427;2.480;2.532;2.585
+50;2.585;2.638;2.691;2.744;2.797;2.850;2.903;2.956;3.009;3.062;3.116
+60;3.116;3.169;3.222;3.275;3.329;3.382;3.436;3.489;3.543;3.596;3.650
+70;3.650;3.703;3.757;3.810;3.864;3.918;3.971;4.025;4.079;4.133;4.187
+80;4.187;4.240;4.294;4.348;4.402;4.456;4.510;4.564;4.618;4.672;4.726
+90;4.726;4.781;4.835;4.889;4.943;4.997;5.052;5.106;5.160;5.215;5.269
+100;5.269;5.323;5.378;5.432;5.487;5.541;5.595;5.650;5.705;5.759;5.814
+110;5.814;5.868;5.923;5.977;6.032;6.087;6.141;6.196;6.251;6.306;6.360
+120;6.360;6.415;6.470;6.525;6.579;6.634;6.689;6.744;6.799;6.854;6.909
+130;6.909;6.964;7.019;7.074;7.129;7.184;7.239;7.294;7.349;7.404;7.459
+140;7.459;7.514;7.569;7.624;7.679;7.734;7.789;7.844;7.900;7.955;8.010
+150;8.010;8.065;8.120;8.175;8.231;8.286;8.341;8.396;8.452;8.507;8.562
+160;8.562;8.618;8.673;8.728;8.783;8.839;8.894;8.949;9.005;9.060;9.115
+170;9.115;9.171;9.226;9.282;9.337;9.392;9.448;9.503;9.559;9.614;9.669
+180;9.669;9.725;9.780;9.836;9.891;9.947;10.002;10.057;10.113;10.168;10.224
+190;10.224;10.279;10.335;10.390;10.446;10.501;10.557;10.612;10.668;10.723;10.779
+200;10.779;10.834;10.890;10.945;11.001;11.056;11.112;11.167;11.223;11.278;11.334
+210;11.334;11.389;11.445;11.501;11.556;11.612;11.667;11.723;11.778;11.834;11.889
+220;11.889;11.945;12.000;12.056;12.111;12.167;12.222;12.278;12.334;12.389;12.445
+230;12.445;12.500;12.556;12.611;12.667;12.722;12.778;12.833;12.889;12.944;13.000
+240;13.000;13.056;13.111;13.167;13.222;13.278;13.333;13.389;13.444;13.500;13.555
+250;13.555;13.611;13.666;13.722;13.777;13.833;13.888;13.944;13.999;14.055;14.110
+260;14.110;14.166;14.221;14.277;14.332;14.388;14.443;14.499;14.554;14.609;14.665
+270;14.665;14.720;14.776;14.831;14.887;14.942;14.998;15.053;15.109;15.164;15.219
+280;15.219;15.275;15.330;15.386;15.441;15.496;15.552;15.607;15.663;15.718;15.773
+290;15.773;15.829;15.884;15.940;15.995;16.050;16.106;16.161;16.216;16.272;16.327
+300;16.327;16.383;16.438;16.493;16.549;16.604;16.659;16.715;16.770;16.825;16.881
+310;16.881;16.936;16.991;17.046;17.102;17.157;17.212;17.268;17.323;17.378;17.434
+320;17.434;17.489;17.544;17.599;17.655;17.710;17.765;17.820;17.876;17.931;17.986
+330;17.986;18.041;18.097;18.152;18.207;18.262;18.318;18.373;18.428;18.483;18.538
+340;18.538;18.594;18.649;18.704;18.759;18.814;18.870;18.925;18.980;19.035;19.090
+350;19.090;19.146;19.201;19.256;19.311;19.366;19.422;19.477;19.532;19.587;19.642
+360;19.642;19.697;19.753;19.808;19.863;19.918;19.973;20.028;20.083;20.139;20.194
+370;20.194;20.249;20.304;20.359;20.414;20.469;20.525;20.580;20.635;20.690;20.745
+380;20.745;20.800;20.855;20.911;20.966;21.021;21.076;21.131;21.186;21.241;21.297
+390;21.297;21.352;21.407;21.462;21.517;21.572;21.627;21.683;21.738;21.793;21.848
+400;21.848;21.903;21.958;22.014;22.069;22.124;22.179;22.234;22.289;22.345;22.400
+410;22.400;22.455;22.510;22.565;22.620;22.676;22.731;22.786;22.841;22.896;22.952
+420;22.952;23.007;23.062;23.117;23.172;23.228;23.283;23.338;23.393;23.449;23.504
+430;23.504;23.559;23.614;23.670;23.725;23.780;23.835;23.891;23.946;24.001;24.057
+440;24.057;24.112;24.167;24.223;24.278;24.333;24.389;24.444;24.499;24.555;24.610
+450;24.610;24.665;24.721;24.776;24.832;24.887;24.943;24.998;25.053;25.109;25.164
+460;25.164;25.220;25.275;25.331;25.386;25.442;25.497;25.553;25.608;25.664;25.720
+470;25.720;25.775;25.831;25.886;25.942;25.998;26.053;26.109;26.165;26.220;26.276
+480;26.276;26.332;26.387;26.443;26.499;26.555;26.610;26.666;26.722;26.778;26.834
+490;26.834;26.889;26.945;27.001;27.057;27.113;27.169;27.225;27.281;27.337;27.393
+500;27.393;27.449;27.505;27.561;27.617;27.673;27.729;27.785;27.841;27.897;27.953
+510;27.953;28.010;28.066;28.122;28.178;28.234;28.291;28.347;28.403;28.460;28.516
+520;28.516;28.572;28.629;28.685;28.741;28.798;28.854;28.911;28.967;29.024;29.080
+530;29.080;29.137;29.194;29.250;29.307;29.363;29.420;29.477;29.534;29.590;29.647
+540;29.647;29.704;29.761;29.818;29.874;29.931;29.988;30.045;30.102;30.159;30.216
+550;30.216;30.273;30.330;30.387;30.444;30.502;30.559;30.616;30.673;30.730;30.788
+560;30.788;30.845;30.902;30.960;31.017;31.074;31.132;31.189;31.247;31.304;31.362
+570;31.362;31.419;31.477;31.535;31.592;31.650;31.708;31.766;31.823;31.881;31.939
+580;31.939;31.997;32.055;32.113;32.171;32.229;32.287;32.345;32.403;32.461;32.519
+590;32.519;32.577;32.636;32.694;32.752;32.810;32.869;32.927;32.985;33.044;33.102
+600;33.102;33.161;33.219;33.278;33.337;33.395;33.454;33.513;33.571;33.630;33.689
+610;33.689;33.748;33.807;33.866;33.925;33.984;34.043;34.102;34.161;34.220;34.279
+620;34.279;34.338;34.397;34.457;34.516;34.575;34.635;34.694;34.754;34.813;34.873
+630;34.873;34.932;34.992;35.051;35.111;35.171;35.230;35.290;35.350;35.410;35.470
+640;35.470;35.530;35.590;35.650;35.710;35.770;35.830;35.890;35.950;36.010;36.071
+650;36.071;36.131;36.191;36.252;36.312;36.373;36.433;36.494;36.554;36.615;36.675
+660;36.675;36.736;36.797;36.858;36.918;36.979;37.040;37.101;37.162;37.223;37.284
+670;37.284;37.345;37.406;37.467;37.528;37.590;37.651;37.712;37.773;37.835;37.896
+680;37.896;37.958;38.019;38.081;38.142;38.204;38.265;38.327;38.389;38.450;38.512
+690;38.512;38.574;38.636;38.698;38.760;38.822;38.884;38.946;39.008;39.070;39.132
+700;39.132;39.194;39.256;39.318;39.381;39.443;39.505;39.568;39.630;39.693;39.755
+710;39.755;39.818;39.880;39.943;40.005;40.068;40.131;40.193;40.256;40.319;40.382
+720;40.382;40.445;40.508;40.570;40.633;40.696;40.759;40.822;40.886;40.949;41.012
+730;41.012;41.075;41.138;41.201;41.265;41.328;41.391;41.455;41.518;41.581;41.645
+740;41.645;41.708;41.772;41.835;41.899;41.962;42.026;42.090;42.153;42.217;42.281
+750;42.281;42.344;42.408;42.472;42.536;42.599;42.663;42.727;42.791;42.855;42.919
+760;42.919;42.983;43.047;43.111;43.175;43.239;43.303;43.367;43.431;43.495;43.559
+770;43.559;43.624;43.688;43.752;43.817;43.881;43.945;44.010;44.074;44.139;44.203
+780;44.203;44.267;44.332;44.396;44.461;44.525;44.590;44.655;44.719;44.784;44.848
+790;44.848;44.913;44.977;45.042;45.107;45.171;45.236;45.301;45.365;45.430;45.494
+800;45.494;45.559;45.624;45.688;45.753;45.818;45.882;45.947;46.011;46.076;46.141
+810;46.141;46.205;46.270;46.334;46.399;46.464;46.528;46.593;46.657;46.722;46.786
+820;46.786;46.851;46.915;46.980;47.044;47.109;47.173;47.238;47.302;47.367;47.431
+830;47.431;47.495;47.560;47.624;47.688;47.753;47.817;47.881;47.946;48.010;48.074
+840;48.074;48.138;48.202;48.267;48.331;48.395;48.459;48.523;48.587;48.651;48.715
+850;48.715;48.779;48.843;48.907;48.971;49.034;49.098;49.162;49.226;49.290;49.353
+860;49.353;49.417;49.481;49.544;49.608;49.672;49.735;49.799;49.862;49.926;49.989
+870;49.989;50.052;50.116;50.179;50.243;50.306;50.369;50.432;50.495;50.559;50.622
+880;50.622;50.685;50.748;50.811;50.874;50.937;51.000;51.063;51.126;51.188;51.251
+890;51.251;51.314;51.377;51.439;51.502;51.565;51.627;51.690;51.752;51.815;51.877
+900;51.877;51.940;52.002;52.064;52.127;52.189;52.251;52.314;52.376;52.438;52.500
+910;52.500;52.562;52.624;52.686;52.748;52.810;52.872;52.934;52.996;53.057;53.119
+920;53.119;53.181;53.243;53.304;53.366;53.427;53.489;53.550;53.612;53.673;53.735
+930;53.735;53.796;53.857;53.919;53.980;54.041;54.102;54.164;54.225;54.286;54.347
+940;54.347;54.408;54.469;54.530;54.591;54.652;54.713;54.773;54.834;54.895;54.956
+950;54.956;55.016;55.077;55.138;55.198;55.259;55.319;55.380;55.440;55.501;55.561
+960;55.561;55.622;55.682;55.742;55.803;55.863;55.923;55.983;56.043;56.104;56.164
+970;56.164;56.224;56.284;56.344;56.404;56.464;56.524;56.584;56.643;56.703;56.763
+980;56.763;56.823;56.883;56.942;57.002;57.062;57.121;57.181;57.240;57.300;57.360
+990;57.360;57.419;57.479;57.538;57.597;57.657;57.716;57.776;57.835;57.894;57.953
+1000;57.953;58.013;58.072;58.131;58.190;58.249;58.309;58.368;58.427;58.486;58.545
+1010;58.545;58.604;58.663;58.722;58.781;58.840;58.899;58.957;59.016;59.075;59.134
+1020;59.134;59.193;59.252;59.310;59.369;59.428;59.487;59.545;59.604;59.663;59.721
+1030;59.721;59.780;59.838;59.897;59.956;60.014;60.073;60.131;60.190;60.248;60.307
+1040;60.307;60.365;60.423;60.482;60.540;60.599;60.657;60.715;60.774;60.832;60.890
+1050;60.890;60.949;61.007;61.065;61.123;61.182;61.240;61.298;61.356;61.415;61.473
+1060;61.473;61.531;61.589;61.647;61.705;61.763;61.822;61.880;61.938;61.996;62.054
+1070;62.054;62.112;62.170;62.228;62.286;62.344;62.402;62.460;62.518;62.576;62.634
+1080;62.634;62.692;62.750;62.808;62.866;62.924;62.982;63.040;63.098;63.156;63.214
+1090;63.214;63.271;63.329;63.387;63.445;63.503;63.561;63.619;63.677;63.734;63.792
+1100;63.792;63.850;63.908;63.966;64.024;64.081;64.139;64.197;64.255;64.313;64.370
+1110;64.370;64.428;64.486;64.544;64.602;64.659;64.717;64.775;64.833;64.890;64.948
+1120;64.948;65.006;65.064;65.121;65.179;65.237;65.295;65.352;65.410;65.468;65.525
+1130;65.525;65.583;65.641;65.699;65.756;65.814;65.872;65.929;65.987;66.045;66.102
+1140;66.102;66.160;66.218;66.275;66.333;66.391;66.448;66.506;66.564;66.621;66.679
+1150;66.679;66.737;66.794;66.852;66.910;66.967;67.025;67.082;67.140;67.198;67.255
+1160;67.255;67.313;67.370;67.428;67.486;67.543;67.601;67.658;67.716;67.773;67.831
+1170;67.831;67.888;67.946;68.003;68.061;68.119;68.176;68.234;68.291;68.348;68.406
+1180;68.406;68.463;68.521;68.578;68.636;68.693;68.751;68.808;68.865;68.923;68.980
+1190;68.980;69.037;69.095;69.152;69.209;69.267;69.324;69.381;69.439;69.496;69.553
diff --git a/DS18B20_Thermocouble/convthermocouple.py b/DS18B20_Thermocouble/convthermocouple.py
new file mode 100644 (file)
index 0000000..79f65ef
--- /dev/null
@@ -0,0 +1,31 @@
+fi=open("Typ-J.csv","r")
+lastv=0
+v=0
+lastt=0
+t=0
+rs=""
+wc=0
+for l in fi.readlines():
+       #print(l)
+       ll=l.split(";")
+       i=0
+       for n in ll[1:10]:
+               s=ll[0]+"."+str(i)
+               lastv=v
+               lastt=t
+               v=float(n)
+               t=float(s)
+               if (int(v)!=int(lastv)):
+                       interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv)
+                       print int(v),interp
+                       rs=rs+", %f" %(interp)
+                       wc=wc+1
+               if (v==0):
+                       interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv)
+                       print int(v),interp
+                       rs="{0"
+                       wc=1
+                       
+               i=i+1
+print rs+"};"
+print wc
\ No newline at end of file
diff --git a/DS2406/DS2406.atsln b/DS2406/DS2406.atsln
new file mode 100644 (file)
index 0000000..2256c96
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Atmel Studio Solution File, Format Version 11.00
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2406", "DS2406.cproj", "{26106A5A-6618-4774-943F-65C46DDB610B}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {26106A5A-6618-4774-943F-65C46DDB610B}.Debug|AVR.ActiveCfg = Debug|AVR
+               {26106A5A-6618-4774-943F-65C46DDB610B}.Debug|AVR.Build.0 = Debug|AVR
+               {26106A5A-6618-4774-943F-65C46DDB610B}.Release|AVR.ActiveCfg = Release|AVR
+               {26106A5A-6618-4774-943F-65C46DDB610B}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS2406/DS2406.c b/DS2406/DS2406.c
new file mode 100644 (file)
index 0000000..5332d97
--- /dev/null
@@ -0,0 +1,118 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+
+
+extern void OWINIT();
+
+uint8_t owid[8]={0x12, 0xA2, 0xD9, 0x84, 0x00, 0x26, 0x02, 0x1E};/**/
+
+       
+
+extern uint8_t mode;
+extern uint8_t gcontrol;
+extern uint8_t reset_indicator;
+
+
+
+typedef union {
+       volatile uint8_t bytes[1];
+       struct {
+               uint8_t status;
+       };
+} pack_t;
+pack_t pack;
+
+
+
+
+int main(void){
+    PRR|=(1<<PRUSI)|(1<<PRADC);  //Switch off usi and adc for save Power
+       OWINIT();
+       
+       ACSR|=(1<<ACD);  //Disable Comparator
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+       
+               
+       
+
+
+
+#ifdef _EEPROM_SAVE_
+               EEARH=0;
+               
+               uint8_t addr;
+               for(uint8_t i=0;i<16;i++) {
+                       addr=i^0x0C;
+                       while(EECR & (1<<EEPE));   
+                       EEARL=i;
+                       EECR |= (1<<EERE);
+                       counters.c8[addr]=EEDR;
+               }
+               for (uint8_t i=0;i<4;i++) {
+                       if (counters.c32[i]==0xFFFFFFFF) counters.c32[i]=0;
+                       //counters.c32[i]=0;
+               }
+
+               /*for(uint8_t i=0;i<16;i++) {
+                       while(EECR & (1<<EEPE));
+                       EECR = (1<<EEPM0);
+                       EEARL = i;
+                       EECR |= (1<<EEMPE);
+                       EECR |= (1<<EEPE);
+               }*/
+       
+   
+#endif
+       sei();
+    while(1)   {
+               
+               //Test if timer active and no sleep then Idle else Power Down
+               if (TEST_TIMER&&(mode==0)) {
+                       MCUCR|=(1<<SE)|(1<<SM1); //Power Down, only low level on 1-Wire and pin change on PCINT wakes up
+                       MCUCR&=~(1<<ISC01);
+               } else {
+                       MCUCR|=(1<<SE);
+                       MCUCR&=~(1<<SM1); 
+               }
+               asm("SLEEP");
+   }
+}
\ No newline at end of file
diff --git a/DS2406/DS2406.cproj b/DS2406/DS2406.cproj
new file mode 100644 (file)
index 0000000..f033ed3
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>6.2</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>{26106a5a-6618-4774-943f-65c46ddb610b}</ProjectGuid>
+    <avrdevice>ATtiny84A</avrdevice>
+    <avrdeviceseries>none</avrdeviceseries>
+    <OutputType>Executable</OutputType>
+    <Language>C</Language>
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>
+    <OutputFileExtension>.elf</OutputFileExtension>
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
+    <AssemblyName>DS2406</AssemblyName>
+    <Name>DS2406</Name>
+    <RootNamespace>DS2406</RootNamespace>
+    <ToolchainFlavour>Native</ToolchainFlavour>
+    <KeepTimersRunning>true</KeepTimersRunning>
+    <OverrideVtor>false</OverrideVtor>
+    <CacheFlash>true</CacheFlash>
+    <ProgFlashFromRam>true</ProgFlashFromRam>
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>
+    <UncachedRange />
+    <preserveEEPROM>true</preserveEEPROM>
+    <OverrideVtorValue>exception_table</OverrideVtorValue>
+    <BootSegment>2</BootSegment>
+    <eraseonlaunchrule>1</eraseonlaunchrule>
+    <AsfFrameworkConfig>
+      <framework-data xmlns="">
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <com_atmel_avrdbg_tool_atmelice>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>debugWIRE</InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
+      <ToolNumber>J41800024445</ToolNumber>
+      <ToolName>Atmel-ICE</ToolName>
+    </com_atmel_avrdbg_tool_atmelice>
+    <avrtoolinterface>debugWIRE</avrtoolinterface>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>NDEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>DEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="DS2406.c">
+      <SubType>compile</SubType>
+    </Compile>
+    <Compile Include="OWDS2406.S">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
diff --git a/DS2406/DS2406.pdf b/DS2406/DS2406.pdf
new file mode 100644 (file)
index 0000000..b6e77e2
Binary files /dev/null and b/DS2406/DS2406.pdf differ
diff --git a/DS2406/Makefile b/DS2406/Makefile
new file mode 100644 (file)
index 0000000..fcc4e3f
--- /dev/null
@@ -0,0 +1,607 @@
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+# Carlos Lamas
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+
+# MCU name
+#MCU = attiny25
+MCU = attiny84a
+
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the 
+#     processor frequency. You can then use this symbol in your source code to 
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+#     Typical values are:
+#                      F_CPU =  1000000
+#         F_CPU =  1843200
+#         F_CPU =  2000000
+#         F_CPU =  3686400
+#         F_CPU =  4000000
+#         F_CPU =  7372800
+F_CPU =  8000000
+#         F_CPU = 11059200
+#         F_CPU = 14745600
+#         F_CPU = 16000000
+#         F_CPU = 18432000
+#         F_CPU = 20000000
+#         F_CPU = 8000000
+
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+
+# Target file name (without extension).
+TARGET = DS2423
+
+
+# Object files directory
+OBJDIR = obj
+
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(TARGET).c
+
+
+# List C++ source files here. (C dependencies are automatically generated.)
+CPPSRC = 
+
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC = OWDS2423.S
+
+
+# Optimization level, can be [0, 1, 2, 3, s]. 
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG = dwarf-2
+
+
+# List any extra directories to look for include files here.
+#     Each directory must be seperated by a space.
+#     Use forward slashes for directory separators.
+#     For a directory that has spaces, enclose it in quotes.
+EXTRAINCDIRS = 
+
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+
+# Place -D or -U options here for C sources
+CDEFS = -DF_CPU=$(F_CPU)UL
+
+
+# Place -D or -U options here for C++ sources
+CPPDEFS = -DF_CPU=$(F_CPU)UL
+#CPPDEFS += -D__STDC_LIMIT_MACROS
+#CPPDEFS += -D__STDC_CONSTANT_MACROS
+
+
+
+#---------------- Compiler Options C ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS)
+CFLAGS += -O$(OPT)
+#CFLAGS += -mint8
+#CFLAGS += -mshort-calls
+CFLAGS += -funsigned-char
+CFLAGS += -funsigned-bitfields
+CFLAGS += -fpack-struct
+CFLAGS += -fshort-enums
+#CFLAGS += -fno-unit-at-a-time
+CFLAGS += -Wall
+CFLAGS += -Wstrict-prototypes
+CFLAGS += -Wundef
+#CFLAGS += -Wunreachable-code
+#CFLAGS += -Wsign-compare
+CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
+CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
+CFLAGS += $(CSTANDARD)
+
+
+#---------------- Compiler Options C++ ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CPPFLAGS = -g$(DEBUG)
+CPPFLAGS += $(CPPDEFS)
+CPPFLAGS += -O$(OPT)
+#CPPFLAGS += -mint8
+#CPPFLAGS += -mshort-calls
+CPPFLAGS += -funsigned-char
+CPPFLAGS += -funsigned-bitfields
+CPPFLAGS += -fpack-struct
+CPPFLAGS += -fshort-enums
+CPPFLAGS += -fno-exceptions
+#CPPFLAGS += -fno-unit-at-a-time
+CPPFLAGS += -Wall
+#CPPFLAGS += -Wstrict-prototypes
+CFLAGS += -Wundef
+#CPPFLAGS += -Wunreachable-code
+#CPPFLAGS += -Wsign-compare
+CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
+CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
+#CPPFLAGS += $(CSTANDARD)
+
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs 
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+PRINTF_LIB = 
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB = 
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+
+MATH_LIB = -lm
+
+
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+#LDFLAGS += -T linker_script.x
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd 
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = pony-stk200
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = lpt1
+
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+DEBUG_UI = gdb
+# DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+#DEBUG_BACKEND = avarice
+DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when 
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before: 
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling C:
+MSG_COMPILING_CPP = Compiling C++:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+MSG_CREATING_LIBRARY = Creating library:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) 
+
+# Define all listing files.
+LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) 
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+# Change the build target to build a HEX file or a library.
+build: elf hex eep lss sym
+#build: lib
+
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+LIBNAME=lib$(TARGET).a
+lib: $(LIBNAME)
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+
+begin:
+       @echo
+       @echo $(MSG_BEGIN)
+
+end:
+       @echo $(MSG_END)
+       @echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+       @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+       $(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+       @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+       $(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion : 
+       @$(CC) --version
+
+
+
+# Program the device.  
+program: $(TARGET).hex $(TARGET).eep
+       $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
+       $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set 
+#     a breakpoint at main().
+gdb-config: 
+       @$(REMOVE) $(GDBINIT_FILE)
+       @echo define reset >> $(GDBINIT_FILE)
+       @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+       @echo end >> $(GDBINIT_FILE)
+       @echo file $(TARGET).elf >> $(GDBINIT_FILE)
+       @echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+       ifeq ($(DEBUG_BACKEND),simulavr)
+       @echo load  >> $(GDBINIT_FILE)
+       endif
+       @echo break main >> $(GDBINIT_FILE)
+
+debug: gdb-config $(TARGET).elf
+       ifeq ($(DEBUG_BACKEND), avarice)
+       @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+       @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+       $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+       @$(WINSHELL) /c pause
+
+       else
+       @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+       $(DEBUG_MFREQ) --port $(DEBUG_PORT)
+       endif
+       @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+       COFFCONVERT = $(OBJCOPY) --debugging
+       COFFCONVERT += --change-section-address .data-0x800000
+       COFFCONVERT += --change-section-address .bss-0x800000
+       COFFCONVERT += --change-section-address .noinit-0x800000
+       COFFCONVERT += --change-section-address .eeprom-0x810000
+
+
+
+coff: $(TARGET).elf
+       @echo
+       @echo $(MSG_COFF) $(TARGET).cof
+       $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+       @echo
+       @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+       $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+       @echo
+       @echo $(MSG_FLASH) $@
+       $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+       @echo
+       @echo $(MSG_EEPROM) $@
+       -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+       @echo
+       @echo $(MSG_EXTENDED_LISTING) $@
+       $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+       @echo
+       @echo $(MSG_SYMBOL_TABLE) $@
+       $(NM) -n $< > $@
+
+
+
+# Create library from object files.
+.SECONDARY : $(TARGET).a
+.PRECIOUS : $(OBJ)
+%.a: $(OBJ)
+       @echo
+       @echo $(MSG_CREATING_LIBRARY) $@
+       $(AR) $@ $(OBJ)
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+       @echo
+       @echo $(MSG_LINKING) $@
+       $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+$(OBJDIR)/%.o : %.c
+       @echo
+       @echo $(MSG_COMPILING) $<
+       $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create object files from C++ source files.
+$(OBJDIR)/%.o : %.cpp
+       @echo
+       @echo $(MSG_COMPILING_CPP) $<
+       $(CC) -c $(ALL_CPPFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+       $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C++ source files.
+%.s : %.cpp
+       $(CC) -S $(ALL_CPPFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+$(OBJDIR)/%.o : %.S
+       @echo
+       @echo $(MSG_ASSEMBLING) $<
+       $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+       $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+       @echo
+       @echo $(MSG_CLEANING)
+       $(REMOVE) $(TARGET).hex
+       $(REMOVE) $(TARGET).eep
+       $(REMOVE) $(TARGET).cof
+       $(REMOVE) $(TARGET).elf
+       $(REMOVE) $(TARGET).map
+       $(REMOVE) $(TARGET).sym
+       $(REMOVE) $(TARGET).lss
+       $(REMOVEDIR) $(OBJDIR)
+       $(REMOVE) $(SRC:.c=.s)
+       $(REMOVE) $(SRC:.c=.d)
+       $(REMOVEDIR) .dep
+
+
+# Create object files directory
+$(shell mkdir $(OBJDIR) 2>/dev/null)
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
diff --git a/DS2406/OWDS2406.S b/DS2406/OWDS2406.S
new file mode 100644 (file)
index 0000000..76addbf
--- /dev/null
@@ -0,0 +1,320 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+#define  _CHANGEABLE_ID_
+#include "../common/OWConfig.s"
+#include "../common/OWCRC16.s"
+
+.extern pack,45
+.extern counters,8
+
+.macro CHIP_INIT       
+.endm
+
+.macro COMMAND_TABLE
+               rjmp h_channelaccess
+.endm
+
+#include "../common/OWRomFunctions.s"
+#include "../common/OWTimerInterrupt.s"
+
+
+
+; Ab hier Geraeteabhaenging
+#define OW_CHANNEL_ACCESS OW_FIRST_COMMAND+0
+
+;---------------------------------------------------
+;      READ COMMAND and start operation
+;---------------------------------------------------
+
+
+h_readcommand:
+       clr r_bytep
+#ifndef _DIS_FLASH_
+       FLASH_COMMANDS ; muss zu erst sein....
+#endif
+       cset 0x0F,OW_WRITE_SCRATCHPAD
+       cjmp 0xAA,hrc_set_readscratchpad
+       cset 0x5A,OW_COPY_SCRATCHPAD
+       cset 0xF0,OW_READ_MEMORY_ADDR
+       cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR
+#ifdef _CHANGEABLE_ID_
+       CHANGE_ID_COMMANDS
+#endif
+       ldi r_mode,OW_SLEEP
+       rjmp handle_end
+
+hrc_set_readscratchpad:
+       ldi r_mode,OW_READ_SCRATCHPAD
+       ldi r_sendflag,1
+       rjmp h_readscratchpad
+
+h_writescratchpad:
+       configZ pack,r_bytep
+       inc  r_bytep
+       st   Z,r_rwbyte
+       cpi  r_bytep,2
+       breq h_writescratchpad_block
+       brsh h_writescratchpad_set_eoffset ;;33
+       rjmp handle_end  ;handle_end zu weit entfernt fuer br...
+h_writescratchpad_set_eoffset:
+       cpi  r_bytep,35
+       breq h_writescratchpad_setcrc
+       mov r_temp,r_bytep
+       subi r_temp,4
+       sts pack+2,r_temp ;AA und PF cleared
+       rjmp handle_end
+;Start writeing to 32 Byte Block ; skip status byte    
+h_writescratchpad_block:
+       lds r_temp,pack ; Adresse low byte
+       andi r_temp,0x1F ;32 byte
+       add r_bytep,r_temp ;Zur angegebenen Startadresse springen
+       ;ori r_temp,0x20 ; Set PF flag
+       sts pack+2,r_temp  ;E4:E0 vorher setzen
+       ; Byte 3 ueberspringen
+       rjmp handle_end_inc
+
+h_writescratchpad_setcrc:
+       ;copy crc to pack
+       lds r_temp,crc
+       com r_temp
+       sts pack+43,r_temp
+       lds r_temp,crc+1
+       com r_temp ; invertieren , komischer name.....
+       sts pack+44,r_temp
+       ldi  r_mode,OW_WRITE_SCRATCHPAD_CRC
+       ldi r_sendflag,1
+       ldi r_bytep,43
+h_writescratchpad_crc:
+       cpi r_bytep,45
+       breq h_writescratchpad_crc_end
+       configZ pack,r_bytep
+       ld r_rwbyte,Z
+       rjmp handle_end_inc
+h_writescratchpad_crc_end:
+       rjmp handle_end_sleep
+       
+       
+h_readscratchpad:
+       cpi r_bytep,35
+       breq h_readscratchpad_end
+       cpi r_bytep,3
+       brne h_readscratchpad_read_byte
+h_readscratchpad_set_offset:
+       lds r_temp,pack
+       andi r_temp,0x1F
+       ldi r_temp2,3
+       add r_temp,r_temp2
+       mov r_bytep,r_temp
+h_readscratchpad_read_byte:
+       configZ pack,r_bytep
+       ld r_rwbyte,Z
+       rjmp handle_end_inc
+h_readscratchpad_end:
+       rjmp handle_end_sleep
+
+
+
+h_copyscratchpad:
+       cpi  r_bytep,3
+       brsh h_copyscratchpad_ok
+       configZ pack,r_bytep
+       inc  r_bytep
+       ld   r_temp,Z
+       cp r_temp,r_rwbyte
+       brne h_copyscratchpad_nok
+       cpi  r_bytep,3
+       breq h_copyscratchpad_ok
+       ldi  r_bcount,1 
+       rjmp handle_end
+h_copyscratchpad_ok:
+       ldi r_rwbyte,0xAA
+       ldi r_sendflag,1
+       rjmp handle_end
+h_copyscratchpad_nok:
+       lds r_temp,pack+3
+       andi r_temp,~0x80
+       sts pack+3,r_temp
+       rjmp handle_end_sleep
+
+
+h_readmemory_addr:
+       cpi r_bytep,0
+       brne h_readmrmory_addr_byte1
+       sts pack,r_rwbyte
+       rjmp handle_end_inc
+h_readmrmory_addr_byte1:
+       sts pack+1,r_rwbyte
+       ldi r_mode,OW_READ_MEMORY
+       ldi r_sendflag,1
+       clr r_bytep
+       rjmp h_readmemory2
+h_readmemory:
+       lds r_bytep,pack
+       lds r_temp2,pack+1
+       inc r_bytep
+       clr r_temp
+       adc r_temp2,r_temp
+       sbrc r_temp2,1
+       rjmp h_readmemory_end
+       sts pack+1,r_temp
+       sts pack,r_bytep
+h_readmemory2:
+       lds r_bytep,pack
+       andi r_bytep,0x1F
+       configZ pack+3,r_bytep
+       ld   r_rwbyte,Z
+       rjmp handle_end
+h_readmemory_end:
+       rjmp handle_end_sleep
+
+
+
+
+
+
+
+
+h_readmemorycounter_addr:
+       cpi r_bytep,0
+       brne h_readmrmorycounter_addr_byte1
+       sts pack,r_rwbyte
+       inc r_bytep
+       ;ldi r_bcount,1
+       rjmp handle_end
+h_readmrmorycounter_addr_byte1:
+       sts pack+1,r_rwbyte
+       ldi r_mode,OW_READ_MEMORYCOUNTER
+       ;ldi r_bcount,1 
+       ldi r_sendflag,1
+       clr r_bytep
+       rjmp h_readmemorycounter2
+h_readmemorycounter:
+       lds r_bytep,pack
+       lds r_temp2,pack+1
+       ldi r_temp,1  ;inc leider kein c flag
+       add r_bytep,r_temp
+       clr r_temp
+       adc r_temp2,r_temp
+       mov r_temp,r_bytep
+       andi r_temp,0x1F
+       breq h_readmemorycounter_next
+       sts pack+1,r_temp2
+       sts pack,r_bytep
+h_readmemorycounter2:  ;Lesen von dem worauf die erstenzwei bytes zeigen
+       lds r_bytep,pack
+       andi r_bytep,0x1F
+       configZ pack+3,r_bytep
+       ld   r_rwbyte,Z
+       ;ldi r_bcount,1
+       rjmp handle_end
+//h_readmemorycounter_end:
+//     ldi  r_mode,OW_SLEEP
+//     clr r_sendflag
+//     rjmp handle_end
+h_readmemorycounter_next:  ; rest lesen
+       ldi  r_mode,OW_READ_MEMORYCOUNTER_EX
+       ldi r_bytep,34
+       lds r_temp2,pack
+       lds r_temp,pack+1
+       //lsr r_temp
+       //ror r_temp2
+
+       lsl r_temp2
+       rol r_temp
+       cpi r_temp,3
+       brne h_readmemorycounter_cFF
+       andi r_temp2,0xC0
+       swap r_temp2
+
+       ;cpi r_temp,0xE0
+
+       configZ counters,r_temp2
+       ld r_temp,Z+
+       sts pack+35,r_temp      
+       ld r_temp,Z+
+       sts pack+36,r_temp      
+       ld r_temp,Z+
+       sts pack+37,r_temp      
+       ld r_temp,Z+
+       sts pack+38,r_temp      
+       rjmp h_readmemorycounter_ex
+h_readmemorycounter_cFF:
+       ldi r_temp,0xFF
+       sts pack+35,r_temp      
+       sts pack+36,r_temp      
+       sts pack+37,r_temp      
+       sts pack+38,r_temp      
+
+h_readmemorycounter_ex:
+       inc r_bytep
+       cpi r_bytep,45
+       breq h_readmemorycounter_ex_end
+       cpi r_bytep,43
+       brne h_readmemorycounter_ex2
+       lds r_temp,crc
+       com r_temp
+       sts pack+43,r_temp
+       lds r_temp,crc+1
+       com r_temp
+       sts pack+44,r_temp
+h_readmemorycounter_ex2:
+       ;ldi r_bcount,1
+       configZ pack,r_bytep
+       ld   r_rwbyte,Z
+       rjmp handle_end
+h_readmemorycounter_ex_end:
+       lds r_bytep,pack
+       lds r_temp2,pack+1
+       ldi r_temp,1  ;inc leider kein c flag
+       add r_bytep,r_temp
+       clr r_temp
+       adc r_temp2,r_temp
+       sbrc r_temp2,1 ;am ene von allem 
+       rjmp h_readmemorycounter_ex_sleep
+       CRCInit1
+       ldi  r_mode,OW_READ_MEMORYCOUNTER
+       sts pack+1,r_temp2
+       sts pack,r_bytep
+       rjmp h_readmemorycounter2
+h_readmemorycounter_ex_sleep:
+       ldi r_mode,OW_SLEEP
+       clr r_sendflag
+       rjmp handle_end
+
+
+
+       
+
+#include "../common/OWPinInterrupt.s"
+.end
\ No newline at end of file
diff --git a/DS2423/DS2423.atsln b/DS2423/DS2423.atsln
new file mode 100644 (file)
index 0000000..b3b4676
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Atmel Studio Solution File, Format Version 11.00
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2423", "DS2423.cproj", "{26106A5A-6618-4774-943F-65C46DDB610B}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {26106A5A-6618-4774-943F-65C46DDB610B}.Debug|AVR.ActiveCfg = Debug|AVR
+               {26106A5A-6618-4774-943F-65C46DDB610B}.Debug|AVR.Build.0 = Debug|AVR
+               {26106A5A-6618-4774-943F-65C46DDB610B}.Release|AVR.ActiveCfg = Release|AVR
+               {26106A5A-6618-4774-943F-65C46DDB610B}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS2423/DS2423.c b/DS2423/DS2423.c
new file mode 100644 (file)
index 0000000..d4d376c
--- /dev/null
@@ -0,0 +1,264 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#define _4_COUNTERS_
+#define _EEPROM_SAVE_
+//#define _CPULLUP_
+
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+
+
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+
+#if defined(_4_COUNTERS_)&&defined(_EEPROM_SAVE_)
+#error on ATtinyX5 you can not enable four counters and EEPROM save
+#endif
+#endif
+
+
+extern void OWINIT();
+
+uint8_t owid[8]={0x1D, 0xA2, 0xD9, 0x84, 0x00, 0x26, 0x02, 0x5C};/**/
+
+       
+
+extern uint8_t mode;
+extern uint8_t gcontrol;
+extern uint8_t reset_indicator;
+
+
+volatile uint8_t wdcounter;
+
+
+
+
+typedef union {
+       volatile uint8_t bytes[45];
+       struct {
+               uint16_t addr;
+               uint8_t status;
+               uint8_t scratch[32];//3
+               uint32_t counter;  //35
+               uint32_t zero;   //39
+               uint16_t crc;  //43
+       };
+} counterpack_t;
+counterpack_t pack;
+
+volatile uint8_t lastcps;
+typedef union {
+       uint32_t c32[4];
+       uint8_t c8[16];
+} counters_t;
+
+volatile counters_t counters;
+
+volatile uint8_t istat;
+
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+#define PCINT_VECTOR PCINT0_vect
+#define PIN_REG PINB
+#define PIN_DDR DDRB
+#define PIN_CH2 (1<<PINB3)
+#define PIN_CH3 (1<<PINB4)
+#define PIN_CH0 (1<<PINB0)
+#define PIN_CH1 (1<<PINB1)
+#define PORT_EE PINB
+#define PIN_EE (1<<PINB0)
+#define TEST_TIMER  ((TIMSK & (1<<TOIE0))==0)
+#endif
+
+
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+#define PCINT_VECTOR PCINT0_vect
+#define PIN_REG PINA
+#define PIN_DDR DDRA
+#define PIN_CH2 (1<<PINA4)
+#define PIN_CH3 (1<<PINA5)
+#define PIN_CH0 (1<<PINA6)
+#define PIN_CH1 (1<<PINA7)
+#define PORT_EE PINA //WARNING have to be the same PORT like PINREG because of istat
+#define PIN_EE (1<<PINA0)
+#define TEST_TIMER  ((TIMSK0 & (1<<TOIE0))==0)
+
+#endif
+
+
+ISR(PCINT0_vect) {
+       if (((PIN_REG&PIN_CH2)==0)&&((istat&PIN_CH2)==PIN_CH2)) {       counters.c32[2]++;      }
+       if (((PIN_REG&PIN_CH3)==0)&&((istat&PIN_CH3)==PIN_CH3)) {       counters.c32[3]++;      }
+       #ifdef _4_COUNTERS_
+       if (((PIN_REG&PIN_CH0)==0)&&((istat&PIN_CH0)==PIN_CH0)) {       counters.c32[0]++;      }
+       if (((PIN_REG&PIN_CH1)==0)&&((istat&PIN_CH1)==PIN_CH1)) {       counters.c32[1]++;      }
+       #endif
+       istat=PIN_REG;
+       #ifdef _EEPROM_SAVE_
+       if (((PORT_EE&PIN_EE)==0)&&((istat&PIN_EE)==PIN_EE)) {
+               //PORTB&=~(1<<PINB1);
+               EEARH=0;
+#ifndef _4_COUNTERS_
+               counters.c32[0]++;//Count the save cycles 
+#endif
+               for(uint8_t i=0;i<16;i++) {
+                       uint8_t addr=i^0x0C;
+                       while(EECR & (1<<EEPE));
+                       EECR = (0<<EEPM1)|(0<<EEPM0);
+                       EEARL = i;
+                       EEDR = counters.c8[addr];
+                       EECR |= (1<<EEMPE);
+                       EECR |= (1<<EEPE);
+               }
+               //PORTB|=(1<<PINB1);
+       }
+       #endif
+}
+
+
+int main(void){
+    PRR|=(1<<PRUSI)|(1<<PRADC);  //Switch off usi and adc for save Power
+       OWINIT();
+       
+       pack.zero=0;
+       counters.c32[0]=223433;
+       counters.c32[2]=233;
+       counters.c32[1]=3433;
+       counters.c32[3]=22433;
+       ACSR|=(1<<ACD);  //Disable Comparator
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+       
+               
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+       PORTB|=(1<<PINB5) //Reset
+#ifdef _CPULLUP_
+       |PIN_CH2|PIN_CH3
+#ifdef _4_COUNTERS_    
+       |PIN_CH0|PIN_CH1
+#endif 
+#endif 
+       ;
+       
+       GIMSK|=(1<<PCIE);
+       
+       PCMSK=(1<<PCINT3)|(1<<PCINT4)
+#ifdef _4_COUNTERS_
+       |(1<<PCINT0)|(1<<PCINT1)
+#endif
+       ;
+#ifdef _EEPROM_SAVE_
+       DDRB&=~PIN_EE;
+       PCMSK|=(1<<PCINT0);
+       PORTB&=~PIN_EE; //Spannungsueberpruefung
+#endif
+       DDRB &=~((1<<PINB3)|(1<<PINB4)
+#ifdef _4_COUNTERS_
+       |(1<<PINB0)|(1<<PINB1)
+#endif
+       );
+       istat=PIN_REG;
+#endif
+
+
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+
+       PORTB|=0xFF-(1<<PINB2); //Make PullUp an all Pins but not OW_PIN
+       PORTA|=0xFF; 
+       if (PINB&(1<<PINB0)) { 
+       } else {//SW set, PINB0 =0 no pullup, clear PORT of ios
+               PORTA&=~((1<<PINA4)|(1<<PINA5));
+#ifdef _4_COUNTERS_
+               PORTA&=~((1<<PINA6)|(1<<PINA7));
+#endif
+               PORTB&=~(1<<PINB0);  //Disable Pullup io switch to save Power
+                               
+       } 
+
+       GIMSK|=(1<<PCIE0);
+       PCMSK0=(1<<PCINT4)|(1<<PCINT5)
+#ifdef _4_COUNTERS_
+               |(1<<PCINT6)|(1<<PCINT7)
+#endif
+       ;
+#ifdef _EEPROM_SAVE_
+       DDRA&=~(1<<PINA0);
+       PCMSK0|=(1<<PCINT0);
+       PORTA&=~(1<<PINA0); //Spannungsueberpruefung
+#endif
+       istat=PINB;
+#endif
+
+#ifdef _EEPROM_SAVE_
+               EEARH=0;
+               
+               uint8_t addr;
+               for(uint8_t i=0;i<16;i++) {
+                       addr=i^0x0C;
+                       while(EECR & (1<<EEPE));   
+                       EEARL=i;
+                       EECR |= (1<<EERE);
+                       counters.c8[addr]=EEDR;
+               }
+               for (uint8_t i=0;i<4;i++) {
+                       if (counters.c32[i]==0xFFFFFFFF) counters.c32[i]=0;
+                       //counters.c32[i]=0;
+               }
+
+               /*for(uint8_t i=0;i<16;i++) {
+                       while(EECR & (1<<EEPE));
+                       EECR = (1<<EEPM0);
+                       EEARL = i;
+                       EECR |= (1<<EEMPE);
+                       EECR |= (1<<EEPE);
+               }*/
+       
+   
+#endif
+       sei();
+    while(1)   {
+               
+               //Test if timer active and no sleep then Idle else Power Down
+               if (TEST_TIMER&&(mode==0)) {
+                       MCUCR|=(1<<SE)|(1<<SM1); //Power Down, only low level on 1-Wire and pin change on PCINT wakes up
+                       MCUCR&=~(1<<ISC01);
+               } else {
+                       MCUCR|=(1<<SE);
+                       MCUCR&=~(1<<SM1); 
+               }
+               asm("SLEEP");
+   }
+}
\ No newline at end of file
diff --git a/DS2423/DS2423.cproj b/DS2423/DS2423.cproj
new file mode 100644 (file)
index 0000000..24adaf9
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>6.2</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>{26106a5a-6618-4774-943f-65c46ddb610b}</ProjectGuid>
+    <avrdevice>ATtiny84A</avrdevice>
+    <avrdeviceseries>none</avrdeviceseries>
+    <OutputType>Executable</OutputType>
+    <Language>C</Language>
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>
+    <OutputFileExtension>.elf</OutputFileExtension>
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
+    <AssemblyName>DS2423</AssemblyName>
+    <Name>DS2423</Name>
+    <RootNamespace>DS2423</RootNamespace>
+    <ToolchainFlavour>Native</ToolchainFlavour>
+    <KeepTimersRunning>true</KeepTimersRunning>
+    <OverrideVtor>false</OverrideVtor>
+    <CacheFlash>true</CacheFlash>
+    <ProgFlashFromRam>true</ProgFlashFromRam>
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>
+    <UncachedRange />
+    <preserveEEPROM>true</preserveEEPROM>
+    <OverrideVtorValue>exception_table</OverrideVtorValue>
+    <BootSegment>2</BootSegment>
+    <eraseonlaunchrule>1</eraseonlaunchrule>
+    <AsfFrameworkConfig>
+      <framework-data xmlns="">
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <com_atmel_avrdbg_tool_atmelice>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>debugWIRE</InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
+      <ToolNumber>J41800024445</ToolNumber>
+      <ToolName>Atmel-ICE</ToolName>
+    </com_atmel_avrdbg_tool_atmelice>
+    <avrtoolinterface>debugWIRE</avrtoolinterface>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>NDEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>DEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="DS2423.c">
+      <SubType>compile</SubType>
+    </Compile>
+    <Compile Include="OWDS2423.S">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
diff --git a/DS2423/Makefile b/DS2423/Makefile
new file mode 100644 (file)
index 0000000..fcc4e3f
--- /dev/null
@@ -0,0 +1,607 @@
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+# Carlos Lamas
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+
+# MCU name
+#MCU = attiny25
+MCU = attiny84a
+
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the 
+#     processor frequency. You can then use this symbol in your source code to 
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+#     Typical values are:
+#                      F_CPU =  1000000
+#         F_CPU =  1843200
+#         F_CPU =  2000000
+#         F_CPU =  3686400
+#         F_CPU =  4000000
+#         F_CPU =  7372800
+F_CPU =  8000000
+#         F_CPU = 11059200
+#         F_CPU = 14745600
+#         F_CPU = 16000000
+#         F_CPU = 18432000
+#         F_CPU = 20000000
+#         F_CPU = 8000000
+
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+
+# Target file name (without extension).
+TARGET = DS2423
+
+
+# Object files directory
+OBJDIR = obj
+
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(TARGET).c
+
+
+# List C++ source files here. (C dependencies are automatically generated.)
+CPPSRC = 
+
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC = OWDS2423.S
+
+
+# Optimization level, can be [0, 1, 2, 3, s]. 
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG = dwarf-2
+
+
+# List any extra directories to look for include files here.
+#     Each directory must be seperated by a space.
+#     Use forward slashes for directory separators.
+#     For a directory that has spaces, enclose it in quotes.
+EXTRAINCDIRS = 
+
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+
+# Place -D or -U options here for C sources
+CDEFS = -DF_CPU=$(F_CPU)UL
+
+
+# Place -D or -U options here for C++ sources
+CPPDEFS = -DF_CPU=$(F_CPU)UL
+#CPPDEFS += -D__STDC_LIMIT_MACROS
+#CPPDEFS += -D__STDC_CONSTANT_MACROS
+
+
+
+#---------------- Compiler Options C ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS)
+CFLAGS += -O$(OPT)
+#CFLAGS += -mint8
+#CFLAGS += -mshort-calls
+CFLAGS += -funsigned-char
+CFLAGS += -funsigned-bitfields
+CFLAGS += -fpack-struct
+CFLAGS += -fshort-enums
+#CFLAGS += -fno-unit-at-a-time
+CFLAGS += -Wall
+CFLAGS += -Wstrict-prototypes
+CFLAGS += -Wundef
+#CFLAGS += -Wunreachable-code
+#CFLAGS += -Wsign-compare
+CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
+CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
+CFLAGS += $(CSTANDARD)
+
+
+#---------------- Compiler Options C++ ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CPPFLAGS = -g$(DEBUG)
+CPPFLAGS += $(CPPDEFS)
+CPPFLAGS += -O$(OPT)
+#CPPFLAGS += -mint8
+#CPPFLAGS += -mshort-calls
+CPPFLAGS += -funsigned-char
+CPPFLAGS += -funsigned-bitfields
+CPPFLAGS += -fpack-struct
+CPPFLAGS += -fshort-enums
+CPPFLAGS += -fno-exceptions
+#CPPFLAGS += -fno-unit-at-a-time
+CPPFLAGS += -Wall
+#CPPFLAGS += -Wstrict-prototypes
+CFLAGS += -Wundef
+#CPPFLAGS += -Wunreachable-code
+#CPPFLAGS += -Wsign-compare
+CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
+CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
+#CPPFLAGS += $(CSTANDARD)
+
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs 
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+PRINTF_LIB = 
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB = 
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+
+MATH_LIB = -lm
+
+
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+#LDFLAGS += -T linker_script.x
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd 
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = pony-stk200
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = lpt1
+
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+DEBUG_UI = gdb
+# DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+#DEBUG_BACKEND = avarice
+DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when 
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before: 
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling C:
+MSG_COMPILING_CPP = Compiling C++:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+MSG_CREATING_LIBRARY = Creating library:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) 
+
+# Define all listing files.
+LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) 
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+# Change the build target to build a HEX file or a library.
+build: elf hex eep lss sym
+#build: lib
+
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+LIBNAME=lib$(TARGET).a
+lib: $(LIBNAME)
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+
+begin:
+       @echo
+       @echo $(MSG_BEGIN)
+
+end:
+       @echo $(MSG_END)
+       @echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+       @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+       $(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+       @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+       $(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion : 
+       @$(CC) --version
+
+
+
+# Program the device.  
+program: $(TARGET).hex $(TARGET).eep
+       $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
+       $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set 
+#     a breakpoint at main().
+gdb-config: 
+       @$(REMOVE) $(GDBINIT_FILE)
+       @echo define reset >> $(GDBINIT_FILE)
+       @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+       @echo end >> $(GDBINIT_FILE)
+       @echo file $(TARGET).elf >> $(GDBINIT_FILE)
+       @echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+       ifeq ($(DEBUG_BACKEND),simulavr)
+       @echo load  >> $(GDBINIT_FILE)
+       endif
+       @echo break main >> $(GDBINIT_FILE)
+
+debug: gdb-config $(TARGET).elf
+       ifeq ($(DEBUG_BACKEND), avarice)
+       @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+       @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+       $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+       @$(WINSHELL) /c pause
+
+       else
+       @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+       $(DEBUG_MFREQ) --port $(DEBUG_PORT)
+       endif
+       @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+       COFFCONVERT = $(OBJCOPY) --debugging
+       COFFCONVERT += --change-section-address .data-0x800000
+       COFFCONVERT += --change-section-address .bss-0x800000
+       COFFCONVERT += --change-section-address .noinit-0x800000
+       COFFCONVERT += --change-section-address .eeprom-0x810000
+
+
+
+coff: $(TARGET).elf
+       @echo
+       @echo $(MSG_COFF) $(TARGET).cof
+       $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+       @echo
+       @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+       $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+       @echo
+       @echo $(MSG_FLASH) $@
+       $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+       @echo
+       @echo $(MSG_EEPROM) $@
+       -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+       @echo
+       @echo $(MSG_EXTENDED_LISTING) $@
+       $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+       @echo
+       @echo $(MSG_SYMBOL_TABLE) $@
+       $(NM) -n $< > $@
+
+
+
+# Create library from object files.
+.SECONDARY : $(TARGET).a
+.PRECIOUS : $(OBJ)
+%.a: $(OBJ)
+       @echo
+       @echo $(MSG_CREATING_LIBRARY) $@
+       $(AR) $@ $(OBJ)
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+       @echo
+       @echo $(MSG_LINKING) $@
+       $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+$(OBJDIR)/%.o : %.c
+       @echo
+       @echo $(MSG_COMPILING) $<
+       $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create object files from C++ source files.
+$(OBJDIR)/%.o : %.cpp
+       @echo
+       @echo $(MSG_COMPILING_CPP) $<
+       $(CC) -c $(ALL_CPPFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+       $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C++ source files.
+%.s : %.cpp
+       $(CC) -S $(ALL_CPPFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+$(OBJDIR)/%.o : %.S
+       @echo
+       @echo $(MSG_ASSEMBLING) $<
+       $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+       $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+       @echo
+       @echo $(MSG_CLEANING)
+       $(REMOVE) $(TARGET).hex
+       $(REMOVE) $(TARGET).eep
+       $(REMOVE) $(TARGET).cof
+       $(REMOVE) $(TARGET).elf
+       $(REMOVE) $(TARGET).map
+       $(REMOVE) $(TARGET).sym
+       $(REMOVE) $(TARGET).lss
+       $(REMOVEDIR) $(OBJDIR)
+       $(REMOVE) $(SRC:.c=.s)
+       $(REMOVE) $(SRC:.c=.d)
+       $(REMOVEDIR) .dep
+
+
+# Create object files directory
+$(shell mkdir $(OBJDIR) 2>/dev/null)
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
diff --git a/DS2423/OWDS2423.S b/DS2423/OWDS2423.S
new file mode 100644 (file)
index 0000000..e0a97fd
--- /dev/null
@@ -0,0 +1,336 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+#define  _CHANGEABLE_ID_
+#include "../common/OWConfig.s"
+#include "../common/OWCRC16.s"
+
+.extern pack,45
+.extern counters,8
+
+.macro CHIP_INIT       
+.endm
+
+.macro COMMAND_TABLE
+               rjmp h_writescratchpad
+               rjmp h_writescratchpad_crc
+               rjmp h_readscratchpad
+               rjmp h_copyscratchpad
+               rjmp h_readmemory_addr
+               rjmp h_readmemory
+               rjmp h_readmemorycounter_addr
+               rjmp h_readmemorycounter
+               rjmp h_readmemorycounter_ex
+.endm
+
+#include "../common/OWRomFunctions.s"
+#include "../common/OWTimerInterrupt.s"
+
+
+
+; Ab hier Geraeteabhaenging
+#define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+0
+#define OW_WRITE_SCRATCHPAD_CRC OW_FIRST_COMMAND+1
+#define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+2
+#define OW_COPY_SCRATCHPAD OW_FIRST_COMMAND+3
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+4
+#define OW_READ_MEMORY OW_FIRST_COMMAND+5
+#define OW_READ_MEMORYCOUNTER_ADDR OW_FIRST_COMMAND+6
+#define OW_READ_MEMORYCOUNTER OW_FIRST_COMMAND+7
+#define OW_READ_MEMORYCOUNTER_EX OW_FIRST_COMMAND+8
+
+;---------------------------------------------------
+;      READ COMMAND and start operation
+;---------------------------------------------------
+
+
+h_readcommand:
+       clr r_bytep
+#ifndef _DIS_FLASH_
+       FLASH_COMMANDS ; muss zu erst sein....
+#endif
+       cset 0x0F,OW_WRITE_SCRATCHPAD
+       cjmp 0xAA,hrc_set_readscratchpad
+       cset 0x5A,OW_COPY_SCRATCHPAD
+       cset 0xF0,OW_READ_MEMORY_ADDR
+       cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR
+#ifdef _CHANGEABLE_ID_
+       CHANGE_ID_COMMANDS
+#endif
+       ldi r_mode,OW_SLEEP
+       rjmp handle_end
+
+hrc_set_readscratchpad:
+       ldi r_mode,OW_READ_SCRATCHPAD
+       ldi r_sendflag,1
+       rjmp h_readscratchpad
+
+h_writescratchpad:
+       configZ pack,r_bytep
+       inc  r_bytep
+       st   Z,r_rwbyte
+       cpi  r_bytep,2
+       breq h_writescratchpad_block
+       brsh h_writescratchpad_set_eoffset ;;33
+       rjmp handle_end  ;handle_end zu weit entfernt fuer br...
+h_writescratchpad_set_eoffset:
+       cpi  r_bytep,35
+       breq h_writescratchpad_setcrc
+       mov r_temp,r_bytep
+       subi r_temp,4
+       sts pack+2,r_temp ;AA und PF cleared
+       rjmp handle_end
+;Start writeing to 32 Byte Block ; skip status byte    
+h_writescratchpad_block:
+       lds r_temp,pack ; Adresse low byte
+       andi r_temp,0x1F ;32 byte
+       add r_bytep,r_temp ;Zur angegebenen Startadresse springen
+       ;ori r_temp,0x20 ; Set PF flag
+       sts pack+2,r_temp  ;E4:E0 vorher setzen
+       ; Byte 3 ueberspringen
+       rjmp handle_end_inc
+
+h_writescratchpad_setcrc:
+       ;copy crc to pack
+       lds r_temp,crc
+       com r_temp
+       sts pack+43,r_temp
+       lds r_temp,crc+1
+       com r_temp ; invertieren , komischer name.....
+       sts pack+44,r_temp
+       ldi  r_mode,OW_WRITE_SCRATCHPAD_CRC
+       ldi r_sendflag,1
+       ldi r_bytep,43
+h_writescratchpad_crc:
+       cpi r_bytep,45
+       breq h_writescratchpad_crc_end
+       configZ pack,r_bytep
+       ld r_rwbyte,Z
+       rjmp handle_end_inc
+h_writescratchpad_crc_end:
+       rjmp handle_end_sleep
+       
+       
+h_readscratchpad:
+       cpi r_bytep,35
+       breq h_readscratchpad_end
+       cpi r_bytep,3
+       brne h_readscratchpad_read_byte
+h_readscratchpad_set_offset:
+       lds r_temp,pack
+       andi r_temp,0x1F
+       ldi r_temp2,3
+       add r_temp,r_temp2
+       mov r_bytep,r_temp
+h_readscratchpad_read_byte:
+       configZ pack,r_bytep
+       ld r_rwbyte,Z
+       rjmp handle_end_inc
+h_readscratchpad_end:
+       rjmp handle_end_sleep
+
+
+
+h_copyscratchpad:
+       cpi  r_bytep,3
+       brsh h_copyscratchpad_ok
+       configZ pack,r_bytep
+       inc  r_bytep
+       ld   r_temp,Z
+       cp r_temp,r_rwbyte
+       brne h_copyscratchpad_nok
+       cpi  r_bytep,3
+       breq h_copyscratchpad_ok
+       ldi  r_bcount,1 
+       rjmp handle_end
+h_copyscratchpad_ok:
+       ldi r_rwbyte,0xAA
+       ldi r_sendflag,1
+       rjmp handle_end
+h_copyscratchpad_nok:
+       lds r_temp,pack+3
+       andi r_temp,~0x80
+       sts pack+3,r_temp
+       rjmp handle_end_sleep
+
+
+h_readmemory_addr:
+       cpi r_bytep,0
+       brne h_readmrmory_addr_byte1
+       sts pack,r_rwbyte
+       rjmp handle_end_inc
+h_readmrmory_addr_byte1:
+       sts pack+1,r_rwbyte
+       ldi r_mode,OW_READ_MEMORY
+       ldi r_sendflag,1
+       clr r_bytep
+       rjmp h_readmemory2
+h_readmemory:
+       lds r_bytep,pack
+       lds r_temp2,pack+1
+       inc r_bytep
+       clr r_temp
+       adc r_temp2,r_temp
+       sbrc r_temp2,1
+       rjmp h_readmemory_end
+       sts pack+1,r_temp
+       sts pack,r_bytep
+h_readmemory2:
+       lds r_bytep,pack
+       andi r_bytep,0x1F
+       configZ pack+3,r_bytep
+       ld   r_rwbyte,Z
+       rjmp handle_end
+h_readmemory_end:
+       rjmp handle_end_sleep
+
+
+
+
+
+
+
+
+h_readmemorycounter_addr:
+       cpi r_bytep,0
+       brne h_readmrmorycounter_addr_byte1
+       sts pack,r_rwbyte
+       inc r_bytep
+       ;ldi r_bcount,1
+       rjmp handle_end
+h_readmrmorycounter_addr_byte1:
+       sts pack+1,r_rwbyte
+       ldi r_mode,OW_READ_MEMORYCOUNTER
+       ;ldi r_bcount,1 
+       ldi r_sendflag,1
+       clr r_bytep
+       rjmp h_readmemorycounter2
+h_readmemorycounter:
+       lds r_bytep,pack
+       lds r_temp2,pack+1
+       ldi r_temp,1  ;inc leider kein c flag
+       add r_bytep,r_temp
+       clr r_temp
+       adc r_temp2,r_temp
+       mov r_temp,r_bytep
+       andi r_temp,0x1F
+       breq h_readmemorycounter_next
+       sts pack+1,r_temp2
+       sts pack,r_bytep
+h_readmemorycounter2:  ;Lesen von dem worauf die erstenzwei bytes zeigen
+       lds r_bytep,pack
+       andi r_bytep,0x1F
+       configZ pack+3,r_bytep
+       ld   r_rwbyte,Z
+       ;ldi r_bcount,1
+       rjmp handle_end
+//h_readmemorycounter_end:
+//     ldi  r_mode,OW_SLEEP
+//     clr r_sendflag
+//     rjmp handle_end
+h_readmemorycounter_next:  ; rest lesen
+       ldi  r_mode,OW_READ_MEMORYCOUNTER_EX
+       ldi r_bytep,34
+       lds r_temp2,pack
+       lds r_temp,pack+1
+       //lsr r_temp
+       //ror r_temp2
+
+       lsl r_temp2
+       rol r_temp
+       cpi r_temp,3
+       brne h_readmemorycounter_cFF
+       andi r_temp2,0xC0
+       swap r_temp2
+
+       ;cpi r_temp,0xE0
+
+       configZ counters,r_temp2
+       ld r_temp,Z+
+       sts pack+35,r_temp      
+       ld r_temp,Z+
+       sts pack+36,r_temp      
+       ld r_temp,Z+
+       sts pack+37,r_temp      
+       ld r_temp,Z+
+       sts pack+38,r_temp      
+       rjmp h_readmemorycounter_ex
+h_readmemorycounter_cFF:
+       ldi r_temp,0xFF
+       sts pack+35,r_temp      
+       sts pack+36,r_temp      
+       sts pack+37,r_temp      
+       sts pack+38,r_temp      
+
+h_readmemorycounter_ex:
+       inc r_bytep
+       cpi r_bytep,45
+       breq h_readmemorycounter_ex_end
+       cpi r_bytep,43
+       brne h_readmemorycounter_ex2
+       lds r_temp,crc
+       com r_temp
+       sts pack+43,r_temp
+       lds r_temp,crc+1
+       com r_temp
+       sts pack+44,r_temp
+h_readmemorycounter_ex2:
+       ;ldi r_bcount,1
+       configZ pack,r_bytep
+       ld   r_rwbyte,Z
+       rjmp handle_end
+h_readmemorycounter_ex_end:
+       lds r_bytep,pack
+       lds r_temp2,pack+1
+       ldi r_temp,1  ;inc leider kein c flag
+       add r_bytep,r_temp
+       clr r_temp
+       adc r_temp2,r_temp
+       sbrc r_temp2,1 ;am ene von allem 
+       rjmp h_readmemorycounter_ex_sleep
+       CRCInit1
+       ldi  r_mode,OW_READ_MEMORYCOUNTER
+       sts pack+1,r_temp2
+       sts pack,r_bytep
+       rjmp h_readmemorycounter2
+h_readmemorycounter_ex_sleep:
+       ldi r_mode,OW_SLEEP
+       clr r_sendflag
+       rjmp handle_end
+
+
+
+       
+
+#include "../common/OWPinInterrupt.s"
+.end
\ No newline at end of file
diff --git a/DS2438_DHT22/.gitignore b/DS2438_DHT22/.gitignore
new file mode 100644 (file)
index 0000000..6142108
--- /dev/null
@@ -0,0 +1,3 @@
+/Debug/
+/Release/
+*.atsuo
diff --git a/DS2438_DHT22/DS2438_DHT22.atsln b/DS2438_DHT22/DS2438_DHT22.atsln
new file mode 100644 (file)
index 0000000..cde51c4
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Atmel Studio Solution File, Format Version 11.00
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_DHT22", "DS2438_DHT22.cproj", "{D8C974E2-4579-49ED-A4E2-6C54B37778FA}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {D8C974E2-4579-49ED-A4E2-6C54B37778FA}.Debug|AVR.ActiveCfg = Debug|AVR
+               {D8C974E2-4579-49ED-A4E2-6C54B37778FA}.Debug|AVR.Build.0 = Debug|AVR
+               {D8C974E2-4579-49ED-A4E2-6C54B37778FA}.Release|AVR.ActiveCfg = Release|AVR
+               {D8C974E2-4579-49ED-A4E2-6C54B37778FA}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS2438_DHT22/DS2438_DHT22.c b/DS2438_DHT22/DS2438_DHT22.c
new file mode 100644 (file)
index 0000000..ed96a55
--- /dev/null
@@ -0,0 +1,408 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+#define F_CPU 8000000UL
+#define FP_CALC
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+
+extern void OWINIT();
+
+
+uint8_t owid[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x00, 0x05, 0x16};/**/
+       
+
+extern uint8_t mode;
+extern uint8_t gcontrol;
+extern uint8_t reset_indicator;
+extern uint8_t alarmflag;
+
+volatile uint8_t wdcounter;
+
+
+typedef union {
+#if  defined(__AVR_ATtiny25__)
+       volatile uint8_t bytes[16];
+#else
+       volatile uint8_t bytes[64];
+#endif
+       struct {
+               uint8_t status;  //1
+               int16_t temp;  //2
+               uint16_t voltage;  //4
+               uint16_t current;  //6
+               uint8_t threshold; //8
+               
+               uint8_t page1[8]; //9
+#if  defined(__AVR_ATtiny25__)
+#else
+               uint8_t page2[8]; //17
+               uint8_t page3[8]; //25
+               uint8_t page4[8];  //33
+               uint8_t page5[8];  //41
+               uint8_t page6[8];  //49
+               uint8_t page7[8];  //57
+               //uint8_t crc;  //65
+#endif
+       };
+} pack_t;
+volatile pack_t pack;
+
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+
+#define DDR_SENSOR   DDRB 
+#define PORT_SENSOR  PORTB
+#define PIN_SENSOR   PINB
+#define SENSOR       PB4
+#endif
+
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+#define DDR_SENSOR   DDRA
+#define PORT_SENSOR  PORTA
+#define PIN_SENSOR   PINA
+#define SENSOR       PINA2
+#endif
+
+
+
+#define SENSOR_sda_out         DDR_SENSOR |= (1 << SENSOR)
+#define SENSOR_sda_in                  DDR_SENSOR &= ~(1 << SENSOR);PORT_SENSOR |= (1 << SENSOR) // release sda => hi in consequence of pullup
+#define SENSOR_sda_low    PORT_SENSOR &= ~(1 << SENSOR)
+#define SENSOR_is_hi                   PIN_SENSOR & (1 << SENSOR)
+#define SENSOR_is_low          !(PIN_SENSOR & (1 << SENSOR))
+
+volatile int16_t am2302_temp;
+volatile uint16_t am2302_hum;
+
+
+uint8_t am_wait(uint8_t _time,uint8_t _signal){
+       TCNT1=0;
+       while(TCNT1==0);
+       if (_signal) 
+               while((SENSOR_is_hi)&&(TCNT1<_time)) {}
+       else
+               while((SENSOR_is_low)&&(TCNT1<_time)) {}
+        
+               if (TCNT1>=_time) {return 1;}
+       return 0;
+}
+
+volatile uint8_t am2302_mode=0;        
+volatile uint8_t timeout=0;
+
+
+
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+ISR(WATCHDOG_vect) {
+#else
+ISR(WDT_vect) {
+#endif 
+       sleep_disable();          // Disable Sleep on Wakeup
+       am2302_mode++;
+       if (reset_indicator==1) reset_indicator++;
+       else if (reset_indicator==2) mode=0;
+/*     if (timeout==2) {
+               DIS_TIMER;
+               EN_OWINT;
+               mode=OWM_SLEEP;
+       }
+       timeout++;*/
+       sleep_enable();           // Enable Sleep Mode
+
+}
+
+       
+       
+uint8_t am2302_1() {
+       int16_t lam2302_temp;
+       uint16_t lam2302_hum;
+       uint8_t rSREG;
+       uint8_t sensor_data[5];
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+       TCCR1=(1<<CS12); //Clock/8 1µs
+#endif
+
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+       TCCR1B=(1<<CS11); //Clock/8 1µs
+#endif
+       SENSOR_sda_out;
+       SENSOR_sda_low; // MCU start signal
+       TCNT1=0;while(TCNT1==0);while(TCNT1<250) {}// start signal (pull sda down for min 0.8ms and maximum 20ms)
+       TCNT1=0;while(TCNT1==0);while(TCNT1<250) {}// start signal (pull sda down for min 0.8ms and maximum 20ms)
+       SENSOR_sda_in;
+       if (am_wait(200,1)) return 2;
+
+       // AM2302 response signal min: 75us typ:80us max:85us
+       if (am_wait(100,0)) return 3;
+       if (am_wait(100,1)) return 4;
+       
+       for(uint8_t i = 0; i < 5; i++)  {
+               uint8_t sensor_byte = 0;
+               for(uint8_t j = 1; j <= 8; j++) {// get 8 bits from sensor
+                       if (am_wait(88,0)) return 5;
+                       
+                       TCNT1=0;while(TCNT1==0);;while(TCNT1<35)                ;
+                       sensor_byte <<= 1; // add new lower byte
+                       if (SENSOR_is_hi) {// if sda high after 30us => bit=1 else bit=0
+                               sensor_byte |= 1;
+                               if (am_wait(45,1)) return 6;// 30us - 75us = 45us
+                       }
+               }
+               sensor_data[i] = sensor_byte;
+       }
+
+       // checksum
+       if ( ((sensor_data[0]+sensor_data[1]+sensor_data[2]+sensor_data[3]) & 0xff ) != sensor_data[4])
+       {
+               // debug output
+               //printf("%b %b %b %b %b %b" CR, sensor_data[0], sensor_data[1], sensor_data[2], sensor_data[3], sensor_data[4], ((sensor_data[0]+sensor_data[1]+sensor_data[2]+sensor_data[3]) & 0xff ));
+               PORTB&=~(1<<PINB0);
+               return 7;
+       }
+#ifdef FP_CALC
+       double htemp;
+       if (sensor_data[2]&0x80) { //min
+               sensor_data[2]&=~(0x80);
+               htemp=-((sensor_data[2]<<8) + sensor_data[3]);
+       } else
+               htemp=((sensor_data[2]<<8) + sensor_data[3]);
+       double hhum=(1.0546-0.000216*htemp)*((sensor_data[0]<<8) + sensor_data[1]);
+       
+       lam2302_hum=0.318*hhum +76;
+       lam2302_temp=htemp*25.6;
+#else
+
+       if (sensor_data[2]&0x80) { //minus
+               sensor_data[2]&=~(0x80);
+               lam2302_temp=-((sensor_data[2]<<8) + sensor_data[3]);
+       } else
+               lam2302_temp=((sensor_data[2]<<8) + sensor_data[3]);
+       
+       lam2302_hum=((sensor_data[0]<<8) + sensor_data[1]);
+       volatile uint32_t h1=lam2302_temp*lam2302_hum*3/44803;
+       lam2302_hum=lam2302_hum*16/49-h1+80;
+       //lam2302_temp=lam2302_temp*128/5;
+
+       int16_t h2=lam2302_temp%5;
+       lam2302_temp=lam2302_temp/5;
+       lam2302_temp*=128;
+       lam2302_temp+=h2*128/5;
+#endif    
+       rSREG=SREG;
+       cli();
+       am2302_hum=lam2302_hum;
+       am2302_temp=lam2302_temp;
+       SREG=rSREG;
+       return 0;
+}
+
+
+uint8_t am2302_2() { //4mhz
+       int16_t lam2302_temp;
+       uint16_t lam2302_hum;
+       uint8_t rSREG;
+       uint8_t sensor_data[5];
+       #if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+       TCCR1=(1<<CS11)|(1<<CS10); //Clock/8 1µs
+       #endif
+
+       #if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+       TCCR1B=(1<<CS11); //Clock/8 1µs
+       #endif
+       SENSOR_sda_out;
+       SENSOR_sda_low; // MCU start signal
+       TCNT1=0;while(TCNT1==0);while(TCNT1<250) {}// start signal (pull sda down for min 0.8ms and maximum 20ms)
+       TCNT1=0;while(TCNT1==0);while(TCNT1<250) {}// start signal (pull sda down for min 0.8ms and maximum 20ms)
+       SENSOR_sda_in;
+       if (am_wait(200,1)) return 2;
+
+       // AM2302 response signal min: 75us typ:80us max:85us
+       if (am_wait(100,0)) return 3;
+       if (am_wait(100,1)) return 4;
+       
+       for(uint8_t i = 0; i < 5; i++)  {
+               uint8_t sensor_byte = 0;
+               for(uint8_t j = 1; j <= 8; j++) {// get 8 bits from sensor
+                       if (am_wait(88,0)) return 5;
+                       
+                       TCNT1=0;while(TCNT1==0);;while(TCNT1<35)                ;
+                       sensor_byte <<= 1; // add new lower byte
+                       if (SENSOR_is_hi) {// if sda high after 30us => bit=1 else bit=0
+                               sensor_byte |= 1;
+                               if (am_wait(45,1)) return 6;// 30us - 75us = 45us
+                       }
+               }
+               sensor_data[i] = sensor_byte;
+       }
+
+       // checksum
+       if ( ((sensor_data[0]+sensor_data[1]+sensor_data[2]+sensor_data[3]) & 0xff ) != sensor_data[4])
+       {
+               // debug output
+               //printf("%b %b %b %b %b %b" CR, sensor_data[0], sensor_data[1], sensor_data[2], sensor_data[3], sensor_data[4], ((sensor_data[0]+sensor_data[1]+sensor_data[2]+sensor_data[3]) & 0xff ));
+               PORTB&=~(1<<PINB0);
+               return 7;
+       }
+#ifdef FP_CALC
+       lam2302_hum=0.318* ((sensor_data[0]<<8) + sensor_data[1])+76;
+       if (sensor_data[2]&0x80) { //minus
+               sensor_data[2]&=~(0x80);
+               lam2302_temp=-((sensor_data[2]<<8) + sensor_data[3])*25.6;
+       } else
+               lam2302_temp=((sensor_data[2]<<8) + sensor_data[3])*25.6;
+#else
+
+
+       if (sensor_data[2]&0x80) { //minus
+               sensor_data[2]&=~(0x80);
+               lam2302_temp=-((sensor_data[2]<<8) + sensor_data[3]);
+       } else
+       lam2302_temp=((sensor_data[2]<<8) + sensor_data[3]);
+       
+       lam2302_hum=((sensor_data[0]<<8) + sensor_data[1]);
+       volatile uint32_t h1=lam2302_temp*lam2302_hum*3/44803;
+       lam2302_hum=lam2302_hum*16/49-h1+80;
+       //lam2302_temp=lam2302_temp*128/5;
+
+       int16_t h2=lam2302_temp%5;
+       lam2302_temp=lam2302_temp/5;
+       lam2302_temp*=128;
+       lam2302_temp+=h2*128/5;
+#endif 
+       
+       
+       rSREG=SREG;
+       cli();
+       am2302_hum=lam2302_hum;
+       am2302_temp=lam2302_temp;
+       SREG=rSREG;
+       return 0;
+}
+
+
+int main(void){
+    PRR|=(1<<PRUSI)|(1<<PRADC);  //Switch off usi and adc for save Power
+       
+       OWINIT();
+
+       ACSR|=(1<<ACD);  //Disable Comparator
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+       MCUCR |=(1<<BODS);
+       MCUCR &=~(1<<PUD);
+       
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+
+       PORTB|=(1<<PINB0)|(1<<PINB1)|(1<<PINB3)|(1<<PINB4)|(1<<PINB5);
+       DDRB|=(1<<PINB1); //DBLINE
+#define SENSON PORTB|=(1<<PINB0);
+#define SENSOFF PORTB&=~(1<<PINB0);
+       DDRB|=(1<<PINB0); //stromversorgung
+       
+       // Set up Watch Dog Timer for Inactivity
+       WDTCR |= ((1<<WDCE) | (1<<WDE));   // Enable the WD Change Bit
+       WDTCR =   (1<<WDIE) |              // Enable WDT Interrupt
+       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~2 seconds
+#endif
+
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+
+       //PORTB|=(1<<PINB0)|(1<<PINB1)|(1<<PINB3)|(1<<PINB4)|(1<<PINB5);
+       //DDRA|=(1<<PINB1);
+       DDRA|=(1<<PINA1); //stromversorgung
+#define SENSON PORTA|=(1<<PINA1);
+#define SENSOFF PORTA&=~(1<<PINA1);
+
+       // Set up Watch Dog Timer for Inactivity
+       WDTCSR |= (1<<WDCE) ;   // Enable the WD Change Bit
+       WDTCSR =   (1<<WDIE) |              // Enable WDT Interrupt
+       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~2 seconds
+#endif
+
+       
+    uint8_t i;
+       uint8_t err;
+#if  defined(__AVR_ATtiny25__)
+    for(i=0;i<16;i++) pack.bytes[i]=0;
+#else
+       uint8_t pn=1;
+    for(i=0;i<64;i++) pack.bytes[i]=0;
+#endif
+       //pack.bytes[0]=1;
+       //pack.bytes[1]=2;
+       SENSON
+       _delay_ms(4000);
+       err =am2302_1();
+       sei();
+    while(1)   {
+               alarmflag=1;
+               if (am2302_mode==2) {
+                       err=am2302_1();
+                       if (err!=0) {
+#if  defined(__AVR_ATtiny25__)
+#else
+                               pack.page3[pn]=err;
+                               pn=pn+1;if (pn>31) pn=1;
+#endif
+                       }
+                       SENSOFF
+                       am2302_mode=3;
+               }
+               if (am2302_mode>=8) {
+                       am2302_mode=0;
+                       SENSON
+               }
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))
+#endif                 
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))
+#endif
+                         {
+//                     CLKPR=(1<<CLKPCE);
+       //              CLKPR=(1<<CLKPS2); /*0.5Mhz*/
+                       //PORTB&=~(1<<PINB1);
+                       MCUCR|=(1<<SE)|(1<<SM1);
+                       MCUCR&=~(1<<ISC01);
+               } else {
+                       MCUCR|=(1<<SE);
+                       MCUCR&=~(1<<SM1);
+               }
+               asm("SLEEP");
+   }
+
+
+}
\ No newline at end of file
diff --git a/DS2438_DHT22/DS2438_DHT22.cproj b/DS2438_DHT22/DS2438_DHT22.cproj
new file mode 100644 (file)
index 0000000..6269c1c
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>6.2</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>{d8c974e2-4579-49ed-a4e2-6c54b37778fa}</ProjectGuid>
+    <avrdevice>ATtiny84A</avrdevice>
+    <avrdeviceseries>none</avrdeviceseries>
+    <OutputType>Executable</OutputType>
+    <Language>C</Language>
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>
+    <OutputFileExtension>.elf</OutputFileExtension>
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
+    <AssemblyName>DS2438_DHT22</AssemblyName>
+    <Name>DS2438_DHT22</Name>
+    <RootNamespace>DS2438_DHT22</RootNamespace>
+    <ToolchainFlavour>Native</ToolchainFlavour>
+    <KeepTimersRunning>true</KeepTimersRunning>
+    <OverrideVtor>false</OverrideVtor>
+    <CacheFlash>true</CacheFlash>
+    <ProgFlashFromRam>true</ProgFlashFromRam>
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>
+    <UncachedRange />
+    <preserveEEPROM>true</preserveEEPROM>
+    <OverrideVtorValue>exception_table</OverrideVtorValue>
+    <BootSegment>2</BootSegment>
+    <eraseonlaunchrule>1</eraseonlaunchrule>
+    <AsfFrameworkConfig>
+      <framework-data xmlns="">
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.19.0" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <com_atmel_avrdbg_tool_atmelice>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>debugWIRE</InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
+      <ToolNumber>J41800000789</ToolNumber>
+      <ToolName>Atmel-ICE</ToolName>
+    </com_atmel_avrdbg_tool_atmelice>
+    <avrtoolinterface>debugWIRE</avrtoolinterface>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>NDEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>DEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="DS2438_DHT22.c">
+      <SubType>compile</SubType>
+    </Compile>
+    <Compile Include="OWDS2438.S">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
diff --git a/DS2438_DHT22/OWDS2438.S b/DS2438_DHT22/OWDS2438.S
new file mode 100644 (file)
index 0000000..f545bed
--- /dev/null
@@ -0,0 +1,184 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+#define _CHANGEABLE_ID_
+//#define _DIS_FLASH_
+
+#include "../common/OWConfig.s"
+#include "../common/OWCRC8.s"
+
+#if  defined(__AVR_ATtiny25__)
+.extern pack,16
+#else
+.extern pack,64
+#endif
+.extern  am2302_temp,2
+.extern  am2302_hum,2
+.comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)
+
+
+.macro CHIP_INIT
+.endm
+
+; Ab hier Geraeteabhaenging
+#define OW_READ_SCRATCHPAD_ADR OW_FIRST_COMMAND+0
+#define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+1
+#define OW_WRITE_SCRATCHPAD_ADR OW_FIRST_COMMAND+2
+#define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+3
+
+
+
+.macro COMMAND_TABLE
+               rjmp h_readscratchpad_adr
+               rjmp h_readscratchpad
+               rjmp h_writescratchpad_adr
+               rjmp h_writescratchpad
+.endm
+
+#include "../common/OWRomFunctions.s"
+#include "../common/OWTimerInterrupt.s"
+
+
+;---------------------------------------------------
+;      READ COMMAND and start operation
+;---------------------------------------------------
+
+
+h_readcommand:
+       clr r_bytep
+#ifndef _DIS_FLASH_
+       FLASH_COMMANDS ; muss zu erst sein....
+#endif
+       cset 0xBE,OW_READ_SCRATCHPAD_ADR
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR
+       cjmp 0x44,hrc_set_convertT
+       cjmp 0xB4,hrc_set_convertV
+#ifdef _CHANGEABLE_ID_
+       CHANGE_ID_COMMANDS
+#endif
+       rjmp handle_end_sleep
+
+
+hrc_set_convertT:
+       ldi r_temp,1
+       sts gcontrol,r_temp
+       lds r_temp,am2302_temp
+       sts pack+1,r_temp
+       lds r_temp,am2302_temp+1
+       sts pack+2,r_temp
+       rjmp handle_end_sleep
+hrc_set_convertV:
+       ldi r_temp,2
+       sts gcontrol,r_temp
+       lds r_temp,pack
+       sbrs r_temp,3
+       rjmp hrc_set_convertVV
+       ldi r_temp,0xF4
+       sts pack+3,r_temp
+       ldi r_temp,0x01
+       sts pack+4,r_temp
+       rjmp hrc_set_convertend
+hrc_set_convertVV:
+       lds r_temp,am2302_hum
+       sts pack+3,r_temp
+       lds r_temp,am2302_hum+1
+       sts pack+4,r_temp
+hrc_set_convertend:
+       rjmp handle_end_sleep
+
+
+
+;---------------------------------------------------
+;   READ SCRATCHPAD
+;---------------------------------------------------
+
+h_readscratchpad_adr:
+       lsl r_rwbyte
+       lsl r_rwbyte
+       lsl r_rwbyte
+#if  defined(__AVR_ATtiny25__)
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
+#endif
+       sts block,r_rwbyte
+       ldi r_sendflag,1
+       ldi r_mode,OW_READ_SCRATCHPAD
+       CRCInit2
+h_readscratchpad:
+       cpi  r_bytep,8
+       breq h_readscratchpad_crc
+       cpi  r_bytep,9
+       breq h_readscratchpad_all
+       lds  r_temp,block
+       add  r_temp,r_bytep
+       configZ pack,r_temp
+       ld   r_rwbyte,Z
+       rjmp handle_end_inc
+h_readscratchpad_crc:
+       lds  r_rwbyte,crc
+       rjmp handle_end_inc
+h_readscratchpad_all:
+       rjmp handle_end_sleep
+
+
+
+
+;---------------------------------------------------
+;   WRITE SCRATCHPAD
+;---------------------------------------------------
+h_writescratchpad_adr:
+       lsl r_rwbyte
+       lsl r_rwbyte
+       lsl r_rwbyte
+#if  defined(__AVR_ATtiny25__)
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
+#endif
+       sts block,r_rwbyte
+       ldi r_mode,OW_WRITE_SCRATCHPAD
+       ldi  r_bcount,1 
+       rjmp handle_end 
+h_writescratchpad:
+       cpi  r_bytep,8
+       breq h_writescratchpad_all
+       lds  r_temp,block
+       add  r_temp,r_bytep
+       configZ pack,r_temp
+       st   Z,r_rwbyte
+       rjmp handle_end_inc
+h_writescratchpad_all:
+       rjmp handle_end_sleep
+
+
+
+
+
+#include "../common/OWPinInterrupt.s"
+.end
\ No newline at end of file
diff --git a/DS2450/DS2450.atsln b/DS2450/DS2450.atsln
new file mode 100644 (file)
index 0000000..e8c4ea1
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Atmel Studio Solution File, Format Version 11.00
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450", "DS2450.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS2450/DS2450.c b/DS2450/DS2450.c
new file mode 100644 (file)
index 0000000..abf083c
--- /dev/null
@@ -0,0 +1,238 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+#include <avr/pgmspace.h>
+
+extern void OWINIT();
+
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/
+       
+#if (owid>128) 
+#error "Variable not correct"
+#endif
+
+extern uint8_t mode;
+extern uint8_t gcontrol;
+extern uint8_t reset_indicator;
+extern uint8_t alarmflag;
+
+
+typedef union {
+       volatile uint8_t bytes[0x20];
+       struct {
+               //Page0
+               uint16_t A;  //0
+               uint16_t B;  //2
+               uint16_t C;  //4
+               uint16_t D;  //6
+               //Page1
+               uint8_t CSA1;
+               uint8_t CSA2;
+               uint8_t CSB1;
+               uint8_t CSB2;
+               uint8_t CSC1;
+               uint8_t CSC2;
+               uint8_t CSD1;
+               uint8_t CSD2;
+               //Page2
+               uint8_t LA;
+               uint8_t HA;
+               uint8_t LB;
+               uint8_t HB;
+               uint8_t LC;
+               uint8_t HC;
+               uint8_t LD;
+               uint8_t HD;
+               //Page3
+               uint8_t FC1;
+               uint8_t FC2;
+               uint8_t FC3;
+               uint8_t FC4;
+               uint8_t VCCP;
+               uint8_t FC5;
+               uint8_t FC6;
+               uint8_t FC7;
+               uint8_t convc1;
+               uint8_t convc2;
+               
+               
+       };
+} pack_t;
+volatile pack_t pack;
+
+
+
+
+
+
+int main(void){
+       pack.A=0;
+       pack.B=0;
+       pack.C=0;
+       pack.D=0;
+       pack.CSA1=0x08;
+       pack.CSA2=0x8C;
+       pack.CSB1=0x08;
+       pack.CSB2=0x8C;
+       pack.CSC1=0x08;
+       pack.CSC2=0x8C;
+       pack.CSD1=0x08;
+       pack.CSD2=0x8C;
+       pack.HA=0xFF;
+       pack.LA=0x00;
+       pack.HB=0xFF;
+       pack.LB=0x00;
+       pack.HC=0xFF;
+       pack.LC=0x00;
+       pack.HD=0xFF;
+       pack.LD=0x00;
+       pack.VCCP=0;
+       OWINIT();
+
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+       MCUCR |=(1<<BODS);
+       PORTA&=~((1<<PINA0)|(1<<PINA1)|(1<<PINA2)|(1<<PINA3));
+       ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
+
+       
+       
+       gcontrol=1;
+       ADCSRB|=(1<<ADLAR); 
+       sei();
+
+    while(1)   {
+
+
+               if (gcontrol) {
+                       uint8_t bb=1;
+                       uint8_t bb1=1;
+                       for(uint8_t i=0;i<4;i++){
+                               if (pack.convc1&bb1) {
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}
+                                       bb=bb<<1;
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}
+                                       bb=bb<<1;
+                               } else bb=bb<<2;
+                               bb1=bb1<<1;                             
+                       }
+                       //CHanel A
+                       if (pack.convc1&1) {
+                               if (pack.CSA2&0x01)     ADMUX=0; else ADMUX=0x80;
+                               _delay_ms(10);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.A=ADC;sei();
+                               alarmflag=0;
+                               if (pack.CSA2&0x08)  //AEH
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}
+                               if (pack.CSA2&0x04)  //AEL
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}
+                       }
+
+                       if (pack.convc1&2) {
+                               if (pack.CSB2&0x01)     ADMUX=1; else ADMUX=0x81;
+                               _delay_ms(10);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.B=ADC;sei();
+                               if (pack.CSB2&0x08)  //AEH
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}
+                               if (pack.CSB2&0x04)  //AEL
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}
+                       }
+
+                       if (pack.convc1&4) {
+                               if (pack.CSC2&0x01)     ADMUX=2; else ADMUX=0x82;
+                               _delay_ms(10);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.C=ADC;sei();
+                               if (pack.CSC2&0x08)  //AEH
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}
+                               if (pack.CSC2&0x04)  //AEL
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}
+                       } 
+                       if (pack.convc1&8) {
+                               if (pack.CSD2&0x01)     ADMUX=3; else ADMUX=0x83;
+                               _delay_ms(10);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.D=ADC;sei();
+                               if (pack.CSD2&0x08)  //AEH
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}
+                               if (pack.CSD2&0x04)  //AEL
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}
+                       }
+                       
+                       gcontrol=0;
+               }
+
+               uint8_t bb=1;
+               for(uint8_t i=0;i<4;i++) {
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output
+                               if (pack.bytes[8+i*2]&0x40) {
+                                       DDRA|=bb;
+                               } else {
+                                       DDRA&=~bb;
+                               }
+                       } else {
+                               DDRA&=~bb;
+                       }
+                       bb=bb*2;
+               }
+               
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))
+#endif                 
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))
+#endif
+                         {
+
+                       MCUCR|=(1<<SE)|(1<<SM1);
+                       MCUCR&=~(1<<ISC01);
+               } else {
+                       MCUCR|=(1<<SE);
+                       MCUCR&=~(1<<SM1);
+               }
+       //      asm("SLEEP");
+   }
+
+
+}
\ No newline at end of file
diff --git a/DS2450/DS2450.cproj b/DS2450/DS2450.cproj
new file mode 100644 (file)
index 0000000..95a82ba
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>6.2</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>{7a5672fe-8226-4158-b931-e1f36b9a8858}</ProjectGuid>
+    <avrdevice>ATtiny84A</avrdevice>
+    <avrdeviceseries>none</avrdeviceseries>
+    <OutputType>Executable</OutputType>
+    <Language>C</Language>
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>
+    <OutputFileExtension>.elf</OutputFileExtension>
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
+    <AssemblyName>DS2450</AssemblyName>
+    <Name>DS2450</Name>
+    <RootNamespace>DS2450</RootNamespace>
+    <ToolchainFlavour>Native</ToolchainFlavour>
+    <KeepTimersRunning>true</KeepTimersRunning>
+    <OverrideVtor>false</OverrideVtor>
+    <CacheFlash>true</CacheFlash>
+    <ProgFlashFromRam>true</ProgFlashFromRam>
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>
+    <UncachedRange />
+    <preserveEEPROM>true</preserveEEPROM>
+    <OverrideVtorValue>exception_table</OverrideVtorValue>
+    <BootSegment>2</BootSegment>
+    <eraseonlaunchrule>1</eraseonlaunchrule>
+    <AsfFrameworkConfig>
+      <framework-data xmlns="">
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.19.0" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <com_atmel_avrdbg_tool_atmelice>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>debugWIRE</InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
+      <ToolNumber>J41800000779</ToolNumber>
+      <ToolName>Atmel-ICE</ToolName>
+    </com_atmel_avrdbg_tool_atmelice>
+    <avrtoolinterface>debugWIRE</avrtoolinterface>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>NDEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
+        <avrgcc.compiler.symbols.DefSymbols>
+          <ListValues>
+            <Value>DEBUG</Value>
+          </ListValues>
+        </avrgcc.compiler.symbols.DefSymbols>
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
+        <avrgcc.linker.libraries.Libraries>
+          <ListValues>
+            <Value>libm</Value>
+          </ListValues>
+        </avrgcc.linker.libraries.Libraries>
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="DS2450.c">
+      <SubType>compile</SubType>
+    </Compile>
+    <Compile Include="OWDS2450.S">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
diff --git a/DS2450/DS2450.pdf b/DS2450/DS2450.pdf
new file mode 100644 (file)
index 0000000..c692e4b
Binary files /dev/null and b/DS2450/DS2450.pdf differ
diff --git a/DS2450/OWDS2450.S b/DS2450/OWDS2450.S
new file mode 100644 (file)
index 0000000..2614786
--- /dev/null
@@ -0,0 +1,240 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+#define _CHANGEABLE_ID_
+
+#include "../common/OWConfig.s"
+#include "../common/OWCRC16.s"
+
+.extern pack,8
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....
+//.extern  am2302_temp,2
+
+
+
+.macro CHIP_INIT       
+.endm
+
+.macro COMMAND_TABLE
+               rjmp h_readmemoryaddr
+               rjmp h_readmemory
+               rjmp h_readmemorycrc1
+               rjmp h_readmemorycrc2
+               rjmp h_writememoryaddr
+               rjmp h_writememory
+               rjmp h_writememorycrc1
+               rjmp h_writememorycrc2
+               rjmp h_writememoryreadback
+               rjmp h_convert
+               rjmp h_convertcrc1
+               rjmp h_convertcrc2
+.endm
+
+#include "../common/OWRomFunctions.s"
+#include "../common/OWTimerInterrupt.s"
+
+
+
+; Ab hier Geraeteabhaenging
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8
+#define OW_CONVERT OW_FIRST_COMMAND+9
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11
+
+
+;---------------------------------------------------
+;      READ COMMAND and start operation
+;---------------------------------------------------
+
+
+h_readcommand:
+       clr r_bytep
+#ifndef _DIS_FLASH_
+       FLASH_COMMANDS ; muss zu erst sein....
+#endif
+       cset 0xAA,OW_READ_MEMORY_ADDR
+       cset 0x55,OW_WRITE_MEMORY_ADDR
+       cset 0x3C,OW_CONVERT
+#ifdef _CHANGEABLE_ID_
+       CHANGE_ID_COMMANDS
+#endif
+       ldi r_mode,OW_SLEEP
+       rjmp handle_end
+
+
+h_readmemoryaddr:
+       cpi r_bytep,0  ;erstes Adressbyte ?
+       brne h_readmemory_addr_byte1 ;nein dann weiter
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen
+       sts addr,r_rwbyte  ;speichern des ersten bytes
+       rjmp handle_end_inc
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory
+       ;;ldi r_bcount,1 ;ist unten
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master
+       clr r_bytep
+       rjmp h_readmemory2
+h_readmemory:
+       lds r_bytep,addr
+       inc r_bytep
+       sts addr,r_bytep
+       andi r_bytep,0x07
+       breq h_readmemory_init_crc
+h_readmemory2:
+       lds r_bytep,addr
+       ;andi r_bytep,0x1F ist oben
+       configZ pack,r_bytep
+       ld   r_rwbyte,Z
+       ;ldi r_bcount,1
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory
+h_readmemory_init_crc:; init erstes CRC byte
+       lds r_rwbyte,crc
+       com r_rwbyte
+       lds r_temp,crc+1
+       com r_temp
+       sts crcsave,r_temp
+       ldi r_mode,OW_READ_MEMORY_CRC1
+       ;ldi r_bcount,1
+       rjmp handle_end
+h_readmemory_end:
+       ldi  r_mode,OW_SLEEP
+       clr r_sendflag
+       rjmp handle_end
+h_readmemorycrc1:;init zweites CRC Byte
+       lds r_rwbyte,crcsave
+       ;ldi r_bcount,1
+       ldi r_mode,OW_READ_MEMORY_CRC2
+       rjmp handle_end
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte
+       lds r_temp,addr
+       andi r_temp,0xE0
+       brne h_readmemory_end; ende des speichers
+       ldi r_mode,OW_READ_MEMORY
+       CRCInit1 ;Start with new CRC
+       rjmp h_readmemory2
+
+h_writememoryaddr:
+       cpi r_bytep,0  ;erstes Adressbyte ?
+       brne h_writememory_addr_byte1 ;nein dann weiter
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen
+       sts addr,r_rwbyte  ;speichern des ersten bytes
+       inc r_bytep
+       ;ldi r_bcount,1
+       rjmp handle_end
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....
+       lds r_bytep,addr
+       rjmp handle_end ;read Memory Byte
+h_writememory:
+       lds r_bytep,addr
+       configZ pack,r_bytep
+       st Z,r_rwbyte
+       ;ldi r_bcount,1
+       ldi r_mode,OW_WRITE_MEMORY_CRC1
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master
+       lds r_rwbyte,crc
+       com r_rwbyte
+       lds r_temp,crc+1
+       com r_temp
+       sts crcsave,r_temp
+       rjmp handle_end
+h_writememorycrc1:
+       lds r_rwbyte,crcsave
+       ;ldi r_bcount,1
+       ldi r_mode,OW_WRITE_MEMORY_CRC2
+       rjmp handle_end
+h_writememorycrc2:
+       lds r_temp,addr
+       configZ pack,r_temp
+       ld r_rwbyte,Z
+       ;ldi r_bcount,1
+       ldi r_mode,OW_WRITE_MEMORY_READBACK
+       rjmp handle_end
+h_writememoryreadback:
+       ldi r_temp,0x00
+       sts crc+1,r_temp
+       lds r_temp,addr
+       inc r_temp
+       sts addr,r_temp
+       sts crc,r_temp
+       ldi r_sendflag,0
+       ;ldi r_bcount,1
+       ldi r_mode,OW_WRITE_MEMORY
+       rjmp handle_end
+
+h_convert:
+       cpi r_bytep,0  ;erstes Adressbyte ?
+       brne h_convert_byte1 ;nein dann weiter
+       inc r_bytep
+       sts pack+0x20,r_rwbyte
+       ;ldi r_bcount,1
+       rjmp handle_end
+h_convert_byte1: ;zweies byte glesen go crc#
+       sts pack+0x21,r_rwbyte
+       lds r_rwbyte,crc
+       com r_rwbyte
+       lds r_temp,crc+1
+       com r_temp
+       sts crcsave,r_temp
+       ldi r_mode,OW_CONVERT_CRC1
+       ;ldi r_bcount,1
+       ldi r_sendflag,1
+       rjmp handle_end 
+h_convertcrc1:
+       lds r_rwbyte,crcsave
+       ;ldi r_bcount,1
+       ldi r_mode,OW_CONVERT_CRC2
+       rjmp handle_end
+h_convertcrc2:
+       ldi r_temp,1
+       sts gcontrol,r_temp
+       ;ldi r_bcount,1
+       ldi r_mode,OW_SLEEP
+       clr r_sendflag
+       rjmp handle_end
+
+
+
+
+#include "../common/OWPinInterrupt.s"
+.end
\ No newline at end of file
diff --git a/common/I2C/BMP280.c b/common/I2C/BMP280.c
new file mode 100644 (file)
index 0000000..3fdc81d
--- /dev/null
@@ -0,0 +1,158 @@
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+#include "USI_TWI_Master.h"
+
+uint16_t dig_T1;
+int16_t dig_T2;
+int16_t dig_T3;
+uint16_t dig_P1;
+int16_t dig_P2;
+int16_t dig_P3;
+int16_t dig_P4;
+int16_t dig_P5;
+int16_t dig_P6;
+int16_t dig_P7;
+int16_t dig_P8;
+int16_t dig_P9;
+
+
+
+
+short bmp280ReadShort(unsigned char address)
+{
+       char msb, lsb;
+       short data;
+       I2c_StartCondition();
+       I2c_WriteByte(0xEC);
+       I2c_WriteByte(address);
+       I2c_StopCondition();
+       I2c_StartCondition();
+       I2c_WriteByte(0xED);
+       lsb=I2c_ReadByte(ACK);
+       msb=I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       
+
+       
+       data = msb << 8;
+       data |= lsb;
+       
+       return data;
+}
+
+void bmp280Init(void) {
+       dig_T1=bmp280ReadShort(0x88);
+       dig_T2=bmp280ReadShort(0x8A);
+       dig_T3=bmp280ReadShort(0x8C);
+       dig_P1=bmp280ReadShort(0x8E);
+       dig_P2=bmp280ReadShort(0x90);
+       dig_P3=bmp280ReadShort(0x92);
+       dig_P4=bmp280ReadShort(0x94);
+       dig_P5=bmp280ReadShort(0x96);
+       dig_P6=bmp280ReadShort(0x98);
+       dig_P7=bmp280ReadShort(0x9A);
+       dig_P8=bmp280ReadShort(0x9C);
+       dig_P9=bmp280ReadShort(0x9E);
+       I2c_StartCondition();
+       I2c_WriteByte(0xEC);
+       I2c_WriteByte(0xF4);
+       I2c_WriteByte(0b01010111); //2x Temp over 16x Press over   Normal mode
+       I2c_WriteByte(0b11100000);  //4s time / no IIfilter
+       I2c_StopCondition();
+       
+       
+}
+int32_t bmp280ReadTemp(void) {
+       uint8_t msb, lsb,xlsb;
+       volatile int32_t data;
+       I2c_StartCondition();
+       I2c_WriteByte(0xEC);
+       I2c_WriteByte(0xFA);
+       I2c_StopCondition();
+       I2c_StartCondition();
+       I2c_WriteByte(0xED);
+       msb=I2c_ReadByte(ACK);
+       lsb=I2c_ReadByte(ACK);
+       xlsb=I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+               
+       data = (int32_t)msb << 12;
+       data |= (int16_t)lsb<<4;
+       data|=xlsb>>4;
+               
+               return data;
+
+       
+}
+int32_t bmp280ReadPressure(uint8_t oss) {
+               uint8_t msb, lsb,xlsb;
+               volatile int32_t data;
+               I2c_StartCondition();
+               I2c_WriteByte(0xEC);
+               I2c_WriteByte(0xF7);
+               I2c_StopCondition();
+               I2c_StartCondition();
+               I2c_WriteByte(0xED);
+               msb=I2c_ReadByte(ACK);
+               lsb=I2c_ReadByte(ACK);
+               xlsb=I2c_ReadByte(NO_ACK);
+               I2c_StopCondition();
+               
+               data = (int32_t)msb << 12;
+               data |= (int16_t)lsb<<4;
+               data|=xlsb>>4;
+               
+               return data;
+
+
+}
+void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss) {
+       int32_t var1,var2,T,t_fine;
+       
+       
+       int32_t adc_T=bmp280ReadTemp();
+       var1 = ((((adc_T>>3) - ((int32_t)dig_T1<<1))) * ((int32_t)dig_T2)) >> 11;
+       var2 = ((((((adc_T>>4) - ((int32_t)dig_T1)) * ((adc_T>>4) - (int32_t)dig_T1))) >> 12) *((int32_t)dig_T3)) >> 14;
+       t_fine = var1 + var2;
+       T = (t_fine * 5 + 128) >> 8;
+       *temperature=T;
+       int32_t adc_P= bmp280ReadPressure(oss);
+       uint32_t p;
+       var1 = (((int32_t)t_fine)>>1) - (int32_t)64000;
+       var2 = (((var1>>2) * (var1>>2)) >> 11 ) * ((int32_t)dig_P6);
+       var2 = var2 + ((var1*((int32_t)dig_P5))<<1);
+       var2 = (var2>>2)+(((int32_t)dig_P4)<<16);
+       var1 = (((dig_P3 * (((var1>>2) * (var1>>2)) >> 13 )) >> 3) + ((((int32_t)dig_P2) * var1)>>1))>>18;
+       var1 =((((32768+var1))*((int32_t)dig_P1))>>15);
+       if (var1 == 0) {
+               return ; // avoid exception caused by division by zero
+       }
+       p = (((uint32_t)(((int32_t)1048576)-adc_P)-(var2>>12)))*3125;
+       if (p < 0x80000000){
+               p = (p << 1) / ((uint32_t)var1);
+               }else{
+               p = (p / (uint32_t)var1) * 2;
+       }
+       var1 = (((int32_t)dig_P9) * ((int32_t)(((p>>3) * (p>>3))>>13)))>>12;
+       var2 = (((int32_t)(p>>2)) * ((int32_t)dig_P8))>>13;
+       p = (uint32_t)((int32_t)p + ((var1 + var2 + dig_P7) >> 4));
+       *pressure=p;
+
+}
+void bmp280Convert(double * temperature, double * pressure,uint8_t oss) {
+
+       uint32_t p;
+       int32_t T;
+       bmp280ConvertInt(&T,&p,oss);
+       *temperature=T/100.0;
+       *pressure=p/100.0;
+}
+               
+               
+               
+
+       
diff --git a/common/I2C/BMP280.h b/common/I2C/BMP280.h
new file mode 100644 (file)
index 0000000..0fab3c5
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef BMP280_H
+#define BMP280_H
+
+
+
+void bmp280Init(void);
+int32_t bmp280ReadTemp(void);
+int32_t bmp280ReadPressure(uint8_t oss);
+void bmp280Convert(double * temperature, double * pressure,uint8_t oss);
+void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss);
+
+
+#endif
\ No newline at end of file
diff --git a/common/I2C/MAX1164x.h b/common/I2C/MAX1164x.h
new file mode 100644 (file)
index 0000000..cf8977c
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef MAX1164x_H
+#define MAX1164x_H
+#define MAX1164x_S_SEL2 0x40
+#define MAX1164x_S_SEL1 0x20
+#define MAX1164x_S_SEL0 0x10
+#define MAX1164x_S_ECLK 0x08
+#define MAX1164x_S_BIP 0x04
+#define MAX1164_S_RESET 0x02
+
+#define MAX1164x_C_SCAN1 0x40
+#define MAX1164x_C_SCAN0 0x20
+#define MAX1164x_C_CS0  0x02
+#define MAX1164x_C_SGL 0x01
+
+
+
+void MAX1164x_init();
+void MAX1164x_config(uint8_t setup,uint8_t config);
+int16_t MAX1164x_read();
+
+
+#endif
\ No newline at end of file
diff --git a/common/I2C/MAX1164x.h.c b/common/I2C/MAX1164x.h.c
new file mode 100644 (file)
index 0000000..8160ac2
--- /dev/null
@@ -0,0 +1,55 @@
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+#include "USI_TWI_Master.h"
+#include "MAX1164x.h"
+
+void MAX1164x_init(){
+       
+       
+}
+void MAX1164x_config(uint8_t setup,uint8_t config){
+       I2c_StartCondition();
+       I2c_WriteByte (0b01101100);
+       I2c_WriteByte (setup|0x80);
+       I2c_WriteByte (config);
+       I2c_StopCondition();
+       
+}
+int16_t MAX1164x_read() {
+       uint16_t res;
+       I2c_StartCondition();
+       I2c_WriteByte (0b01101101);
+       //DDR_USI&=~(1<<PIN_USI_SCL);
+       //while ((PIN_USI&(1<<PIN_USI_SCL))==0);
+       //DDR_USI|=(1<<PIN_USI_SCL);
+       _delay_us(80);
+       res=((int16_t)(I2c_ReadByte(ACK)&0x0F))<<8;
+       res|=I2c_ReadByte(NO_ACK);
+       
+       
+       I2c_StopCondition();
+       return res;
+       
+}
+
+
+int16_t MAX1164x_read8() {
+       uint16_t res;
+       I2c_StartCondition();
+       I2c_WriteByte (0b01101101);
+       //DDR_USI&=~(1<<PIN_USI_SCL);
+       //while ((PIN_USI&(1<<PIN_USI_SCL))==0);
+       //DDR_USI|=(1<<PIN_USI_SCL);
+       _delay_us(80);
+       res=((int16_t)(I2c_ReadByte(ACK)&0x0F))<<8;
+       res|=I2c_ReadByte(NO_ACK);
+       
+       
+       I2c_StopCondition();
+       return res;
+       
+}
diff --git a/common/I2C/MAX44009.c b/common/I2C/MAX44009.c
new file mode 100644 (file)
index 0000000..eabcda6
--- /dev/null
@@ -0,0 +1,69 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#define F_CPU 8000000UL
+#include <avr/io.h>
+
+#include <util/delay.h>
+
+
+#include "USI_TWI_Master.h"
+#include "MAX44009.h"
+
+double MAX44009getlux()  {
+       volatile uint8_t b1,b2;
+       
+       
+       I2c_StartCondition();
+       I2c_WriteByte(0b10010100);
+       I2c_WriteByte(0x03);
+       I2c_StartCondition();
+       I2c_WriteByte (0b10010101);
+       b1 =I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       I2c_StartCondition();
+       I2c_WriteByte(0b10010100);
+       I2c_WriteByte(0x04);
+       I2c_StartCondition();
+       I2c_WriteByte (0b10010101);
+       b2 =I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       uint8_t exponent = (b1 & 0xF0) >> 4;// upper four bits of high byte register
+       uint8_t mantissa = (b1 & 0x0F) << 4;// lower four bits of high byte register =
+       // upper four bits of mantissa
+       mantissa += b2 & 0x0F;    // lower four bits of low byte register =
+       // lower four bits of mantissa
+       
+       return (double)mantissa * (double)(1 << (uint16_t)exponent) * 0.045;
+       
+       
+
+}
diff --git a/common/I2C/MAX44009.h b/common/I2C/MAX44009.h
new file mode 100644 (file)
index 0000000..370637f
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef MAX44009_H
+#define MAX44009_H
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+double MAX44009getlux();
+
+
+#endif
\ No newline at end of file
diff --git a/common/I2C/SHT2x.c b/common/I2C/SHT2x.c
new file mode 100644 (file)
index 0000000..157faca
--- /dev/null
@@ -0,0 +1,216 @@
+//==============================================================================
+// S E N S I R I O N AG, Laubisruetistr. 50, CH-8712 Staefa, Switzerland
+//==============================================================================
+// Project : SHT2x Sample Code (V1.2)
+// File : SHT2x.c
+// Author : MST
+// Controller: NEC V850/SG3 (uPD70F3740)
+// Compiler : IAR compiler for V850 (3.50A)
+// Brief : Sensor layer. Functions for sensor access
+//==============================================================================
+//---------- Includes ----------------------------------------------------------
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+#include "USI_TWI_Master.h"
+#include "SHT2x.h"
+
+const uint16_t POLYNOMIAL = 0x131; //P(x)=x^8+x^5+x^4+1 = 100110001
+
+
+//==============================================================================
+uint8_t SHT2x_CheckCrc(uint8_t data[], uint8_t nbrOfBytes, uint8_t checksum)
+//==============================================================================
+{
+       uint8_t crc = 0;
+       uint8_t byteCtr;
+       //calculates 8-Bit checksum with given polynomial
+       for (byteCtr = 0; byteCtr < nbrOfBytes; ++byteCtr)
+       { crc ^= (data[byteCtr]);
+               for (uint8_t bit = 8; bit > 0; --bit)
+               { if (crc & 0x80) crc = (crc << 1) ^ POLYNOMIAL;
+                       else crc = (crc << 1);
+               }
+       }
+       if (crc != checksum) return CHECKSUM_ERROR;
+       else return 0;
+}
+//===========================================================================
+uint8_t SHT2x_ReadUserRegister(uint8_t *pRegisterValue)
+//===========================================================================
+{
+       uint8_t checksum; //variable for checksum byte
+       uint8_t error=0; //variable for error code
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W);
+       error |= I2c_WriteByte (USER_REG_R);
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_R);
+       *pRegisterValue = I2c_ReadByte(ACK);
+       checksum=I2c_ReadByte(NO_ACK);
+       error |= SHT2x_CheckCrc (pRegisterValue,1,checksum);
+       I2c_StopCondition();
+       return error;
+}
+//===========================================================================
+uint8_t SHT2x_WriteUserRegister(uint8_t *pRegisterValue)
+//===========================================================================
+{
+       uint8_t error=0; //variable for error code
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W);
+       error |= I2c_WriteByte (USER_REG_W);
+       error |= I2c_WriteByte (*pRegisterValue);
+       I2c_StopCondition();
+       return error;
+}
+//===========================================================================
+uint8_t SHT2x_MeasureHM(etSHT2xMeasureType eSHT2xMeasureType, int16_t *pMeasurand)
+//===========================================================================
+{
+       uint8_t checksum; //checksum
+       uint8_t data[2]; //data array for checksum verification
+       uint8_t error=0; //error variable
+       uint16_t i; //counting variable
+       //-- write I2C sensor address and command --
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr
+       switch(eSHT2xMeasureType)
+       { case HUMIDITY: error |= I2c_WriteByte (TRIG_RH_MEASUREMENT_HM); break;
+               case TEMP : error |= I2c_WriteByte (TRIG_T_MEASUREMENT_HM); break;
+               //default: assert(0);
+       }
+       //-- wait until hold master is released --
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_R);
+       //SCL=HIGH; // set SCL I/O port as input
+       DDR_USI&=~(1<<PIN_USI_SCL);
+       for(i=0; i<1000; i++) // wait until master hold is released or ;;;;; Son quatsch.... 1000 s *kopfschuettel*
+       { _delay_ms(1); // a timeout (~1s) is reached
+               //if (SCL_CONF==1) break;
+               if (PIN_USI&(1<<PIN_USI_SCL)) break;
+       }
+       //-- check for timeout --
+       //Was wenn der SHT2x die leitung auf 0 laesst? Kurzschluss???
+       if((PIN_USI&(1<<PIN_USI_SCL))==0) error |= TIME_OUT_ERROR; else DDR_USI|=(1<<PIN_USI_SCL);
+       
+       //-- read two data bytes and one checksum byte --
+       *pMeasurand=((data[0] = I2c_ReadByte(ACK))>>8) & 0xFF;
+       *pMeasurand|=0xFF & (data[1] = I2c_ReadByte(ACK));
+//     pMeasurand->s16.u8H = data[0] = I2c_ReadByte(ACK);
+//     pMeasurand->s16.u8L = data[1] = I2c_ReadByte(ACK);
+
+       checksum=I2c_ReadByte(NO_ACK);
+       //-- verify checksum --
+       error |= SHT2x_CheckCrc (data,2,checksum);
+       I2c_StopCondition();
+       return error;
+}
+//===========================================================================
+uint8_t SHT2x_MeasurePoll(etSHT2xMeasureType eSHT2xMeasureType, int16_t *pMeasurand)
+//===========================================================================
+{
+       uint8_t checksum; //checksum
+       uint8_t data[2]; //data array for checksum verification
+       uint8_t error=0; //error variable
+       uint16_t i=0; //counting variable
+       //-- write I2C sensor address and command --
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr
+       switch(eSHT2xMeasureType)
+       { case HUMIDITY: error |= I2c_WriteByte (TRIG_RH_MEASUREMENT_POLL); break;
+               case TEMP : error |= I2c_WriteByte (TRIG_T_MEASUREMENT_POLL); break;
+               //default: assert(0);
+       }
+       //-- poll every 10ms for measurement ready. Timeout after 20 retries (200ms)--
+       do
+       { I2c_StartCondition();
+               _delay_ms(1000); //delay 10ms
+               if(i++ >= 20) break;
+       } while(I2c_WriteByte (I2C_ADR_R) == ACK_ERROR);
+       if (i>=20) error |= TIME_OUT_ERROR;
+       //-- read two data bytes and one checksum byte --
+       data[0]=I2c_ReadByte(ACK);
+       data[1]=I2c_ReadByte(ACK);
+       *pMeasurand=(data[0]<<8)|data[1];
+       
+//     pMeasurand->s16.u8H = data[0] = I2c_ReadByte(ACK);
+//     pMeasurand->s16.u8L = data[1] = I2c_ReadByte(ACK);
+       checksum=I2c_ReadByte(NO_ACK);
+       //-- verify checksum --
+       error |= SHT2x_CheckCrc (data,2,checksum);
+       I2c_StopCondition();
+       return error;
+}
+//===========================================================================
+uint8_t SHT2x_SoftReset()
+//===========================================================================
+{
+       uint8_t error=0; //error variable
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr
+       error |= I2c_WriteByte (SOFT_RESET); // Command
+       I2c_StopCondition();
+       _delay_ms(15); // wait till sensor has restarted
+       return error;
+}
+//==============================================================================
+float SHT2x_CalcRH(uint16_t u16sRH)
+//==============================================================================
+{
+       double humidityRH; // variable for result
+       u16sRH &= ~0x0003; // clear bits [1..0] (status bits)
+       //-- calculate relative humidity [%RH] --
+       humidityRH = -6.0 + 125.0/65536 * (double)u16sRH; // RH= -6 + 125 * SRH/2^16
+       return humidityRH;
+}
+//==============================================================================
+float SHT2x_CalcTemperatureC(uint16_t u16sT)
+//==============================================================================
+{
+       double temperatureC; // variable for result
+       u16sT &= ~0x0003; // clear bits [1..0] (status bits)
+       //-- calculate temperature [°C] --
+       temperatureC= -46.85 + 175.72/65536 *(double)u16sT; //T= -46.85 + 175.72 * ST/2^16
+       return temperatureC;
+}
+//==============================================================================
+uint8_t SHT2x_GetSerialNumber(uint8_t u8SerialNumber[])
+//==============================================================================
+{
+       uint8_t error=0; //error variable
+       //Read from memory location 1
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W); //I2C address
+       error |= I2c_WriteByte (0xFA); //Command for readout on-chip memory
+       error |= I2c_WriteByte (0x0F); //on-chip memory address
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_R); //I2C address
+       u8SerialNumber[5] = I2c_ReadByte(ACK); //Read SNB_3
+       I2c_ReadByte(ACK); //Read CRC SNB_3 (CRC is not analyzed)
+       u8SerialNumber[4] = I2c_ReadByte(ACK); //Read SNB_2
+       I2c_ReadByte(ACK); //Read CRC SNB_2 (CRC is not analyzed)
+       u8SerialNumber[3] = I2c_ReadByte(ACK); //Read SNB_1
+       I2c_ReadByte(ACK); //Read CRC SNB_1 (CRC is not analyzed)
+       u8SerialNumber[2] = I2c_ReadByte(ACK); //Read SNB_0
+       I2c_ReadByte(NO_ACK); //Read CRC SNB_0 (CRC is not analyzed)
+       I2c_StopCondition();
+       //Read from memory location 2
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W); //I2C address
+       error |= I2c_WriteByte (0xFC); //Command for readout on-chip memory
+       error |= I2c_WriteByte (0xC9); //on-chip memory address
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_R); //I2C address
+       u8SerialNumber[1] = I2c_ReadByte(ACK); //Read SNC_1
+       u8SerialNumber[0] = I2c_ReadByte(ACK); //Read SNC_0
+       I2c_ReadByte(ACK); //Read CRC SNC0/1 (CRC is not analyzed)
+       u8SerialNumber[7] = I2c_ReadByte(ACK); //Read SNA_1
+       u8SerialNumber[6] = I2c_ReadByte(ACK); //Read SNA_0
+       I2c_ReadByte(NO_ACK); //Read CRC SNA0/1 (CRC is not analyzed)
+       I2c_StopCondition();
+       return error;
+}
\ No newline at end of file
diff --git a/common/I2C/SHT2x.h b/common/I2C/SHT2x.h
new file mode 100644 (file)
index 0000000..e734a9e
--- /dev/null
@@ -0,0 +1,134 @@
+#ifndef SHT2x_H
+#define SHT2x_H
+//==============================================================================
+// S E N S I R I O N AG, Laubisruetistr. 50, CH-8712 Staefa, Switzerland
+//==============================================================================
+// Project : SHT2x Sample Code (V1.2)
+// File : SHT2x.h
+// Author : MST
+// Controller: NEC V850/SG3 (uPD70F3740)
+// Compiler : IAR compiler for V850 (3.50A)
+// Brief : Sensor layer. Definitions of commands and registers,
+// functions for sensor access
+//==============================================================================
+
+
+//---------- Defines -----------------------------------------------------------
+// CRC
+#define CHECKSUM_ERROR 1
+#define TIME_OUT_ERROR 2
+#define ACK_ERROR 4
+
+
+// sensor command
+typedef enum{
+       TRIG_T_MEASUREMENT_HM = 0xE3, // command trig. temp meas. hold master
+       TRIG_RH_MEASUREMENT_HM = 0xE5, // command trig. humidity meas. hold master
+       TRIG_T_MEASUREMENT_POLL = 0xF3, // command trig. temp meas. no hold master
+       TRIG_RH_MEASUREMENT_POLL = 0xF5, // command trig. humidity meas. no hold master
+       USER_REG_W = 0xE6, // command writing user register
+       USER_REG_R = 0xE7, // command reading user register
+       SOFT_RESET = 0xFE // command soft reset
+}etSHT2xCommand;
+typedef enum {
+       SHT2x_RES_12_14BIT = 0x00, // RH=12bit, T=14bit
+       SHT2x_RES_8_12BIT = 0x01, // RH= 8bit, T=12bit
+       SHT2x_RES_10_13BIT = 0x80, // RH=10bit, T=13bit
+       SHT2x_RES_11_11BIT = 0x81, // RH=11bit, T=11bit
+       SHT2x_RES_MASK = 0x81 // Mask for res. bits (7,0) in user reg.
+} etSHT2xResolution;
+typedef enum {
+       SHT2x_EOB_ON = 0x40, // end of battery
+       SHT2x_EOB_MASK = 0x40, // Mask for EOB bit(6) in user reg.
+} etSHT2xEob;
+typedef enum {
+       SHT2x_HEATER_ON = 0x04, // heater on
+       SHT2x_HEATER_OFF = 0x00, // heater off
+       SHT2x_HEATER_MASK = 0x04, // Mask for Heater bit(2) in user reg.
+} etSHT2xHeater;
+// measurement signal selection
+typedef enum{
+       HUMIDITY,
+       TEMP
+}etSHT2xMeasureType;
+typedef enum{
+       I2C_ADR_W = 128, // sensor I2C address + write bit
+       I2C_ADR_R = 129 // sensor I2C address + read bit
+}etI2cHeader;
+//==============================================================================
+uint8_t SHT2x_CheckCrc(uint8_t data[], uint8_t nbrOfBytes, uint8_t checksum);
+//==============================================================================
+// calculates checksum for n bytes of data and compares it with expected
+// checksum
+// input: data[] checksum is built based on this data
+// nbrOfBytes checksum is built for n bytes of data
+// checksum expected checksum
+// return: error: CHECKSUM_ERROR = checksum does not match
+// 0 = checksum matches
+//==============================================================================
+uint8_t SHT2x_ReadUserRegister(uint8_t *pRegisterValue);
+//==============================================================================
+// reads the SHT2x user register (8bit)
+// input : -
+// output: *pRegisterValue
+// return: error
+//==============================================================================
+uint8_t SHT2x_WriteUserRegister(uint8_t *pRegisterValue);
+//==============================================================================
+//Sample Code SHT21
+//www.sensirion.com Version 1.2 \96 February 2010 4/14
+// writes the SHT2x user register (8bit)
+// input : *pRegisterValue
+// output: -
+// return: error
+//==============================================================================
+uint8_t SHT2x_MeasurePoll(etSHT2xMeasureType eSHT2xMeasureType, int16_t *pMeasurand);
+//==============================================================================
+// measures humidity or temperature. This function polls every 10ms until
+// measurement is ready.
+// input: eSHT2xMeasureType
+// output: *pMeasurand: humidity / temperature as raw value
+// return: error
+// note: timing for timeout may be changed
+//==============================================================================
+uint8_t SHT2x_MeasureHM(etSHT2xMeasureType eSHT2xMeasureType, int16_t *pMeasurand);
+//==============================================================================
+// measures humidity or temperature. This function waits for a hold master until
+// measurement is ready or a timeout occurred.
+// input: eSHT2xMeasureType
+// output: *pMeasurand: humidity / temperature as raw value
+// return: error
+// note: timing for timeout may be changed
+//==============================================================================
+uint8_t SHT2x_SoftReset();
+//==============================================================================
+// performs a reset
+// input: -
+// output: -
+// return: error
+//==============================================================================
+float SHT2x_CalcRH(uint16_t u16sRH);
+//==============================================================================
+// calculates the relative humidity
+// input: sRH: humidity raw value (16bit scaled)
+// return: pHumidity relative humidity [%RH]
+//==============================================================================
+float SHT2x_CalcTemperatureC(uint16_t u16sT);
+//==============================================================================
+// calculates temperature
+// input: sT: temperature raw value (16bit scaled)
+// return: temperature [°C]
+//==============================================================================
+uint8_t SHT2x_GetSerialNumber(uint8_t u8SerialNumber[]);
+//==============================================================================
+// gets serial number of SHT2x according application note "How To
+// Read-Out the Serial Number"
+// note: readout of this function is not CRC checked
+//
+// input: -
+// output: u8SerialNumber: Array of 8 bytes (64Bits)
+// MSB LSB
+// u8SerialNumber[7] u8SerialNumber[0]
+// SNA_1 SNA_0 SNB_3 SNB_2 SNB_1 SNB_0 SNC_1 SNC_0
+// return: error
+#endif
\ No newline at end of file
diff --git a/common/I2C/TSL256x.c b/common/I2C/TSL256x.c
new file mode 100644 (file)
index 0000000..140dd86
--- /dev/null
@@ -0,0 +1,146 @@
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+#include "USI_TWI_Master.h"
+
+void TSL256x_init() {
+       I2c_StartCondition();
+       I2c_WriteByte(0b01010010);  // 0x0101001 1001001 0111001
+       I2c_WriteByte(0x80);
+       I2c_WriteByte(0x03);
+       I2c_StopCondition();
+       I2c_StartCondition();
+       I2c_WriteByte(0b01010010);  // 0x0101001 1001001 0111001
+       I2c_WriteByte(0x81);
+       I2c_WriteByte(0x12);
+       I2c_StopCondition();
+       _delay_ms(500);
+}
+
+void TSL256x_setup(uint8_t conf) {
+       I2c_StartCondition();
+       I2c_WriteByte(0b01010010);  // 0x0101001 1001001 0111001
+       I2c_WriteByte(0x81);
+       I2c_WriteByte(conf);
+       I2c_StopCondition();
+}
+
+uint16_t TSL256x_Ch(uint8_t ch){
+       uint16_t res;
+       I2c_StartCondition();
+       I2c_WriteByte(0b01010010);  // 0x0101001 1001001 0111001
+       //I2c_WriteByte(0xAD);
+       I2c_WriteByte(0xAC+(ch<<1));
+       I2c_StopCondition();
+       I2c_StartCondition();
+       I2c_WriteByte(0b01010011); 
+       res=I2c_ReadByte(ACK);
+       res|=((uint16_t)I2c_ReadByte(NO_ACK))<<8;
+       I2c_StopCondition();
+       return res;
+}
+
+#define LUX_SCALE 14 // scale by 2^14
+#define RATIO_SCALE 9 // scale ratio by 2^9
+//???????????????????????????????????????????????????
+// Integration time scaling factors
+//???????????????????????????????????????????????????
+#define CH_SCALE 10 // scale channel values by 2^10
+#define CHSCALE_TINT0 0x7517 // 322/11 * 2^CH_SCALE
+#define CHSCALE_TINT1 0x0fe7 // 322/81 * 2^CH_SCALE
+
+#define K1T 0x0040 // 0.125 * 2^RATIO_SCALE
+#define B1T 0x01f2 // 0.0304 * 2^LUX_SCALE
+#define M1T 0x01be // 0.0272 * 2^LUX_SCALE
+#define K2T 0x0080 // 0.250 * 2^RATIO_SCALE
+#define B2T 0x0214 // 0.0325 * 2^LUX_SCALE
+#define M2T 0x02d1 // 0.0440 * 2^LUX_SCALE
+#define K3T 0x00c0 // 0.375 * 2^RATIO_SCALE
+#define B3T 0x023f // 0.0351 * 2^LUX_SCALE
+#define M3T 0x037b // 0.0544 * 2^LUX_SCALE
+#define K4T 0x0100 // 0.50 * 2^RATIO_SCALE
+#define B4T 0x0270 // 0.0381 * 2^LUX_SCALE
+#define M4T 0x03fe // 0.0624 * 2^LUX_SCALE
+#define K5T 0x0138 // 0.61 * 2^RATIO_SCALE
+#define B5T 0x016f // 0.0224 * 2^LUX_SCALE
+#define M5T 0x01fc // 0.0310 * 2^LUX_SCALE
+#define K6T 0x019a // 0.80 * 2^RATIO_SCALE
+#define B6T 0x00d2 // 0.0128 * 2^LUX_SCALE
+#define M6T 0x00fb // 0.0153 * 2^LUX_SCALE
+#define K7T 0x029a // 1.3 * 2^RATIO_SCALE
+#define B7T 0x0018 // 0.00146 * 2^LUX_SCALE
+#define M7T 0x0012 // 0.00112 * 2^LUX_SCALE
+#define K8T 0x029a // 1.3 * 2^RATIO_SCALE
+#define B8T 0x0000 // 0.000 * 2^LUX_SCALE
+#define M8T 0x0000 // 0.000 * 2^LUX_SCALE
+
+uint32_t CalculateLux(uint8_t iGain, uint8_t tInt, uint16_t ch0, uint16_t ch1)
+{
+       //????????????????????????????????????????????????????????????????????????
+       // first, scale the channel values depending on the gain and integration time
+       // 16X, 402mS is nominal.
+       // scale if integration time is NOT 402 msec
+       uint32_t chScale;
+       uint32_t channel1;
+       uint32_t channel0;
+       switch (tInt)
+       {
+               case 0: // 13.7 msec
+               chScale = CHSCALE_TINT0;
+               break;
+               case 1: // 101 msec
+               chScale = CHSCALE_TINT1;
+               break;
+               default: // assume no scaling
+               chScale = (1 << CH_SCALE);
+               break;
+       }
+       // scale if gain is NOT 16X
+       if (!iGain) chScale = chScale << 4; // scale 1X to 16X
+       // scale the channel values
+       channel0 = (ch0 * chScale) >> CH_SCALE;
+       channel1 = (ch1 * chScale) >> CH_SCALE;
+       //????????????????????????????????????????????????????????????????????????
+       // find the ratio of the channel values (Channel1/Channel0)
+       // protect against divide by zero
+       uint32_t ratio1 = 0;
+       if (channel0 != 0) ratio1 = (channel1 << (RATIO_SCALE+1)) / channel0;
+       // round the ratio value
+       uint32_t ratio = (ratio1 + 1) >> 1;
+       // is ratio <= eachBreak ?
+       uint16_t b, m;
+               if ((ratio >= 0) && (ratio <= K1T))
+               {b=B1T; m=M1T;}
+               else if (ratio <= K2T)
+               {b=B2T; m=M2T;}
+               else if (ratio <= K3T)
+               {b=B3T; m=M3T;}
+               else if (ratio <= K4T)
+               {b=B4T; m=M4T;}
+               else if (ratio <= K5T)
+               {b=B5T; m=M5T;}
+               else if (ratio <= K6T)
+               {b=B6T; m=M6T;}
+               else if (ratio <= K7T)
+               {b=B7T; m=M7T;}
+               else if (ratio > K8T)
+               {b=B8T; m=M8T;}
+       uint32_t temp;
+       temp = ((channel0 * b) - (channel1 * m));
+       // do not allow negative lux value
+       if (temp < 0) temp = 0;
+       // round lsb (2^(LUX_SCALE?1))
+       temp += (1 << (LUX_SCALE-1));
+       // strip off fractional portion
+       uint32_t lux = temp ;//>> LUX_SCALE;
+       return(lux);
+}
+
+
+
+
+       
+
diff --git a/common/I2C/TSL256x.h b/common/I2C/TSL256x.h
new file mode 100644 (file)
index 0000000..16f7b06
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef TSL256x_H
+#define TSL256x_H
+
+#define TSL_GAIN16 0x10
+#define TSL_GAIN1 0x00
+#define TSL_INT_TIME1 0x00
+#define TSL_INT_TIME2 0x01
+#define TSL_INT_TIME3 0x02
+
+void TSL256x_init();
+void TSL256x_setup(uint8_t conf);
+uint16_t TSL256x_Ch(uint8_t ch);
+ uint32_t CalculateLux(unsigned int iGain, unsigned int tInt, unsigned int ch0, unsigned int ch1);
+
+uint16_t TSL256x_Lux();
+
+#endif
diff --git a/common/I2C/USI_TWI_Master.c b/common/I2C/USI_TWI_Master.c
new file mode 100644 (file)
index 0000000..5e6dea8
--- /dev/null
@@ -0,0 +1,322 @@
+/*****************************************************************************
+*
+* Atmel Corporation
+*
+* File              : USI_TWI_Master.c
+* Compiler          : AVRGCC Toolchain version 3.4.2
+* Revision          : $Revision: 992 $
+* Date              : $Date: 2013-11-07 $
+* Updated by        : $Author: Atmel $
+*
+* Support mail      : avr@atmel.com
+*
+* Supported devices : All device with USI module can be used.
+*                     The example is written for the ATmega169, ATtiny26 and ATtiny2313
+*
+* AppNote           : AVR310 - Using the USI module as a TWI Master
+*
+* Description       : This is an implementation of an TWI master using
+*                     the USI module as basis. The implementation assumes the AVR to
+*                     be the only TWI master in the system and can therefore not be
+*                     used in a multi-master system.
+* Usage             : Initialize the USI module by calling the USI_TWI_Master_Initialise() 
+*                     function. Hence messages/data are transceived on the bus using
+*                     the USI_TWI_Transceive() function. The transceive function 
+*                     returns a status byte, which can be used to evaluate the 
+*                     success of the transmission.
+*
+****************************************************************************/
+#define F_CPU 8000000UL
+#include <avr/io.h>
+#include "USI_TWI_Master.h"
+#include <util/delay.h>
+
+unsigned char USI_TWI_Master_Transfer( unsigned char );
+unsigned char USI_TWI_Master_Stop( void );
+
+union  USI_TWI_state
+{
+  unsigned char errorState;         // Can reuse the TWI_state for error states due to that it will not be need if there exists an error.
+  struct
+  {
+    unsigned char addressMode         : 1;
+    unsigned char masterWriteDataMode : 1;
+    unsigned char unused              : 6;
+  }; 
+}   USI_TWI_state;
+
+/*---------------------------------------------------------------
+ USI TWI single master initialization function
+---------------------------------------------------------------*/
+void USI_TWI_Master_Initialise( void )
+{
+  PORT_USI |= (1<<PIN_USI_SDA);           // Enable pullup on SDA, to set high as released state.
+  PORT_USI |= (1<<PIN_USI_SCL);           // Enable pullup on SCL, to set high as released state.
+  
+  DDR_USI  |= (1<<PIN_USI_SCL);           // Enable SCL as output.
+  DDR_USI  |= (1<<PIN_USI_SDA);           // Enable SDA as output.
+  
+  USIDR    =  0xFF;                       // Preload dataregister with "released level" data.
+  USICR    =  (0<<USISIE)|(0<<USIOIE)|                            // Disable Interrupts.
+              (1<<USIWM1)|(0<<USIWM0)|                            // Set USI in Two-wire mode.
+              (1<<USICS1)|(0<<USICS0)|(1<<USICLK)|                // Software stobe as counter clock source
+              (0<<USITC);
+  USISR   =   (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Clear flags,
+              (0x0<<USICNT0);                                     // and reset counter.
+}
+
+/*---------------------------------------------------------------
+Use this function to get hold of the error message from the last transmission
+---------------------------------------------------------------*/
+unsigned char USI_TWI_Get_State_Info( void )
+{
+  return ( USI_TWI_state.errorState );                            // Return error state.
+}
+
+/*---------------------------------------------------------------
+ USI Transmit and receive function. LSB of first byte in data 
+ indicates if a read or write cycles is performed. If set a read
+ operation is performed.
+
+ Function generates (Repeated) Start Condition, sends address and
+ R/W, Reads/Writes Data, and verifies/sends ACK.
+ Success or error code is returned. Error codes are defined in 
+ USI_TWI_Master.h
+---------------------------------------------------------------*/
+unsigned char USI_TWI_Start_Transceiver_With_Data( unsigned char *msg, unsigned char msgSize)
+{
+  unsigned char tempUSISR_8bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and
+                                 (0x0<<USICNT0);                                     // set USI to shift 8 bits i.e. count 16 clock edges.
+  unsigned char tempUSISR_1bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and
+                                 (0xE<<USICNT0);                                     // set USI to shift 1 bit i.e. count 2 clock edges.
+
+  USI_TWI_state.errorState = 0;
+  USI_TWI_state.addressMode = TRUE;
+
+#ifdef PARAM_VERIFICATION
+  if(msg > (unsigned char*)RAMEND)                 // Test if address is outside SRAM space
+  {
+    USI_TWI_state.errorState = USI_TWI_DATA_OUT_OF_BOUND;
+    return (FALSE);
+  }
+  if(msgSize <= 1)                                 // Test if the transmission buffer is empty
+  {
+    USI_TWI_state.errorState = USI_TWI_NO_DATA;
+    return (FALSE);
+  }
+#endif
+
+#ifdef NOISE_TESTING                                // Test if any unexpected conditions have arrived prior to this execution.
+  if( USISR & (1<<USISIF) )
+  {
+    USI_TWI_state.errorState = USI_TWI_UE_START_CON;
+    return (FALSE);
+  }
+  if( USISR & (1<<USIPF) )
+  {
+    USI_TWI_state.errorState = USI_TWI_UE_STOP_CON;
+    return (FALSE);
+  }
+  if( USISR & (1<<USIDC) )
+  {
+    USI_TWI_state.errorState = USI_TWI_UE_DATA_COL;
+    return (FALSE);
+  }
+#endif
+
+  if ( !(*msg & (1<<TWI_READ_BIT)) )                // The LSB in the address byte determines if is a masterRead or masterWrite operation.
+  {
+    USI_TWI_state.masterWriteDataMode = TRUE;
+  }
+
+/* Release SCL to ensure that (repeated) Start can be performed */
+  PORT_USI |= (1<<PIN_USI_SCL);                     // Release SCL.
+  while( !(PIN_USI & (1<<PIN_USI_SCL)) );          // Verify that SCL becomes high.
+#ifdef TWI_FAST_MODE
+  _delay_us( T4_TWI/4 );                         // Delay for T4TWI if TWI_FAST_MODE
+#else
+  _delay_us( T2_TWI/4 );                         // Delay for T2TWI if TWI_STANDARD_MODE
+#endif
+
+/* Generate Start Condition */
+  PORT_USI &= ~(1<<PIN_USI_SDA);                    // Force SDA LOW.
+  _delay_us( T4_TWI/4 );                         
+  PORT_USI &= ~(1<<PIN_USI_SCL);                    // Pull SCL LOW.
+  PORT_USI |= (1<<PIN_USI_SDA);                     // Release SDA.
+
+#ifdef SIGNAL_VERIFY
+  if( !(USISR & (1<<USISIF)) )
+  {
+    USI_TWI_state.errorState = USI_TWI_MISSING_START_CON;  
+    return (FALSE);
+  }
+#endif
+
+/*Write address and Read/Write data */
+  do
+  {
+    /* If masterWrite cycle (or inital address tranmission)*/
+    if (USI_TWI_state.addressMode || USI_TWI_state.masterWriteDataMode)
+    {
+      /* Write a byte */
+      PORT_USI &= ~(1<<PIN_USI_SCL);                // Pull SCL LOW.
+      USIDR     = *(msg++);                        // Setup data.
+      USI_TWI_Master_Transfer( tempUSISR_8bit );    // Send 8 bits on bus.
+      
+      /* Clock and verify (N)ACK from slave */
+      DDR_USI  &= ~(1<<PIN_USI_SDA);                // Enable SDA as input.
+      if( USI_TWI_Master_Transfer( tempUSISR_1bit ) & (1<<TWI_NACK_BIT) ) 
+      {
+        if ( USI_TWI_state.addressMode )
+          USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_ADDRESS;
+        else
+          USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_DATA;
+        return (FALSE);
+      }
+      USI_TWI_state.addressMode = FALSE;            // Only perform address transmission once.
+    }
+    /* Else masterRead cycle*/
+    else
+    {
+      /* Read a data byte */
+      DDR_USI   &= ~(1<<PIN_USI_SDA);               // Enable SDA as input.
+      *(msg++)  = USI_TWI_Master_Transfer( tempUSISR_8bit );
+
+      /* Prepare to generate ACK (or NACK in case of End Of Transmission) */
+      if( msgSize == 1)                            // If transmission of last byte was performed.
+      {
+        USIDR = 0xFF;                              // Load NACK to confirm End Of Transmission.
+      }
+      else
+      {
+        USIDR = 0x00;                              // Load ACK. Set data register bit 7 (output for SDA) low.
+      }
+      USI_TWI_Master_Transfer( tempUSISR_1bit );   // Generate ACK/NACK.
+    }
+  }while( --msgSize) ;                             // Until all data sent/received.
+  
+  USI_TWI_Master_Stop();                           // Send a STOP condition on the TWI bus.
+
+/* Transmission successfully completed*/
+  return (TRUE);
+}
+
+/*---------------------------------------------------------------
+ Core function for shifting data in and out from the USI.
+ Data to be sent has to be placed into the USIDR prior to calling
+ this function. Data read, will be return'ed from the function.
+---------------------------------------------------------------*/
+unsigned char USI_TWI_Master_Transfer( unsigned char temp )
+{
+  USISR = temp;                                     // Set USISR according to temp.
+                                                    // Prepare clocking.
+  temp  =  (0<<USISIE)|(0<<USIOIE)|                 // Interrupts disabled
+           (1<<USIWM1)|(0<<USIWM0)|                 // Set USI in Two-wire mode.
+           (1<<USICS1)|(0<<USICS0)|(1<<USICLK)|     // Software clock strobe as source.
+           (1<<USITC);                              // Toggle Clock Port.
+  do
+  {
+    _delay_us( T2_TWI/4 );              
+    USICR = temp;                          // Generate positve SCL edge.
+    while( !(PIN_USI & (1<<PIN_USI_SCL)) );// Wait for SCL to go high.
+    _delay_us( T4_TWI/4 );              
+    USICR = temp;                          // Generate negative SCL edge.
+  }while( !(USISR & (1<<USIOIF)) );        // Check for transfer complete.
+  
+  _delay_us( T2_TWI/4 );                
+  temp  = USIDR;                           // Read out data.
+  USIDR = 0xFF;                            // Release SDA.
+  DDR_USI |= (1<<PIN_USI_SDA);             // Enable SDA as output.
+
+  return temp;                             // Return the data from the USIDR
+}
+
+/*---------------------------------------------------------------
+ Function for generating a TWI Stop Condition. Used to release 
+ the TWI bus.
+---------------------------------------------------------------*/
+unsigned char USI_TWI_Master_Stop( void )
+{
+  PORT_USI &= ~(1<<PIN_USI_SDA);           // Pull SDA low.
+  PORT_USI |= (1<<PIN_USI_SCL);            // Release SCL.
+  while( !(PIN_USI & (1<<PIN_USI_SCL)) );  // Wait for SCL to go high.
+  _delay_us( T4_TWI/4 );               
+  PORT_USI |= (1<<PIN_USI_SDA);            // Release SDA.
+  _delay_us( T2_TWI/4 );                
+  
+#ifdef SIGNAL_VERIFY
+  if( !(USISR & (1<<USIPF)) )
+  {
+    USI_TWI_state.errorState = USI_TWI_MISSING_STOP_CON;    
+    return (FALSE);
+  }
+#endif
+
+  return (TRUE);
+}
+
+
+
+unsigned char I2c_WriteByte(unsigned char msg) {
+  unsigned char tempUSISR_8bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and
+  (0x0<<USICNT0);                                     // set USI to shift 8 bits i.e. count 16 clock edges.
+  unsigned char tempUSISR_1bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and
+  (0xE<<USICNT0);                                     // set USI to shift 1 bit i.e. count 2 clock edges.
+
+       /* Write a byte */
+       PORT_USI &= ~(1<<PIN_USI_SCL);                // Pull SCL LOW.
+       USIDR     = msg;                        // Setup data.
+       USI_TWI_Master_Transfer( tempUSISR_8bit );    // Send 8 bits on bus.
+       /* Clock and verify (N)ACK from slave */
+       DDR_USI  &= ~(1<<PIN_USI_SDA);                // Enable SDA as input.
+       if( USI_TWI_Master_Transfer( tempUSISR_1bit ) & (1<<TWI_NACK_BIT) ){
+               if ( USI_TWI_state.addressMode )
+                       USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_ADDRESS;
+               else
+                       USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_DATA;
+               return 2;
+       }
+       return 0;
+}
+unsigned char I2c_ReadByte(unsigned char ack_mode) {
+  unsigned char tempUSISR_8bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and
+  (0x0<<USICNT0);                                     // set USI to shift 8 bits i.e. count 16 clock edges.
+  unsigned char tempUSISR_1bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and
+  (0xE<<USICNT0);                                     // set USI to shift 1 bit i.e. count 2 clock edges.
+       
+       /* Read a data byte */
+       DDR_USI   &= ~(1<<PIN_USI_SDA);               // Enable SDA as input.
+    unsigned char msg = USI_TWI_Master_Transfer( tempUSISR_8bit );
+
+    /* Prepare to generate ACK (or NACK in case of End Of Transmission) */
+    if( ack_mode == NO_ACK) {                           // If transmission of last byte was performed.
+               USIDR = 0xFF;                              // Load NACK to confirm End Of Transmission.
+    } else   {
+               USIDR = 0x00;                              // Load ACK. Set data register bit 7 (output for SDA) low.
+    }
+    USI_TWI_Master_Transfer( tempUSISR_1bit );   // Generate ACK/NACK.
+       return msg;
+}
+
+void I2c_StartCondition() {
+/* Release SCL to ensure that (repeated) Start can be performed */
+PORT_USI |= (1<<PIN_USI_SCL);                     // Release SCL.
+while( !(PIN_USI & (1<<PIN_USI_SCL)) );          // Verify that SCL becomes high.
+#ifdef TWI_FAST_MODE
+_delay_us( T4_TWI/4 );                         // Delay for T4TWI if TWI_FAST_MODE
+#else
+_delay_us( T2_TWI/4 );                         // Delay for T2TWI if TWI_STANDARD_MODE
+#endif
+
+/* Generate Start Condition */
+PORT_USI &= ~(1<<PIN_USI_SDA);                    // Force SDA LOW.
+_delay_us( T4_TWI/4 );
+PORT_USI &= ~(1<<PIN_USI_SCL);                    // Pull SCL LOW.
+PORT_USI |= (1<<PIN_USI_SDA);                     // Release SDA.
+       
+       
+}
+void I2c_StopCondition() {
+       USI_TWI_Master_Stop();
+}
diff --git a/common/I2C/USI_TWI_Master.h b/common/I2C/USI_TWI_Master.h
new file mode 100644 (file)
index 0000000..dbf9da1
--- /dev/null
@@ -0,0 +1,137 @@
+/*****************************************************************************
+*
+* Atmel Corporation
+*
+* File              : USI_TWI_Master.h
+* Compiler          : AVRGCC Toolchain version 3.4.2
+* Revision          : $Revision: 992 $
+* Date              : $Date: 2013-11-07 $
+* Updated by        : $Author: Atmel $
+*
+* Support mail      : avr@atmel.com
+*
+* Supported devices : All device with USI module can be used.
+*                     The example is written for the ATmega169, ATtiny26 and ATtiny2313
+*
+* AppNote           : AVR310 - Using the USI module as a TWI Master
+*
+* Description       : This is an implementation of an TWI master using
+*                     the USI module as basis. The implementation assumes the AVR to
+*                     be the only TWI master in the system and can therefore not be
+*                     used in a multi-master system.
+* Usage             : Initialize the USI module by calling the USI_TWI_Master_Initialise() 
+*                     function. Hence messages/data are transceived on the bus using
+*                     the USI_TWI_Start_Transceiver_With_Data() function. If the transceiver
+*                     returns with a fail, then use USI_TWI_Get_Status_Info to evaluate the 
+*                     couse of the failure.
+*
+****************************************************************************/
+    #include<avr/io.h> 
+//********** Defines **********//
+
+// Defines controlling timing limits
+#define TWI_FAST_MODE
+
+#define SYS_CLK   8000.0  // [kHz]
+
+#ifdef TWI_FAST_MODE               // TWI FAST mode timing limits. SCL = 100-400kHz
+  #define T2_TWI    ((SYS_CLK *1300) /1000000) +1 // >1,3us
+  #define T4_TWI    ((SYS_CLK * 600) /1000000) +1 // >0,6us
+  
+#else                              // TWI STANDARD mode timing limits. SCL <= 100kHz
+  #define T2_TWI    ((SYS_CLK *4700) /1000000) +1 // >4,7us
+  #define T4_TWI    ((SYS_CLK *4000) /1000000) +1 // >4,0us
+#endif
+
+// Defines controling code generating
+//#define PARAM_VERIFICATION
+//#define NOISE_TESTING
+//#define SIGNAL_VERIFY
+
+//USI_TWI messages and flags and bit masks
+//#define SUCCESS   7
+//#define MSG       0
+/****************************************************************************
+  Bit and byte definitions
+****************************************************************************/
+#define TWI_READ_BIT  0       // Bit position for R/W bit in "address byte".
+#define TWI_ADR_BITS  1       // Bit position for LSB of the slave address bits in the init byte.
+#define TWI_NACK_BIT  0       // Bit position for (N)ACK bit.
+
+#define USI_TWI_NO_DATA             0x00  // Transmission buffer is empty
+#define USI_TWI_DATA_OUT_OF_BOUND   0x01  // Transmission buffer is outside SRAM space
+#define USI_TWI_UE_START_CON        0x02  // Unexpected Start Condition
+#define USI_TWI_UE_STOP_CON         0x03  // Unexpected Stop Condition
+#define USI_TWI_UE_DATA_COL         0x04  // Unexpected Data Collision (arbitration)
+#define USI_TWI_NO_ACK_ON_DATA      0x05  // The slave did not acknowledge  all data
+#define USI_TWI_NO_ACK_ON_ADDRESS   0x06  // The slave did not acknowledge  the address
+#define USI_TWI_MISSING_START_CON   0x07  // Generated Start Condition not detected on bus
+#define USI_TWI_MISSING_STOP_CON    0x08  // Generated Stop Condition not detected on bus
+
+// Device dependant defines
+
+#if defined(__AVR_AT90Mega169__) | defined(__AVR_ATmega169PA__) | \
+    defined(__AVR_AT90Mega165__) | defined(__AVR_ATmega165__) | \
+    defined(__AVR_ATmega325__) | defined(__AVR_ATmega3250__) | \
+    defined(__AVR_ATmega645__) | defined(__AVR_ATmega6450__) | \
+    defined(__AVR_ATmega329__) | defined(__AVR_ATmega3290__) | \
+    defined(__AVR_ATmega649__) | defined(__AVR_ATmega6490__)
+    #define DDR_USI             DDRE
+    #define PORT_USI            PORTE
+    #define PIN_USI             PINE
+    #define PORT_USI_SDA        PORTE5
+    #define PORT_USI_SCL        PORTE4
+    #define PIN_USI_SDA         PINE5
+    #define PIN_USI_SCL         PINE4
+#endif
+
+#if defined(__AVR_ATtiny25__) | defined(__AVR_ATtiny45__) | defined(__AVR_ATtiny85__) | \
+    defined(__AVR_AT90Tiny26__) | defined(__AVR_ATtiny26__)
+    #define DDR_USI             DDRB
+    #define PORT_USI            PORTB
+    #define PIN_USI             PINB
+    #define PORT_USI_SDA        PORTB0
+    #define PORT_USI_SCL        PORTB2
+    #define PIN_USI_SDA         PINB0
+    #define PIN_USI_SCL         PINB2
+#endif
+
+#if defined(__AVR_AT90Tiny2313__) | defined(__AVR_ATtiny2313__)
+    #define DDR_USI             DDRB
+    #define PORT_USI            PORTB
+    #define PIN_USI             PINB
+    #define PORT_USI_SDA        PORTB5
+    #define PORT_USI_SCL        PORTB7
+    #define PIN_USI_SDA         PINB5
+    #define PIN_USI_SCL         PINB7
+#endif
+
+#if defined(__AVR_ATtiny84__) | defined(__AVR_ATtiny84A__)
+#define DDR_USI             DDRA
+#define PORT_USI            PORTA
+#define PIN_USI             PINA
+#define PORT_USI_SDA        PORTA6
+#define PORT_USI_SCL        PORTA4
+#define PIN_USI_SDA         PINA6
+#define PIN_USI_SCL         PINA4
+#endif
+
+// General defines
+#define TRUE  1
+#define FALSE 0
+
+#define ACK (1<<TWI_NACK_BIT )
+#define NO_ACK 0
+
+
+//********** Prototypes **********//
+
+void USI_TWI_Master_Initialise( void );
+unsigned char USI_TWI_Start_Transceiver_With_Data( unsigned char * , unsigned char );
+unsigned char USI_TWI_Get_State_Info( void );
+
+unsigned char I2c_WriteByte(unsigned char msg);
+unsigned char I2c_ReadByte(unsigned char ack_mode);
+void I2c_StartCondition();
+void I2c_StopCondition();
+
diff --git a/common/OWCRC16.s b/common/OWCRC16.s
new file mode 100644 (file)
index 0000000..4d6920e
--- /dev/null
@@ -0,0 +1,82 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+.comm crc,2
+
+
+CRC16_alg:
+       ;crc
+       push r_crc
+       lds r_crc,crc;lade low byte fuer vergleich mit bit
+       mov r_temp,r_crc
+       andi r_temp,0x01 ;nur bit 0
+       cp r_temp2,r_temp  ;r_temp2 wird in interruptroutine gesetzt
+       brne crc2 ;nur schieben
+       ;schieben und XOR
+       lds r_temp2,crc+1
+       lsr     r_temp2
+       ror     r_crc
+       ldi     r_temp, 0x01    
+       eor     r_crc, r_temp
+       ldi     r_temp, 0xA0    ;
+       eor     r_temp2, r_temp
+       rjmp crce
+crc2:
+       lds r_temp2,crc+1
+       lsr     r_temp2
+       ror     r_crc
+crce:
+       sts crc,r_crc
+       sts crc+1,r_temp2
+       pop r_crc
+       ret
+
+.macro CRCS ; CRC beim Senden
+       rcall CRC16_alg
+.endm
+
+.macro CRCR; CRC beim Empfangen
+       ;clr r_temp2
+       ;sbrc r_rwbyte,7
+       ;ldi r_temp2,1
+       rcall CRC16_alg
+.endm
+
+.macro CRCInit1; CRC initialisierung bei READ_COMMAND
+       ldi r_temp,0
+       sts crc,r_temp
+       sts crc+1,r_temp
+.endm
+
+.macro CRCInit2; CRC initialisierung bei READ_DATA
+.endm
diff --git a/common/OWCRC8.s b/common/OWCRC8.s
new file mode 100644 (file)
index 0000000..90d2cd7
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+.comm crc,1
+
+
+
+.macro CRCS ; CRC beim Senden
+       ;crc
+       push r_crc
+       lds r_crc,crc
+       mov r_temp,r_crc
+       andi r_temp,0x01
+       cp r_temp2,r_temp
+       brne crc2
+       lsr r_crc
+       ldi r_temp,0x8c
+       eor r_crc,r_temp
+       rjmp crce
+crc2:
+       lsr r_crc
+crce:
+       sts crc,r_crc
+       pop r_crc
+
+.endm
+
+.macro CRCR; CRC beim Empfangen
+.endm
+
+.macro CRCInit1; CRC initialisierung bei READ_COMMAND
+.endm
+
+.macro CRCInit2; CRC initialisierung bei READ_DATA
+       ldi r_temp,0
+       sts crc,r_temp
+.endm
diff --git a/common/OWConfig.s b/common/OWConfig.s
new file mode 100644 (file)
index 0000000..21a5351
--- /dev/null
@@ -0,0 +1,97 @@
+
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+
+#include <avr/io.h>
+
+#define r_temp  16
+#define r_rwbyte  17
+#define r_temp2  18
+#define r_bcount  19
+#define r_mode  20
+#define r_sendflag 21
+#define r_bytep 22
+#define r_crc 23
+
+#define r_idm1 25  
+#define r_idm2 24
+#define r_idn1 15  
+#define r_idn2 14
+
+#define xl 26
+#define xh 27
+#define yl 28
+#define yh 29
+#define zl 30
+#define zh 31
+
+.extern owid,8
+
+
+.comm mode,1  ; Aktueller Zustand nach dem die Unterprogramme aufgerufen werden
+.comm srbyte,1 ; aktuelles Byte fuer Searchrom
+.comm bytep,1 ; pointer fuer Zugriffe auf owid usw
+.comm bcount,1 ;bit counter, bit wird durchgeschoben 
+.comm rwbyte,1 ; alktuelles byte beim Senden oder Empfangen
+.comm sendflag,1; sendfalg= 1 -> Senden sonst Empfangen
+.comm gcontrol,1  ;im Test
+.comm reset_indicator,1  ; zeigt an wenn ein Reset empfangen wurde (Fuer das C Programm)
+.comm alarmflag,1
+#ifndef _DIS_FLASH_
+.comm flashmarker,1
+#endif
+
+.macro configZ m,offs
+       ldi  zl,lo8(\m)       
+       ; daten im gleichen 256 Segment
+//#if (((handle_stable>>1)&0xFF00)!= (m&0xFF00)) 
+    ldi  zh,hi8(\m)
+//#endif
+       add  zl,\offs
+//#if ((pack&0x00FF)>(0xC0))
+       clr r_temp      
+       adc zh,r_temp
+//#endif
+       
+.endm
+
+
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__)||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)
+#include "../common/OWSet_ATTINYX4.s"
+#endif
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)
+#include "../common/OWSet_ATTINYX5.s"
+#endif
+
diff --git a/common/OWPinInterrupt.s b/common/OWPinInterrupt.s
new file mode 100644 (file)
index 0000000..660c7f3
--- /dev/null
@@ -0,0 +1,194 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+       
+.global PIN_INTERRIPT  
+PIN_INTERRIPT:
+       ;leitung auf Low ziehen
+       TESTZEROMARKER ; ueberspringe wenn zeromarker=0   ;sbic und cbi/sbi andern SREG nicht
+       sbi OW_DDR,OW_PINN  
+       push r_temp2                //; wichtig: Benutzte Register und das
+    in r_temp2,_SFR_IO_ADDR(SREG)     //; Status-Register (SREG) sichern!
+       ;Zeromarker loeschen
+       RESETZEROMARKER 
+       ;Weitere Register sichern
+    push r_temp2 
+       push r_temp
+       ; Wegen Power Down Mode Widerherstellen der fallenden Flanke und disable von POWER DONW 
+       SET_FALLING_RESET_SLEEP
+       push r_bcount
+       push r_rwbyte
+       push r_sendflag
+       ;schauen ob noch ein Bit in der Pipeline 
+       lds r_bcount,bcount
+       lds r_rwbyte,rwbyte
+       lds r_sendflag,sendflag
+int_internal_start:
+       ;Timer zuruecksetzen
+       ldi r_temp,~OWT_MIN_RESET
+       out TCNT_REG,r_temp
+       EN_TIM_INT
+       tst r_sendflag
+       breq receive_bit ; sendflag=0 Slave empfaengt
+
+send_bit: ; bit senden
+       ;nachstes bit vorbereiten
+       tst r_bcount
+       brne send_bit_no_handle ;noch bits da 
+       rcall handle_byte ; neues Byte muss bearbeitet werden
+       tst r_sendflag  
+       breq send_bit_low_loop ; Nach dem Gelesen byte koennte gesendet werden muessen....
+send_bit_no_handle:  ;noch bits da
+       ldi r_temp2,0   ; fuer die CRC berechnung in CRCS
+       ror r_rwbyte
+       brcs send_bit_no_low
+       SETZEROMARKER
+       ldi r_temp2,1 ;WICHTIG fuer CRC berechnung
+send_bit_no_low: ;ueberspringen von r_wzero=1 wenn leitung nicht auf 0 gezogen wird
+       CRCS
+       ;naechstes byte ....
+       lsl r_bcount
+       sbis OW_DDR,OW_PINN
+       rjmp iend ;abkuerzung wenn leitung nicht low
+send_bit_low_loop:
+       in r_temp,TCNT_REG
+       cpi r_temp,(~OWT_MIN_RESET)+OWT_WRITE ;aller zwei us zaehlt der timer
+       brlo send_bit_low_loop ;wenn kleiner 
+       cbi OW_DDR,OW_PINN  ;Leitung auf hochohmig 
+       rjmp iend
+
+receive_bit: ;or reset 
+       ;beim lesen zuerst zeit bis zum lesen abwarten 
+       ;(9us nach den 6 us vom low impuls) 
+       in r_temp,TCNT_REG
+       cpi r_temp,(~OWT_MIN_RESET)+OWT_READ ;aller zwei us zaehlt der timer
+       brlo receive_bit ;wenn kleiner 
+       lsr r_rwbyte 
+       ldi r_temp2,1  ;fuer CRC Berechnung
+       sbis OW_PIN,OW_PINN
+       rjmp receive_bit_crc
+       ori r_rwbyte,0x80
+       ldi r_temp2,0 ;fuer CRC Berechnung
+receive_bit_crc:
+       CRCR
+       lsl r_bcount
+       brne recive_bit_no_handle ;bcount nicht 0
+       ;naechstes byte ....
+       rcall handle_byte
+       tst r_sendflag  
+       brne send_bit ; Nach dem Gelesen byte koennte gesendet werden muessen....
+recive_bit_no_handle:  
+iend:
+#ifdef _ZERO_POLLING_
+       ;--------------------------------------- Polling for set low... for 4us low impuls of DS2490
+       TESTZEROMARKER ; ueberspringe wenn zeromarker=0  
+       rjmp zeropolling
+       rjmp no_zerromaker
+zeropolling:
+       sbic OW_PIN,OW_PINN ;warten bis leitung wieder h 
+       rjmp zeropolling_wait  ;leitung ist low ->Schleie
+       in r_temp,TCNT_REG
+       cpi r_temp,(~OWT_MIN_RESET)+50;aller zwei us zaehlt der timer
+       brsh  zeropolling_timeout ;Timeout Reset?
+       rjmp zeropolling
+zeropolling_wait:
+       sbis OW_PIN,OW_PINN ;warten bis leitung wieder l
+       rjmp zeropolling_low_imp ;Leitung ist low raus aus schleufe
+       in r_temp,TCNT_REG
+       cpi r_temp,(~OWT_MIN_RESET)+70 ;aller zwei us zaehlt der timer
+       brsh  zeropolling_timeout ;Timeout
+       rjmp zeropolling_wait
+zeropolling_low_imp:
+       sbi OW_DDR,OW_PINN 
+       RESETZEROMARKER 
+       rjmp int_internal_start
+
+zeropolling_timeout:
+       //in r_temp,TCNT_REG
+       //clr r_sendflag
+       //RESETZEROMARKER 
+
+no_zerromaker: 
+#endif
+       CLEAR_INTERRUPT_FLAG  ; wichtig falls inzwischen wider ein Interrupt aufgelaufen ist
+       sts sendflag,r_sendflag
+       sts bcount,r_bcount
+       sts rwbyte,r_rwbyte
+       pop r_sendflag
+       pop r_rwbyte
+       pop r_bcount
+       pop r_temp
+       cbi OW_DDR,OW_PINN  ;vorsichtsmassname Nicht dauerhaft auf low
+       pop r_temp2                       //; die benutzten Register wiederherstellen
+    out _SFR_IO_ADDR(SREG),r_temp2
+    pop r_temp2
+    reti
+
+
+
+
+handle_byte:
+       push zl
+       push zh
+       push r_mode
+       push r_bytep
+       //cdb
+       lds r_mode,mode
+       lds r_bytep,bytep
+
+
+       ldi zl,lo8(pm(handle_stable)) 
+       ldi zh,hi8(pm(handle_stable)) 
+       add zl,r_mode
+#if ((handle_stable&0xFE00)!=(handle_stable_end&0xFE00))
+       ldi r_temp,0 
+       adc zh,r_temp
+#endif
+       ijmp 
+handle_end_sleep:
+       clr r_bcount
+       ldi r_mode,OW_SLEEP
+       clr r_sendflag
+       rjmp handle_end_no_bcount
+handle_end_inc:
+       inc r_bytep
+handle_end:
+       ldi r_bcount,1
+handle_end_no_bcount:
+       sts mode,r_mode
+       sts bytep,r_bytep
+       //sdb
+       pop r_bytep
+       pop r_mode
+       pop zh
+       pop zl
+       ret
diff --git a/common/OWRomFunctions.s b/common/OWRomFunctions.s
new file mode 100644 (file)
index 0000000..fdcc919
--- /dev/null
@@ -0,0 +1,427 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+
+.macro cjmp val,addr
+       cpi r_rwbyte,\val
+       breq \addr
+.endm
+.macro cljmp val,addr; Weiter sprung, wenn das ziel zu weit entfernt fuer brxx
+       cpi r_rwbyte,\val
+       brne 1f
+       rjmp \addr
+1:
+.endm
+
+.macro cset val,mod ;Nur der Mode wird gesetzt. Abkuerzung da oft nur das noch bleibt
+       cpi r_rwbyte,\val
+       brne 1f
+       ldi r_mode,\mod
+       rjmp handle_end
+1:
+.endm
+
+
+
+
+#define OW_SLEEP 0
+#define OW_READ_ROM_COMMAND 1
+#define OW_MATCHROM 2
+#define OW_SEARCHROMS 3  ;next send two bit
+#define OW_SEARCHROMR 4  ; next resive master answer
+#define OW_READROM 5
+#define OW_READ_COMMAND 6
+
+
+#ifdef _CHANGEABLE_ID_
+#define OW_WRITE_NEWID 7
+#define OW_READ_NEWID 8
+#define OW_SET_NEWID 9
+#define OW_FIRST_COMMAND 10
+.comm newid,8
+
+       
+.macro CHANGE_ID_COMMANDS
+       cset 0x75,OW_WRITE_NEWID
+       cljmp 0xA7,hrc_set_readid
+       cljmp 0x79,hrc_set_setid
+.endm
+
+
+#else
+#define OW_FIRST_COMMAND 7
+#endif
+
+#ifndef _DIS_FLASH_
+; test auf run flasher command 0x88 in h_readcommand
+.macro FLASH_COMMANDS
+       cpi r_rwbyte,0x88
+       brne 1f
+       rjmp hrc_jmp_flasher
+1: ldi r_temp,0 ;Anderes Kommando flashmarker zuruecksetzen...
+       sts flashmarker,r_temp
+.endm
+#endif
+
+
+
+#ifdef _CHANGEABLE_ID_
+; lesen der ID aus dem EEPROM beim Start
+read_EEPROM_ID:  
+       ldi r_temp2,lo8(E2END)
+       ldi zh,hi8(E2END)
+       subi r_temp2,7
+       out _SFR_IO_ADDR(EEARH), zh
+       ldi r_bytep,0
+       ldi  zl,lo8(owid)       
+    ldi  zh,hi8(owid)
+read_EEPROM_ID_loop:
+       sbic _SFR_IO_ADDR(EECR), EEPE
+       rjmp read_EEPROM_ID_loop
+       out _SFR_IO_ADDR(EEARL),r_temp2
+       sbi _SFR_IO_ADDR(EECR), EERE
+       in r_rwbyte,_SFR_IO_ADDR(EEDR)
+       cpi r_rwbyte,0xFF
+       breq read_EEPROM_ID_end
+       st Z+,r_rwbyte
+       inc r_bytep
+       inc r_temp2
+       cpi r_bytep,8
+       brne read_EEPROM_ID_loop
+read_EEPROM_ID_end:
+       ret
+#endif
+
+
+
+
+
+
+handle_stable: 
+               rjmp handle_end_no_bcount // sleep eventuell reset, nichts tun und auf Timeout warten
+               rjmp h_readromcommand 
+               rjmp h_matchrom 
+               rjmp h_searchroms 
+               rjmp h_searchromr
+               rjmp h_readrom
+               rjmp h_readcommand 
+#ifdef _CHANGEABLE_ID_
+               rjmp h_writeid
+               rjmp h_readid
+               rjmp h_setid
+#endif
+               COMMAND_TABLE
+
+
+
+h_readromcommand:
+       clr r_bytep
+       cset 0x55,OW_MATCHROM 
+       cjmp 0xF0,hrc_set_searchrom
+       cjmp 0xCC,hrc_start_read_command ;skip rom
+       cjmp 0x33,hrc_set_read_rom
+       cjmp 0xEC,hrc_set_alarm_search
+       
+       rjmp handle_end_sleep
+
+#ifndef _DIS_FLASH_
+;sprung zum flasher
+hrc_jmp_flasher:
+       lds r_temp,flashmarker
+       cpi r_temp,2
+       brne hrc_jmp_flasher_inc
+       ldi r_temp,0xE0
+       push r_temp
+       ldi r_temp,0x0E
+       push r_temp
+       ret ; Direkter Sprung zum Bootloader
+hrc_jmp_flasher_inc:
+       inc r_temp
+       sts flashmarker,r_temp
+       rjmp handle_end_sleep
+#endif
+
+
+hrc_set_searchrom:     
+       lds r_rwbyte,owid ;erstes Byte lesen
+       rjmp h_searchrom_next_bit
+
+hrc_start_read_command: ;Skip rom und Matchrom ok...
+       ldi r_mode,OW_READ_COMMAND
+       CRCInit1
+       rjmp handle_end
+
+hrc_set_read_rom:
+       ldi r_mode,OW_READROM
+       ldi r_sendflag,1
+       rjmp h_readrom
+
+hrc_set_alarm_search:
+       lds r_temp,alarmflag
+       tst r_temp
+       brne hrc_set_searchrom ;alarm flag nicht 0 also gehe zu searchrom
+       ; sonst tue nichts
+       rjmp handle_end_sleep
+
+;---------------------------------------------------
+;   MATCH ROM
+;---------------------------------------------------
+       
+
+h_matchrom:
+       configZ owid,r_bytep
+       ld r_temp,Z
+       cp r_temp,r_rwbyte
+       breq hmr_next_byte
+       rjmp handle_end_sleep
+
+hmr_next_byte:
+       cpi r_bytep,7
+       breq hrc_start_read_command ;Starten von Read Command
+       rjmp handle_end_inc
+
+
+
+;---------------------------------------------------
+;   SEARCH ROM
+;---------------------------------------------------
+
+
+h_searchrom_next_bit:  ;Setup next Bit of ID
+       sts srbyte,r_rwbyte ;erstes Byte speichern von der Aufrufenden Ebene
+       mov r_temp2,r_rwbyte
+       com r_rwbyte ; negieren
+       ror r_temp2 ; erstes unnegiertes bit in Carry
+       rol r_rwbyte ;und dann als erstes bit in r_rwbyte
+       ldi r_sendflag,1
+       ldi r_bcount,0x40 ; zwei bits sensden dann zu Searchromr 
+       ldi r_mode,OW_SEARCHROMR
+       rjmp handle_end_no_bcount
+
+
+
+h_searchroms:  ; Modus Send zwei bit
+       clr r_temp
+       sbrc r_rwbyte,7 ; bit gesetz (1 empfangen)
+       ldi r_temp,1
+       lds r_bcount,srbyte ;r_bcount wird am ende gesetzt
+       eor r_temp,r_bcount
+       sbrs r_temp,0
+       rjmp h_searchroms_next ; Vergleich des letzen gelesenen bits mit der id
+       ;Ungleich....
+       ;goto sleep
+       ;clr r_sendflag
+       ; ist ja auf lesen
+       rjmp handle_end_sleep
+h_searchroms_next: ; Setup next bit
+       inc r_bytep  ; zaehler der Bits erhoehen
+       sbrc r_bytep,6 ; 64 bit erreicht 
+       rjmp h_searchrom_end_ok ;alles ok auf Command warten
+       mov r_temp,r_bytep 
+       andi r_temp,0x07
+       brne h_searchroms_next_bit  ; bit zwischen 0 und 8
+       mov r_bcount,r_bytep  ; next Byte lesen
+       lsr r_bcount    
+       lsr r_bcount
+       lsr r_bcount
+
+       configZ owid,r_bcount
+       ld r_rwbyte,Z
+       sts srbyte,r_rwbyte
+       rjmp h_searchrom_next_bit
+               
+h_searchroms_next_bit: ;next Bit lesen
+       ;sts srbytep,r_bcount
+       lds r_rwbyte,srbyte
+       lsr r_rwbyte ;aktuelles byte weiterschieben r_rwbyte hier zweckefrei verwendet
+       rjmp h_searchrom_next_bit  ;algemeine routine zum vorbereiten
+h_searchrom_end_ok:
+       clr r_sendflag
+       rjmp hrc_start_read_command
+
+h_searchromr:
+       clr r_sendflag
+       ldi r_mode,OW_SEARCHROMS
+       ldi r_bcount,0
+       rjmp handle_end_no_bcount
+
+
+;---------------------------------------------------
+;   READ ROM
+;---------------------------------------------------
+
+h_readrom:
+       cpi  r_bytep,8
+       breq h_readrom_all
+       configZ owid,r_bytep
+       ld   r_rwbyte,Z
+       rjmp handle_end_inc
+h_readrom_all:
+       rjmp handle_end_sleep
+
+
+;---------------------------------------------------
+;   CHANGE ROM FUNCTIONS
+;---------------------------------------------------
+
+
+#ifdef _CHANGEABLE_ID_
+
+h_writeid:
+       configZ newid,r_bytep
+       st   Z,r_rwbyte
+       cpi  r_bytep,7
+       breq h_writeid_all
+       rjmp handle_end_inc
+h_writeid_all:
+       rjmp handle_end_sleep
+
+
+hrc_set_readid:
+       ldi r_mode,OW_READ_NEWID
+       ldi r_sendflag,1
+h_readid:
+       cpi  r_bytep,8
+       breq h_readid_all
+       configZ newid,r_bytep
+       ld   r_rwbyte,Z
+       rjmp handle_end_inc
+h_readid_all:
+       clr  r_sendflag
+       rjmp handle_end_sleep
+
+hrc_set_setid:
+       ldi r_mode,OW_SET_NEWID
+       ;ldi r_bytep,1 ;start to write in 2
+       rjmp handle_end_inc ;set r_bytep to 1!!!
+
+h_setid:
+       configZ owid,r_bytep
+       ld r_temp,Z
+       cp r_rwbyte,r_temp
+       brne h_setid_bad_code_all
+       cpi r_bytep,1
+       breq h_setid_set2
+       cpi r_bytep,5 
+       breq h_setid_set3
+       cpi r_bytep,6
+       breq h_setid_copy_id
+       rjmp h_setid_bad_code_all ;sollte eigentlich nicht passieren
+h_setid_set2:
+       ldi r_temp,3
+       add r_bytep,r_temp
+h_setid_set3:
+       inc r_bytep
+       rjmp handle_end
+h_setid_copy_id:
+       ldi r_temp2,lo8(E2END)
+       ldi zh,hi8(E2END)
+       ldi r_temp,7
+       sub r_temp2,r_temp
+       ;ldi r_temp,0 ;kommt nicht vor das ein E2ROM genau n*256+(0 bis 7) byte gross ist
+       ;sbc zh
+       out _SFR_IO_ADDR(EEARH),zh
+       ldi zl,lo8(newid)
+       ldi zh,hi8(newid)
+       ldi r_bytep,0
+h_setid_EEPROM_write:
+       sbic _SFR_IO_ADDR(EECR), EEPE   
+       rjmp h_setid_EEPROM_write
+       ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
+       out _SFR_IO_ADDR(EECR), r_temp
+       ;nur adresse L schreiben H bleibt aus oben genannten grund gleich.
+       out _SFR_IO_ADDR(EEARL),r_temp2
+       ld  r_rwbyte,Z+
+       out _SFR_IO_ADDR(EEDR), r_rwbyte
+       sbi _SFR_IO_ADDR(EECR), EEMPE
+       sbi _SFR_IO_ADDR(EECR), EEPE
+       inc r_bytep
+       inc r_temp2
+       cpi r_bytep,8
+       brne h_setid_EEPROM_write
+       rcall read_EEPROM_ID
+h_setid_bad_code_all:
+       rjmp handle_end_sleep
+
+
+
+#endif
+
+
+spause:
+       nop
+       nop
+       nop
+       nop
+       ret
+
+
+.global OWINIT
+OWINIT:
+#ifndef _DIS_FLASH_
+; check for bootloader jumper
+       ;vor allen anderen Registerconfigs
+       
+       ldi r_temp,(1<<PUD) ;enable pullup 
+       out _SFR_IO_ADDR(MCUCR) ,r_temp
+       sbi _SFR_IO_ADDR(PORTA),PINA5 ;internal pullup on PINA5
+       sbi _SFR_IO_ADDR(PORTA),PINA4 ;internal pullup on PINA4
+       rcall spause
+       sbis _SFR_IO_ADDR(PINA),PINA5
+       rjmp owinit_botest_end  ;PinA5 nicht auf 1
+       sbis _SFR_IO_ADDR(PINA),PINA4
+       rjmp owinit_botest_end ;PinA4 nicht auf 1
+       cbi _SFR_IO_ADDR(PORTA),PINA4 
+       sbi _SFR_IO_ADDR(DDRA),PINA4  ;PINA4 AUSGANG und 0
+       rcall spause
+       sbic _SFR_IO_ADDR(PINA),PINA5 
+       rjmp owinit_botest_end ;PINA5 nicht 0.... nicht verbunden
+       cbi _SFR_IO_ADDR(DDRA),PINA4
+       ldi r_temp,0xE0
+       push r_temp
+       ldi r_temp,0x0E
+       push r_temp
+       ret ; Direkter Sprung zum Bootloader*/
+owinit_botest_end:
+#endif
+       HW_INIT  //Microcontroller specific
+       CHIP_INIT //1-Wire device specific
+#ifdef _CHANGEABLE_ID_
+       rcall read_EEPROM_ID
+#endif
+       ldi r_temp,0
+       sts mode,r_temp
+       sts bcount,r_temp
+       sts alarmflag,r_temp
+       RESETZEROMARKER
+       ret
diff --git a/common/OWRomFunctionsDual.s b/common/OWRomFunctionsDual.s
new file mode 100644 (file)
index 0000000..c28d855
--- /dev/null
@@ -0,0 +1,562 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+
+.macro cjmp val,addr
+       cpi r_rwbyte,\val
+       breq \addr
+.endm
+.macro cljmp val,addr; Weiter sprung, wenn das ziel zu weit entfernt fuer brxx
+       cpi r_rwbyte,\val
+       brne 1f
+       rjmp \addr
+1:
+.endm
+
+.macro cset val,mod ;Nur der Mode wird gesetzt. Abkuerzung da oft nur das noch bleibt
+       cpi r_rwbyte,\val
+       brne 1f
+       ldi r_mode,\mod
+       rjmp handle_end
+1:
+.endm
+
+
+
+
+#define OW_SLEEP 0
+#define OW_READ_ROM_COMMAND 1
+#define OW_MATCHROM 2
+#define OW_SEARCHROMS 3  ;next send two bit
+#define OW_SEARCHROMR 4  ; next resive master answer
+#define OW_READ_COMMAND1 5
+#define OW_READ_COMMAND2 6
+
+
+#ifdef _CHANGEABLE_ID_
+#define OW_WRITE_NEWID 7
+#define OW_READ_NEWID 8
+#define OW_SET_NEWID 9
+#define OW_FIRST_COMMAND 10
+.comm newid,8
+.comm idtable,64
+       
+.macro CHANGE_ID_COMMANDS
+       cset 0x75,OW_WRITE_NEWID
+       cljmp 0xA7,hrc_set_readid
+       cljmp 0x79,hrc_set_setid
+.endm
+
+
+#else
+#define OW_FIRST_COMMAND 7
+#endif
+
+#ifndef _DIS_FLASH_
+; test auf run flasher command 0x88 in h_readcommand
+.macro FLASH_COMMANDS
+       cpi r_rwbyte,0x88
+       brne 1f
+       rjmp hrc_jmp_flasher
+1: ldi r_temp,0 ;Anderes Kommando flashmarker zuruecksetzen...
+       sts flashmarker,r_temp
+.endm
+#endif
+
+
+
+#ifdef _CHANGEABLE_ID_
+; lesen der ID aus dem EEPROM beim Start
+read_EEPROM_ID1:  
+       ldi r_temp2,lo8(E2END)
+       ldi zh,hi8(E2END)
+       subi r_temp2,7
+       out _SFR_IO_ADDR(EEARH), zh
+       ldi r_bytep,0
+       ldi  zl,lo8(owid1)       
+    ldi  zh,hi8(owid1)
+       rjmp read_EEPROM_ID_loop
+read_EEPROM_ID2:  
+       ldi r_temp2,lo8(E2END)
+       ldi zh,hi8(E2END)
+       subi r_temp2,15
+       out _SFR_IO_ADDR(EEARH), zh
+       ldi r_bytep,0
+       ldi  zl,lo8(owid2)       
+    ldi  zh,hi8(owid2)
+read_EEPROM_ID_loop:
+       sbic _SFR_IO_ADDR(EECR), EEPE
+       rjmp read_EEPROM_ID_loop
+       out _SFR_IO_ADDR(EEARL),r_temp2
+       sbi _SFR_IO_ADDR(EECR), EERE
+       in r_rwbyte,_SFR_IO_ADDR(EEDR)
+       cpi r_rwbyte,0xFF
+       breq read_EEPROM_ID_end
+       st Z+,r_rwbyte
+       inc r_bytep
+       inc r_temp2
+       cpi r_bytep,8
+       brne read_EEPROM_ID_loop
+read_EEPROM_ID_end:
+       ret
+#endif
+
+
+
+
+
+
+
+handle_stable: 
+               rjmp handle_end_no_bcount // sleep eventuell reset, nichts tun und auf Timeout warten
+               rjmp h_readromcommand 
+               rjmp h_matchrom 
+               rjmp h_searchroms 
+               rjmp h_searchromr
+               rjmp h_readcommand1 
+               rjmp h_readcommand2
+#ifdef _CHANGEABLE_ID_
+               rjmp h_writeid
+               rjmp h_readid
+               rjmp h_setid
+#endif
+               COMMAND_TABLE
+
+
+
+h_readromcommand:
+       clr r_bytep
+       cjmp 0x55,hrc_set_matchrom
+       cjmp 0xF0,hrc_set_searchrom
+       cjmp 0xEC,hrc_set_alarm_search
+       
+       rjmp handle_end_sleep
+
+#ifndef _DIS_FLASH_
+;sprung zum flasher
+hrc_jmp_flasher:
+       lds r_temp,flashmarker
+       cpi r_temp,2
+       brne hrc_jmp_flasher_inc
+       ldi r_temp,0xE0
+       push r_temp
+       ldi r_temp,0x0E
+       push r_temp
+       ret ; Direkter Sprung zum Bootloader
+hrc_jmp_flasher_inc:
+       inc r_temp
+       sts flashmarker,r_temp
+       rjmp handle_end_sleep
+#endif
+
+hrc_set_matchrom:
+       ldi r_temp,3
+       sts srbyte,r_temp ; Beide geraete nehmen an searchrom teil
+       ldi r_mode,OW_MATCHROM
+       rjmp handle_end
+
+
+
+hrc_set_searchrom:     
+       ldi r_temp,3
+       sts srbyte,r_temp ; Beide geraete nehmen an searchrom teil
+       configZ idtable,r_bytep
+       rjmp h_searchrom_next_bit
+
+hrc_start_read_command: ;Skip rom und Matchrom ok...
+       lds r_temp,srbyte
+       cpi r_temp,1
+       breq hrc_start_read_command1
+       cpi r_temp,2
+       breq hrc_start_read_command2
+       rjmp handle_end_sleep
+       CRCInit1
+hrc_start_read_command1:
+       ldi r_mode,OW_READ_COMMAND1
+       rjmp handle_end
+hrc_start_read_command2:
+       ldi r_mode,OW_READ_COMMAND2
+       rjmp handle_end
+
+
+hrc_set_alarm_search:
+       lds r_temp,alarmflag
+       tst r_temp
+       brne hrc_set_searchrom ;alarm flag nicht 0 also gehe zu searchrom
+       ; sonst tue nichts
+       rjmp handle_end_sleep
+
+;---------------------------------------------------
+;   MATCH ROM
+;---------------------------------------------------
+       
+
+h_matchrom:
+       lds r_bcount,srbyte
+       sbrs r_bcount,0 ;ueberspringe wenn bit 1 =0 also geraet 1 nich mehr im rennen
+       rjmp h_matchrom_id2
+       configZ owid1,r_bytep
+       ld r_temp2,Z
+       cp r_temp2,r_rwbyte
+       breq h_matchrom_id2
+       cbr r_bcount,1 ; loesche geraet
+       breq h_matchrom_sleep
+h_matchrom_id2:
+       configZ owid2,r_bytep
+       ld r_temp2,Z
+       cp r_temp2,r_rwbyte
+       breq hmr_next_byte
+       cbr r_bcount,2 ; loesche geraet
+       breq h_matchrom_sleep
+
+hmr_next_byte:
+       sts srbyte,r_bcount
+       cpi r_bytep,7
+       breq hrc_start_read_command ;Starten von Read Command
+       rjmp handle_end_inc
+
+h_matchrom_sleep:
+       sts srbyte,r_bcount
+       rjmp handle_end_sleep
+
+
+;---------------------------------------------------
+;   SEARCH ROM
+;---------------------------------------------------
+
+
+h_searchrom_next_bit:  ;Setup next Bit of ID
+       ld r_temp2,Z
+       lds r_temp,srbyte  ;srbyte ist ein zeiger auf die bits fuer ein bit im Table
+h_searchrom_next_bit_l2:
+       cpi r_temp,3
+       breq h_searchrom_next_bit_l1
+       lsr r_temp2
+       lsr r_temp2
+       inc r_temp
+       rjmp h_searchrom_next_bit_l2
+h_searchrom_next_bit_l1:
+       lsr r_temp2
+       rol r_rwbyte  ; negiertes bit in rwbyte
+       lsr r_temp2
+       rol r_rwbyte  ; bit in rwbyte
+       ldi r_sendflag,1
+       ldi r_bcount,0x40 ; zwei bits sensden dann zu Searchromr 
+       ldi r_mode,OW_SEARCHROMR
+       rjmp handle_end_no_bcount
+
+
+
+h_searchroms:  ; Modus Send zwei bit
+       configZ idtable,r_bytep
+       ld r_temp2,Z+
+       lds r_temp,srbyte
+       cpi r_temp,3
+       breq h_searchroms_idd
+       cpi r_temp,1
+       breq h_searchroms_id1
+       cpi r_temp,2
+       breq h_searchroms_id2
+       rjmp handle_end_sleep ; zur Sicherheit.....
+h_searchroms_idd:
+       andi r_rwbyte,0x80
+       breq h_searchroms_idd_zero
+       ; Master send 1
+       sbrc r_temp2,0 ;springe wenn nicht beide bits 0 (id 1 negiert und id 2 negiert)
+       rjmp handle_end_sleep ;
+       sbrc r_temp2,4  ;id1 set? then skip
+       cbr r_temp,1  ; loesche bit 1 in srbyte
+       sbrc r_temp2,2 ; springe wenn id 2 gesetzt ist
+       cbr r_temp,2 ;  loesche bit 2 in srbyte 
+       sts srbyte,r_temp
+       rjmp h_searchroms_idX_end
+h_searchroms_idd_zero:
+       sbrc r_temp2,1 ;springe wenn nicht beide 1 (id 1  und id 2 )
+       rjmp handle_end_sleep ;beide 1 gehe schlafen
+       sbrs r_temp2,4  ;id1 0? then skip
+       cbr r_temp,1  ; loesche bit 1 in srbyte
+       sbrs r_temp2,2 ; springe wenn id 2  null ist
+       cbr r_temp,2  ; loesche bit 2 in srbyte
+       sts srbyte,r_temp
+       rjmp h_searchroms_idX_end
+h_searchroms_id1:
+       andi r_rwbyte,0x80
+       breq h_searchroms_id1_zero
+       ; Master send 1
+       sbrs r_temp2,5  ;id1 set? then skip
+       rjmp handle_end_sleep ;
+       rjmp h_searchroms_idX_end
+h_searchroms_id1_zero:         
+       sbrs r_temp2,4  ;id1 set? then skip
+       rjmp handle_end_sleep ;
+       rjmp h_searchroms_idX_end
+h_searchroms_id2:
+       andi r_rwbyte,0x80
+       breq h_searchroms_id2_zero
+       ; Master send 1
+       sbrs r_temp2,3  ;id1 set? then skip
+       rjmp handle_end_sleep ;
+       rjmp h_searchroms_idX_end
+h_searchroms_id2_zero:         
+       sbrs r_temp2,2  ;id1 set? then skip
+       rjmp handle_end_sleep ;
+       rjmp h_searchroms_idX_end
+h_searchroms_idX_end:
+       lds r_temp,srbyte
+       tst r_temp
+       brne h_searchroms_idX_end1
+       rjmp handle_end_sleep
+h_searchroms_idX_end1:
+       inc r_bytep
+       cpi r_bytep,64
+       breq h_searchrom_end_ok  ;unterschied nur das letzt bit wird wohl nie vorkommen
+       rjmp h_searchrom_next_bit
+
+h_searchrom_end_ok:
+       clr r_sendflag
+       rjmp hrc_start_read_command
+
+h_searchromr:  ; stelle um auf empfangen
+       clr r_sendflag
+       ldi r_mode,OW_SEARCHROMS
+       ldi r_bcount,0  ;gehe nach einem bit zu SEARCHROMS
+       rjmp handle_end_no_bcount
+
+
+
+;---------------------------------------------------
+;   CHANGE ROM FUNCTIONS
+;---------------------------------------------------
+
+
+#ifdef _CHANGEABLE_ID_
+
+h_writeid:
+       configZ newid,r_bytep
+       st   Z,r_rwbyte
+       cpi  r_bytep,7
+       breq h_writeid_all
+       rjmp handle_end_inc
+h_writeid_all:
+       rjmp handle_end_sleep
+
+
+hrc_set_readid:
+       ldi r_mode,OW_READ_NEWID
+       ldi r_sendflag,1
+h_readid:
+       cpi  r_bytep,8
+       breq h_readid_all
+       configZ newid,r_bytep
+       ld   r_rwbyte,Z
+       rjmp handle_end_inc
+h_readid_all:
+       clr  r_sendflag
+       rjmp handle_end_sleep
+
+hrc_set_setid:
+       ldi r_mode,OW_SET_NEWID
+       ;ldi r_bytep,1 ;start to write in 2
+       rjmp handle_end_inc ;set r_bytep to 1!!!
+
+h_setid:
+       lds r_bcount,srbyte
+       cpi r_bcount,2
+       breq h_setid2
+h_setid1:
+       configZ owid1,r_bytep
+       rjmp h_setido
+h_setid2:
+       configZ owid2,r_bytep
+h_setido:
+       ld r_temp,Z
+       cp r_rwbyte,r_temp
+       brne h_setid_bad_code_all
+       cpi r_bytep,1
+       breq h_setid_set2
+       cpi r_bytep,5 
+       breq h_setid_set3
+       cpi r_bytep,6
+       breq h_setid_copy_id
+       rjmp h_setid_bad_code_all ;sollte eigentlich nicht passieren
+h_setid_set2:
+       ldi r_temp,3
+       add r_bytep,r_temp
+h_setid_set3:
+       inc r_bytep
+       rjmp handle_end
+h_setid_copy_id:
+       ldi r_temp2,lo8(E2END)
+       ldi zh,hi8(E2END)
+       ldi r_temp,7
+       sbrc r_bcount,1
+       ldi r_temp,15
+       sub r_temp2,r_temp
+       ;ldi r_temp,0 ;kommt nicht vor das ein E2ROM genau n*256+(0 bis 7) byte gross ist
+       ;sbc zh
+       out _SFR_IO_ADDR(EEARH),zh
+       ldi zl,lo8(newid)
+       ldi zh,hi8(newid)
+       ldi r_bytep,0
+h_setid_EEPROM_write:
+       sbic _SFR_IO_ADDR(EECR), EEPE   
+       rjmp h_setid_EEPROM_write
+       ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
+       out _SFR_IO_ADDR(EECR), r_temp
+       ;nur adresse L schreiben H bleibt aus oben genannten grund gleich.
+       out _SFR_IO_ADDR(EEARL),r_temp2
+       ld  r_rwbyte,Z+
+       out _SFR_IO_ADDR(EEDR), r_rwbyte
+       sbi _SFR_IO_ADDR(EECR), EEMPE
+       sbi _SFR_IO_ADDR(EECR), EEPE
+       inc r_bytep
+       inc r_temp2
+       cpi r_bytep,8
+       brne h_setid_EEPROM_write
+       //rcall read_EEPROM_ID1
+       //rcall read_EEPROM_ID2
+       push r_idm1
+       push r_idm2
+       push r_idn1
+       push r_idn2
+       push xl
+       push xh
+       push yl
+       push yh
+       rcall init_idtable
+       pop yh
+       pop yl
+       pop xh
+       pop xl
+       pop r_idn2
+       pop r_idn1
+       pop r_idm2
+       pop r_idm1
+h_setid_bad_code_all:
+       rjmp handle_end_sleep
+
+
+
+#endif
+
+
+spause:
+       nop
+       nop
+       nop
+       nop
+       ret
+
+
+.global OWINIT
+OWINIT:
+#ifndef _DIS_FLASH_
+; check for bootloader jumper
+       ;vor allen anderen Registerconfigs
+       
+       ldi r_temp,(1<<PUD) ;enable pullup 
+       out _SFR_IO_ADDR(MCUCR) ,r_temp
+       sbi _SFR_IO_ADDR(PORTA),PINA5 ;internal pullup on PINA5
+       sbi _SFR_IO_ADDR(PORTA),PINA4 ;internal pullup on PINA4
+       rcall spause
+       sbis _SFR_IO_ADDR(PINA),PINA5
+       rjmp owinit_botest_end  ;PinA5 nicht auf 1
+       sbis _SFR_IO_ADDR(PINA),PINA4
+       rjmp owinit_botest_end ;PinA4 nicht auf 1
+       cbi _SFR_IO_ADDR(PORTA),PINA4 
+       sbi _SFR_IO_ADDR(DDRA),PINA4  ;PINA4 AUSGANG und 0
+       rcall spause
+       sbic _SFR_IO_ADDR(PINA),PINA5 
+       rjmp owinit_botest_end ;PINA5 nicht 0.... nicht verbunden
+       cbi _SFR_IO_ADDR(DDRA),PINA4
+       ldi r_temp,0xE0
+       push r_temp
+       ldi r_temp,0x0E
+       push r_temp
+       ret ; Direkter Sprung zum Bootloader*/
+owinit_botest_end:
+#endif
+       HW_INIT  //Microcontroller specific
+       CHIP_INIT //1-Wire device specific
+#ifdef _CHANGEABLE_ID_
+init_idtable:
+       rcall read_EEPROM_ID1
+       rcall read_EEPROM_ID2
+#endif
+       ldi r_bytep,8
+       ldi r_temp,0
+       ldi  zl,lo8(idtable)
+    ldi  zh,hi8(idtable)
+       ldi  xl,lo8(owid1)
+       ldi  xh,hi8(owid1)
+       ldi      yl,lo8(owid2)
+       ldi  yh,hi8(owid2)
+owinit_odgen1:
+       ld r_idm1,X+
+       ld r_idm2,Y+
+       mov r_idn1,r_idm1
+       com r_idn1
+       mov r_idn2,r_idm2
+       com r_idn2
+       ldi r_bcount,8
+       mov r_temp,r_idm1
+       and r_temp,r_idm2
+       mov r_temp2,r_idn1
+       and r_temp2,r_idn2
+owinit_odgen2:
+       ldi r_mode,0
+       lsr r_idm1
+       rol r_mode  ;6. Bit id1 
+       lsr r_idn1  
+       rol r_mode ; 5. Bit id1negiert
+       lsr r_idm2
+       rol r_mode  ;;4. Bit id2 
+       lsr r_idn2  
+       rol r_mode  ;3. Bit id2 negiert
+       lsr r_temp 
+       rol r_mode ;zweites bit  id1 und id2
+       lsr r_temp2
+       rol r_mode   ;erstes bit id1 negiert und id2  negiert
+       st  Z+,r_mode
+       dec r_bcount
+       brne owinit_odgen2
+       dec r_bytep
+       brne owinit_odgen1
+
+
+       ldi r_temp,0
+       sts mode,r_temp
+       sts bcount,r_temp
+       sts alarmflag,r_temp
+       RESETZEROMARKER
+       ret
diff --git a/common/OWSet_ATTINYX4.s b/common/OWSet_ATTINYX4.s
new file mode 100644 (file)
index 0000000..c0a074b
--- /dev/null
@@ -0,0 +1,124 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+#define OW_PORT _SFR_IO_ADDR(PORTB) //1 Wire Port
+#define OW_PIN _SFR_IO_ADDR(PINB) //1 Wire Pin as number
+#define OW_PINN PORTB2
+#define OW_DDR _SFR_IO_ADDR(DDRB)  //pin direction register
+#define TCNT_REG _SFR_IO_ADDR(TCNT0)
+
+#define DB_PORT _SFR_IO_ADDR(PORTB) //DEBUG
+#define DB_PIN _SFR_IO_ADDR(PINB) //DEBUG
+#define DB_DDR _SFR_IO_ADDR(DDRB) //DEBUG
+#define DB_PINN PORTB1
+
+#define SETZEROMARKER sbi _SFR_IO_ADDR(DDRB),3
+#define RESETZEROMARKER cbi _SFR_IO_ADDR(DDRB),3
+#define TESTZEROMARKER sbic _SFR_IO_ADDR(DDRB),3
+
+//#define sdb sbi _SFR_IO_ADDR(PORTB),DB_PINN
+//#define cdb cbi _SFR_IO_ADDR(PORTB),DB_PINN
+
+#define TIMER_INTERRUPT TIM0_OVF_vect
+#define PIN_INTERRIPT EXT_INT0_vect
+
+
+//#define OWT_MIN_RESET 160 
+//#define OWT_RESET2 40
+//#define OWT_RESET_PRESENT 15
+//#define OWT_PRESENT 50
+//#define OWT_WRITE 18
+//#define OWT_READ 4
+
+#define OWT_MIN_RESET 80 
+#define OWT_RESET2 100
+#define OWT_RESET_PRESENT 30
+#define OWT_PRESENT 130
+#define OWT_WRITE 35
+#define OWT_READ 12
+
+
+
+.macro CLEAR_INTERRUPT_FLAG 
+       ldi r_temp,(1<<INTF0);inerrupt flags durch 1 loeschen..... 0 macht nix
+       out _SFR_IO_ADDR(GIFR),r_temp
+.endm
+
+.macro EN_TIM_INT
+       in r_temp,_SFR_IO_ADDR(TIMSK0)
+       sbr r_temp,(1<<TOIE0)
+       out _SFR_IO_ADDR(TIMSK0),r_temp
+       ldi r_temp,(1<<TOV0) ;inerrupt flags durch 1 loeschen..... 0 macht nix
+       out _SFR_IO_ADDR(TIFR0),r_temp
+.endm
+
+.macro DIS_TIM_INT
+       in r_temp,_SFR_IO_ADDR(TIMSK0)
+       cbr r_temp,(1<<TOIE0)
+       out _SFR_IO_ADDR(TIMSK0),r_temp
+.endm
+
+.macro SET_FALLING_RESET_SLEEP
+       in r_temp,_SFR_IO_ADDR(MCUCR)
+       ori r_temp,(1<<ISC01)
+       andi r_temp,~(1<<SM1)
+       out     _SFR_IO_ADDR(MCUCR),r_temp
+.endm
+
+.macro HW_INIT
+       ;set clock to 8 MHz
+       ldi r_temp,0x80;
+       out _SFR_IO_ADDR(CLKPR),r_temp
+       //ldi r_temp,(1<<CLKPS0)
+       ldi r_temp,0
+       out _SFR_IO_ADDR(CLKPR),r_temp
+       ;Disable Timer int
+       ldi r_temp,0
+       out _SFR_IO_ADDR(TIMSK0),r_temp ;; is default
+       ;Enable Pin int
+       ldi r_temp,(1<<INT0)
+       out _SFR_IO_ADDR(GIMSK),r_temp
+       ;Set Timerclock to Clock / 8 (2us bei 4MHz) bzw 1us bei 8 MHz
+       ldi r_temp,(1<<CS01)
+       out _SFR_IO_ADDR(TCCR0B),r_temp
+       ;OWPin as input
+       cbi OW_DDR,OW_PINN ;; is default.... 
+       cbi OW_PORT,OW_PINN ;; vereinfachung im Hauptprogram (PORTB=0xFF) wegen pullup
+       ;set falling edge
+       ldi r_temp,(1<<ISC01)
+       out _SFR_IO_ADDR(MCUCR),r_temp
+       //sbi DB_DDR,DB_PINN
+.endm
+
+
+
diff --git a/common/OWSet_ATTINYX5.s b/common/OWSet_ATTINYX5.s
new file mode 100644 (file)
index 0000000..4c4528f
--- /dev/null
@@ -0,0 +1,133 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+//#define __4M__
+
+#define OW_PORT _SFR_IO_ADDR(PORTB) //1 Wire Port
+#define OW_PIN _SFR_IO_ADDR(PINB) //1 Wire Pin as number
+#define OW_PINN PORTB2
+#define OW_DDR _SFR_IO_ADDR(DDRB)  //pin direction register
+#define TCNT_REG _SFR_IO_ADDR(TCNT0)
+
+#define DB_PORT _SFR_IO_ADDR(PORTB) //1 Wire Port
+#define DB_PIN _SFR_IO_ADDR(PINB) //1 Wire Pin as number
+#define DB_PINN PORTB1
+
+#define SETZEROMARKER sbi _SFR_IO_ADDR(DDRB),5
+#define RESETZEROMARKER cbi _SFR_IO_ADDR(DDRB),5
+#define TESTZEROMARKER sbic _SFR_IO_ADDR(DDRB),5
+
+;#define sdb sbi _SFR_IO_ADDR(PORTB),1
+;#define cdb cbi _SFR_IO_ADDR(PORTB),1
+
+#define TIMER_INTERRUPT TIM0_OVF_vect
+#define PIN_INTERRIPT INT0_vect
+
+#ifdef __4M__
+
+#define OWT_MIN_RESET 70 
+#define OWT_RESET2 40
+#define OWT_RESET_PRESENT 15
+#define OWT_PRESENT 50
+#define OWT_WRITE 18
+#define OWT_READ 5
+
+#else
+
+#define OWT_MIN_RESET 120 
+#define OWT_RESET2 60
+#define OWT_RESET_PRESENT 30
+#define OWT_PRESENT 130
+//#define OWT_WRITE 35
+//#define OWT_READ 12
+#define OWT_WRITE 35
+#define OWT_READ 12
+
+#endif
+
+
+
+.macro CLEAR_INTERRUPT_FLAG 
+       ldi r_temp,(1<<INTF0);inerrupt flags durch 1 loeschen..... 0 macht nix
+       out _SFR_IO_ADDR(GIFR),r_temp
+.endm
+
+.macro EN_TIM_INT
+       in r_temp,_SFR_IO_ADDR(TIMSK)
+       sbr r_temp,(1<<TOIE0)
+       out _SFR_IO_ADDR(TIMSK),r_temp
+       ldi r_temp,(1<<TOV0) ;inerrupt flags durch 1 loeschen..... 0 macht nix
+       out _SFR_IO_ADDR(TIFR),r_temp
+.endm
+
+.macro DIS_TIM_INT
+       in r_temp,_SFR_IO_ADDR(TIMSK)
+       cbr r_temp,(1<<TOIE0)
+       out _SFR_IO_ADDR(TIMSK),r_temp
+.endm
+
+
+.macro SET_FALLING
+       in r_temp,_SFR_IO_ADDR(MCUCR)
+       ori r_temp,(1<<ISC01)
+       out     _SFR_IO_ADDR(MCUCR),r_temp
+.endm
+
+
+
+
+.macro HW_INIT
+       ;set clock to 8 MHz
+       ldi r_temp,0x80;
+       out _SFR_IO_ADDR(CLKPR),r_temp
+#ifdef __4M__
+       ldi r_temp,(1<<CLKPS0)
+#else
+       ldi r_temp,0
+#endif
+       out _SFR_IO_ADDR(CLKPR),r_temp
+       ;Disable Timer int
+       ldi r_temp,0
+       out _SFR_IO_ADDR(TIMSK),r_temp ;; is default
+       ;Enable Pin int
+       ldi r_temp,(1<<INT0)
+       out _SFR_IO_ADDR(GIMSK),r_temp
+       ;Set Timerclock to Clock / 8 (2us)
+       ldi r_temp,(1<<CS01)
+       out _SFR_IO_ADDR(TCCR0B),r_temp
+       ;OWPin as input
+       cbi OW_DDR,OW_PINN ;; is default.... 
+       ;set falling edge
+       ldi r_temp,(1<<ISC01)
+       out _SFR_IO_ADDR(MCUCR),r_temp
+.endm
diff --git a/common/OWTimerInterrupt.s b/common/OWTimerInterrupt.s
new file mode 100644 (file)
index 0000000..cd8af1c
--- /dev/null
@@ -0,0 +1,80 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved. 
+// 
+// Redistribution and use in source and binary forms, with or without 
+// modification, are permitted provided that the following conditions are 
+// met: 
+// 
+//  * Redistributions of source code must retain the above copyright 
+//    notice, this list of conditions and the following disclaimer. 
+//  * Redistributions in binary form must reproduce the above copyright 
+//    notice, this list of conditions and the following disclaimer in the 
+//    documentation and/or other materials provided with the 
+//    distribution. 
+//  * All advertising materials mentioning features or use of this 
+//    software must display the following acknowledgement: This product 
+//    includes software developed by tm3d.de and its contributors. 
+//  * Neither the name of tm3d.de nor the names of its contributors may 
+//    be used to endorse or promote products derived from this software 
+//    without specific prior written permission. 
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+.global TIMER_INTERRUPT
+       TIMER_INTERRUPT:
+       push r_temp
+       in r_temp,_SFR_IO_ADDR(SREG)  
+       push r_temp
+       sbic OW_PIN,OW_PINN  ; abkuerzung wenn Leitung schon h
+       rjmp tint_end ; Leitung 1 kein Reset
+       ldi r_temp,0  
+       out TCNT_REG,r_temp
+tint_loop_rend:
+       sbis OW_PIN,OW_PINN ;warten bis leitung wieder h 
+       rjmp tint_loop_rend
+       in r_temp,TCNT_REG ;schauen ob es lange genug gedauert hat fuer reset
+       cpi r_temp,OWT_RESET2 
+       brlo tint_end
+       ldi r_temp,0
+       out TCNT_REG,r_temp
+       ;zwischen Reset und Presets
+tint_loop_res_pres:
+       in r_temp,TCNT_REG
+       cpi r_temp,OWT_RESET_PRESENT
+       brlo tint_loop_res_pres ;Warten zwischen reset und presets
+       sbi OW_DDR,OW_PINN  ;presents impuls
+       ;reset impuls
+tint_loop_pres:
+       in r_temp,TCNT_REG
+       cpi r_temp,OWT_PRESENT
+       brlo tint_loop_pres
+       cbi OW_DDR,OW_PINN  
+       ldi r_temp,OW_READ_ROM_COMMAND ; Initialisieren von Rom command
+       sts mode,r_temp
+       ldi r_temp,1
+       sts reset_indicator,r_temp
+       sts bcount,r_temp ;bit eins
+       clr r_temp
+       sts sendflag,r_temp ;empfangen (rom_command)
+       ;sts wzero,r_temp ;alles 0 
+       RESETZEROMARKER
+       CLEAR_INTERRUPT_FLAG
+tint_end:
+       ;CLEAR_INTERRUPT_FLAG
+       DIS_TIM_INT
+       pop r_temp
+       out _SFR_IO_ADDR(SREG),r_temp
+       pop r_temp
+       reti
+;;;
diff --git a/programmer/flash/avrdude.conf b/programmer/flash/avrdude.conf
new file mode 100644 (file)
index 0000000..4ecdd78
--- /dev/null
@@ -0,0 +1,16941 @@
+# $Id: avrdude.conf.in 1012 2011-09-15 14:57:51Z joerg_wunsch $ -*- text -*-
+#
+# AVRDUDE Configuration File
+#
+# This file contains configuration data used by AVRDUDE which describes
+# the programming hardware pinouts and also provides part definitions.
+# AVRDUDE's "-C" command line option specifies the location of the
+# configuration file.  The "-c" option names the programmer configuration
+# which must match one of the entry's "id" parameter.  The "-p" option
+# identifies which part AVRDUDE is going to be programming and must match
+# one of the parts' "id" parameter.
+#
+# Possible entry formats are:
+#
+#   programmer
+#       id       = <id1> [, <id2> [, <id3>] ...] ;  # <idN> are quoted strings
+#       desc     = <description> ;                  # quoted string
+#       type     = par | stk500 | stk500v2 | stk500pp | stk500hvsp | stk500generic |
+#                  stk600 | stk600pp | stk600hvsp |
+#                  avr910 | butterfly | usbasp |
+#                  jtagmki | jtagmkii | jtagmkii_isp | jtagmkii_dw |
+#                  jtagmkII_avr32 | jtagmkii_pdi |
+#                  dragon_dw | dragon_jtag | dragon_isp | dragon_pp |
+#                  dragon_hvsp | dragon_pdi | arduino | wiring; # programmer type
+#       baudrate = <num> ;                          # baudrate for avr910-programmer
+#       vcc      = <num1> [, <num2> ... ] ;         # pin number(s)
+#       reset    = <num> ;                          # pin number
+#       sck      = <num> ;                          # pin number
+#       mosi     = <num> ;                          # pin number
+#       miso     = <num> ;                          # pin number
+#       errled   = <num> ;                          # pin number
+#       rdyled   = <num> ;                          # pin number
+#       pgmled   = <num> ;                          # pin number
+#       vfyled   = <num> ;                          # pin number
+#                      usbvid   = <hexnum>;                                                                                            # USB VID (Vendor ID)
+#       usbpid   = <hexnum>;                                                                                           #       USB PID (Product ID)
+#       usbdev   = <interface>;                                                                                        # USB interface or other device info 
+#       usbvendor = <vendorname>;                                                                              #       USB Vendor Name
+#       usbproduct = <productname>;                                                                    # USB Product Name
+#       usbsn    = <serialno>;                      # USB Serial Number
+#
+#        To invert a bit, use = ~ <num>, the spaces are important.
+#     ;
+#
+#   part
+#       id               = <id> ;                 # quoted string
+#       desc             = <description> ;        # quoted string
+#       has_jtag         = <yes/no> ;             # part has JTAG i/f
+#       has_debugwire    = <yes/no> ;             # part has debugWire i/f
+#       has_pdi          = <yes/no> ;             # part has PDI i/f
+#       has_tpi          = <yes/no> ;             # part has TPI i/f
+#       devicecode       = <num> ;            # deprecated, use stk500_devcode
+#       stk500_devcode   = <num> ;                # numeric
+#       avr910_devcode   = <num> ;                # numeric
+#       signature        = <num> <num> <num> ;    # signature bytes
+#       chip_erase_delay = <num> ;                # micro-seconds
+#       reset            = dedicated | io;
+#       retry_pulse      = reset | sck;
+#       pgm_enable       = <instruction format> ;
+#       chip_erase       = <instruction format> ;
+#       chip_erase_delay = <num> ;                # chip erase delay (us)
+#       # STK500 parameters (parallel programming IO lines)
+#       pagel            = <num> ;                # pin name in hex, i.e., 0xD7
+#       bs2              = <num> ;                # pin name in hex, i.e., 0xA0
+#       serial           = <yes/no> ;             # can use serial downloading
+#       parallel         = <yes/no/pseudo>;       # can use par. programming
+#       # STK500v2 parameters, to be taken from Atmel's XML files
+#       timeout          = <num> ;
+#       stabdelay        = <num> ;
+#       cmdexedelay      = <num> ;
+#       synchloops       = <num> ;
+#       bytedelay        = <num> ;
+#       pollvalue        = <num> ;
+#       pollindex        = <num> ;
+#       predelay         = <num> ;
+#       postdelay        = <num> ;
+#       pollmethod       = <num> ;
+#       mode             = <num> ;
+#       delay            = <num> ;
+#       blocksize        = <num> ;
+#       readsize         = <num> ;
+#       hvspcmdexedelay  = <num> ;
+#       # STK500v2 HV programming parameters, from XML
+#       pp_controlstack  = <num>, <num>, ...;   # PP only
+#       hvsp_controlstack = <num>, <num>, ...;  # HVSP only
+#       hventerstabdelay = <num>;
+#       progmodedelay    = <num>;               # PP only
+#       latchcycles      = <num>;
+#       togglevtg        = <num>;
+#       poweroffdelay    = <num>;
+#       resetdelayms     = <num>;
+#       resetdelayus     = <num>;
+#       hvleavestabdelay = <num>;
+#       resetdelay       = <num>;
+#       synchcycles      = <num>;               # HVSP only
+#       chiperasepulsewidth = <num>;            # PP only
+#       chiperasepolltimeout = <num>;
+#       chiperasetime    = <num>;               # HVSP only
+#       programfusepulsewidth = <num>;          # PP only
+#       programfusepolltimeout = <num>;
+#       programlockpulsewidth = <num>;          # PP only
+#       programlockpolltimeout = <num>;
+#       # JTAG ICE mkII parameters, also from XML files
+#       allowfullpagebitstream = <yes/no> ;
+#       enablepageprogramming = <yes/no> ;
+#       idr              = <num> ;                # IO addr of IDR (OCD) reg.
+#       rampz            = <num> ;                # IO addr of RAMPZ reg.
+#       spmcr            = <num> ;                # mem addr of SPMC[S]R reg.
+#       eecr             = <num> ;                # mem addr of EECR reg.
+#                                                 # (only when != 0x3c)
+#       is_avr32         = <yes/no> ;             # AVR32 part
+#
+#       memory <memtype>
+#           paged           = <yes/no> ;          # yes / no
+#           size            = <num> ;             # bytes
+#           page_size       = <num> ;             # bytes
+#           num_pages       = <num> ;             # numeric
+#           min_write_delay = <num> ;             # micro-seconds
+#           max_write_delay = <num> ;             # micro-seconds
+#           readback_p1     = <num> ;             # byte value
+#           readback_p2     = <num> ;             # byte value
+#           pwroff_after_write = <yes/no> ;       # yes / no
+#           read            = <instruction format> ;
+#           write           = <instruction format> ;
+#           read_lo         = <instruction format> ;
+#           read_hi         = <instruction format> ;
+#           write_lo        = <instruction format> ;
+#           write_hi        = <instruction format> ;
+#           loadpage_lo     = <instruction format> ;
+#           loadpage_hi     = <instruction format> ;
+#           writepage       = <instruction format> ;
+#         ;
+#     ;
+#
+# If any of the above parameters are not specified, the default value
+# of 0 is used for numerics or the empty string ("") for string
+# values.  If a required parameter is left empty, AVRDUDE will
+# complain.
+#
+# NOTES:
+#   * 'devicecode' is the device code used by the STK500 (see codes 
+#       listed below)
+#   * Not all memory types will implement all instructions.
+#   * AVR Fuse bits and Lock bits are implemented as a type of memory.
+#   * Example memory types are:
+#       "flash", "eeprom", "fuse", "lfuse" (low fuse), "hfuse" (high
+#       fuse), "signature", "calibration", "lock"
+#   * The memory type specified on the avrdude command line must match
+#     one of the memory types defined for the specified chip.
+#   * The pwroff_after_write flag causes avrdude to attempt to
+#     power the device off and back on after an unsuccessful write to
+#     the affected memory area if VCC programmer pins are defined.  If
+#     VCC pins are not defined for the programmer, a message
+#     indicating that the device needs a power-cycle is printed out.
+#     This flag was added to work around a problem with the
+#     at90s4433/2333's; see the at90s4433 errata at:
+#
+#         http://www.atmel.com/atmel/acrobat/doc1280.pdf
+#
+# INSTRUCTION FORMATS
+#
+#    Instruction formats are specified as a comma seperated list of
+#    string values containing information (bit specifiers) about each
+#    of the 32 bits of the instruction.  Bit specifiers may be one of
+#    the following formats:
+#
+#       '1'  = the bit is always set on input as well as output
+#
+#       '0'  = the bit is always clear on input as well as output
+#
+#       'x'  = the bit is ignored on input and output
+#
+#       'a'  = the bit is an address bit, the bit-number matches this bit
+#              specifier's position within the current instruction byte
+#
+#       'aN' = the bit is the Nth address bit, bit-number = N, i.e., a12
+#              is address bit 12 on input, a0 is address bit 0.
+#
+#       'i'  = the bit is an input data bit
+#
+#       'o'  = the bit is an output data bit
+#
+#    Each instruction must be composed of 32 bit specifiers.  The
+#    instruction specification closely follows the instruction data
+#    provided in Atmel's data sheets for their parts.
+#
+# See below for some examples.
+#
+#
+# The following are STK500 part device codes to use for the
+# "devicecode" field of the part.  These came from Atmel's software
+# section avr061.zip which accompanies the application note
+# AVR061 available from:
+#
+#      http://www.atmel.com/atmel/acrobat/doc2525.pdf
+#
+
+#define ATTINY10    0x10  /* the _old_ one that never existed! */
+#define ATTINY11    0x11
+#define ATTINY12    0x12
+#define ATTINY15    0x13
+#define ATTINY13    0x14
+
+#define ATTINY22    0x20
+#define ATTINY26    0x21
+#define ATTINY28    0x22
+#define ATTINY2313  0x23
+
+#define AT90S1200   0x33
+
+#define AT90S2313   0x40
+#define AT90S2323   0x41
+#define AT90S2333   0x42
+#define AT90S2343   0x43
+
+#define AT90S4414   0x50
+#define AT90S4433   0x51
+#define AT90S4434   0x52
+#define ATMEGA48    0x59
+
+#define AT90S8515   0x60
+#define AT90S8535   0x61
+#define AT90C8534   0x62
+#define ATMEGA8515  0x63
+#define ATMEGA8535  0x64
+
+#define ATMEGA8     0x70
+#define ATMEGA88    0x73
+#define ATMEGA168   0x86
+
+#define ATMEGA161   0x80
+#define ATMEGA163   0x81
+#define ATMEGA16    0x82
+#define ATMEGA162   0x83
+#define ATMEGA169   0x84
+
+#define ATMEGA323   0x90
+#define ATMEGA32    0x91
+
+#define ATMEGA64    0xA0
+
+#define ATMEGA103   0xB1
+#define ATMEGA128   0xB2
+#define AT90CAN128  0xB3
+#define AT90CAN64   0xB3
+#define AT90CAN32   0xB3
+
+#define AT86RF401   0xD0
+
+#define AT89START   0xE0
+#define AT89S51            0xE0
+#define AT89S52            0xE1
+
+# The following table lists the devices in the original AVR910
+# appnote:
+# |Device |Signature | Code |
+# +-------+----------+------+
+# |tiny12 | 1E 90 05 | 0x55 |
+# |tiny15 | 1E 90 06 | 0x56 |
+# |       |          |      |
+# | S1200 | 1E 90 01 | 0x13 |
+# |       |          |      |
+# | S2313 | 1E 91 01 | 0x20 |
+# | S2323 | 1E 91 02 | 0x48 |
+# | S2333 | 1E 91 05 | 0x34 |
+# | S2343 | 1E 91 03 | 0x4C |
+# |       |          |      |
+# | S4414 | 1E 92 01 | 0x28 |
+# | S4433 | 1E 92 03 | 0x30 |
+# | S4434 | 1E 92 02 | 0x6C |
+# |       |          |      |
+# | S8515 | 1E 93 01 | 0x38 |
+# | S8535 | 1E 93 03 | 0x68 |
+# |       |          |      |
+# |mega32 | 1E 95 01 | 0x72 |
+# |mega83 | 1E 93 05 | 0x65 |
+# |mega103| 1E 97 01 | 0x41 |
+# |mega161| 1E 94 01 | 0x60 |
+# |mega163| 1E 94 02 | 0x64 |
+
+# Appnote AVR109 also has a table of AVR910 device codes, which
+# lists:
+# dev         avr910   signature
+# ATmega8     0x77     0x1E 0x93 0x07
+# ATmega8515  0x3B     0x1E 0x93 0x06
+# ATmega8535  0x6A     0x1E 0x93 0x08
+# ATmega16    0x75     0x1E 0x94 0x03
+# ATmega162   0x63     0x1E 0x94 0x04
+# ATmega163   0x66     0x1E 0x94 0x02
+# ATmega169   0x79     0x1E 0x94 0x05
+# ATmega32    0x7F     0x1E 0x95 0x02
+# ATmega323   0x73     0x1E 0x95 0x01
+# ATmega64    0x46     0x1E 0x96 0x02
+# ATmega128   0x44     0x1E 0x97 0x02
+#
+# These codes refer to "BOOT" device codes which are apparently
+# different than standard device codes, for whatever reasons
+# (often one above the standard code).
+
+# There are several extended versions of AVR910 implementations around
+# in the Internet.  These add the following codes (only devices that
+# actually exist are listed):
+
+# ATmega8515   0x3A
+# ATmega128    0x43
+# ATmega64     0x45
+# ATtiny26     0x5E
+# ATmega8535   0x69
+# ATmega32     0x72
+# ATmega16     0x74
+# ATmega8      0x76
+# ATmega169    0x78
+
+#
+# Overall avrdude defaults
+#
+default_parallel   = "lpt1";
+default_serial     = "com1";
+# default_bitclock = 2.5
+
+
+#
+# PROGRAMMER DEFINITIONS
+#
+
+# http://wiring.org.co/
+# Basically STK500v2 protocol, with some glue to trigger the
+# bootloader.
+programmer
+  id    = "wiring";
+  desc  = "Wiring";
+  type  = wiring;
+;
+
+programmer
+  id    = "arduino";
+  desc  = "Arduino";
+  type  = arduino;
+;
+# this will interface with the chips on these programmers:
+#
+# http://real.kiev.ua/old/avreal/en/adapters
+# http://www.amontec.com/jtagkey.shtml, jtagkey-tiny.shtml
+# http://www.olimex.com/dev/arm-usb-ocd.html, arm-usb-tiny.html
+# http://www.ethernut.de/en/hardware/turtelizer/index.html
+# http://elk.informatik.fh-augsburg.de/hhweb/doc/openocd/usbjtag/usbjtag.html
+# http://dangerousprototypes.com/docs/FT2232_breakout_board
+# http://www.ftdichip.com/Products/Modules/DLPModules.htm,DLP-2232*,DLP-USB1232H
+# http://flashrom.org/FT2232SPI_Programmer
+# 
+# The drivers will look for a specific device and use the first one found.
+# If you have mulitple devices, then look for unique information (like SN)
+# And fill that in here.
+
+programmer
+  id   = "avrftdi";
+  desc = "FT2232D based generic programmer";
+  type = avrftdi;
+  usbvid     = 0x0403;
+  usbpid     = 0x6010;
+  usbvendor  = "";
+  usbproduct = "";
+  usbdev     = "A";
+  usbsn      = "";
+#ISP-signals - lower ACBUS-Nibble (default)
+  reset  = 4;
+  sck    = 1;
+  mosi   = 2;
+  miso   = 3;
+#LED SIGNALs - higher ACBUS-Nibble
+#  errled = 5;
+#  rdyled = 6;
+#  pgmled = 7;
+#  vfyled = 8;
+#Buffer Signal - ADBUS - Nibble
+#  buff   = 9;
+;
+# This is an implementation of the above with a buffer IC (74AC244) and
+# 4 LEDs directly attached, active low. The buff and reset pins are
+# understood (by avrdude) to be active low, so there's no
+# need to invert the bits.
+programmer
+  id   = "2232HIO";
+  desc = "FT2232H based generic programmer";
+  type = avrftdi;
+  usbvid     = 0x0403;
+# Note: This PID is reserved for generic H devices and 
+# should be programmed into the EEPROM
+#  usbpid     = 0x8A48;
+   usbpid    = 0x6010;
+  usbdev = "A";
+  usbvendor  = "";
+  usbproduct = "";
+  usbsn      = "";
+#ISP-signals 
+  reset  = 4;
+  sck    = 1;
+  mosi   = 2;
+  miso   = 3;
+  buff   = 5;
+#LED SIGNALs 
+  errled = ~ 12;
+  rdyled = ~ 15;
+  pgmled = ~ 14;
+  vfyled = ~ 13;
+;
+
+programmer
+  id    = "jtagkey";
+  desc  = "Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2";
+  type  = avrftdi;
+  usbvid     = 0x0403;
+# Note: This PID is used in all JTAGKey variants
+  usbpid    = 0xCFF8;
+  usbdev = "A";
+  usbvendor  = "";
+  usbproduct = "";
+  usbsn      = "";
+#ISP-signals => 20 - Pin connector on JTAGKey
+  reset  = 4; # TMS 7 violet
+  sck    = 1; # TCK 9 white
+  mosi   = 2; # TDI 5 green
+  miso   = 3; # TDO 13 orange
+  buff   = 5;
+# VTG           VREF 1 brown with red tip
+# GND           GND 20 black
+# The colors are on the 20 pin breakout cable
+# from Amontec
+;
+
+programmer
+  id    = "avrisp";
+  desc  = "Atmel AVR ISP";
+  type  = stk500;
+;
+
+programmer
+  id    = "avrispv2";
+  desc  = "Atmel AVR ISP V2";
+  type  =  stk500v2;
+;
+
+programmer
+  id    = "avrispmkII";
+  desc  = "Atmel AVR ISP mkII";
+  type  =  stk500v2;
+;
+
+programmer
+  id    = "avrisp2";
+  desc  = "Atmel AVR ISP mkII";
+  type  =  stk500v2;
+;
+
+programmer
+  id    = "buspirate";
+  desc  = "The Bus Pirate";
+  type  = buspirate;
+;
+
+# This is supposed to be the "default" STK500 entry.
+# Attempts to select the correct firmware version
+# by probing for it.  Better use one of the entries
+# below instead.
+programmer
+  id    = "stk500";
+  desc  = "Atmel STK500";
+  type  = stk500generic;
+;
+
+programmer
+  id    = "stk500v1";
+  desc  = "Atmel STK500 Version 1.x firmware";
+  type  = stk500;
+;
+
+programmer
+  id    = "mib510";
+  desc  = "Crossbow MIB510 programming board";
+  type  = stk500;
+;
+
+programmer
+  id    = "stk500v2";
+  desc  = "Atmel STK500 Version 2.x firmware";
+  type  = stk500v2;
+;
+
+programmer
+  id    = "stk500pp";
+  desc  = "Atmel STK500 V2 in parallel programming mode";
+  type  = stk500pp;
+;
+
+programmer
+  id    = "stk500hvsp";
+  desc  = "Atmel STK500 V2 in high-voltage serial programming mode";
+  type  = stk500hvsp;
+;
+
+programmer
+  id    = "stk600";
+  desc  = "Atmel STK600";
+  type  = stk600;
+;
+
+programmer
+  id    = "stk600pp";
+  desc  = "Atmel STK600 in parallel programming mode";
+  type  = stk600pp;
+;
+
+programmer
+  id    = "stk600hvsp";
+  desc  = "Atmel STK600 in high-voltage serial programming mode";
+  type  = stk600hvsp;
+;
+
+programmer
+  id    = "avr910";
+  desc  = "Atmel Low Cost Serial Programmer";
+  type  = avr910;
+;
+
+programmer
+  id    = "usbasp";
+  desc  = "USBasp, http://www.fischl.de/usbasp/";
+  type  = usbasp;
+;
+
+programmer
+  id    = "usbtiny";
+  desc  = "USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/";
+  type  = usbtiny;
+;
+
+programmer
+  id    = "butterfly";
+  desc  = "Atmel Butterfly Development Board";
+  type  = butterfly;
+;
+
+programmer
+  id    = "avr109";
+  desc  = "Atmel AppNote AVR109 Boot Loader";
+  type  = butterfly;
+;
+
+programmer
+  id    = "avr911";
+  desc  = "Atmel AppNote AVR911 AVROSP";
+  type  = butterfly;
+;
+# suggested in http://forum.mikrokopter.de/topic-post48317.html
+programmer
+  id    = "mkbutterfly";
+  desc  = "Mikrokopter.de Butterfly";
+  type  = butterfly_mk;
+;
+
+programmer
+  id    = "butterfly_mk";
+  desc  = "Mikrokopter.de Butterfly";
+  type  = butterfly_mk;
+;
+
+programmer
+  id    = "jtagmkI";
+  desc  = "Atmel JTAG ICE (mkI)";
+  baudrate = 115200;    # default is 115200
+  type  = jtagmki;
+;
+
+# easier to type
+programmer
+  id    = "jtag1";
+  desc  = "Atmel JTAG ICE (mkI)";
+  baudrate = 115200;    # default is 115200
+  type  = jtagmki;
+;
+
+# easier to type
+programmer
+  id    = "jtag1slow";
+  desc  = "Atmel JTAG ICE (mkI)";
+  baudrate = 19200;
+  type  = jtagmki;
+;
+
+programmer
+  id    = "jtagmkII";
+  desc  = "Atmel JTAG ICE mkII";
+  baudrate = 19200;    # default is 19200
+  type  = jtagmkii;
+;
+
+# easier to type
+programmer
+  id    = "jtag2slow";
+  desc  = "Atmel JTAG ICE mkII";
+  baudrate = 19200;    # default is 19200
+  type  = jtagmkii;
+;
+
+# JTAG ICE mkII @ 115200 Bd
+programmer
+  id    = "jtag2fast";
+  desc  = "Atmel JTAG ICE mkII";
+  baudrate = 115200;
+  type  = jtagmkii;
+;
+
+# make the fast one the default, people will love that
+programmer
+  id    = "jtag2";
+  desc  = "Atmel JTAG ICE mkII";
+  baudrate = 115200;
+  type  = jtagmkii;
+;
+
+# JTAG ICE mkII in ISP mode
+programmer
+  id    = "jtag2isp";
+  desc  = "Atmel JTAG ICE mkII in ISP mode";
+  baudrate = 115200;
+  type  = jtagmkii_isp;
+;
+
+# JTAG ICE mkII in debugWire mode
+programmer
+  id    = "jtag2dw";
+  desc  = "Atmel JTAG ICE mkII in debugWire mode";
+  baudrate = 115200;
+  type  = jtagmkii_dw;
+;
+
+# JTAG ICE mkII in AVR32 mode
+programmer
+  id    = "jtagmkII_avr32";
+  desc  = "Atmel JTAG ICE mkII im AVR32 mode";
+  baudrate = 115200;
+  type  = jtagmkii_avr32;
+;
+
+# JTAG ICE mkII in AVR32 mode
+programmer
+  id    = "jtag2avr32";
+  desc  = "Atmel JTAG ICE mkII im AVR32 mode";
+  baudrate = 115200;
+  type  = jtagmkii_avr32;
+;
+
+# JTAG ICE mkII in PDI mode
+programmer
+  id    = "jtag2pdi";
+  desc  = "Atmel JTAG ICE mkII PDI mode";
+  baudrate = 115200;
+  type  = jtagmkii_pdi;
+;
+
+# AVR Dragon in JTAG mode
+programmer
+  id    = "dragon_jtag";
+  desc  = "Atmel AVR Dragon in JTAG mode";
+  baudrate = 115200;
+  type  = dragon_jtag;
+;
+
+# AVR Dragon in ISP mode
+programmer
+  id    = "dragon_isp";
+  desc  = "Atmel AVR Dragon in ISP mode";
+  baudrate = 115200;
+  type  = dragon_isp;
+;
+
+# AVR Dragon in PP mode
+programmer
+  id    = "dragon_pp";
+  desc  = "Atmel AVR Dragon in PP mode";
+  baudrate = 115200;
+  type  = dragon_pp;
+;
+
+# AVR Dragon in HVSP mode
+programmer
+  id    = "dragon_hvsp";
+  desc  = "Atmel AVR Dragon in HVSP mode";
+  baudrate = 115200;
+  type  = dragon_hvsp;
+;
+
+# AVR Dragon in debugWire mode
+programmer
+  id    = "dragon_dw";
+  desc  = "Atmel AVR Dragon in debugWire mode";
+  baudrate = 115200;
+  type  = dragon_dw;
+;
+
+# AVR Dragon in PDI mode
+programmer
+  id    = "dragon_pdi";
+  desc  = "Atmel AVR Dragon in PDI mode";
+  baudrate = 115200;
+  type  = dragon_pdi;
+;
+
+programmer
+  id    = "pavr";
+  desc  = "Jason Kyle's pAVR Serial Programmer";
+  type  = avr910;
+;
+
+# Parallel port programmers.
+
+programmer
+  id    = "bsd";
+  desc  = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/";
+  type  = par;
+  vcc   = 2, 3, 4, 5;
+  reset = 7;
+  sck   = 8;
+  mosi  = 9;
+  miso  = 10;
+;
+
+programmer
+  id    = "stk200";
+  desc  = "STK200";
+  type  = par;
+  buff  = 4, 5;
+  sck   = 6;
+  mosi  = 7;
+  reset = 9;
+  miso  = 10;
+;
+
+# The programming dongle used by the popular Ponyprog
+# utility.  It is almost similar to the STK200 one,
+# except that there is a LED indicating that the
+# programming is currently in progress.
+
+programmer
+  id    = "pony-stk200";
+  desc  = "Pony Prog STK200";
+  type  = par;
+  buff  = 4, 5;
+  sck   = 6;
+  mosi  = 7;
+  reset = 9;
+  miso  = 10;
+  pgmled = 8; 
+;
+
+programmer
+  id    = "dt006";
+  desc  = "Dontronics DT006";
+  type  = par;
+  reset = 4;
+  sck   = 5;
+  mosi  = 2;
+  miso  = 11;
+;
+
+programmer
+  id    = "dasaftdi";
+  desc  = "FTDI serial port banging, reset=rts sck=dtr mosi=txd miso=cts";
+  type  = serbb;
+  reset = ~7;
+  sck   = ~4;
+  mosi  = ~3;
+  miso  = ~8;
+;
+
+programmer
+  id    = "dasaftdit1";
+  desc  = "FTDI serial port banging, reset=rts sck=dtr mosi=txd miso=cts";
+  type  = serbb;
+  reset = ~7;
+  sck   = ~4;
+  mosi  = ~3;
+  miso  = ~8;
+;
+
+
+programmer
+  id    = "bascom";
+  desc  = "Bascom SAMPLE programming cable";
+  type  = par;
+  reset = 4;
+  sck   = 5;
+  mosi  = 2;
+  miso  = 11;
+;
+
+programmer
+  id     = "alf";
+  desc   = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/";
+  type   = par;
+  vcc    = 2, 3, 4, 5;
+  buff   = 6;
+  reset  = 7;
+  sck    = 8;
+  mosi   = 9;
+  miso   = 10;
+  errled = 1;
+  rdyled = 14;
+  pgmled = 16;
+  vfyled = 17;
+;
+
+programmer
+  id    = "sp12";
+  desc  = "Steve Bolt's Programmer";
+  type  = par;
+  vcc   = 4,5,6,7,8;
+  reset = 3;
+  sck   = 2;
+  mosi  = 9;
+  miso  = 11;
+;
+
+programmer
+  id     = "picoweb";
+  desc   = "Picoweb Programming Cable, http://www.picoweb.net/";
+  type   = par;
+  reset  = 2;
+  sck    = 3;
+  mosi   = 4;
+  miso   = 13;
+;
+
+programmer
+  id    = "abcmini";
+  desc  = "ABCmini Board, aka Dick Smith HOTCHIP";
+  type  = par;
+  reset = 4;
+  sck   = 3;
+  mosi  = 2;
+  miso  = 10;
+;
+
+programmer
+  id    = "futurlec";
+  desc  = "Futurlec.com programming cable.";
+  type  = par;
+  reset = 3;
+  sck   = 2;
+  mosi  = 1;
+  miso  = 10;
+;
+
+
+# From the contributor of the "xil" jtag cable:
+# The "vcc" definition isn't really vcc (the cable gets its power from
+# the programming circuit) but is necessary to switch one of the
+# buffer lines (trying to add it to the "buff" lines doesn't work in 
+# avrdude versions before 5.5j).
+# With this, TMS connects to RESET, TDI to MOSI, TDO to MISO and TCK
+# to SCK (plus vcc/gnd of course)
+programmer
+  id    = "xil";
+  desc  = "Xilinx JTAG cable";
+  type  = par;
+  mosi  = 2;
+  sck   = 3;
+  reset = 4;
+  buff  = 5;
+  miso  = 13;
+  vcc   = 6;
+;
+
+
+programmer
+  id = "dapa";
+  desc = "Direct AVR Parallel Access cable";
+  type = par;
+  vcc   = 3;
+  reset = 16;
+  sck = 1;
+  mosi = 2;
+  miso = 11;
+;
+
+programmer
+  id    = "atisp";
+  desc  = "AT-ISP V1.1 programming cable for AVR-SDK1 from <http://micro-research.co.th/> micro-research.co.th";
+  type  = par;
+  reset = ~6;
+  sck   = ~8;
+  mosi  = ~7;
+  miso  = ~10;
+;
+
+programmer
+  id    = "ere-isp-avr";
+  desc  = "ERE ISP-AVR <http://www.ere.co.th/download/sch050713.pdf>";
+  type  = par;
+  reset = ~4;
+  sck   = 3;
+  mosi  = 2;
+  miso  = 10;
+;
+
+programmer
+  id    = "blaster";
+  desc  = "Altera ByteBlaster";
+  type  = par;
+  sck   = 2;
+  miso  = 11;
+  reset = 3;
+  mosi  = 8;
+  buff  = 14;
+;
+
+# It is almost same as pony-stk200, except vcc on pin 5 to auto
+# disconnect port (download on http://electropol.free.fr)
+programmer
+  id    = "frank-stk200";
+  desc  = "Frank STK200";
+  type  = par;
+  vcc   = 5;
+  sck   = 6;
+  mosi  = 7;
+  reset = 9;
+  miso  = 10;
+  pgmled = 8;
+;
+
+# The AT98ISP Cable is a simple parallel dongle for AT89 family.
+# http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2877
+programmer
+id = "89isp";
+desc = "Atmel at89isp cable";
+type = par;
+reset = 17;
+sck = 1;
+mosi = 2;
+miso = 10;
+;
+
+
+#
+# some ultra cheap programmers use bitbanging on the 
+# serialport.
+#
+# PC - DB9 - Pins for RS232:
+#
+# GND   5   -- |O
+#              |   O| <-   9   RI
+# DTR   4   <- |O   |
+#              |   O| <-   8   CTS
+# TXD   3   <- |O   |
+#              |   O| ->   7   RTS
+# RXD   2   -> |O   |
+#              |   O| <-   6   DSR
+# DCD   1   -> |O
+#
+# Using RXD is currently not supported.
+# Using RI is not supported under Win32 but is supported under Posix.
+
+# serial ponyprog design (dasa2 in uisp)
+# reset=!txd sck=rts mosi=dtr miso=cts
+
+programmer
+  id    = "ponyser";
+  desc  = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts";
+  type  = serbb;
+  reset = ~3;
+  sck   = 7;
+  mosi  = 4;
+  miso  = 8;
+;
+
+# Same as above, different name
+# reset=!txd sck=rts mosi=dtr miso=cts
+
+programmer
+  id    = "siprog";
+  desc  = "Lancos SI-Prog <http://www.lancos.com/siprogsch.html>";
+  type  = serbb;
+  reset = ~3;
+  sck   = 7;
+  mosi  = 4;
+  miso  = 8;
+;
+
+# unknown (dasa in uisp)
+# reset=rts sck=dtr mosi=txd miso=cts
+
+programmer
+  id    = "dasa";
+  desc  = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts";
+  type  = serbb;
+  reset = 7;
+  sck   = 4;
+  mosi  = 3;
+  miso  = 8;
+;
+
+# unknown (dasa3 in uisp)
+# reset=!dtr sck=rts mosi=txd miso=cts
+
+programmer
+  id    = "dasa3";
+  desc  = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts";
+  type  = serbb;
+  reset = ~4;
+  sck   = 7;
+  mosi  = 3;
+  miso  = 8;
+;
+
+# C2N232i (jumper configuration "auto")
+# reset=dtr sck=!rts mosi=!txd miso=!cts
+
+programmer
+  id    = "c2n232i";
+  desc  = "serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts";
+  type  = serbb;
+  reset = 4;
+  sck   = ~7;
+  mosi  = ~3;
+  miso  = ~8;
+;
+
+#
+# PART DEFINITIONS
+#
+
+#------------------------------------------------------------
+# ATtiny11
+#------------------------------------------------------------
+
+# This is an HVSP-only device.
+
+part
+    id                  = "t11";
+    desc                = "ATtiny11";
+    stk500_devcode      = 0x11;
+    signature           = 0x1e 0x90 0x04;
+    chip_erase_delay    = 20000;
+
+    timeout            = 200;
+    hvsp_controlstack     =
+        0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x00,
+        0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78,
+        0x78, 0x00, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 0;
+    resetdelayus        = 50;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+    memory "eeprom"
+        size            = 64;
+       blocksize       = 64;
+       readsize        = 256;
+       delay           = 5;
+    ;
+
+    memory "flash"
+        size            = 1024;
+       blocksize       = 128;
+       readsize        = 256;
+       delay           = 3;
+    ;
+
+    memory "signature"
+        size            = 3;
+    ;
+
+    memory "lock"
+        size            = 1;
+    ;
+
+    memory "calibration"
+        size            = 1;
+    ;
+
+    memory "fuse"
+        size            = 1;
+    ;
+;
+
+#------------------------------------------------------------
+# ATtiny12
+#------------------------------------------------------------
+
+part
+    id                  = "t12";
+    desc                = "ATtiny12";
+    stk500_devcode      = 0x12;
+    avr910_devcode      = 0x55;
+    signature           = 0x1e 0x90 0x05;
+    chip_erase_delay    = 20000;
+    pgm_enable          = "1 0 1 0  1 1 0 0   0 1 0 1  0 0 1 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    chip_erase          = "1 0 1 0  1 1 0 0   1 0 0 x  x x x x",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    hvsp_controlstack   =
+        0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x00,
+        0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78,
+        0x78, 0x00, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00;
+    hventerstabdelay    = 100;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 0;
+    resetdelayus        = 50;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+    memory "eeprom"
+        size            = 64;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "1  0  1  0   0  0  0  0    x x x x  x x x x",
+                          "x  x a5 a4  a3 a2 a1 a0    o o o o  o o o o";
+
+        write           = "1  1  0  0   0  0  0  0    x x x x  x x x x",
+                          "x  x a5 a4  a3 a2 a1 a0    i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 8;
+       blocksize       = 64;
+       readsize        = 256;
+    ;
+
+    memory "flash"
+        size            = 1024;
+        min_write_delay = 4500;
+        max_write_delay = 20000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0  0  1  0   0  0  0  0",
+                          "  x  x  x  x   x  x  x a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        read_hi         = "  0  0  1  0   1  0  0  0",
+                          "  x  x  x  x   x  x  x a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        write_lo        = "  0  1  0  0   0  0  0  0",
+                          "  x  x  x  x   x  x  x a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        write_hi        = "  0  1  0  0   1  0  0  0",
+                          "  x  x  x  x   x  x  x a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+       mode            = 0x04;
+       delay           = 5;
+       blocksize       = 128;
+       readsize        = 256;
+    ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0 a1 a0    o o o o  o o o o";
+    ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0  1  0  1   1  0  0  0    x x x x  x x x x",
+                          "x  x  x  x   x  x  x  x    x x x x  x o o x";
+
+        write           = "1  0  1  0   1  1  0  0    1 1 1 1  1 i i 1",
+                          "x  x  x  x   x  x  x  x    x x x x  x x x x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+    ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0  0  1  1   1  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0  0  0    o o o o  o o o o";
+    ;
+
+    memory "fuse"
+        size            = 1;
+        read            = "0  1  0  1   0  0  0  0    x x x x  x x x x",
+                          "x  x  x  x   x  x  x  x    o o o o  o o o o";
+
+        write           = "1  0  1  0   1  1  0  0    1 0 1 x  x x x x",
+                          "x  x  x  x   x  x  x  x    i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+    ;
+;
+
+#------------------------------------------------------------
+# ATtiny13
+#------------------------------------------------------------
+
+part
+    id                  = "t13";
+    desc                = "ATtiny13";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x0E, 0x1E;
+     eeprom_instr  = 0xBB, 0xFE, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBC, 0x0E, 0xB4, 0x0E, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+    stk500_devcode      = 0x14;
+    signature           = 0x1e 0x90 0x07;
+    chip_erase_delay    = 4000;
+    pgm_enable          = "1 0 1 0  1 1 0 0   0 1 0 1  0 0 1 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    chip_erase          = "1 0 1 0  1 1 0 0   1 0 0 x  x x x x",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    hvsp_controlstack     =
+       0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66,
+        0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78,
+        0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 0;
+    resetdelayus        = 90;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+    memory "eeprom"
+        size            = 64;
+        page_size       = 4;
+        min_write_delay = 4000;
+        max_write_delay = 4000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "1  0  1  0   0  0  0  0    0 0 0 x  x x x x",
+                          "x  x a5 a4  a3 a2 a1 a0    o o o o  o o o o";
+
+        write           = "1  1  0  0   0  0  0  0    0 0 0 x  x x x x",
+                          "x  x a5 a4  a3 a2 a1 a0    i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         "  x   x  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 5;
+       blocksize       = 4;
+       readsize        = 256;
+    ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 1024;
+        page_size       = 32;
+        num_pages       = 32;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0  0  1  0   0  0  0  0",
+                          "  0  0  0  0   0  0  0 a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        read_hi         = "  0  0  1  0   1  0  0  0",
+                          "  0  0  0  0   0  0  0 a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        loadpage_lo     = "  0  1  0  0   0  0  0  0",
+                          "  0  0  0  x   x  x  x  x",
+                          "  x  x  x  x  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        loadpage_hi     = "  0  1  0  0   1  0  0  0",
+                          "  0  0  0  x   x  x  x  x",
+                          "  x  x  x  x  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        writepage       = "  0  1  0  0   1  1  0  0",
+                          "  0  0  0  0   0  0  0 a8",
+                          " a7 a6 a5 a4   x  x  x  x",
+                          "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+    ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0    0 0 0 x  x x x x",
+                          "x  x  x  x   x  x a1 a0    o o o o  o o o o";
+    ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+
+       read            = "0  1  0  1   1  0  0  0    0 0 0 0  0 0 0 0",
+                          "x  x  x  x   x  x  x  x    x x o o  o o o o";
+
+        write           = "1  0  1  0   1  1  0  0    1 1 1 x  x x x x",
+                          "x  x  x  x   x  x  x  x    1 1 i i  i i i i";
+    ;
+
+    memory "calibration"
+        size            = 2;
+        read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                          "0  0  0  0   0  0  0 a0    o o o o  o o o o";
+    ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+      ;
+
+;
+
+
+#------------------------------------------------------------
+# ATtiny15
+#------------------------------------------------------------
+
+part
+    id                  = "t15";
+    desc                = "ATtiny15";
+    stk500_devcode      = 0x13;
+    avr910_devcode      = 0x56;
+    signature           = 0x1e 0x90 0x06;
+    chip_erase_delay    = 8200;
+    pgm_enable          = "1 0 1 0  1 1 0 0   0 1 0 1  0 0 1 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    chip_erase          = "1 0 1 0  1 1 0 0   1 0 0 x  x x x x",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    hvsp_controlstack   =
+        0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x00,
+        0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78,
+        0x78, 0x00, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00;
+    hventerstabdelay    = 100;
+    hvspcmdexedelay     = 5;
+    synchcycles         = 6;
+    latchcycles         = 16;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 0;
+    resetdelayus        = 50;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+    memory "eeprom"
+        size            = 64;
+        min_write_delay = 8200;
+        max_write_delay = 8200;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "1  0  1  0   0  0  0  0    x x x x  x x x x",
+                          "x  x a5 a4  a3 a2 a1 a0    o o o o  o o o o";
+
+        write           = "1  1  0  0   0  0  0  0    x x x x  x x x x",
+                          "x  x a5 a4  a3 a2 a1 a0    i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 10;
+       blocksize       = 64;
+       readsize        = 256;
+    ;
+
+    memory "flash"
+        size            = 1024;
+        min_write_delay = 4100;
+        max_write_delay = 4100;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0  0  1  0   0  0  0  0",
+                          "  x  x  x  x   x  x  x a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        read_hi         = "  0  0  1  0   1  0  0  0",
+                          "  x  x  x  x   x  x  x a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        write_lo        = "  0  1  0  0   0  0  0  0",
+                          "  x  x  x  x   x  x  x a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        write_hi        = "  0  1  0  0   1  0  0  0",
+                          "  x  x  x  x   x  x  x a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+       mode            = 0x04;
+       delay           = 5;
+       blocksize       = 128;
+       readsize        = 256;
+    ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0 a1 a0    o o o o  o o o o";
+    ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0  1  0  1   1  0  0  0    x x x x  x x x x",
+                          "x  x  x  x   x  x  x  x    x x x x  x o o x";
+
+        write           = "1  0  1  0   1  1  0  0    1 1 1 1  1 i i 1",
+                          "x  x  x  x   x  x  x  x    x x x x  x x x x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+    ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0  0  1  1   1  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0  0  0    o o o o  o o o o";
+    ;
+
+    memory "fuse"
+        size            = 1;
+        read            = "0  1  0  1   0  0  0  0    x x x x  x x x x",
+                          "x  x  x  x   x  x  x  x    o o o o  x x o o";
+
+        write           = "1  0  1  0   1  1  0  0    1 0 1 x  x x x x",
+                          "x  x  x  x   x  x  x  x    i i i i  1 1 i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+    ;
+;
+
+#------------------------------------------------------------
+# AT90s1200
+#------------------------------------------------------------
+
+part
+    id               = "1200";
+    desc             = "AT90S1200";
+    is_at90s1200     = yes;
+    stk500_devcode   = 0x33;
+    avr910_devcode   = 0x13;
+    signature        = 0x1e 0x90 0x01;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 20000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 1;
+    bytedelay          = 0;
+    pollindex          = 0;
+    pollvalue          = 0xFF;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 15;
+    chiperasepolltimeout = 0;
+    programfusepulsewidth = 2;
+    programfusepolltimeout = 0;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 1;
+
+    memory "eeprom"
+        size            = 64;
+        min_write_delay = 4000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0xff;
+        read            = "1 0  1  0   0  0  0  0   x x x x  x x x x", 
+                          "x x a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+        write           = "1 1  0  0   0  0  0  0   x x x x  x x x x",
+                          "x x a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 20;
+       blocksize       = 32;
+       readsize        = 256;
+      ;
+    memory "flash"
+        size            = 1024;
+        min_write_delay = 4000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  x   x   x   x    x   x   x  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  x   x   x   x    x   x   x  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        write_lo        = "  0   1   0   0    0   0   0   0",
+                          "  x   x   x   x    x   x   x  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+        write_hi        = "  0   1   0   0    1   0   0   0",
+                          "  x   x   x   x    x   x   x  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+       mode            = 0x02;
+       delay           = 15;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "fuse"
+        size            = 1;
+      ;
+    memory "lock"
+        size            = 1;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        write           = "1 0 1 0  1 1 0 0   1 1 1 1  1 i i 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90s4414
+#------------------------------------------------------------
+
+part
+    id               = "4414";
+    desc             = "AT90S4414";
+    stk500_devcode   = 0x50;
+    avr910_devcode   = 0x28;
+    signature        = 0x1e 0x92 0x01;
+    chip_erase_delay = 20000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 15;
+    chiperasepolltimeout = 0;
+    programfusepulsewidth = 2;
+    programfusepolltimeout = 0;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 1;
+
+    memory "eeprom"
+        size            = 256;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0x80;
+        readback_p2     = 0x7f;
+        read            = " 1  0  1  0   0  0  0  0  x x x x  x x x a8", 
+                          "a7 a6 a5 a4 a3 a2 a1 a0   o o o o  o o o o";
+
+        write           = " 1  1  0  0   0  0  0  0   x x x x  x x x a8",
+                          "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+    memory "flash"
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0x7f;
+        readback_p2     = 0x7f;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        write_lo        = "  0   1   0   0    0   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+        write_hi        = "  0   1   0   0    1   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "fuse"
+       size            = 1;
+      ;
+    memory "lock"
+       size            = 1;
+       write           = "1  0  1  0   1  1  0  0   1  1  1  1   1  i  i  1",
+                         "x  x  x  x   x  x  x  x   x  x  x  x   x  x  x  x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90s2313
+#------------------------------------------------------------
+
+part
+    id               = "2313";
+    desc             = "AT90S2313";
+    stk500_devcode   = 0x40;
+    avr910_devcode   = 0x20;
+    signature        = 0x1e 0x91 0x01;
+    chip_erase_delay = 20000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 15;
+    chiperasepolltimeout = 0;
+    programfusepulsewidth = 2;
+    programfusepolltimeout = 0;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 1;
+
+    memory "eeprom"
+        size            = 128;
+        min_write_delay = 4000;
+        max_write_delay = 9000;
+        readback_p1     = 0x80;
+        readback_p2     = 0x7f;
+        read            = "1  0  1  0   0  0  0  0   x x x x  x x x x", 
+                          "x a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+        write           = "1  1  0  0   0  0  0  0   x x x x  x x x x",
+                          "x a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+    memory "flash"
+        size            = 2048;
+        min_write_delay = 4000;
+        max_write_delay = 9000;
+        readback_p1     = 0x7f;
+        readback_p2     = 0x7f;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        write_lo        = "  0   1   0   0    0   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+        write_hi        = "  0   1   0   0    1   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "fuse"
+        size            = 1;
+      ;
+    memory "lock"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 1 1 x  x i i x",
+                          "x x x x  x x x x  x x x x  x x x x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90s2333
+#------------------------------------------------------------
+
+part
+    id               = "2333";
+##### WARNING: No XML file for device 'AT90S2333'! #####
+    desc             = "AT90S2333";
+    stk500_devcode   = 0x42;
+    avr910_devcode   = 0x34;
+    signature        = 0x1e 0x91 0x05;
+    chip_erase_delay = 20000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 15;
+    chiperasepolltimeout = 0;
+    programfusepulsewidth = 2;
+    programfusepolltimeout = 0;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 1;
+
+    memory "eeprom"
+        size            = 128;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0x00;
+        readback_p2     = 0xff;
+        read            = "1  0  1  0   0  0  0  0   x x x x  x x x x", 
+                          "x a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+        write           = "1  1  0  0   0  0  0  0   x x x x  x x x x",
+                          "x a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        write_lo        = "  0   1   0   0    0   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+        write_hi        = "  0   1   0   0    1   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "fuse"
+        size            = 1;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        pwroff_after_write = yes;
+        read            = "0 1 0 1  0 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 i  i i i i",
+                          "x x x x  x x x x   x x x x  x x x x";
+      ;
+    memory "lock"
+        size            = 1;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        read            = "0 1 0 1  1 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   x x x x  x o o x";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 1  1 i i 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+      ;
+  ;
+
+
+#------------------------------------------------------------
+# AT90s2343 (also AT90s2323 and ATtiny22)
+#------------------------------------------------------------
+
+part
+    id               = "2343";
+    desc             = "AT90S2343";
+    stk500_devcode   = 0x43;
+    avr910_devcode   = 0x4c;
+    signature        = 0x1e 0x91 0x03;
+    chip_erase_delay = 18000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    hvsp_controlstack   =
+        0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x00,
+        0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78,
+        0x78, 0x00, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00;
+    hventerstabdelay    = 100;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 0;
+    poweroffdelay       = 25;
+    resetdelayms        = 0;
+    resetdelayus        = 50;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+    memory "eeprom"
+        size            = 128;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0x00;
+        readback_p2     = 0xff;
+        read            = "1  0  1  0   0  0  0  0   0 0 0 0  0 0 0 0", 
+                          "x a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+        write           = "1  1  0  0   0  0  0  0   0 0 0 0  0 0 0 0",
+                          "x a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+    memory "flash"
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        write_lo        = "  0   1   0   0    0   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+        write_hi        = "  0   1   0   0    1   0   0   0",
+                          "  x   x   x   x    x   x  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 128;
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "fuse"
+        size            = 1;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        read            = "0 1 0 1  1 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   o o o x  x x x o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 1  1 1 1 i",
+                          "x x x x  x x x x   x x x x  x x x x";
+      ;
+    memory "lock"
+        size            = 1;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        read            = "0 1 0 1  1 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   o o o x  x x x o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 1  1 i i 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+      ;
+  ;
+
+
+#------------------------------------------------------------
+# AT90s4433
+#------------------------------------------------------------
+
+part
+    id               = "4433";
+    desc             = "AT90S4433";
+    stk500_devcode   = 0x51;
+    avr910_devcode   = 0x30;
+    signature        = 0x1e 0x92 0x03;
+    chip_erase_delay = 20000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 15;
+    chiperasepolltimeout = 0;
+    programfusepulsewidth = 2;
+    programfusepolltimeout = 0;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 1;
+
+    memory "eeprom"
+        size            = 256;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0x00;
+        readback_p2     = 0xff;
+        read            = " 1  0  1  0   0  0  0  0   x x x x  x x x x", 
+                          "a7 a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+        write           = " 1  1  0  0   0  0  0  0   x x x x  x x x x",
+                          "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "flash"
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  x   x   x   x    x a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  x   x   x   x    x a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        write_lo        = "  0   1   0   0    0   0   0   0",
+                          "  x   x   x   x    x a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+        write_hi        = "  0   1   0   0    1   0   0   0",
+                          "  x   x   x   x    x a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "fuse"
+        size            = 1;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        pwroff_after_write = yes;
+        read            = "0 1 0 1  0 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 i  i i i i",
+                          "x x x x  x x x x   x x x x  x x x x";
+      ;
+    memory "lock"
+        size            = 1;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        read            = "0 1 0 1  1 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   x x x x  x o o x";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 1  1 i i 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90s4434
+#------------------------------------------------------------
+
+part
+    id               = "4434";
+##### WARNING: No XML file for device 'AT90S4434'! #####
+    desc             = "AT90S4434";
+    stk500_devcode   = 0x52;
+    avr910_devcode   = 0x6c;
+    signature        = 0x1e 0x92 0x02;
+    chip_erase_delay = 20000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    memory "eeprom"
+        size            = 256;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0x00;
+        readback_p2     = 0xff;
+        read            = " 1  0  1  0   0  0  0  0   x x x x  x x x x", 
+                          "a7 a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+        write           = " 1  1  0  0   0  0  0  0   x x x x  x x x x",
+                          "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+      ;
+    memory "flash"
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  x   x   x   x    x a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  x   x   x   x    x a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        write_lo        = "  0   1   0   0    0   0   0   0",
+                          "  x   x   x   x    x a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+        write_hi        = "  0   1   0   0    1   0   0   0",
+                          "  x   x   x   x    x a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "fuse"
+        size            = 1;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        read            = "0 1 0 1  0 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 i  i i i i",
+                          "x x x x  x x x x   x x x x  x x x x";
+      ;
+    memory "lock"
+        size            = 1;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        read            = "0 1 0 1  1 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   x x x x  x o o x";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 1  1 i i 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90s8515
+#------------------------------------------------------------
+
+part
+    id               = "8515";
+    desc             = "AT90S8515";
+    stk500_devcode   = 0x60;
+    avr910_devcode   = 0x38;
+    signature        = 0x1e 0x93 0x01;
+    chip_erase_delay = 20000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+       0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+       0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+       0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+       0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    resetdelay          = 15;
+    chiperasepulsewidth = 15;
+    chiperasepolltimeout = 0;
+    programfusepulsewidth = 2;
+    programfusepolltimeout = 0;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 1;
+
+    memory "eeprom"
+        size            = 512;
+        min_write_delay = 4000;
+        max_write_delay = 9000;
+        readback_p1     = 0x80;
+        readback_p2     = 0x7f;
+        read            = " 1  0  1  0   0  0  0  0  x x x x  x x x a8", 
+                          "a7 a6 a5 a4 a3 a2 a1 a0   o o o o  o o o o";
+
+        write           = " 1  1  0  0   0  0  0  0   x x x x  x x x a8",
+                          "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "flash"
+        size            = 8192;
+        min_write_delay = 4000;
+        max_write_delay = 9000;
+        readback_p1     = 0x7f;
+        readback_p2     = 0x7f;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        write_lo        = "  0   1   0   0    0   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+        write_hi        = "  0   1   0   0    1   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "fuse"
+       size            = 1;
+      ;
+    memory "lock"
+       size            = 1;
+       write           = "1  0  1  0   1  1  0  0   1  1  1  1   1  i  i  1",
+                         "x  x  x  x   x  x  x  x   x  x  x  x   x  x  x  x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90s8535
+#------------------------------------------------------------
+
+part
+    id               = "8535";
+    desc             = "AT90S8535";
+    stk500_devcode   = 0x61;
+    avr910_devcode   = 0x68;
+    signature        = 0x1e 0x93 0x03;
+    chip_erase_delay = 20000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 15;
+    chiperasepolltimeout = 0;
+    programfusepulsewidth = 2;
+    programfusepolltimeout = 0;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 1;
+
+    memory "eeprom"
+        size            = 512;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0x00;
+        readback_p2     = 0xff;
+        read            = " 1  0  1  0   0  0  0  0   x x x x  x x x a8", 
+                          "a7 a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+        write           = " 1  1  0  0   0  0  0  0   x x x x  x x x a8",
+                          "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "flash"
+        size            = 8192;
+        min_write_delay = 9000;
+        max_write_delay = 20000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        write_lo        = "  0   1   0   0    0   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+        write_hi        = "  0   1   0   0    1   0   0   0",
+                          "  x   x   x   x  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  i   i   i   i    i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "fuse"
+       size            = 1;
+       read            = "0  1  0  1   1  0  0  0   x  x  x  x   x  x  x  x",
+                         "x  x  x  x   x  x  x  x   x  x  x  x   x  x  x  o";
+       write           = "1  0  1  0   1  1  0  0   1  0  1  1   1  1  1  i",
+                         "x  x  x  x   x  x  x  x   x  x  x  x   x  x  x  x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+    memory "lock"
+       size            = 1;
+       read            = "0  1  0  1   1  0  0  0   x  x  x  x   x  x  x  x",
+                         "x  x  x  x   x  x  x  x   o  o  x  x   x  x  x  x";
+       write           = "1  0  1  0   1  1  0  0   1  1  1  1   1  i  i  1",
+                         "x  x  x  x   x  x  x  x   x  x  x  x   x  x  x  x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega103
+#------------------------------------------------------------
+
+part
+    id               = "m103";
+    desc             = "ATMEGA103";
+    stk500_devcode   = 0xB1;
+    avr910_devcode   = 0x41;
+    signature        = 0x1e 0x97 0x01;
+    chip_erase_delay = 112000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x8E, 0x9E, 0x2E, 0x3E, 0xAE, 0xBE,
+        0x4E, 0x5E, 0xCE, 0xDE, 0x6E, 0x7E, 0xEE, 0xDE,
+        0x66, 0x76, 0xE6, 0xF6, 0x6A, 0x7A, 0xEA, 0x7A,
+        0x7F, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 15;
+    chiperasepolltimeout = 0;
+    programfusepulsewidth = 2;
+    programfusepolltimeout = 0;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 10;
+
+    memory "eeprom"
+        size            = 4096;
+        min_write_delay = 4000;
+        max_write_delay = 9000;
+        readback_p1     = 0x80;
+        readback_p2     = 0x7f;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 131072;
+        page_size       = 256;
+        num_pages       = 512;
+        min_write_delay = 22000;
+        max_write_delay = 56000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x11;
+       delay           = 70;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "fuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0  x x x x  x x x x",
+                          "x x x x  x x x x  x x o x  o 1 o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 1  i 1 i i",
+                          "x x x x  x x x x  x x x x  x x x x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   x x x x  x o o x";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 1  1 i i 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+#------------------------------------------------------------
+# ATmega64
+#------------------------------------------------------------
+
+part
+    id               = "m64";
+    desc             = "ATMEGA64";
+    has_jtag         = yes;
+    stk500_devcode   = 0xA0;
+    avr910_devcode   = 0x45;
+    signature        = 0x1e 0x96 0x02;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x22;
+    spmcr               = 0x68;
+    allowfullpagebitstream = yes;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 20;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  x x i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 4;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 a1 a0  o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+
+
+#------------------------------------------------------------
+# ATmega128
+#------------------------------------------------------------
+
+part
+    id               = "m128";
+    desc             = "ATMEGA128";
+    has_jtag         = yes;
+    stk500_devcode   = 0xB2;
+    avr910_devcode   = 0x43;
+    signature        = 0x1e 0x97 0x02;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x22;
+    spmcr               = 0x68;
+    rampz               = 0x3b;
+    allowfullpagebitstream = yes;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 12;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 131072;
+        page_size       = 256;
+        num_pages       = 512;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  x x i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 4;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 a1 a0  o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90CAN128
+#------------------------------------------------------------
+
+part
+    id               = "c128";
+    desc             = "AT90CAN128";
+    has_jtag         = yes;
+    stk500_devcode   = 0xB3;
+#    avr910_devcode   = 0x43;
+    signature        = 0x1e 0x97 0x81;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    eecr                = 0x3f;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 131072;
+        page_size       = 256;
+        num_pages       = 512;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0  0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0  o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90CAN64
+#------------------------------------------------------------
+
+part
+    id               = "c64";
+    desc             = "AT90CAN64";
+    has_jtag         = yes;
+    stk500_devcode   = 0xB3;
+#    avr910_devcode   = 0x43;
+    signature        = 0x1e 0x96 0x81;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    eecr                = 0x3f;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0  0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0  o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90CAN32
+#------------------------------------------------------------
+
+part
+    id               = "c32";
+    desc             = "AT90CAN32";
+    has_jtag         = yes;
+    stk500_devcode   = 0xB3;
+#    avr910_devcode   = 0x43;
+    signature        = 0x1e 0x95 0x81;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    eecr                = 0x3f;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 256;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0  0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0  o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+#------------------------------------------------------------
+# ATmega16
+#------------------------------------------------------------
+
+part
+    id               = "m16";
+    desc             = "ATMEGA16";
+    has_jtag         = yes;
+    stk500_devcode   = 0x82;
+    avr910_devcode   = 0x74;
+    signature        = 0x1e 0x94 0x03;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+       0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+       0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+       0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+       0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 100;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    resetdelay          = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = yes;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 512;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x  a9  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x04;
+       delay           = 10;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+    memory "calibration"
+        size            = 4;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 a1 a0 o o o o  o o o o";
+        ;
+  ;
+
+
+#------------------------------------------------------------
+# ATmega164P
+#------------------------------------------------------------
+
+# close to ATmega16
+
+part
+    id               = "m164p";
+    desc             = "ATMEGA164P";
+    has_jtag         = yes;
+    stk500_devcode   = 0x82; # no STK500v1 support, use the ATmega16 one
+    avr910_devcode   = 0x74;
+    signature        = 0x1e 0x94 0x0a;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 512;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x  a9  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+
+#------------------------------------------------------------
+# ATmega324P
+#------------------------------------------------------------
+
+# similar to ATmega164P
+
+part
+    id               = "m324p";
+    desc             = "ATMEGA324P";
+    has_jtag         = yes;
+    stk500_devcode   = 0x82; # no STK500v1 support, use the ATmega16 one
+    avr910_devcode   = 0x74;
+    signature        = 0x1e 0x95 0x08;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+
+#------------------------------------------------------------
+# ATmega324PA
+#------------------------------------------------------------
+
+# similar to ATmega324P
+
+part
+    id               = "m324pa";
+    desc             = "ATmega324PA";
+    has_jtag         = yes;
+    stk500_devcode   = 0x82; # no STK500v1 support, use the ATmega16 one
+    avr910_devcode   = 0x74;
+    signature        = 0x1e 0x95 0x11;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+
+#------------------------------------------------------------
+# ATmega644
+#------------------------------------------------------------
+
+# similar to ATmega164
+
+part
+    id               = "m644";
+    desc             = "ATMEGA644";
+    has_jtag         = yes;
+    stk500_devcode   = 0x82; # no STK500v1 support, use the ATmega16 one
+    avr910_devcode   = 0x74;
+    signature        = 0x1e 0x96 0x09;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+#------------------------------------------------------------
+# ATmega644P
+#------------------------------------------------------------
+
+# similar to ATmega164p
+
+part
+    id               = "m644p";
+    desc             = "ATMEGA644P";
+    has_jtag         = yes;
+    stk500_devcode   = 0x82; # no STK500v1 support, use the ATmega16 one
+    avr910_devcode   = 0x74;
+    signature        = 0x1e 0x96 0x0a;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+
+
+#------------------------------------------------------------
+# ATmega1284P
+#------------------------------------------------------------
+
+# similar to ATmega164p
+
+part
+    id               = "m1284p";
+    desc             = "ATMEGA1284P";
+    has_jtag         = yes;
+    stk500_devcode   = 0x82; # no STK500v1 support, use the ATmega16 one
+    avr910_devcode   = 0x74;
+    signature        = 0x1e 0x97 0x05;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 131072;
+        page_size       = 256;
+        num_pages       = 512;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+
+
+#------------------------------------------------------------
+# ATmega162
+#------------------------------------------------------------
+
+part
+    id               = "m162";
+    desc             = "ATMEGA162";
+    has_jtag         = yes;
+    stk500_devcode   = 0x83;
+    avr910_devcode   = 0x63;
+    signature        = 0x1e 0x94 0x04;
+    chip_erase_delay = 9000;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+
+    idr              = 0x04;
+    spmcr            = 0x57;
+    allowfullpagebitstream = yes;
+
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+       mode        = 0x41;
+    delay       = 10;
+    blocksize   = 128;
+    readsize    = 256;  
+
+        ;
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 512;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+
+                read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+                write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x  a9  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+        ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 16000;
+        max_write_delay = 16000;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 16000;
+        max_write_delay = 16000;
+
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+        ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 16000;
+        max_write_delay = 16000;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  1 1 1 1  1 i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 16000;
+        max_write_delay = 16000;
+
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        ;
+
+    memory "signature"
+        size            = 3;
+
+        read            = "0  0  1  1   0  0  0  0   0  0  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+        ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 x x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+;
+
+
+
+#------------------------------------------------------------
+# ATmega163
+#------------------------------------------------------------
+
+part
+    id               = "m163";
+    desc             = "ATMEGA163";
+    stk500_devcode   = 0x81;
+    avr910_devcode   = 0x64;
+    signature        = 0x1e 0x94 0x02;
+    chip_erase_delay = 32000;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout             = 200;
+    stabdelay           = 100;
+    cmdexedelay         = 25;
+    synchloops          = 32;
+    bytedelay           = 0;
+    pollindex           = 3;
+    pollvalue           = 0x53;
+    predelay            = 1;
+    postdelay           = 1;
+    pollmethod          = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 30;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 2;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 2;
+
+
+   memory "eeprom"
+        size            = 512;
+        min_write_delay = 4000;
+        max_write_delay = 4000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+        mode            = 0x41;
+        delay           = 20;
+        blocksize       = 4;
+        readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 16000;
+        max_write_delay = 16000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x11;
+       delay           = 20;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o x x  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i 1 1  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   x x x x  1 o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   1 1 1 1  1 i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  0 x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0   x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega169
+#------------------------------------------------------------
+
+part
+    id               = "m169";
+    desc             = "ATMEGA169";
+    has_jtag         = yes;
+    stk500_devcode   = 0x85;
+    avr910_devcode   = 0x78;
+    signature        = 0x1e 0x94 0x05;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+
+   memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 512;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega329
+#------------------------------------------------------------
+
+part
+    id               = "m329";
+    desc             = "ATMEGA329";
+    has_jtag         = yes;
+#    stk500_devcode   = 0x85; # no STK500 support, only STK500v2
+#    avr910_devcode   = 0x?;  # try the ATmega169 one:
+    avr910_devcode   = 0x75;
+    signature        = 0x1e 0x95 0x03;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+
+   memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x  a9  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega329P
+#------------------------------------------------------------
+# Identical to ATmega329 except of the signature
+
+part
+    id               = "m329p";
+    desc             = "ATMEGA329P";
+    has_jtag         = yes;
+#    stk500_devcode   = 0x85; # no STK500 support, only STK500v2
+#    avr910_devcode   = 0x?;  # try the ATmega169 one:
+    avr910_devcode   = 0x75;
+    signature        = 0x1e 0x95 0x0b;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+
+   memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x  a9  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega3290
+#------------------------------------------------------------
+
+# identical to ATmega329
+
+part
+    id               = "m3290";
+    desc             = "ATMEGA3290";
+    has_jtag         = yes;
+#    stk500_devcode   = 0x85; # no STK500 support, only STK500v2
+#    avr910_devcode   = 0x?;  # try the ATmega169 one:
+    avr910_devcode   = 0x75;
+    signature        = 0x1e 0x95 0x04;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+
+   memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x  a9  a8",
+                         " a7  a6  a5  a4     a3  a3   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega3290P
+#------------------------------------------------------------
+
+# identical to ATmega3290 except of the signature
+
+part
+    id               = "m3290p";
+    desc             = "ATMEGA3290P";
+    has_jtag         = yes;
+#    stk500_devcode   = 0x85; # no STK500 support, only STK500v2
+#    avr910_devcode   = 0x?;  # try the ATmega169 one:
+    avr910_devcode   = 0x75;
+    signature        = 0x1e 0x95 0x0c;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+
+   memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x  a9  a8",
+                         " a7  a6  a5  a4     a3  a3   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  x a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega649
+#------------------------------------------------------------
+
+part
+    id               = "m649";
+    desc             = "ATMEGA649";
+    has_jtag         = yes;
+#    stk500_devcode   = 0x85; # no STK500 support, only STK500v2
+#    avr910_devcode   = 0x?;  # try the ATmega169 one:
+    avr910_devcode   = 0x75;
+    signature        = 0x1e 0x96 0x03;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+
+   memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega6490
+#------------------------------------------------------------
+
+# identical to ATmega649
+
+part
+    id               = "m6490";
+    desc             = "ATMEGA6490";
+    has_jtag         = yes;
+#    stk500_devcode   = 0x85; # no STK500 support, only STK500v2
+#    avr910_devcode   = 0x?;  # try the ATmega169 one:
+    avr910_devcode   = 0x75;
+    signature        = 0x1e 0x96 0x04;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+
+   memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega32
+#------------------------------------------------------------
+
+part
+    id               = "m32";
+    desc             = "ATMEGA32";
+    has_jtag         = yes;
+    stk500_devcode   = 0x91;
+    avr910_devcode   = 0x72;
+    signature        = 0x1e 0x95 0x02;
+    chip_erase_delay = 9000;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = yes;
+
+   memory "eeprom"
+        paged           = no;   /* leave this "no" */
+        page_size       = 4;    /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x  a9  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x04;
+       delay           = 10;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o o";
+      ;
+
+    memory "calibration"
+        size            = 4;
+        read            = "0 0 1 1  1 0 0 0    0 0 x x  x x x x",
+                          "0 0 0 0  0 0 a1 a0  o o o o  o o o o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega161
+#------------------------------------------------------------
+
+part
+    id               = "m161";
+    desc             = "ATMEGA161";
+    stk500_devcode   = 0x80;
+    avr910_devcode   = 0x60;
+    signature        = 0x1e 0x94 0x01;
+    chip_erase_delay = 28000;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 0;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 30;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 2;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 2;
+
+   memory "eeprom"
+        size            = 512;
+        min_write_delay = 3400;
+        max_write_delay = 3400;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 5;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 14000;
+        max_write_delay = 14000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  x   x   x a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 16;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "fuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  0 0 0 0   x x x x  x x x x",
+                          "x x x x  x x x x   x o x o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 x  x x x x",
+                          "x x x x  x x x x   1 i 1 i  i i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+#------------------------------------------------------------
+# ATmega8
+#------------------------------------------------------------
+
+part
+    id               = "m8";
+    desc             = "ATMEGA8";
+    stk500_devcode   = 0x70;
+    avr910_devcode   = 0x76;
+    signature        = 0x1e 0x93 0x07;
+    pagel            = 0xd7;
+    bs2              = 0xc2;
+    chip_erase_delay = 10000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+       0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+       0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+       0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+       0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 2;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    resetdelay          = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        size            = 512;
+        page_size       = 4;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 20;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "flash"
+        paged           = yes;
+        size            = 8192;
+        page_size       = 64;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   0      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   0      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 10;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "calibration"
+        size            = 4;
+        read            = "0  0  1  1   1  0  0  0   0  0  x  x   x  x  x  x",
+                          "0  0  0  0   0  0 a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+
+#------------------------------------------------------------
+# ATmega8515
+#------------------------------------------------------------
+
+part
+    id               = "m8515";
+    desc             = "ATMEGA8515";
+    stk500_devcode   = 0x63;
+    avr910_devcode   = 0x3A;
+    signature        = 0x1e 0x93 0x06;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        size            = 512;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+ read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+ write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 20;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "flash"
+        paged           = yes;
+        size            = 8192;
+        page_size       = 64;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   0      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   0      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "calibration"
+        size            = 4;
+        read            = "0 0 1 1  1 0 0 0     0 0 x x  x x x x",
+                          "0 0 0 0  0 0 a1 a0   o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+
+
+#------------------------------------------------------------
+# ATmega8535
+#------------------------------------------------------------
+
+part
+    id               = "m8535";
+    desc             = "ATMEGA8535";
+    stk500_devcode   = 0x64;
+    avr910_devcode   = 0x69;
+    signature        = 0x1e 0x93 0x08;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 6;
+    togglevtg           = 0;
+    poweroffdelay       = 0;
+    resetdelayms        = 0;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        size            = 512;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       mode            = 0x04;
+       delay           = 20;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+    memory "flash"
+        paged           = yes;
+        size            = 8192;
+        page_size       = 64;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   0      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   0      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 2000;
+        max_write_delay = 2000;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "calibration"
+        size            = 4;
+        read            = "0 0 1 1  1 0 0 0   0 0 x x  x x x x",
+                          "0 0 0 0  0 0 a1 a0 o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+#------------------------------------------------------------
+# ATtiny26
+#------------------------------------------------------------
+
+part
+    id                  = "t26";
+    desc                = "ATTINY26";
+    stk500_devcode      = 0x21;
+    avr910_devcode      = 0x5e;
+    signature           = 0x1e 0x91 0x09;
+    pagel               = 0xb3;
+    bs2                 = 0xb2;
+    chip_erase_delay    = 9000;
+    pgm_enable          = "1 0 1 0  1 1 0 0   0 1 0 1  0 0 1 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    chip_erase          = "1 0 1 0  1 1 0 0   1 0 0 x  x x x x",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0xC4, 0xE4, 0xC4, 0xE4, 0xCC, 0xEC, 0xCC, 0xEC,
+        0xD4, 0xF4, 0xD4, 0xF4, 0xDC, 0xFC, 0xDC, 0xFC,
+        0xC8, 0xE8, 0xD8, 0xF8, 0x4C, 0x6C, 0x5C, 0x7C,
+        0xEC, 0xBC, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 2;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        size            = 128;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "1  0  1  0   0  0  0  0    x x x x  x x x x",
+                          "x a6 a5 a4  a3 a2 a1 a0    o o o o  o o o o";
+
+        write           = "1  1  0  0   0  0  0  0    x x x x  x x x x",
+                          "x a6 a5 a4  a3 a2 a1 a0    i i i i  i i i i";
+
+       mode            = 0x04;
+       delay           = 10;
+       blocksize       = 64;
+       readsize        = 256;
+    ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 2048;
+        page_size       = 32;
+        num_pages       = 64;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0  0  1  0   0  0  0  0",
+                          "  x  x  x  x   x  x a9 a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        read_hi         = "  0  0  1  0   1  0  0  0",
+                          "  x  x  x  x   x  x a9 a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        loadpage_lo     = "  0  1  0  0   0  0  0  0",
+                          "  x  x  x  x   x  x  x  x",
+                          "  x  x  x  x  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        loadpage_hi     = "  0  1  0  0   1  0  0  0",
+                          "  x  x  x  x   x  x  x  x",
+                          "  x  x  x  x  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        writepage       = "  0  1  0  0   1  1  0  0",
+                          "  x  x  x  x   x  x a9 a8",
+                          " a7 a6 a5 a4   x  x  x  x",
+                          "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x21;
+       delay           = 6;
+       blocksize       = 16;
+       readsize        = 256;
+    ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0 a1 a0    o o o o  o o o o";
+    ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0  1  0  1   1  0  0  0    x x x x  x x x x",
+                          "x  x  x  x   x  x  x  x    x x x x  x x o o";
+
+        write           = "1  0  1  0   1  1  0  0    1 1 1 1  1 1 i i",
+                          "x  x  x  x   x  x  x  x    x x x x  x x x x";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+    ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  x x x i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  x x x o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 4;
+        read            = "0  0  1  1   1  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0 a1 a0    o o o o  o o o o";
+    ;
+
+;
+
+
+#------------------------------------------------------------
+# ATtiny261
+#------------------------------------------------------------
+# Close to ATtiny26
+
+part
+    id                  = "t261";
+    desc                = "ATTINY261";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x00, 0x10;
+     eeprom_instr  = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBC, 0x00, 0xB4, 0x00, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+#    stk500_devcode      = 0x21;
+#    avr910_devcode      = 0x5e;
+    signature           = 0x1e 0x91 0x0c;
+    pagel               = 0xb3;
+    bs2                 = 0xb2;
+    chip_erase_delay    = 4000;
+
+    pgm_enable          = "1 0 1 0  1 1 0 0   0 1 0 1  0 0 1 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    chip_erase          = "1 0 1 0  1 1 0 0   1 0 0 x  x x x x",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0xC4, 0xE4, 0xC4, 0xE4, 0xCC, 0xEC, 0xCC, 0xEC,
+        0xD4, 0xF4, 0xD4, 0xF4, 0xDC, 0xFC, 0xDC, 0xFC,
+        0xC8, 0xE8, 0xD8, 0xF8, 0x4C, 0x6C, 0x5C, 0x7C,
+        0xEC, 0xBC, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 2;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no;
+        size            = 128;
+        page_size       = 4;
+        num_pages       = 32;
+        min_write_delay = 4000;
+        max_write_delay = 4000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+
+        read            = "1  0  1  0   0  0  0  0    x x x x  x x x x",
+                          "x a6 a5 a4  a3 a2 a1 a0    o o o o  o o o o";
+
+        write           = "1  1  0  0   0  0  0  0    x x x x  x x x x",
+                          "x a6 a5 a4  a3 a2 a1 a0    i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         "  x  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 4;
+       readsize        = 256;
+    ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 2048;
+        page_size       = 32;
+        num_pages       = 64;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+
+        read_lo         = "  0  0  1  0   0  0  0  0",
+                          "  x  x  x  x   x  x a9 a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        read_hi         = "  0  0  1  0   1  0  0  0",
+                          "  x  x  x  x   x  x a9 a8",
+                          " a7 a6 a5 a4  a3 a2 a1 a0",
+                          "  o  o  o  o   o  o  o  o";
+
+        loadpage_lo     = "  0  1  0  0   0  0  0  0",
+                          "  x  x  x  x   x  x  x  x",
+                          "  x  x  x  x  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        loadpage_hi     = "  0  1  0  0   1  0  0  0",
+                          "  x  x  x  x   x  x  x  x",
+                          "  x  x  x  x  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        writepage       = "  0  1  0  0   1  1  0  0",
+                          "  x  x  x  x   x  x a9 a8",
+                          " a7 a6 a5 a4   x  x  x  x",
+                          "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+    ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0 a1 a0    o o o o  o o o o";
+    ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0  1  0  1   1  0  0  0    x x x x  x x x x",
+                          "x  x  x  x   x  x  x  x    x x x x  x x o o";
+
+        write           = "1  0  1  0   1  1  0  0    1 1 1 1  1 1 i i",
+                          "x  x  x  x   x  x  x  x    x x x x  x x x x";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+    ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x x x i";
+
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   x x x x  x x x o";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0  0  1  1   1  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0  0  0    o o o o  o o o o";
+    ;
+
+;
+
+
+#------------------------------------------------------------
+# ATtiny461
+#------------------------------------------------------------
+# Close to ATtiny261
+
+part
+    id                  = "t461";
+    desc                = "ATTINY461";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x00, 0x10;
+     eeprom_instr  = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBC, 0x00, 0xB4, 0x00, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+#    stk500_devcode      = 0x21;
+#    avr910_devcode      = 0x5e;
+    signature           = 0x1e 0x92 0x08;
+    pagel               = 0xb3;
+    bs2                 = 0xb2;
+    chip_erase_delay    = 4000;
+
+    pgm_enable          = "1 0 1 0  1 1 0 0   0 1 0 1  0 0 1 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    chip_erase          = "1 0 1 0  1 1 0 0   1 0 0 x  x x x x",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0xC4, 0xE4, 0xC4, 0xE4, 0xCC, 0xEC, 0xCC, 0xEC,
+        0xD4, 0xF4, 0xD4, 0xF4, 0xDC, 0xFC, 0xDC, 0xFC,
+        0xC8, 0xE8, 0xD8, 0xF8, 0x4C, 0x6C, 0x5C, 0x7C,
+        0xEC, 0xBC, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 2;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no;
+        size            = 256;
+        page_size       = 4;
+        num_pages       = 64;
+        min_write_delay = 4000;
+        max_write_delay = 4000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+
+        read            = " 1  0  1  0   0  0  0  0    x x x x  x x x x",
+                          "a7 a6 a5 a4  a3 a2 a1 a0    o o o o  o o o o";
+
+        write           = " 1  1  0  0   0  0  0  0    x x x x  x x x x",
+                          "a7 a6 a5 a4  a3 a2 a1 a0    i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 4;
+       readsize        = 256;
+    ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 4096;
+        page_size       = 64;
+        num_pages       = 64;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+
+        read_lo         = "  0  0  1  0   0   0  0  0",
+                          "  x  x  x  x   x a10 a9 a8",
+                          " a7 a6 a5 a4  a3  a2 a1 a0",
+                          "  o  o  o  o   o   o  o  o";
+
+        read_hi         = "  0  0  1  0   1   0  0  0",
+                          "  x  x  x  x   x a10 a9 a8",
+                          " a7 a6 a5 a4  a3  a2 a1 a0",
+                          "  o  o  o  o   o   o  o  o";
+
+        loadpage_lo     = "  0  1  0  0   0  0  0  0",
+                          "  x  x  x  x   x  x  x  x",
+                          "  x  x  x a4  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        loadpage_hi     = "  0  1  0  0   1  0  0  0",
+                          "  x  x  x  x   x  x  x  x",
+                          "  x  x  x a4  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        writepage       = "  0  1  0  0   1   1  0  0",
+                          "  x  x  x  x   x a10 a9 a8",
+                          " a7 a6 a5  x   x   x  x  x",
+                          "  x  x  x  x   x   x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+    ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0 a1 a0    o o o o  o o o o";
+    ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0  1  0  1   1  0  0  0    x x x x  x x x x",
+                          "x  x  x  x   x  x  x  x    x x x x  x x o o";
+
+        write           = "1  0  1  0   1  1  0  0    1 1 1 1  1 1 i i",
+                          "x  x  x  x   x  x  x  x    x x x x  x x x x";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+    ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x x x i";
+
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   x x x x  x x x o";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0  0  1  1   1  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0  0  0    o o o o  o o o o";
+    ;
+
+;
+
+
+#------------------------------------------------------------
+# ATtiny861
+#------------------------------------------------------------
+# Close to ATtiny461
+
+part
+    id                  = "t861";
+    desc                = "ATTINY861";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x00, 0x10;
+     eeprom_instr  = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBC, 0x00, 0xB4, 0x00, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+#    stk500_devcode      = 0x21;
+#    avr910_devcode      = 0x5e;
+    signature           = 0x1e 0x93 0x0d;
+    pagel               = 0xb3;
+    bs2                 = 0xb2;
+    chip_erase_delay    = 4000;
+
+    pgm_enable          = "1 0 1 0  1 1 0 0   0 1 0 1  0 0 1 1",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    chip_erase          = "1 0 1 0  1 1 0 0   1 0 0 x  x x x x",
+                          "x x x x  x x x x   x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 0;
+
+    pp_controlstack     =
+        0xC4, 0xE4, 0xC4, 0xE4, 0xCC, 0xEC, 0xCC, 0xEC,
+        0xD4, 0xF4, 0xD4, 0xF4, 0xDC, 0xFC, 0xDC, 0xFC,
+        0xC8, 0xE8, 0xD8, 0xF8, 0x4C, 0x6C, 0x5C, 0x7C,
+        0xEC, 0xBC, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 2;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no;
+        size            = 512;
+        num_pages       = 128;
+        page_size       = 4;
+        min_write_delay = 4000;
+        max_write_delay = 4000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+
+        read            = " 1  0  1  0   0  0  0  0    x x x x  x x x a8",
+                          "a7 a6 a5 a4  a3 a2 a1 a0    o o o o  o o o  o";
+
+        write           = " 1  1  0  0   0  0  0  0    x x x x  x x x a8",
+                          "a7 a6 a5 a4  a3 a2 a1 a0    i i i i  i i i  i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 4;
+       readsize        = 256;
+    ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 8192;
+        page_size       = 64;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+
+        read_lo         = "  0  0  1  0   0   0  0  0",
+                          "  x  x  x  x a11 a10 a9 a8",
+                          " a7 a6 a5 a4  a3  a2 a1 a0",
+                          "  o  o  o  o   o   o  o  o";
+
+        read_hi         = "  0  0  1  0   1   0  0  0",
+                          "  x  x  x  x a11 a10 a9 a8",
+                          " a7 a6 a5 a4  a3  a2 a1 a0",
+                          "  o  o  o  o   o   o  o  o";
+
+        loadpage_lo     = "  0  1  0  0   0  0  0  0",
+                          "  x  x  x  x   x  x  x  x",
+                          "  x  x  x a4  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        loadpage_hi     = "  0  1  0  0   1  0  0  0",
+                          "  x  x  x  x   x  x  x  x",
+                          "  x  x  x a4  a3 a2 a1 a0",
+                          "  i  i  i  i   i  i  i  i";
+
+        writepage       = "  0  1  0  0   1   1  0  0",
+                          "  x  x  x  x a11 a10 a9 a8",
+                          " a7 a6 a5  x   x   x  x  x",
+                          "  x  x  x  x   x   x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+    ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0 a1 a0    o o o o  o o o o";
+    ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0  1  0  1   1  0  0  0    x x x x  x x x x",
+                          "x  x  x  x   x  x  x  x    x x x x  x x o o";
+
+        write           = "1  0  1  0   1  1  0  0    1 1 1 1  1 1 i i",
+                          "x  x  x  x   x  x  x  x    x x x x  x x x x";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+    ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x x x i";
+
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   x x x x  x x x o";
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0  0  1  1   1  0  0  0    x x x x  x x x x",
+                          "0  0  0  0   0  0  0  0    o o o o  o o o o";
+    ;
+
+;
+
+
+#------------------------------------------------------------
+# ATmega48
+#------------------------------------------------------------
+
+part
+    id               = "m48";
+    desc             = "ATMEGA48";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                    0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                    0x99, 0xF9, 0xBB, 0xAF;
+    stk500_devcode   = 0x59;
+#    avr910_devcode   = 0x;
+    signature        = 0x1e 0x92 0x05;
+    pagel            = 0xd7;
+    bs2              = 0xc2;
+    chip_erase_delay = 45000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+       0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+       0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+       0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+       0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    resetdelay          = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no;
+        page_size       = 4;
+        size            = 256;
+        min_write_delay = 3600;
+        max_write_delay = 3600;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+      ;
+    memory "flash"
+        paged           = yes;
+        size            = 4096;
+        page_size       = 64;
+        num_pages       = 64;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  0   0   0   0    0 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  0   0   0   0    0 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0   0   0      0 a10  a9  a8",
+                          " a7  a6  a5   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   x x x x  x x x o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x x x i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0  0  1  1   1  0  0  0   0  0  0  x   x  x  x  x",
+                          "0  0  0  0   0  0  0  0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+#------------------------------------------------------------
+# ATmega88
+#------------------------------------------------------------
+
+part
+    id               = "m88";
+    desc             = "ATMEGA88";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                    0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                    0x99, 0xF9, 0xBB, 0xAF;
+    stk500_devcode   = 0x73;
+#    avr910_devcode   = 0x;
+    signature        = 0x1e 0x93 0x0a;
+    pagel            = 0xd7;
+    bs2              = 0xc2;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+       0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+       0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+       0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+       0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    resetdelay          = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no;
+        page_size       = 4;
+        size            = 512;
+        min_write_delay = 3600;
+        max_write_delay = 3600;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+      ;
+    memory "flash"
+        paged           = yes;
+        size            = 8192;
+        page_size       = 64;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   x x x x  x o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0  0  1  1   1  0  0  0   0  0  0  x   x  x  x  x",
+                          "0  0  0  0   0  0  0  0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega88P
+#------------------------------------------------------------
+
+part
+    id               = "m88p";
+    desc             = "ATMEGA88P";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                     0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                     0x99, 0xF9, 0xBB, 0xAF;
+    stk500_devcode   = 0x73;
+#    avr910_devcode   = 0x;
+    signature        = 0x1e 0x93 0x0f;
+    pagel            = 0xd7;
+    bs2              = 0xc2;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout             = 200;
+    stabdelay           = 100;
+    cmdexedelay         = 25;
+    synchloops          = 32;
+    bytedelay           = 0;
+    pollindex           = 3;
+    pollvalue           = 0x53;
+    predelay            = 1;
+    postdelay           = 1;
+    pollmethod          = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    resetdelay          = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no;
+        page_size       = 4;
+        size            = 512;
+        min_write_delay = 3600;
+        max_write_delay = 3600;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                          "  0   0   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   x   x      x   x   x  a8",
+                          " a7  a6  a5  a4     a3  a2   0   0",
+                          "  x   x   x   x      x   x   x   x";
+
+        mode            = 0x41;
+        delay           = 20;
+        blocksize       = 4;
+        readsize        = 256;
+      ;
+    memory "flash"
+        paged           = yes;
+        size            = 8192;
+        page_size       = 64;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+        mode            = 0x41;
+        delay           = 6;
+        blocksize       = 64;
+        readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   x x x x  x o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x i i i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0  0  1  1   1  0  0  0   0  0  0  x   x  x  x  x",
+                          "0  0  0  0   0  0  0  0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+#------------------------------------------------------------
+# ATmega168
+#------------------------------------------------------------
+
+part
+    id              = "m168";
+    desc            = "ATMEGA168";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                    0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                    0x99, 0xF9, 0xBB, 0xAF;
+    stk500_devcode  = 0x86;
+    # avr910_devcode = 0x;
+    signature       = 0x1e 0x94 0x06;
+    pagel           = 0xd7;
+    bs2             = 0xc2;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
+                       "x x x x x x x x x x x x x x x x";
+
+    chip_erase       = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
+                       "x x x x x x x x x x x x x x x x";
+
+    timeout         = 200;
+    stabdelay       = 100;
+    cmdexedelay     = 25;
+    synchloops      = 32;
+    bytedelay       = 0;
+    pollindex       = 3;
+    pollvalue       = 0x53;
+    predelay        = 1;
+    postdelay       = 1;
+    pollmethod      = 1;
+
+    pp_controlstack     =
+       0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+       0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+       0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+       0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    resetdelay          = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no;
+        page_size       = 4;
+        size            = 512;
+        min_write_delay = 3600;
+        max_write_delay = 3600;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = " 1 0 1 0 0 0 0 0",
+                          " 0 0 0 x x x x a8",
+                          " a7 a6 a5 a4 a3 a2 a1 a0",
+                          " o o o o o o o o";
+    
+        write           = " 1 1 0 0 0 0 0 0",
+                          " 0 0 0 x x x x a8",
+                          " a7 a6 a5 a4 a3 a2 a1 a0",
+                          " i i i i i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+        ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = " 0 0 1 0 0 0 0 0",
+                          " 0 0 0 a12 a11 a10 a9 a8",
+                          " a7 a6 a5 a4 a3 a2 a1 a0",
+                          " o o o o o o o o";
+        
+        read_hi          = " 0 0 1 0 1 0 0 0",
+                           " 0 0 0 a12 a11 a10 a9 a8",
+                           " a7 a6 a5 a4 a3 a2 a1 a0",
+                           " o o o o o o o o";
+        
+        loadpage_lo     = " 0 1 0 0 0 0 0 0",
+                          " 0 0 0 x x x x x",
+                          " x x a5 a4 a3 a2 a1 a0",
+                          " i i i i i i i i";
+        
+        loadpage_hi     = " 0 1 0 0 1 0 0 0",
+                          " 0 0 0 x x x x x",
+                          " x x a5 a4 a3 a2 a1 a0",
+                          " i i i i i i i i";
+        
+        writepage       = " 0 1 0 0 1 1 0 0",
+                          " 0 0 0 a12 a11 a10 a9 a8",
+                          " a7 a6 x x x x x x",
+                          " x x x x x x x x";
+
+        mode        = 0x41;
+        delay       = 6;
+        blocksize   = 128;
+        readsize    = 256;
+
+        ;
+        
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
+                          "x x x x x x x x o o o o o o o o";
+        
+        write           = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
+                          "x x x x x x x x i i i i i i i i";
+        ;
+    
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
+                          "x x x x x x x x o o o o o o o o";
+        
+        write           = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
+                          "x x x x x x x x i i i i i i i i";
+        ;
+    
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
+                          "x x x x x x x x x x x x x o o o";
+        
+        write           = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
+                          "x x x x x x x x x x x x x i i i";
+        ;
+    
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
+                          "x x x x x x x x x x o o o o o o";
+        
+        write           = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
+                          "x x x x x x x x 1 1 i i i i i i";
+        ;
+    
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
+                          "0 0 0 0 0 0 0 0 o o o o o o o o";
+        ;
+    
+    memory "signature"
+        size            = 3;
+        read            = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
+                          "x x x x x x a1 a0 o o o o o o o o";
+        ;
+;
+
+#------------------------------------------------------------
+# ATmega168P
+#------------------------------------------------------------
+
+part
+    id              = "m168p";
+    desc            = "ATMEGA168P";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                    0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                    0x99, 0xF9, 0xBB, 0xAF;
+    stk500_devcode  = 0x86;
+    # avr910_devcode = 0x;
+    signature       = 0x1e 0x94 0x0b;
+    pagel           = 0xd7;
+    bs2             = 0xc2;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
+                       "x x x x x x x x x x x x x x x x";
+
+    chip_erase       = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
+                       "x x x x x x x x x x x x x x x x";
+
+    timeout         = 200;
+    stabdelay       = 100;
+    cmdexedelay     = 25;
+    synchloops      = 32;
+    bytedelay       = 0;
+    pollindex       = 3;
+    pollvalue       = 0x53;
+    predelay        = 1;
+    postdelay       = 1;
+    pollmethod      = 1;
+
+    pp_controlstack     =
+       0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+       0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+       0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+       0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    resetdelay          = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no;
+        page_size       = 4;
+        size            = 512;
+        min_write_delay = 3600;
+        max_write_delay = 3600;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = " 1 0 1 0 0 0 0 0",
+                          " 0 0 0 x x x x a8",
+                          " a7 a6 a5 a4 a3 a2 a1 a0",
+                          " o o o o o o o o";
+    
+        write           = " 1 1 0 0 0 0 0 0",
+                          " 0 0 0 x x x x a8",
+                          " a7 a6 a5 a4 a3 a2 a1 a0",
+                          " i i i i i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+        ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = " 0 0 1 0 0 0 0 0",
+                          " 0 0 0 a12 a11 a10 a9 a8",
+                          " a7 a6 a5 a4 a3 a2 a1 a0",
+                          " o o o o o o o o";
+        
+        read_hi          = " 0 0 1 0 1 0 0 0",
+                           " 0 0 0 a12 a11 a10 a9 a8",
+                           " a7 a6 a5 a4 a3 a2 a1 a0",
+                           " o o o o o o o o";
+        
+        loadpage_lo     = " 0 1 0 0 0 0 0 0",
+                          " 0 0 0 x x x x x",
+                          " x x a5 a4 a3 a2 a1 a0",
+                          " i i i i i i i i";
+        
+        loadpage_hi     = " 0 1 0 0 1 0 0 0",
+                          " 0 0 0 x x x x x",
+                          " x x a5 a4 a3 a2 a1 a0",
+                          " i i i i i i i i";
+        
+        writepage       = " 0 1 0 0 1 1 0 0",
+                          " 0 0 0 a12 a11 a10 a9 a8",
+                          " a7 a6 x x x x x x",
+                          " x x x x x x x x";
+
+        mode        = 0x41;
+        delay       = 6;
+        blocksize   = 128;
+        readsize    = 256;
+
+        ;
+        
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
+                          "x x x x x x x x o o o o o o o o";
+        
+        write           = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
+                          "x x x x x x x x i i i i i i i i";
+        ;
+    
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
+                          "x x x x x x x x o o o o o o o o";
+        
+        write           = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
+                          "x x x x x x x x i i i i i i i i";
+        ;
+    
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
+                          "x x x x x x x x x x x x x o o o";
+        
+        write           = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
+                          "x x x x x x x x x x x x x i i i";
+        ;
+    
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
+                          "x x x x x x x x x x o o o o o o";
+        
+        write           = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
+                          "x x x x x x x x 1 1 i i i i i i";
+        ;
+    
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
+                          "0 0 0 0 0 0 0 0 o o o o o o o o";
+        ;
+    
+    memory "signature"
+        size            = 3;
+        read            = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
+                          "x x x x x x a1 a0 o o o o o o o o";
+        ;
+;
+
+#------------------------------------------------------------
+# ATtiny88
+#------------------------------------------------------------
+
+part
+    id               = "t88";
+    desc             = "attiny88";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                    0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                    0x99, 0xF9, 0xBB, 0xAF;
+    stk500_devcode   = 0x73;
+#    avr910_devcode   = 0x;
+    signature        = 0x1e 0x93 0x11;
+    pagel            = 0xd7;
+    bs2              = 0xc2;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+       0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+       0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+       0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+       0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    resetdelay          = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no;
+        page_size       = 4;
+        size            = 64;
+        min_write_delay = 3600;
+        max_write_delay = 3600;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+       read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+       write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         "  x  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 64;
+      ;
+    memory "flash"
+        paged           = yes;
+        size            = 8192;
+        page_size       = 64;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0    0   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        read_hi         = "  0   0   1   0    1   0   0   0",
+                          "  0   0   0   0  a11 a10  a9  a8",
+                          " a7  a6  a5  a4   a3  a2  a1  a0",
+                          "  o   o   o   o    o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   x      x   x   x   x",
+                          "  x   x   x  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x   i i i i  i i i i";
+      ;
+
+    memory "efuse"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x   x x x x  x o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x   x x x x  x x x i";
+      ;
+
+    memory "lock"
+        size            = 1;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0  0  1  1   1  0  0  0   0  0  0  x   x  x  x  x",
+                          "0  0  0  0   0  0  0  0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega328P
+#------------------------------------------------------------
+
+part
+    id                 = "m328p";
+    desc               = "ATMEGA328P";
+    has_debugwire      = yes;
+    flash_instr                = 0xB6, 0x01, 0x11;
+    eeprom_instr       = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                         0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                         0x99, 0xF9, 0xBB, 0xAF;
+    stk500_devcode     = 0x86;
+    # avr910_devcode   = 0x;
+    signature          = 0x1e 0x95 0x0F;
+    pagel              = 0xd7;
+    bs2                        = 0xc2;
+    chip_erase_delay   = 9000;
+    pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
+                "x x x x x x x x x x x x x x x x";
+
+    chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
+                "x x x x x x x x x x x x x x x x";
+
+    timeout    = 200;
+    stabdelay  = 100;
+    cmdexedelay        = 25;
+    synchloops = 32;
+    bytedelay  = 0;
+    pollindex  = 3;
+    pollvalue  = 0x53;
+    predelay   = 1;
+    postdelay  = 1;
+    pollmethod = 1;
+
+    pp_controlstack =
+       0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+       0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+       0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+       0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay   = 100;
+    progmodedelay      = 0;
+    latchcycles                = 5;
+    togglevtg          = 1;
+    poweroffdelay      = 15;
+    resetdelayms       = 1;
+    resetdelayus       = 0;
+    hvleavestabdelay   = 15;
+    resetdelay         = 15;
+    chiperasepulsewidth        = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+       paged           = no;
+       page_size       = 4;
+       size            = 1024;
+       min_write_delay = 3600;
+       max_write_delay = 3600;
+       readback_p1     = 0xff;
+       readback_p2     = 0xff;
+       read = " 1 0 1 0 0 0 0 0",
+              " 0 0 0 x x x a9 a8",
+              " a7 a6 a5 a4 a3 a2 a1 a0",
+              " o o o o o o o o";
+
+       write = " 1 1 0 0 0 0 0 0",
+               " 0 0 0 x x x a9 a8",
+               " a7 a6 a5 a4 a3 a2 a1 a0",
+               " i i i i i i i i";
+
+       loadpage_lo = " 1 1 0 0 0 0 0 1",
+                     " 0 0 0 0 0 0 0 0",
+                     " 0 0 0 0 0 0 a1 a0",
+                     " i i i i i i i i";
+
+       writepage = " 1 1 0 0 0 0 1 0",
+                   " 0 0 x x x x a9 a8",
+                   " a7 a6 a5 a4 a3 a2 0 0",
+                   " x x x x x x x x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+    ;
+
+    memory "flash"
+       paged           = yes;
+       size            = 32768;
+       page_size       = 128;
+       num_pages       = 256;
+       min_write_delay = 4500;
+       max_write_delay = 4500;
+       readback_p1     = 0xff;
+       readback_p2     = 0xff;
+       read_lo = " 0 0 1 0 0 0 0 0",
+                 " 0 0 a13 a12 a11 a10 a9 a8",
+                 " a7 a6 a5 a4 a3 a2 a1 a0",
+                 " o o o o o o o o";
+
+       read_hi = " 0 0 1 0 1 0 0 0",
+                 " 0 0 a13 a12 a11 a10 a9 a8",
+                 " a7 a6 a5 a4 a3 a2 a1 a0",
+                 " o o o o o o o o";
+
+       loadpage_lo = " 0 1 0 0 0 0 0 0",
+                     " 0 0 0 x x x x x",
+                     " x x a5 a4 a3 a2 a1 a0",
+                     " i i i i i i i i";
+
+       loadpage_hi = " 0 1 0 0 1 0 0 0",
+                     " 0 0 0 x x x x x",
+                     " x x a5 a4 a3 a2 a1 a0",
+                     " i i i i i i i i";
+
+       writepage = " 0 1 0 0 1 1 0 0",
+                   " 0 0 a13 a12 a11 a10 a9 a8",
+                   " a7 a6 x x x x x x",
+                   " x x x x x x x x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+
+    ;
+
+    memory "lfuse"
+       size = 1;
+       min_write_delay = 4500;
+       max_write_delay = 4500;
+       read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
+              "x x x x x x x x o o o o o o o o";
+
+       write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
+               "x x x x x x x x i i i i i i i i";
+    ;
+
+    memory "hfuse"
+       size = 1;
+       min_write_delay = 4500;
+       max_write_delay = 4500;
+       read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
+              "x x x x x x x x o o o o o o o o";
+
+       write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
+               "x x x x x x x x i i i i i i i i";
+    ;
+
+    memory "efuse"
+       size = 1;
+       min_write_delay = 4500;
+       max_write_delay = 4500;
+       read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
+              "x x x x x x x x x x x x x o o o";
+
+       write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
+               "x x x x x x x x x x x x x i i i";
+    ;
+
+    memory "lock"
+       size = 1;
+       min_write_delay = 4500;
+       max_write_delay = 4500;
+       read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
+              "x x x x x x x x x x o o o o o o";
+
+       write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
+               "x x x x x x x x 1 1 i i i i i i";
+    ;
+
+    memory "calibration"
+       size = 1;
+       read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
+              "0 0 0 0 0 0 0 0 o o o o o o o o";
+    ;
+
+    memory "signature"
+       size = 3;
+       read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
+              "x x x x x x a1 a0 o o o o o o o o";
+    ;
+;
+
+#------------------------------------------------------------
+# ATtiny2313
+#------------------------------------------------------------
+
+part
+     id            = "t2313";
+     desc          = "ATtiny2313";
+     has_debugwire = yes;
+     flash_instr   = 0xB2, 0x0F, 0x1F;
+     eeprom_instr  = 0xBB, 0xFE, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBA, 0x0F, 0xB2, 0x0F, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+     stk500_devcode   = 0x23;
+##   Use the ATtiny26 devcode:
+     avr910_devcode   = 0x5e;
+     signature        = 0x1e 0x91 0x0a;
+     pagel            = 0xD4;
+     bs2              = 0xD6;
+     reset            = io;
+     chip_erase_delay = 9000;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0E, 0x1E, 0x2E, 0x3E, 0x2E, 0x3E,
+        0x4E, 0x5E, 0x4E, 0x5E, 0x6E, 0x7E, 0x6E, 0x7E,
+        0x26, 0x36, 0x66, 0x76, 0x2A, 0x3A, 0x6A, 0x7A,
+        0x2E, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+     memory "eeprom"
+         size            = 128;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0   0 0 0 x  x x x x",
+                           "x a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0   0 0 0 x  x x x x",
+                           "x a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         "  x  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 2048;
+         page_size       = 32;
+         num_pages       = 64;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0    0   0  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0    0   0  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+# The information in the data sheet of April/2004 is wrong, this works:
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x   x   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+# The information in the data sheet of April/2004 is wrong, this works:
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x   x   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+# The information in the data sheet of April/2004 is wrong, this works:
+         writepage       = "  0  1  0  0   1  1  0  0",
+                           "  0  0  0  0   0  0 a9 a8",
+                           " a7 a6 a5 a4   x  x  x  x",
+                           "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+       ;
+#   ATtiny2313 has Signature Bytes: 0x1E 0x91 0x0A.
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  1 1 i i  i i i i";
+         read           = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  x x o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+# The Tiny2313 has calibration data for both 4 MHz and 8 MHz.
+# The information in the data sheet of April/2004 is wrong, this works:
+
+     memory "calibration"
+         size            = 2;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  a0   o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# ATtiny4313
+#------------------------------------------------------------
+
+part
+     id            = "t4313";
+     desc          = "ATtiny4313";
+     has_debugwire = yes;
+     flash_instr   = 0xB2, 0x0F, 0x1F;
+     eeprom_instr  = 0xBB, 0xFE, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBA, 0x0F, 0xB2, 0x0F, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+     stk500_devcode   = 0x23;
+##   Use the ATtiny26 devcode:
+     avr910_devcode   = 0x5e;
+     signature        = 0x1e 0x92 0x0d;
+     pagel            = 0xD4;
+     bs2              = 0xD6;
+     reset            = io;
+     chip_erase_delay = 9000;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0E, 0x1E, 0x2E, 0x3E, 0x2E, 0x3E,
+        0x4E, 0x5E, 0x4E, 0x5E, 0x6E, 0x7E, 0x6E, 0x7E,
+        0x26, 0x36, 0x66, 0x76, 0x2A, 0x3A, 0x6A, 0x7A,
+        0x2E, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+     memory "eeprom"
+         size            = 256;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1   0  1  0   0  0  0  0   0 0 0 x  x x x x",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+         write           = "1   1  0  0   0  0  0  0   0 0 0 x  x x x x",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 4096;
+         page_size       = 64;
+         num_pages       = 64;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0    0 a10  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0    0 a10  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1   1  0  0",
+                           "  0  0  0  0   0 a10 a9 a8",
+                           " a7 a6 a5  x   x   x  x  x",
+                           "  x  x  x  x   x   x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+       ;
+#   ATtiny4313 has Signature Bytes: 0x1E 0x92 0x0D.
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  1 1 i i  i i i i";
+         read           = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  x x o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 2;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  a0   o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# AT90PWM2
+#------------------------------------------------------------
+
+part
+     id            = "pwm2";
+     desc          = "AT90PWM2";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                    0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                    0x99, 0xF9, 0xBB, 0xAF;
+     stk500_devcode   = 0x65;
+##  avr910_devcode   = ?;
+     signature        = 0x1e 0x93 0x81;
+     pagel            = 0xD8;
+     bs2              = 0xE2;
+     reset            = io;
+     chip_erase_delay = 9000;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+     memory "eeprom"
+         size            = 512;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0   0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0  o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0   0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0  i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 8192;
+         page_size       = 64;
+         num_pages       = 128;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0   a11 a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0   a11 a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1   1   0   0",
+                           "  0  0  0  0   a11 a10 a9  a8",
+                           " a7 a6 a5  x   x   x   x   x",
+                           "  x  x  x  x   x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+       ;
+#   AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81.
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  x  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  1 1 i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  x x o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 1;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  0    o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# AT90PWM3
+#------------------------------------------------------------
+
+# Completely identical to AT90PWM2 (including the signature!)
+
+part
+     id            = "pwm3";
+     desc          = "AT90PWM3";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                    0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                    0x99, 0xF9, 0xBB, 0xAF;
+     stk500_devcode   = 0x65;
+##  avr910_devcode   = ?;
+     signature        = 0x1e 0x93 0x81;
+     pagel            = 0xD8;
+     bs2              = 0xE2;
+     reset            = io;
+     chip_erase_delay = 9000;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+     memory "eeprom"
+         size            = 512;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0   0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0  o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0   0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0  i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 8192;
+         page_size       = 64;
+         num_pages       = 128;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0   a11 a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0   a11 a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1   1   0   0",
+                           "  0  0  0  0   a11 a10 a9  a8",
+                           " a7 a6 a5  x   x   x   x   x",
+                           "  x  x  x  x   x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+       ;
+#   AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81.
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  x  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  1 1 i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  x x o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 1;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  0    o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# AT90PWM2B
+#------------------------------------------------------------
+# Same as AT90PWM2 but different signature.
+
+part
+     id            = "pwm2b";
+     desc          = "AT90PWM2B";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                    0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                    0x99, 0xF9, 0xBB, 0xAF;
+     stk500_devcode   = 0x65;
+##  avr910_devcode   = ?;
+     signature        = 0x1e 0x93 0x83;
+     pagel            = 0xD8;
+     bs2              = 0xE2;
+     reset            = io;
+     chip_erase_delay = 9000;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+     memory "eeprom"
+         size            = 512;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0   0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0  o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0   0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0  i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 8192;
+         page_size       = 64;
+         num_pages       = 128;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0   a11 a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0   a11 a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1   1   0   0",
+                           "  0  0  0  0   a11 a10 a9  a8",
+                           " a7 a6 a5  x   x   x   x   x",
+                           "  x  x  x  x   x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+       ;
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  x  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  1 1 i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  x x o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 1;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  0    o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# AT90PWM3B
+#------------------------------------------------------------
+
+# Completely identical to AT90PWM2B (including the signature!)
+
+part
+     id            = "pwm3b";
+     desc          = "AT90PWM3B";
+     has_debugwire = yes;
+     flash_instr   = 0xB6, 0x01, 0x11;
+     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
+                    0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
+                    0x99, 0xF9, 0xBB, 0xAF;
+     stk500_devcode   = 0x65;
+##  avr910_devcode   = ?;
+     signature        = 0x1e 0x93 0x83;
+     pagel            = 0xD8;
+     bs2              = 0xE2;
+     reset            = io;
+     chip_erase_delay = 9000;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+     memory "eeprom"
+         size            = 512;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0   0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0  o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0   0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0  i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 8192;
+         page_size       = 64;
+         num_pages       = 128;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0   a11 a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0   a11 a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1   1   0   0",
+                           "  0  0  0  0   a11 a10 a9  a8",
+                           " a7 a6 a5  x   x   x   x   x",
+                           "  x  x  x  x   x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+       ;
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  x  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  1 1 i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  x x o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 1;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  0    o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# ATtiny25
+#------------------------------------------------------------
+
+part
+     id            = "t25";
+     desc          = "ATtiny25";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x02, 0x12;
+     eeprom_instr  = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBC, 0x02, 0xB4, 0x02, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+## no STK500 devcode in XML file, use the ATtiny45 one
+     stk500_devcode   = 0x14;
+##  avr910_devcode   = ?;
+##  Try the AT90S2313 devcode:
+     avr910_devcode   = 0x20;
+     signature        = 0x1e 0x91 0x08;
+     reset            = io;
+     chip_erase_delay = 4500;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    hvsp_controlstack   =
+        0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66,
+        0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78,
+        0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00;
+    hventerstabdelay    = 100;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+     memory "eeprom"
+         size            = 128;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0   0 0 0 x  x x x x",
+                           "x a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0   0 0 0 x  x x x x",
+                           "x a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         "  x  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 2048;
+         page_size       = 32;
+         num_pages       = 64;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0    0   0  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0    0   0  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x   x   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x   x   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1  1  0  0",
+                           "  0  0  0  0   0  0 a9 a8",
+                           " a7 a6 a5 a4   x  x  x  x",
+                           "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+       ;
+#   ATtiny25 has Signature Bytes: 0x1E 0x91 0x08.
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 2;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  a0   o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# ATtiny45
+#------------------------------------------------------------
+
+part
+     id            = "t45";
+     desc          = "ATtiny45";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x02, 0x12;
+     eeprom_instr  = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBC, 0x02, 0xB4, 0x02, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+     stk500_devcode   = 0x14;
+##  avr910_devcode   = ?;
+##  Try the AT90S2313 devcode:
+     avr910_devcode   = 0x20;
+     signature        = 0x1e 0x92 0x06;
+     reset            = io;
+     chip_erase_delay = 4500;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    hvsp_controlstack     =
+       0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66,
+        0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78,
+        0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+     memory "eeprom"
+         size            = 256;
+         page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0    0 0 0 x  x x x x",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0    0 0 0 x  x x x x",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 4096;
+         page_size       = 64;
+         num_pages       = 64;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0    0  a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0    0  a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1  1  0  0",
+                           "  0  0  0  0   0 a10 a9 a8",
+                           " a7 a6 a5  x   x  x  x  x",
+                           "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+       ;
+#   ATtiny45 has Signature Bytes: 0x1E 0x92 0x08. (Data sheet 2586C-AVR-06/05 (doc2586.pdf) indicates otherwise!)
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 2;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  a0   o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# ATtiny85
+#------------------------------------------------------------
+
+part
+     id            = "t85";
+     desc          = "ATtiny85";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x02, 0x12;
+     eeprom_instr  = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBC, 0x02, 0xB4, 0x02, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+## no STK500 devcode in XML file, use the ATtiny45 one
+     stk500_devcode   = 0x14;
+##  avr910_devcode   = ?;
+##  Try the AT90S2313 devcode:
+     avr910_devcode   = 0x20;
+     signature        = 0x1e 0x93 0x0b;
+     reset            = io;
+     chip_erase_delay = 4500;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    hvsp_controlstack   =
+        0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66,
+        0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78,
+        0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00;
+    hventerstabdelay    = 100;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+     memory "eeprom"
+         size            = 512;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0    0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0    0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x  a8",
+                         " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 8192;
+         page_size       = 64;
+         num_pages       = 128;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0  a11 a10  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0  a11 a10  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1   1   0  0",
+                           "  0  0  0  0  a11 a10 a9 a8",
+                           " a7 a6 a5  x   x  x  x  x",
+                           "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+       ;
+#   ATtiny85 has Signature Bytes: 0x1E 0x93 0x08.
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 2;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  a0   o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# ATmega640
+#------------------------------------------------------------
+# Almost same as ATmega1280, except for different memory sizes
+
+part
+    id               = "m640";
+    desc             = "ATMEGA640";
+    signature        = 0x1e 0x96 0x08;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  x i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega1280
+#------------------------------------------------------------
+
+part
+    id               = "m1280";
+    desc             = "ATMEGA1280";
+    signature        = 0x1e 0x97 0x03;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 131072;
+        page_size       = 256;
+        num_pages       = 512;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  x i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega1281
+#------------------------------------------------------------
+# Identical to ATmega1280
+
+part
+    id               = "m1281";
+    desc             = "ATMEGA1281";
+    signature        = 0x1e 0x97 0x04;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 131072;
+        page_size       = 256;
+        num_pages       = 512;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  x i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega2560
+#------------------------------------------------------------
+
+part
+    id               = "m2560";
+    desc             = "ATMEGA2560";
+    signature        = 0x1e 0x98 0x01;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 262144;
+        page_size       = 256;
+        num_pages       = 1024;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+        load_ext_addr   = "  0   1   0   0      1   1   0   1",
+                          "  0   0   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0   0 a16",
+                          "  0   0   0   0      0   0   0   0";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  x i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega2561
+#------------------------------------------------------------
+
+part
+    id               = "m2561";
+    desc             = "ATMEGA2561";
+    signature        = 0x1e 0x98 0x02;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 262144;
+        page_size       = 256;
+        num_pages       = 1024;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+        load_ext_addr   = "  0   1   0   0      1   1   0   1",
+                          "  0   0   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0   0 a16",
+                          "  0   0   0   0      0   0   0   0";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  x i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega128RFA1
+#------------------------------------------------------------
+# Identical to ATmega2561 but half the ROM
+
+part
+    id               = "m128rfa1";
+    desc             = "ATMEGA128RFA1";
+    signature        = 0x1e 0xa7 0x01;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 55000;
+    pagel            = 0xD7;
+    bs2              = 0xE2;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 50000;
+        max_write_delay = 50000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x    a11 a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 131072;
+        page_size       = 256;
+        num_pages       = 512;
+        min_write_delay = 50000;
+        max_write_delay = 50000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  x i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATtiny24
+#------------------------------------------------------------
+
+part
+     id            = "t24";
+     desc          = "ATtiny24";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x07, 0x17;
+     eeprom_instr  = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBC, 0x07, 0xB4, 0x07, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+## no STK500 devcode in XML file, use the ATtiny45 one
+     stk500_devcode   = 0x14;
+##  avr910_devcode   = ?;
+##  Try the AT90S2313 devcode:
+     avr910_devcode   = 0x20;
+     signature        = 0x1e 0x91 0x0b;
+     reset            = io;
+     chip_erase_delay = 4500;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    hvsp_controlstack   =
+        0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66,
+        0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78,
+        0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0F;
+    hventerstabdelay    = 100;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 0;
+    resetdelayus        = 70;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+     memory "eeprom"
+         size            = 128;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0   0 0 0 x  x x x x",
+                           "x a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0   0 0 0 x  x x x x",
+                           "x a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         "  x  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 2048;
+         page_size       = 32;
+         num_pages       = 64;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0    0   0  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0    0   0  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x   x   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x   x   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1  1  0  0",
+                           "  0  0  0  0   0  0 a9 a8",
+                           " a7 a6 a5 a4   x  x  x  x",
+                           "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+       ;
+#   ATtiny24 has Signature Bytes: 0x1E 0x91 0x0B.
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  x x x x  x x i i";
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
+                           "0 0 0 0  0 0 0 0  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 1;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  a0   o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# ATtiny44
+#------------------------------------------------------------
+
+part
+     id            = "t44";
+     desc          = "ATtiny44";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x07, 0x17;
+     eeprom_instr  = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                     0xBC, 0x07, 0xB4, 0x07, 0xBA, 0x0D, 0xBB, 0xBC,
+                     0x99, 0xE1, 0xBB, 0xAC;
+## no STK500 devcode in XML file, use the ATtiny45 one
+     stk500_devcode   = 0x14;
+##  avr910_devcode   = ?;
+##  Try the AT90S2313 devcode:
+     avr910_devcode   = 0x20;
+     signature        = 0x1e 0x92 0x07;
+     reset            = io;
+     chip_erase_delay = 4500;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    hvsp_controlstack   =
+        0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66,
+        0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78,
+        0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0F;
+    hventerstabdelay    = 100;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 0;
+    resetdelayus        = 70;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+     memory "eeprom"
+         size            = 256;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0    0 0 0 x  x x x x",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0    0 0 0 x  x x x x",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         "  x  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 4096;
+         page_size       = 64;
+         num_pages       = 64;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0    0  a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0    0  a10 a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1  1  0  0",
+                           "  0  0  0  0   0 a10 a9 a8",
+                           " a7 a6 a5  x   x  x  x  x",
+                           "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+       ;
+#   ATtiny44 has Signature Bytes: 0x1E 0x92 0x07.
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  x x x x  x x i i";
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
+                           "0 0 0 0  0 0 0 0  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 1;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  a0   o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# ATtiny84
+#------------------------------------------------------------
+
+part
+     id            = "t84";
+     desc          = "ATtiny84";
+     has_debugwire = yes;
+     flash_instr   = 0xB4, 0x07, 0x17;
+     eeprom_instr  = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
+                    0xBC, 0x07, 0xB4, 0x07, 0xBA, 0x0D, 0xBB, 0xBC,
+                    0x99, 0xE1, 0xBB, 0xAC;
+## no STK500 devcode in XML file, use the ATtiny45 one
+     stk500_devcode   = 0x14;
+##  avr910_devcode   = ?;
+##  Try the AT90S2313 devcode:
+     avr910_devcode   = 0x20;
+     signature        = 0x1e 0x93 0x0c;
+     reset            = io;
+     chip_erase_delay = 4500;
+
+     pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+     chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                        "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    hvsp_controlstack   =
+        0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66,
+        0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78,
+        0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10,
+        0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0F;
+    hventerstabdelay    = 100;
+    hvspcmdexedelay     = 0;
+    synchcycles         = 6;
+    latchcycles         = 1;
+    togglevtg           = 1;
+    poweroffdelay       = 25;
+    resetdelayms        = 0;
+    resetdelayus        = 70;
+    hvleavestabdelay    = 100;
+    resetdelay          = 25;
+    chiperasepolltimeout = 40;
+    chiperasetime       = 0;
+    programfusepolltimeout = 25;
+    programlockpolltimeout = 25;
+
+     memory "eeprom"
+         size            = 512;
+        paged           = no;
+        page_size       = 4;
+         min_write_delay = 4000;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read            = "1  0  1  0   0  0  0  0    0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   o o o o  o o o o";
+
+         write           = "1  1  0  0   0  0  0  0    0 0 0 x  x x x a8",
+                           "a7 a6 a5 a4  a3 a2 a1 a0   i i i i  i i i i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x   x   x   x",
+                         "  x  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 4;
+       readsize        = 256;
+       ;
+     memory "flash"
+         paged           = yes;
+         size            = 8192;
+         page_size       = 64;
+         num_pages       = 128;
+         min_write_delay = 4500;
+         max_write_delay = 4500;
+         readback_p1     = 0xff;
+         readback_p2     = 0xff;
+         read_lo         = "  0   0   1   0    0   0   0   0",
+                           "  0   0   0   0  a11 a10  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         read_hi         = "  0   0   1   0    1   0   0   0",
+                           "  0   0   0   0  a11 a10  a9  a8",
+                           " a7  a6  a5  a4   a3  a2  a1  a0",
+                           "  o   o   o   o    o   o   o   o";
+
+         loadpage_lo     = "  0   1   0   0    0   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         loadpage_hi     = "  0   1   0   0    1   0   0   0",
+                           "  0   0   0   x    x   x   x   x",
+                           "  x   x   x  a4   a3  a2  a1  a0",
+                           "  i   i   i   i    i   i   i   i";
+
+         writepage       = "  0  1  0  0   1   1   0  0",
+                           "  0  0  0  0  a11 a10 a9 a8",
+                           " a7 a6 a5  x   x  x  x  x",
+                           "  x  x  x  x   x  x  x  x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 32;
+       readsize        = 256;
+       ;
+#   ATtiny84 has Signature Bytes: 0x1E 0x93 0x0C.
+     memory "signature"
+         size            = 3;
+         read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                           "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+       ;
+
+     memory "lock"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
+                           "x x x x  x x x x  x x x x  x x i i";
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
+                           "0 0 0 0  0 0 0 0  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "lfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "hfuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                           "x x x x  x x x x  i i i i  i i i i";
+
+         read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+       ;
+
+     memory "efuse"
+         size            = 1;
+         write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                           "x x x x  x x x x  x x x x  x x x i";
+
+         read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                           "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+     ;
+
+     memory "calibration"
+         size            = 1;
+         read            = "0  0  1  1   1  0  0  0    0 0 0 x  x x x x",
+                           "0  0  0  0   0  0  0  a0   o o o o  o o o o";
+     ;
+  ;
+
+#------------------------------------------------------------
+# ATmega32u4
+#------------------------------------------------------------
+
+part
+    id               = "m32u4";
+    desc             = "ATmega32U4";
+    signature        = 0x1e 0x95 0x87;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          " a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90USB646
+#------------------------------------------------------------
+
+part
+    id               = "usb646";
+    desc             = "AT90USB646";
+    signature        = 0x1e 0x96 0x82;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90USB647
+#------------------------------------------------------------
+# identical to AT90USB646
+
+part
+    id               = "usb647";
+    desc             = "AT90USB647";
+    signature        = 0x1e 0x96 0x82;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90USB1286
+#------------------------------------------------------------
+
+part
+    id               = "usb1286";
+    desc             = "AT90USB1286";
+    signature        = 0x1e 0x97 0x82;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 131072;
+        page_size       = 256;
+        num_pages       = 512;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90USB1287
+#------------------------------------------------------------
+# identical to AT90USB1286
+
+part
+    id               = "usb1287";
+    desc             = "AT90USB1287";
+    signature        = 0x1e 0x97 0x82;
+    has_jtag         = yes;
+#    stk500_devcode   = 0xB2;
+#    avr910_devcode   = 0x43;
+    chip_erase_delay = 9000;
+    pagel            = 0xD7;
+    bs2              = 0xA0;
+    reset            = dedicated;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "x x x x  x x x x    x x x x  x x x x";
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    rampz               = 0x3b;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 4096;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  x   x   x   x    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0", 
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0  a2  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                         "  0   0   x   x      x a10  a9  a8",
+                         " a7  a6  a5  a4     a3   0   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 10;
+       blocksize       = 8;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 131072;
+        page_size       = 256;
+        num_pages       = 512;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7   x   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 256;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  x x x x  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    x x x x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+
+#------------------------------------------------------------
+# AT90USB162
+#------------------------------------------------------------
+
+part
+    id               = "usb162";
+    desc             = "AT90USB162";
+    has_jtag         = no;
+    has_debugwire    = yes;
+    signature        = 0x1e 0x94 0x82;
+    chip_erase_delay = 9000;
+    reset            = io;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+    pagel            = 0xD7;
+    bs2              = 0xC6;
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 512;
+        num_pages       = 128;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# AT90USB82
+#------------------------------------------------------------
+# Changes against AT90USB162 (beside IDs)
+#    memory "flash"
+#        size            = 8192;
+#        num_pages       = 64;
+
+part
+    id               = "usb82";
+    desc             = "AT90USB82";
+    has_jtag         = no;
+    has_debugwire    = yes;
+    signature        = 0x1e 0x93 0x82;
+    chip_erase_delay = 9000;
+    reset            = io;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+    pagel            = 0xD7;
+    bs2              = 0xC6;
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 512;
+        num_pages       = 128;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 8192;
+        page_size       = 128;
+        num_pages       = 64;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega32U2
+#------------------------------------------------------------
+# Changes against AT90USB162 (beside IDs)
+#    memory "flash"
+#        size            = 32768;
+#        num_pages       = 256;
+#    memory "eeprom"
+#        size            = 1024;
+#        num_pages       = 256;
+part
+    id               = "m32u2";
+    desc             = "ATmega32U2";
+    has_jtag         = no;
+    has_debugwire    = yes;
+    signature        = 0x1e 0x95 0x8a;
+    chip_erase_delay = 9000;
+    reset            = io;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+    pagel            = 0xD7;
+    bs2              = 0xC6;
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 1024;
+        num_pages       = 256;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+#------------------------------------------------------------
+# ATmega16U2
+#------------------------------------------------------------
+# Changes against ATmega32U2 (beside IDs)
+#    memory "flash"
+#        size            = 16384;
+#        num_pages       = 128;
+#    memory "eeprom"
+#        size            = 512;
+#        num_pages       = 128;
+part
+    id               = "m16u2";
+    desc             = "ATmega16U2";
+    has_jtag         = no;
+    has_debugwire    = yes;
+    signature        = 0x1e 0x94 0x89;
+    chip_erase_delay = 9000;
+    reset            = io;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+    pagel            = 0xD7;
+    bs2              = 0xC6;
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 512;
+        num_pages       = 128;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 16384;
+        page_size       = 128;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 128;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+
+#------------------------------------------------------------
+# ATmega8U2
+#------------------------------------------------------------
+# Changes against ATmega16U2 (beside IDs)
+#    memory "flash"
+#        size            = 8192;
+#        page_size       = 64;
+#        blocksize       = 64;
+
+part
+    id               = "m8u2";
+    desc             = "ATmega8U2";
+    has_jtag         = no;
+    has_debugwire    = yes;
+    signature        = 0x1e 0x93 0x89;
+    chip_erase_delay = 9000;
+    reset            = io;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "x x x x  x x x x    x x x x  x x x x";
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
+                       "x x x x  x x x x    x x x x  x x x x";
+    pagel            = 0xD7;
+    bs2              = 0xC6;
+
+    timeout            = 200;
+    stabdelay          = 100;
+    cmdexedelay                = 25;
+    synchloops         = 32;
+    bytedelay          = 0;
+    pollindex          = 3;
+    pollvalue          = 0x53;
+    predelay           = 1;
+    postdelay          = 1;
+    pollmethod         = 1;
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 512;
+        num_pages       = 128;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+       loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                         "  0   0   0   0      0   0   0   0",
+                         "  0   0   0   0      0   0  a1  a0",
+                         "  i   i   i   i      i   i   i   i";
+
+       writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   0   0    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2   0   0",
+                         "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 20;
+       blocksize       = 4;
+       readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 8192;
+        page_size       = 64;
+        num_pages       = 128;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0x00;
+        readback_p2     = 0x00;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  x   x   x   x      x   x   x   x",
+                          "  x   x  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "a15 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6   x   x      x   x   x   x",
+                          "  x   x   x   x      x   x   x   x";
+
+       mode            = 0x41;
+       delay           = 6;
+       blocksize       = 64;
+       readsize        = 256;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  1 0 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  1 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "x x x x  x x x x  i i i i  i i i i";
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "x x x x  x x x x  o o o o  o o o o";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
+                          "x x x x  x x x x   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "calibration"
+        size            = 1;
+        read            = "0 0 1 1  1 0 0 0    0 0 0 x  x x x x",
+                          "0 0 0 0  0 0 0 0    o o o o  o o o o";
+      ;
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  x   x  x  x  x",
+                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
+      ;
+  ;
+#------------------------------------------------------------
+# ATmega325
+#------------------------------------------------------------
+
+part
+    id               = "m325";
+    desc             = "ATMEGA325";
+    signature        = 0x1e 0x95 0x05;
+    has_jtag         = yes;
+#   stk500_devcode   = 0x??; # No STK500v1 support?
+#   avr910_devcode   = 0x??; # Try the ATmega16 one
+    avr910_devcode   = 0x74;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "0 0 0 0  0 0 0 0    0 0 0 0  0 0 0 0";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "0 0 0 0  0 0 0 0    0 0 0 0  0 0 0 0";
+
+    timeout             = 200;
+    stabdelay           = 100;
+    cmdexedelay         = 25;
+    synchloops          = 32;
+    bytedelay           = 0;
+    pollindex           = 3;
+    pollvalue           = 0x53;
+    predelay            = 1;
+    postdelay           = 1;
+    pollmethod          = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   0      0   0  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                          "  0   0   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   0   0      0   0  a9  a8",
+                          " a7  a6  a5  a4     a3  a2   0   0",
+                          "  x   x   x   x      x   x   x   x";
+
+        mode            = 0x41;
+        delay           = 10;
+        blocksize       = 4;
+        readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0   0   0",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   0      0   0   0   0",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  x   x   x   x      x   x   x   x";
+
+        mode            = 0x41;
+        delay           = 10;
+        blocksize       = 128;
+        readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "0 0 0 0  0 0 0 0  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  0   0  0  0  0",
+                          "0  0  0  0   0  0 a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+#------------------------------------------------------------
+# ATmega645
+#------------------------------------------------------------
+
+part
+    id               = "m645";
+    desc             = "ATMEGA645";
+    signature        = 0x1E 0x96 0x05;
+    has_jtag         = yes;
+#   stk500_devcode   = 0x??; # No STK500v1 support?
+#   avr910_devcode   = 0x??; # Try the ATmega16 one
+    avr910_devcode   = 0x74;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "0 0 0 0  0 0 0 0    0 0 0 0  0 0 0 0";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "0 0 0 0  0 0 0 0    0 0 0 0  0 0 0 0";
+
+    timeout             = 200;
+    stabdelay           = 100;
+    cmdexedelay         = 25;
+    synchloops          = 32;
+    bytedelay           = 0;
+    pollindex           = 3;
+    pollvalue           = 0x53;
+    predelay            = 1;
+    postdelay           = 1;
+    pollmethod          = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   0      0 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   0      0 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                          "  0   0   0   0      0   0   0   0",
+                          "  0   0   0   0      0  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   0   0      0 a10  a9  a8",
+                          " a7  a6  a5  a4     a3   0   0   0",
+                          "  x   x   x   x      x   x   x   x";
+
+        mode            = 0x41;
+        delay           = 10;
+        blocksize       = 8;
+        readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "   0   0   1   0      0   0   0   0",
+                          " a15 a14 a13 a12    a11 a10  a9  a8",
+                          "  a7  a6  a5  a4     a3  a2  a1  a0",
+                          "   o   o   o   o      o   o   o   o";
+
+        read_hi         = "   0   0   1   0      1   0   0   0",
+                          " a15 a14 a13 a12    a11 a10  a9  a8",
+                          "  a7  a6  a5  a4     a3  a2  a1  a0",
+                          "   o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0   0   0",
+                          "  a7 a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   0      0   0   0   0",
+                          "  a7 a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "   0   1   0   0      1   1   0   0",
+                          " a15 a14 a13 a12    a11 a10  a9  a8",
+                          "  a7  a6  a5  a4     a3  a2  a1  a0",
+                          "   0   0   0   0      0   0   0   0";
+
+        mode            = 0x41;
+        delay           = 10;
+        blocksize       = 128;
+        readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "0 0 0 0  0 0 0 0  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  0   0  0  0  0",
+                          "0  0  0  0   0  0 a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+#------------------------------------------------------------
+# ATmega3250
+#------------------------------------------------------------
+
+part
+    id               = "m3250";
+    desc             = "ATMEGA3250";
+    signature        = 0x1E 0x95 0x06;
+    has_jtag         = yes;
+#   stk500_devcode   = 0x??; # No STK500v1 support?
+#   avr910_devcode   = 0x??; # Try the ATmega16 one
+    avr910_devcode   = 0x74;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "0 0 0 0  0 0 0 0    0 0 0 0  0 0 0 0";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "0 0 0 0  0 0 0 0    0 0 0 0  0 0 0 0";
+
+    timeout             = 200;
+    stabdelay           = 100;
+    cmdexedelay         = 25;
+    synchloops          = 32;
+    bytedelay           = 0;
+    pollindex           = 3;
+    pollvalue           = 0x53;
+    predelay            = 1;
+    postdelay           = 1;
+    pollmethod          = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 4;  /* for parallel programming */
+        size            = 1024;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   0      0   0  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                          "  0   0   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   0   0      0   0  a9  a8",
+                          " a7  a6  a5  a4     a3  a2   0   0",
+                          "  x   x   x   x      x   x   x   x";
+
+        mode            = 0x41;
+        delay           = 10;
+        blocksize       = 4;
+        readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 32768;
+        page_size       = 128;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "  0   0   1   0      0   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        read_hi         = "  0   0   1   0      1   0   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0   0   0",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   0      0   0   0   0",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  0   1   0   0      1   1   0   0",
+                          "  0 a14 a13 a12    a11 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  x   x   x   x      x   x   x   x";
+
+        mode            = 0x41;
+        delay           = 10;
+        blocksize       = 128;
+        readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "0 0 0 0  0 0 0 0  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  0   0  0  0  0",
+                          "0  0  0  0   0  0 a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+#------------------------------------------------------------
+# ATmega6450
+#------------------------------------------------------------
+
+part
+    id               = "m6450";
+    desc             = "ATMEGA6450";
+    signature        = 0x1E 0x96 0x06;
+    has_jtag         = yes;
+#   stk500_devcode   = 0x??; # No STK500v1 support?
+#   avr910_devcode   = 0x??; # Try the ATmega16 one
+    avr910_devcode   = 0x74;
+    pagel            = 0xd7;
+    bs2              = 0xa0;
+    chip_erase_delay = 9000;
+    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
+                       "0 0 0 0  0 0 0 0    0 0 0 0  0 0 0 0";
+
+    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 0  0 0 0 0",
+                       "0 0 0 0  0 0 0 0    0 0 0 0  0 0 0 0";
+
+    timeout             = 200;
+    stabdelay           = 100;
+    cmdexedelay         = 25;
+    synchloops          = 32;
+    bytedelay           = 0;
+    pollindex           = 3;
+    pollvalue           = 0x53;
+    predelay            = 1;
+    postdelay           = 1;
+    pollmethod          = 1;
+
+    pp_controlstack     =
+        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
+        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
+        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
+        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
+    hventerstabdelay    = 100;
+    progmodedelay       = 0;
+    latchcycles         = 5;
+    togglevtg           = 1;
+    poweroffdelay       = 15;
+    resetdelayms        = 1;
+    resetdelayus        = 0;
+    hvleavestabdelay    = 15;
+    chiperasepulsewidth = 0;
+    chiperasepolltimeout = 10;
+    programfusepulsewidth = 0;
+    programfusepolltimeout = 5;
+    programlockpulsewidth = 0;
+    programlockpolltimeout = 5;
+
+    idr                 = 0x31;
+    spmcr               = 0x57;
+    allowfullpagebitstream = no;
+
+    memory "eeprom"
+        paged           = no; /* leave this "no" */
+        page_size       = 8;  /* for parallel programming */
+        size            = 2048;
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read            = "  1   0   1   0      0   0   0   0",
+                          "  0   0   0   0      0 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  o   o   o   o      o   o   o   o";
+
+        write           = "  1   1   0   0      0   0   0   0",
+                          "  0   0   0   0      0 a10  a9  a8",
+                          " a7  a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_lo     = "  1   1   0   0      0   0   0   1",
+                          "  0   0   0   0      0   0   0   0",
+                          "  0   0   0   0      0  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "  1   1   0   0      0   0   1   0",
+                          "  0   0   0   0      0 a10  a9  a8",
+                          " a7  a6  a5  a4     a3   0   0   0",
+                          "  x   x   x   x      x   x   x   x";
+
+        mode            = 0x41;
+        delay           = 10;
+        blocksize       = 4;
+        readsize        = 256;
+      ;
+
+    memory "flash"
+        paged           = yes;
+        size            = 65536;
+        page_size       = 256;
+        num_pages       = 256;
+        min_write_delay = 4500;
+        max_write_delay = 4500;
+        readback_p1     = 0xff;
+        readback_p2     = 0xff;
+        read_lo         = "   0   0   1   0      0   0   0   0",
+                          " a15 a14 a13 a12    a11 a10  a9  a8",
+                          "  a7  a6  a5  a4     a3  a2  a1  a0",
+                          "   o   o   o   o      o   o   o   o";
+
+        read_hi         = "   0   0   1   0      1   0   0   0",
+                          " a15 a14 a13 a12    a11 a10  a9  a8",
+                          "  a7  a6  a5  a4     a3  a2  a1  a0",
+                          "   o   o   o   o      o   o   o   o";
+
+        loadpage_lo     = "  0   1   0   0      0   0   0   0",
+                          "  0   0   0   0      0   0   0   0",
+                          "  a7 a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        loadpage_hi     = "  0   1   0   0      1   0   0   0",
+                          "  0   0   0   0      0   0   0   0",
+                          "  a7 a6  a5  a4     a3  a2  a1  a0",
+                          "  i   i   i   i      i   i   i   i";
+
+        writepage       = "   0   1   0   0      1   1   0   0",
+                          " a15 a14 a13 a12    a11 a10  a9  a8",
+                          "  a7  a6  a5  a4     a3  a2  a1  a0",
+                          "   0   0   0   0      0   0   0   0";
+
+        mode            = 0x41;
+        delay           = 10;
+        blocksize       = 128;
+        readsize        = 256;
+      ;
+
+    memory "lock"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "x x x x  x x x x   x x o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 1 1 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   1 1 i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "lfuse"
+        size            = 1;
+        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "hfuse"
+        size            = 1;
+        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0   i i i i  i i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "efuse"
+        size            = 1;
+
+        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
+                          "0 0 0 0  0 0 0 0  o o o o  o o o o";
+
+        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
+                          "0 0 0 0  0 0 0 0  1 1 1 1  1 i i i";
+        min_write_delay = 9000;
+        max_write_delay = 9000;
+      ;
+
+    memory "signature"
+        size            = 3;
+        read            = "0  0  1  1   0  0  0  0   0  0  0  0   0  0  0  0",
+                          "0  0  0  0   0  0 a1 a0   o  o  o  o   o  o  o  o";
+      ;
+
+    memory "calibration"
+        size            = 1;
+
+        read            = "0 0 1 1  1 0 0 0   0 0 0 0  0 0 0 0",
+                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
+        ;
+  ;
+
+#------------------------------------------------------------
+# ATXMEGA64A1
+#------------------------------------------------------------
+
+part
+    id         = "x64a1";
+    desc       = "ATXMEGA64A1";
+    signature  = 0x1e 0x96 0x4e;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0800;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00010000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00001000;
+        offset         = 0x0080f000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00001000;
+        offset         = 0x00810000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00011000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA128A1
+#------------------------------------------------------------
+
+part
+    id         = "x128a1";
+    desc       = "ATXMEGA128A1";
+    signature  = 0x1e 0x97 0x4c;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0800;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00020000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00002000;
+        offset         = 0x0081e000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00002000;
+        offset         = 0x00820000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00022000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA128A1REVD
+#------------------------------------------------------------
+
+part
+    id         = "x128a1d";
+    desc       = "ATXMEGA128A1REVD";
+    signature  = 0x1e 0x97 0x41;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0800;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00020000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00002000;
+        offset         = 0x0081e000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00002000;
+        offset         = 0x00820000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00022000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA192A1
+#------------------------------------------------------------
+
+part
+    id         = "x192a1";
+    desc       = "ATXMEGA192A1";
+    signature  = 0x1e 0x97 0x4e;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0800;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00030000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00002000;
+        offset         = 0x0082e000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00002000;
+        offset         = 0x00830000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00032000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA256A1
+#------------------------------------------------------------
+
+part
+    id         = "x256a1";
+    desc       = "ATXMEGA256A1";
+    signature  = 0x1e 0x98 0x46;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x1000;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00040000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00002000;
+        offset         = 0x0083e000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00002000;
+        offset         = 0x00840000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00042000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA64A3
+#------------------------------------------------------------
+
+part
+    id         = "x64a3";
+    desc       = "ATXMEGA64A3";
+    signature  = 0x1e 0x96 0x42;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0800;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00010000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00001000;
+        offset         = 0x0080f000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00001000;
+        offset         = 0x00810000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00011000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA128A3
+#------------------------------------------------------------
+
+part
+    id         = "x128a3";
+    desc       = "ATXMEGA128A3";
+    signature  = 0x1e 0x97 0x42;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0800;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00020000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00002000;
+        offset         = 0x0081e000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00002000;
+        offset         = 0x00820000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00022000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA192A3
+#------------------------------------------------------------
+
+part
+    id         = "x192a3";
+    desc       = "ATXMEGA192A3";
+    signature  = 0x1e 0x97 0x44;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0800;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00030000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00002000;
+        offset         = 0x0082e000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00002000;
+        offset         = 0x00830000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00032000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA256A3
+#------------------------------------------------------------
+
+part
+    id         = "x256a3";
+    desc       = "ATXMEGA256A3";
+    signature  = 0x1e 0x98 0x42;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x1000;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00040000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00002000;
+        offset         = 0x0083e000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00002000;
+        offset         = 0x00840000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00042000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA256A3B
+#------------------------------------------------------------
+
+part
+    id         = "x256a3b";
+    desc       = "ATXMEGA256A3B";
+    signature  = 0x1e 0x98 0x43;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x1000;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00040000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00002000;
+        offset         = 0x0083e000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00002000;
+        offset         = 0x00840000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00042000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA16A4
+#------------------------------------------------------------
+
+part
+    id         = "x16a4";
+    desc       = "ATXMEGA16A4";
+    signature  = 0x1e 0x94 0x41;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0400;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00004000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00001000;
+        offset         = 0x00803000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00001000;
+        offset         = 0x00804000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00005000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA32A4
+#------------------------------------------------------------
+
+part
+    id         = "x32a4";
+    desc       = "ATXMEGA32A4";
+    signature  = 0x1e 0x95 0x41;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0400;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00008000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00001000;
+        offset         = 0x00807000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00001000;
+        offset         = 0x00808000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00009000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA64A4
+#------------------------------------------------------------
+
+part
+    id         = "x64a4";
+    desc       = "ATXMEGA64A4";
+    signature  = 0x1e 0x96 0x46;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0800;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00010000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00001000;
+        offset         = 0x0080f000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00001000;
+        offset         = 0x00810000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00011000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+#------------------------------------------------------------
+# ATXMEGA128A4
+#------------------------------------------------------------
+
+part
+    id         = "x128a4";
+    desc       = "ATXMEGA128A4";
+    signature  = 0x1e 0x97 0x46;
+    has_jtag   = yes;
+    has_pdi    = yes;
+    nvm_base   = 0x01c0;
+
+    memory "eeprom"
+        size           = 0x0800;
+        offset         = 0x08c0000;
+        page_size      = 0x20;
+        readsize       = 0x100;
+    ;
+
+    memory "application"
+        size           = 0x00020000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "apptable"
+        size           = 0x00002000;
+        offset         = 0x0081e000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "boot"
+        size           = 0x00002000;
+        offset         = 0x00820000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "flash"
+        size           = 0x00022000;
+        offset         = 0x0800000;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "prodsig"
+        size           = 0x200;
+        offset         = 0x8e0200;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "usersig"
+        size           = 0x200;
+        offset         = 0x8e0400;
+        page_size      = 0x100;
+        readsize       = 0x100;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x1000090;
+    ;
+
+    memory "fuse0"
+        size           = 1;
+        offset         = 0x8f0020;
+    ;
+
+    memory "fuse1"
+        size           = 1;
+        offset         = 0x8f0021;
+    ;
+
+    memory "fuse2"
+        size           = 1;
+        offset         = 0x8f0022;
+    ;
+
+    memory "fuse4"
+        size           = 1;
+        offset         = 0x8f0024;
+    ;
+
+    memory "fuse5"
+        size           = 1;
+        offset         = 0x8f0025;
+    ;
+
+    memory "lock"
+        size           = 1;
+        offset         = 0x8f0027;
+    ;
+;
+
+
+#------------------------------------------------------------
+# AVR32UC3A0512
+#------------------------------------------------------------
+
+part
+    id         = "ucr2";
+    desc       = "32UC3A0512";
+    signature  = 0xED 0xC0 0x3F;
+    has_jtag   = yes;
+    is_avr32    = yes;
+
+    memory "flash"
+        paged           = yes;
+        page_size              = 512;               # bytes
+        readsize               = 512;                           # bytes
+        num_pages       = 1024;              # could be set dynamicly
+        size                   = 0x00080000;            # could be set dynamicly
+        offset                 = 0x80000000;
+    ;
+;
+
+#------------------------------------------------------------
+# ATtiny4
+#------------------------------------------------------------
+
+part
+    id         = "t4";
+    desc       = "ATtiny4";
+    signature  = 0x1e 0x8f 0x0a;
+    has_tpi    = yes;
+
+    memory "flash"
+        size           = 512;
+        offset         = 0x4000;
+        page_size      = 16;
+        blocksize      = 128;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x3fc0;
+        page_size      = 16;
+    ;
+
+    memory "fuse"
+        size           = 1;
+        offset         = 0x3f40;
+        page_size      = 16;
+       blocksize       = 4;
+    ;
+
+    memory "calibration"
+        size           = 1;
+        offset         = 0x3f80;
+        page_size      = 16;
+    ;
+
+    memory "lockbits"
+        size           = 1;
+        offset         = 0x3f00;
+        page_size      = 16;
+    ;
+;
+
+
+#------------------------------------------------------------
+# ATtiny5
+#------------------------------------------------------------
+
+part
+    id         = "t5";
+    desc       = "ATtiny5";
+    signature  = 0x1e 0x8f 0x09;
+    has_tpi    = yes;
+
+    memory "flash"
+        size           = 512;
+        offset         = 0x4000;
+        page_size      = 16;
+        blocksize      = 128;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x3fc0;
+        page_size      = 16;
+    ;
+
+    memory "fuse"
+        size           = 1;
+        offset         = 0x3f40;
+        page_size      = 16;
+       blocksize       = 4;
+    ;
+
+    memory "calibration"
+        size           = 1;
+        offset         = 0x3f80;
+        page_size      = 16;
+    ;
+
+    memory "lockbits"
+        size           = 1;
+        offset         = 0x3f00;
+        page_size      = 16;
+    ;
+;
+
+
+#------------------------------------------------------------
+# ATtiny9
+#------------------------------------------------------------
+
+part
+    id         = "t9";
+    desc       = "ATtiny9";
+    signature  = 0x1e 0x90 0x08;
+    has_tpi    = yes;
+
+    memory "flash"
+        size           = 1024;
+        offset         = 0x4000;
+        page_size      = 16;
+        blocksize      = 128;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x3fc0;
+        page_size      = 16;
+    ;
+
+    memory "fuse"
+        size           = 1;
+        offset         = 0x3f40;
+        page_size      = 16;
+       blocksize       = 4;
+    ;
+
+    memory "calibration"
+        size           = 1;
+        offset         = 0x3f80;
+        page_size      = 16;
+    ;
+
+    memory "lockbits"
+        size           = 1;
+        offset         = 0x3f00;
+        page_size      = 16;
+    ;
+;
+
+
+#------------------------------------------------------------
+# ATtiny10
+#------------------------------------------------------------
+
+part
+    id         = "t10";
+    desc       = "ATtiny10";
+    signature  = 0x1e 0x90 0x03;
+    has_tpi    = yes;
+
+    memory "flash"
+        size           = 1024;
+        offset         = 0x4000;
+        page_size      = 16;
+        blocksize      = 128;
+    ;
+
+    memory "signature"
+        size           = 3;
+        offset         = 0x3fc0;
+        page_size      = 16;
+    ;
+
+    memory "fuse"
+        size           = 1;
+        offset         = 0x3f40;
+        page_size      = 16;
+       blocksize       = 4;
+    ;
+
+    memory "calibration"
+        size           = 1;
+        offset         = 0x3f80;
+        page_size      = 16;
+    ;
+
+    memory "lockbits"
+        size           = 1;
+        offset         = 0x3f00;
+        page_size      = 16;
+    ;
+;
+
+
diff --git a/programmer/flash/avrdude.exe b/programmer/flash/avrdude.exe
new file mode 100644 (file)
index 0000000..bcdf2f4
Binary files /dev/null and b/programmer/flash/avrdude.exe differ
diff --git a/programmer/flash/flashp.bat b/programmer/flash/flashp.bat
new file mode 100644 (file)
index 0000000..02aef01
--- /dev/null
@@ -0,0 +1,2 @@
+avrdude -c usbasp -p t84 -U lfuse:w:0xE2:m -U hfuse:w:0xDF:m
+avrdude -c usbasp -p t84 -e -U flash:w:"../programmer/Debug/programmer.hex"
diff --git a/programmer/owflash.py b/programmer/owflash.py
new file mode 100644 (file)
index 0000000..5083173
--- /dev/null
@@ -0,0 +1,232 @@
+#!/usr/bin/python
+# Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+# All rights reserved. 
+# 
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions are 
+# met: 
+# 
+#  * Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+#  * Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the 
+#    distribution. 
+#  * All advertising materials mentioning features or use of this 
+#    software must display the following acknowledgement: This product 
+#    includes software developed by tm3d.de and its contributors. 
+#  * Neither the name of tm3d.de nor the names of its contributors may 
+#    be used to endorse or promote products derived from this software 
+#    without specific prior written permission. 
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+
+
+import time
+import subprocess
+import sys
+
+def owcom(dev,send,rc):
+       res=[]
+       f=open("/sys/bus/w1/devices/%s/rw" %(dev),"r+b",0)
+       f.write("".join(map(chr, send)))
+       if (rc!=0):
+               res=map(ord,f.read(rc))
+       f.close()
+       return res
+               
+
+def crc8(arr):
+       lscrc=0x0;
+       for v in arr:
+               bit=1;
+               while bit<256:
+                       if (v&bit)==bit:
+                               lb=1
+                       else:
+                               lb=0
+                       if (lscrc&1)!=lb:
+                               lscrc=(lscrc>>1)^0x8c 
+                       else:
+                               lscrc=(lscrc>>1)
+                       bit=bit*2
+       return lscrc
+       
+def testnr(s):
+       for c in s.lower()[:]:
+               if not((c) in ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','-']):
+                       return False
+       return True
+def addid(id,val):
+       for i in range(7):
+               id[i+1]=id[i+1]+val
+               if id[i+1]>254:
+                       id[i+1]=id[i+1]-254
+                       val=1
+               else:
+                       return id
+       return id
+#
+
+print "Open Hex File ...",
+fi=open(sys.argv[1],"r")
+data=[]
+for l in fi.readlines():
+       sys.stdout.write(".")
+       sys.stdout.flush()
+       bc=int(l[1:3],16)
+       fw=int(l[3:7],16)
+       ty=int(l[7:9],16)
+       chsm=bc+(fw>>8)+(fw&0xFF)+ty
+       for i in range(bc):
+               p=9+(i*2)
+               d=int(l[p:p+2],16)
+               chsm=(chsm+d)&0xFF
+               data.append(d)
+       chsm=(chsm+int(l[9+bc*2:11+bc*2],16))&0xFF
+       if (chsm!=0):
+               print "Error Checksum...."
+               exit()
+       #print bc,fw,ty,chsm
+fi.close()
+print
+
+l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True)
+dc=0
+dl=[]
+for g in  (l.split("\n")):
+       if len(g)>2:
+               if testnr(g[0:2]):
+                       dl.append(g)
+                       dc=dc+1
+                       print dc,") ",g
+if dc==0:
+       print "No 1-Wire Device found"
+       exit(0)
+n=int(raw_input("No. of Device: "))
+n=n-1
+if (n>dc-1)or(n<0):
+               exit(0)
+s=dl[n]
+sys.stdout.write('Go to Flashmode....')
+sys.stdout.flush()
+owcom(s,[0x88],0)
+owcom(s,[0x88],0)
+owcom(s,[0x88],0)
+for i in range (20):
+       l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True)
+       dc=0
+       dl=[]
+       sys.stdout.write(".")
+       sys.stdout.flush()
+       for g in  (l.split("\n")):
+               if (g[0:15]=="a3-55aa55aa55aa"):
+                       break
+       if (g[0:15]!="a3-55aa55aa55aa"):
+               time.sleep(1)
+if (g[0:15]=="a3-55aa55aa55aa"):
+       print "found"
+else:
+       print "ERROR Enter Flashmode!" 
+       exit()
+f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_remove","r+b",0)
+f.write(s)
+f.close()
+time.sleep(5)
+s="a3-55aa55aa55aa"
+prog=data
+l=len(prog)
+if (l>7616):
+       print "Code to big  ... Max 7616 Byte (119 Pages)"
+       exit()
+pages= l/64
+for i in range(64-(l%64)):
+       #print i
+       prog.append(0xFF)
+pages= len(prog)/64
+if (pages>119):
+       print "Code to big  ... Max 7616 Byte (119 Pages)"
+       exit()
+
+
+print "Programm Page (of ", pages,")"
+       
+for i in range(pages):
+       sys.stdout.write("%i " % (i+1) )
+       sys.stdout.flush()
+
+       h=i*64;
+       hl=h&0xFF
+       hh=h>>8
+       #print hh, hl
+       mem=[hl,hh]+prog[h:h+64]
+       erroc=0
+       while (1):
+               owcom(s,[0x0F]+mem,0) 
+               rmem=owcom(s,[0xAA],66)
+               if (rmem!=mem):
+                       print rmem
+                       erroc=erroc+1
+                       if erroc>5:
+                               print "WRITING ERROR ... "
+                               exit()
+                       continue
+               owcom(s,[0x55],0)       
+               time.sleep(0.05)
+               owcom(s,[0xB8,hl,hh],0)
+               time.sleep(0.05)
+               rmem=owcom(s,[0xAA],66)
+               if (rmem!=mem):
+                       print "error in flash"
+                       print mem
+                       print rmem
+                       erroc=erroc+1
+                       if erroc>5:
+                               print "WRITING ERROR ... "
+                               exit()
+                       continue
+               #for v in rmem:
+               #       print "%02X " % (v),
+               break
+print "\nReset AVR"
+owcom(s,[0x89],0)
+time.sleep(1)
+f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_remove","r+b",0)
+f.write("a3-55aa55aa55aa")
+f.close()      
+       
+       
+
+
+
+
+#mem=[0x00,0x2]
+#for i in range (64):
+#      mem.append(i)
+#owcom(s,[0x0F]+mem,0)
+#rmem=owcom(s,[0xAA],70)
+#print rmem
+#owcom(s,[0x55],0)
+#time.sleep(0.05)
+#owcom(s,[0xB8,0x00,0x02],0)
+#time.sleep(0.05)
+#rmem=owcom(s,[0xAA],70)
+#print rmem
+#for v in rmem:
+#      print "%02X " % (v)
+               
+
+               
diff --git a/programmer/programmer.atsln b/programmer/programmer.atsln
new file mode 100644 (file)
index 0000000..bf34f1d
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Atmel Studio Solution File, Format Version 11.00
+Project("{18226A42-8477-4023-8AD2-40C49DA407C9}") = "programmer", "programmer\programmer.asmproj", "{73DCF55E-6410-4DEA-8872-EE17F76DD05A}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {73DCF55E-6410-4DEA-8872-EE17F76DD05A}.Debug|AVR.ActiveCfg = Debug|AVR
+               {73DCF55E-6410-4DEA-8872-EE17F76DD05A}.Debug|AVR.Build.0 = Debug|AVR
+               {73DCF55E-6410-4DEA-8872-EE17F76DD05A}.Release|AVR.ActiveCfg = Release|AVR
+               {73DCF55E-6410-4DEA-8872-EE17F76DD05A}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/programmer/programmer/programmer.asm b/programmer/programmer/programmer.asm
new file mode 100644 (file)
index 0000000..718eeea
--- /dev/null
@@ -0,0 +1,483 @@
+.def srbyte = r12  ;byty for search rom algorithm
+.def writelow = r13;  marker for send low
+.def zero =r14;  always zero 
+.def smode=r15; if 1 then send 
+.def temp = r16 ; 
+.def temp2 = r17; 
+.def mode = r18 ; 
+.def bitp = r19 ; bit counter ... shift...
+.def rwbyte = r21;
+.def param = r22;
+.def bytep = r23  ;byte counter
+#define spmcrval  param
+
+
+.equ OWM_READ_ROM_COMMAND=0 ; 0 wegen schnellen test ist dieser wert 0! Daturch wird die Sprungdabelle nicht verwendet
+.equ OWM_SLEEP=1 ; Warten auf Reset
+.equ OWM_MATCH_ROM=2
+.equ OWM_SEARCH_ROM_S=3  ;send bit
+.equ OWM_SEARCH_ROM_R=4  ;resive master
+.equ OWM_READ_COMMAND=5
+.equ OWM_WRITE_SCRATCHPAD=6
+.equ OWM_READ_SCRATCHPAD=7
+.equ OWM_PROGRAMM_PAGE=8
+.equ OWM_RECALL_FLASH=9
+
+
+.equ OW_DDR = DDRB 
+.equ OW_PIN = PORTB2
+.equ OW_PORT = PORTB 
+.equ OW_PINN = PINB 
+
+;.equ SRAM_START = 0x60
+
+.macro set_clock
+               ldi temp,0x80;
+               out CLKPR,temp
+               ldi temp,@0
+               out CLKPR,temp
+.endmacro 
+
+.macro owwl
+               sbic OW_PINN,OW_PIN
+               rjmp pc-1
+.endmacro 
+
+.macro owwh
+               sbis OW_PINN,OW_PIN
+               rjmp pc-1
+.endmacro 
+
+
+
+
+ ;---------------------------------------------------
+; START of PROG 
+;---------------------------------------------------
+
+
+.CSEG 
+.ORG 0x000
+jreset:
+               rjmp start ; Reset-Vector 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+               reti ; 
+
+
+.ORG 0x0EE0
+
+
+start: 
+               cli
+               ldi temp,0
+               mov zero,temp
+               set_clock 0x00 ;8mhz
+               ldi mode,OWM_SLEEP
+               ldi temp,(1<<CS01) //1us
+               out TCCR0B,temp
+               ldi temp, HIGH(RAMEND) ; HIGH-Byte der obersten RAM-Adresse 
+               out SPH, temp 
+               ldi temp, LOW(RAMEND) ; LOW-Byte der obersten RAM-Adresse 
+               out SPL, temp 
+               ;ldi temp,1
+               ;out DDRB,temp
+               clr writelow
+               clr bitp
+       
+               ;sbi PORTB,0
+               ldi ZL,low(pro_owid*2) 
+               ldi ZH,high(pro_owid*2) 
+               ldi XL,low(sowid)
+               ldi XH,high(sowid)
+               ;ldi temp2,8
+pro_copy_loop: ;copy ID on SRAM for better handling
+               lpm temp,Z+
+               st X+,temp
+               cpi XL,SRAM_START+8
+               brlo pro_copy_loop
+pro_loop:
+               ;sbi PORTB,0
+               owwl                            ;wait for line goes low (polling)
+               sbrs writelow,0         ;test of zero send
+               rjmp pro_loop1          ;no ? goes next
+               sbi OW_DDR,OW_PIN       ;yes pull line to low
+               ldi param,50            ;wait for 50 us
+               rcall wait_time
+               clr writelow            ;reset write low indecator
+               cbi OW_DDR,OW_PIN   ;release line
+               owwh                            ;wait for line is high (it can takes some time cause of the capacity of line)
+pro_loop1:
+               tst smode                       ;smode=1 for slave sends to master
+               breq pro_loop_resv
+pro_loop_send:
+               tst bitp
+               brne pro_loop_send1
+               rcall pro_hb
+               tst smode
+               breq pro_loop_end ; now reading ... do nothing 
+pro_loop_send1:  ;prebare next bit
+               sbrs rwbyte ,0; if bit 0 set in rwbyte then skip next command
+               inc writelow
+               lsl bitp
+               ror rwbyte
+               rjmp pro_loop_end
+
+pro_loop_resv:
+               ldi param,15  ;wait 15us
+               rcall wait_time
+               lsr rwbyte
+               ;cbi PORTB,0
+               sbic OW_PINN,OW_PIN  ;test line
+               ori rwbyte,0x80
+               lsl bitp
+               brne pro_loop_end ;no handle need
+               rcall pro_hb
+               tst smode
+               brne pro_loop_send ; Nach dem Gelesen byte koennte gesendet werden muessen....
+pro_loop_end:
+               //owwh
+               out TCNT0,zero
+pro_loop_end_test_reset:
+               sbic OW_PINN,OW_PIN  //leitung wieder high
+               rjmp pro_loop
+               in temp,TCNT0
+               cpi temp,130
+               brlo pro_loop_end_test_reset
+               rcall pro_sleep_s2
+               rjmp pro_loop
+
+
+
+
+pro_sleep:
+               out TCNT0,zero
+pro_sleep_s1:
+               sbic OW_PINN,OW_PIN  //leitung wieder high
+               ret
+               in temp,TCNT0
+               cpi temp,200
+               brlo pro_sleep_s1
+               //leitung wieder high
+pro_sleep_s2:
+               owwh 
+               ldi param,40
+               rcall wait_time
+               //Presents Impuls
+               sbi OW_DDR,OW_PIN
+               ldi param,130
+               rcall wait_time
+               cbi OW_DDR,OW_PIN
+               //init read byte
+               ldi bitp,0x01
+               ldi rwbyte,0
+               clr smode
+               ldi mode,OWM_READ_ROM_COMMAND
+               //Wait for all other devices presents impuls finished
+               ldi param,40
+               rcall wait_time
+               ret
+
+
+
+pro_hb:
+               ldi ZL,low(pro_stable) 
+               ldi ZH,high(pro_stable) 
+               add ZL,mode 
+               adc ZH,zero
+               icall
+               ret
+
+pro_stable: 
+               rjmp pro_read_rom_command
+               rjmp pro_sleep 
+               rjmp pro_match_rom
+               rjmp pro_search_rom_s
+               rjmp pro_search_rom_r
+               rjmp pro_read_command
+               rjmp pro_write_scratchpad
+               rjmp pro_read_scratchpad
+               rjmp pro_programm_page
+               rjmp pro_recall_flash
+
+pro_read_rom_command:
+               ldi mode,OWM_SLEEP
+               cpi rwbyte,0xCC
+               brne pro_rcc_1
+               ldi mode,OWM_READ_COMMAND
+               rjmp pro_out_bitp1
+pro_rcc_1:
+               cpi rwbyte,0xF0
+               brne pro_rcc_2
+               ldi XL,low(sowid)  ;init sram pointer
+               ldi XH,high(sowid)
+               ld srbyte,X+
+               ldi bytep,0
+               rjmp pro_serchrom_next_bit
+pro_rcc_2:
+               cpi rwbyte,0x55
+               brne pro_rcc_3
+//             rcall pro_owidinit
+               ldi XL,low(sowid)  ;init sram pointer
+               ldi XH,high(sowid)
+               ldi mode,OWM_MATCH_ROM
+               rjmp pro_out_bytep0
+
+pro_rcc_3:
+               ret
+
+pro_match_rom:         
+               ld temp,X+
+               cp temp,rwbyte
+               breq pro_match_rom_next
+               ldi mode,OWM_SLEEP
+               ret
+pro_match_rom_next:                                    
+               cpi XL,SRAM_START+8
+               breq pro_match_rom_found
+               rjmp pro_out_bitp1
+pro_match_rom_found:
+           ldi mode,OWM_READ_COMMAND
+               rjmp pro_out_bitp1
+
+pro_read_command:
+               ldi mode,OWM_SLEEP
+               cpi rwbyte,0x0F
+               brne pro_rc_1
+               ldi mode,OWM_WRITE_SCRATCHPAD
+               ldi XL,low(scratchpad)  ;init sram pointer
+               ldi XH,high(scratchpad)
+               rjmp pro_out_bytep0
+pro_rc_1:
+               cpi rwbyte,0xAA
+               brne pro_rc_2
+               ldi mode,OWM_READ_SCRATCHPAD
+               ldi XL,low(scratchpad)  ;init sram pointer
+               ldi XH,high(scratchpad)
+               inc smode
+               ld rwbyte,X+
+               rjmp pro_out_bytep0
+
+pro_rc_2:
+               cpi rwbyte,0xB8
+               brne pro_rc_3
+               ldi mode,OWM_RECALL_FLASH
+               ldi XL,low(scratchpad)  ;init sram pointer
+               ldi XH,high(scratchpad)
+               rjmp pro_out_bytep0
+pro_rc_3:
+               cpi rwbyte,0x55
+               brne pro_rc_4
+               ldi mode,OWM_SLEEP
+               rjmp pro_programm_page
+               
+pro_rc_4:
+               cpi rwbyte,0x89
+               brne pro_rc_5
+               rjmp jreset             
+pro_rc_5:
+               cpi rwbyte,0x8B
+               brne pro_rc_6   
+               ldi XL,low(E2END)
+               ldi XH,high(E2END)
+               subi XL,7
+               out EEARH,XH
+               out EEARL,XL
+               ldi temp, (0<<EEPM1)|(0<<EEPM0)
+               out EECR, temp
+               ldi temp,0xFF
+               out EEDR, temp
+               sbi EECR, EEMPE
+               sbi EECR, EEPE
+               ret
+
+
+pro_rc_6:
+               ret
+
+
+pro_write_scratchpad:
+               st X+,rwbyte
+               cpi XL,SRAM_START+8+66
+               brlo pro_write_scratchpad_next
+               ldi mode,OWM_SLEEP
+               ret             
+pro_write_scratchpad_next:
+               ldi bitp,1
+               ret
+
+pro_read_scratchpad:
+               cpi XL,SRAM_START+8+66
+               brlo pro_read_scratchpad_next
+               ldi mode,OWM_SLEEP
+               clr smode
+               ret
+pro_read_scratchpad_next:
+               ld rwbyte,X+
+               rjmp pro_out_bitp1
+
+
+pro_programm_page:
+.equ PAGESIZEB = PAGESIZE*2;PAGESIZEB is page size in BYTES, not words
+// .org SMALLBOOTSTART
+write_page:
+               ;transfer data from RAM to Flash page buffer
+               ldi bytep, PAGESIZEB ;init loop variable
+               ldi YL,low(scratchpad)  ;init sram pointer
+               ldi YH,high(scratchpad)
+               ld ZL,Y+
+               ld ZH,Y+
+               ;page erase
+               ldi spmcrval, (1<<PGERS) + (1<<SPMEN)
+               rcall do_spm
+wrloop:
+               ld r0, Y+
+               ld r1, Y+
+               ldi spmcrval, (1<<SPMEN)
+               rcall do_spm
+               adiw ZH:ZL, 2
+               subi bytep, 2;use subi for PAGESIZEB<=256
+               brne wrloop
+               ;execute page write
+               subi ZL, low(PAGESIZEB) ;restore pointer
+               sbci ZH, high(PAGESIZEB) ;not required for PAGESIZEB<=256
+               ldi spmcrval, (1<<PGWRT) + (1<<SPMEN)
+               rcall do_spm
+               ;read back and check, optional
+               ldi bytep, PAGESIZEB
+               subi YL, low(PAGESIZEB) ;restore pointer
+               sbci YH, high(PAGESIZEB)
+rdloop:
+               lpm r0, Z+
+               ld r1, Y+
+               cpse r0, r1
+               rjmp error
+               subi bytep, 2;use subi for PAGESIZEB<=256
+               brne rdloop
+               ;return
+               ret
+do_spm:
+                ;input: spmcrval determines SPM action
+               ;disable interrupts if enabled, store status
+               in temp2, SREG
+               cli
+               ;check for previous SPM complete
+wait:
+               in temp, SPMCSR
+               sbrc temp, SPMEN
+               rjmp wait
+               ;SPM timed sequence
+               out SPMCSR, spmcrval
+               spm
+               ;restore SREG (to enable interrupts if originally enabled)
+               out SREG, temp2
+               ret
+
+error:
+
+
+               ret
+
+pro_recall_flash:
+               st X+,rwbyte
+               ;inc bytep
+               cpi XL,SRAM_START+8+2
+               brlo pro_out_bitp1;pro_recall_flash_next
+               lds ZL,scratchpad
+               lds ZH,scratchpad+1
+pro_recall_flash_cl:
+               lpm temp,Z+
+               st X+,temp
+               cpi XL,SRAM_START+8+66
+               brne pro_recall_flash_cl
+               ldi mode,OWM_SLEEP
+               ret
+
+pro_out_read_command:
+               ldi mode,OWM_READ_COMMAND
+pro_out_bytep0:
+               ldi bytep,0
+pro_out_bitp1:
+               ldi bitp,1
+               ret             
+
+
+
+pro_serchrom_next_bit:
+               mov rwbyte,srbyte
+               mov temp2,rwbyte
+               com rwbyte
+               ror temp2  ;first bit in C
+               rol rwbyte ;C in first bit 
+               inc smode
+               ldi bitp,0x40
+               ldi mode,OWM_SEARCH_ROM_R  ;next mod Resive
+               ret
+
+
+pro_search_rom_s:
+               clr temp2
+               lsr srbyte ;shift in C lowest bit
+               ror temp2  ; shift in temp2 as highest bit
+               andi rwbyte,0x80  ;  clear other bits
+               eor temp2,rwbyte
+               breq pro_search_rom_s_goon
+               ldi mode,OWM_SLEEP
+               ret
+pro_search_rom_s_goon:
+               inc bytep
+               mov temp2,bytep
+               andi temp2,0x07
+               brne pro_serchrom_next_bit ;prepare next bit
+               mov temp2,bytep
+               andi temp2,0x40 ;;end
+               brne pro_search_rom_found
+               ;read next byte
+               ld srbyte,X+
+               rjmp pro_serchrom_next_bit
+
+pro_search_rom_found:
+               ldi mode,OWM_READ_COMMAND
+               rjmp pro_out_bytep0
+
+pro_search_rom_r:
+               clr smode
+               ldi mode,OWM_SEARCH_ROM_S
+               ldi bitp,0  ;go to searchrom_s after bit get
+               ret
+
+pro_owid: .DB  0xA3, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xFA
+
+
+
+
+
+wait_time:
+               out TCNT0,zero
+wait_time1:
+               in temp,TCNT0
+               cp temp,param
+               brlo wait_time1
+               ret
+
+
+.DSEG
+sowid: .BYTE 8
+scratchpad: .BYTE 66
\ No newline at end of file
diff --git a/programmer/programmer/programmer.asmproj b/programmer/programmer/programmer.asmproj
new file mode 100644 (file)
index 0000000..592cc91
--- /dev/null
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>6.2</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRAssembler</ToolchainName>
+    <ProjectGuid>{73dcf55e-6410-4dea-8872-ee17f76dd05a}</ProjectGuid>
+    <avrdeviceseries>none</avrdeviceseries>
+    <avrdevice>ATtiny84A</avrdevice>
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>
+    <OutputFileExtension>.obj</OutputFileExtension>
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
+    <Language>ASSEMBLY</Language>
+    <AssemblyName>programmer</AssemblyName>
+    <Name>programmer</Name>
+    <RootNamespace>programmer</RootNamespace>
+    <EntryFile>$(MSBuildProjectDirectory)\programmer.asm</EntryFile>
+    <ToolchainFlavour>Native</ToolchainFlavour>
+    <KeepTimersRunning>true</KeepTimersRunning>
+    <OverrideVtor>false</OverrideVtor>
+    <CacheFlash>true</CacheFlash>
+    <ProgFlashFromRam>true</ProgFlashFromRam>
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>
+    <UncachedRange />
+    <preserveEEPROM>true</preserveEEPROM>
+    <OverrideVtorValue>exception_table</OverrideVtorValue>
+    <BootSegment>2</BootSegment>
+    <eraseonlaunchrule>1</eraseonlaunchrule>
+    <AsfFrameworkConfig>
+      <framework-data>
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.18.1" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <com_atmel_avrdbg_tool_atmelice>
+      <ToolOptions>
+        <InterfaceProperties>
+          <IspClock>100000</IspClock>
+          <DebugWireClockDiv>8000</DebugWireClockDiv>
+        </InterfaceProperties>
+        <InterfaceName>debugWIRE</InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
+      <ToolNumber>J41800000779</ToolNumber>
+      <ToolName>Atmel-ICE</ToolName>
+    </com_atmel_avrdbg_tool_atmelice>
+    <avrtoolinterface>debugWIRE</avrtoolinterface>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrAssembler>
+        <avrasm.assembler.general.IncludeFile>(%24IncludeFile)</avrasm.assembler.general.IncludeFile>
+      </AvrAssembler>
+    </ToolchainSettings>
+    <OutputType>Executable</OutputType>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrAssembler>
+        <avrasm.assembler.general.IncludeFile>(%24IncludeFile)</avrasm.assembler.general.IncludeFile>
+      </AvrAssembler>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="programmer.asm">
+      <SubType>Code</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Assembler.targets" />
+</Project>
\ No newline at end of file
diff --git a/tools/chowid.py b/tools/chowid.py
new file mode 100644 (file)
index 0000000..0eed2c5
--- /dev/null
@@ -0,0 +1,143 @@
+#!/usr/bin/python
+# Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+# All rights reserved. 
+# 
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions are 
+# met: 
+# 
+#  * Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+#  * Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the 
+#    distribution. 
+#  * All advertising materials mentioning features or use of this 
+#    software must display the following acknowledgement: This product 
+#    includes software developed by tm3d.de and its contributors. 
+#  * Neither the name of tm3d.de nor the names of its contributors may 
+#    be used to endorse or promote products derived from this software 
+#    without specific prior written permission. 
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+
+
+
+import time
+import subprocess
+
+def owcom(dev,send,rc):
+       res=[]
+       f=open("/sys/bus/w1/devices/%s/rw" %(dev),"r+b",0)
+       f.write("".join(map(chr, send)))
+       if (rc!=0):
+               res=map(ord,f.read(rc))
+       f.close()
+       return res
+               
+
+def crc8(arr):
+       lscrc=0x0;
+       for v in arr:
+               bit=1;
+               while bit<256:
+                       if (v&bit)==bit:
+                               lb=1
+                       else:
+                               lb=0
+                       if (lscrc&1)!=lb:
+                               lscrc=(lscrc>>1)^0x8c 
+                       else:
+                               lscrc=(lscrc>>1)
+                       bit=bit*2
+       return lscrc
+       
+def testnr(s):
+       for c in s.lower()[:]:
+               if not((c) in ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','-']):
+                       return False
+       return True
+
+def addid(id,val):
+       for i in range(7):
+               id[i+1]=id[i+1]+val
+               if id[i+1]>254:
+                       id[i+1]=id[i+1]-254
+                       val=1
+               else:
+                       return id
+       return id
+#
+
+l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True)
+dc=0
+dl=[]
+for g in  (l.split("\n")):
+       if len(g)>2:
+               if testnr(g[0:2]):
+                       dl.append(g)
+                       dc=dc+1
+                       print dc,") ",g
+if dc==0:
+       print "No 1-Wire Device found"
+       exit(0)
+n=int(raw_input("No. of Device: "))
+n=n-1
+if (n>dc-1)or(n<0):
+               exit(0)
+print dl[n], "will be changed"
+s=dl[n]
+nr=[int(s[0:2],16),int(s[13:15],16),int(s[11:13],16),int(s[9:11],16),int(s[7:9],16),int(s[5:7],16),int(s[3:5],16)]
+nr.append(crc8(nr))
+onr=nr[:]
+re=1
+while re:
+       re=0
+       print "Number: %02X %02X %02X %02X %02X %02X %02X %02X" % tuple(nr)
+       print "1) Increment the old ID"
+       print "2) Add a value to the old ID (value < 255)"
+       print "3) Input 6 hex numbers like AA,B5,00,32,12,F1"
+       print "4) Exit"
+       cho=int(raw_input("Press the number of your choice: "))
+       if cho==1:
+               nr=addid(nr,1)
+       elif cho==2:
+               val=int(raw_input("Add value <255: "))
+               nr=addid(nr,val)
+       elif cho==3:
+               hn=raw_input("Input six numbers in hex (like AA,B5,00,32,12,F1): ")
+               i=1
+               for hnt in hn.split(","):
+                       nr[i]=int(hnt,16)
+                       i=i+1
+       elif cho==4:
+               exit()
+       else:
+               re=1
+nr[7]=crc8(nr[:-1])
+print "New ID: %02X %02X %02X %02X %02X %02X %02X %02X" % tuple(nr)
+cho=raw_input("Set this ID? [Y/n): ")
+if (cho!='Y'):
+       exit()
+
+
+owcom(s,[0x75]+nr,0)
+nnr=owcom(s,[0xA7],8)
+print "New ID: %02X %02X %02X %02X %02X %02X %02X %02X" % tuple(nnr)
+if nr!=nnr:
+       print "ERROR writing new ID\nMaybe it's no simulatet ow device from tm3d.de"
+       exit(0)
+print "Old ID: %02X %02X %02X %02X %02X %02X %02X %02X" % tuple(onr)
+owcom(s,[0x79,onr[1],onr[5],onr[6]],0)
+print "Done.\nWait for a new Searchrom from Master\nSometimes the old nr keeps in the directory"