New Devices
authorTobias Müller <muto@wsk.tu-chemnitz.de>
Wed, 23 Nov 2016 08:05:12 +0000 (09:05 +0100)
committerTobias Müller <muto@wsk.tu-chemnitz.de>
Wed, 23 Nov 2016 08:05:12 +0000 (09:05 +0100)
Loxone convert Temp of all Devices with CC 44 in double Devices included

33 files changed:
DS18B20_BMP280_DS2438_SHT/DS18B20_BMP280_DS2438_SHT.cproj
DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c
DS18B20_MAX44009/DS18B20_MAX44009.cproj
DS18B20_Thermocouble/DS18B20_TC.c
DS18B20_Thermocouble/DS18B20_TC.cproj
DS18B20_Thermocouble_DS2438_SHT/DS18B20_DS2438.c [new file with mode: 0644]
DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.atsln [new file with mode: 0644]
DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.cproj [new file with mode: 0644]
DS2423/DS2423.cproj
DS2423_komische platine/DS2423.atsln [new file with mode: 0644]
DS2423_komische platine/DS2423.c [new file with mode: 0644]
DS2423_komische platine/DS2423.cproj [new file with mode: 0644]
DS2438_DHT22/DS2438_DHT22.cproj
DS2438_HDC1080/DS2438_HDC1080.atsln [new file with mode: 0644]
DS2438_HDC1080/DS2438_HDC1080.c [new file with mode: 0644]
DS2438_HDC1080/DS2438_HDC1080.cproj [new file with mode: 0644]
DS2438_SHT2X/DS2438_SHT2X.c
DS2438_SHT2X/DS2438_SHT2X.cproj
DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.atsln [new file with mode: 0644]
DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.c [new file with mode: 0644]
DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.cproj [new file with mode: 0644]
DS2450_SHT2X_BMP280/OWDS2450.S [new file with mode: 0644]
DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.atsln [new file with mode: 0644]
DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.c [new file with mode: 0644]
DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.cproj [new file with mode: 0644]
DS2450_SHT2X_MAX44009/OWDS2450.S [new file with mode: 0644]
DS2450_VOC_SHT_BMP/DS2450_VOC_SHT_BMP.c [new file with mode: 0644]
common/I2C/BMP280.c
common/I2C/HDC1080.c [new file with mode: 0644]
common/I2C/HDC1080.h [new file with mode: 0644]
common/OWDS18B20_DS2438.S
common/OWRomFunctions.s
common/OWRomFunctionsDual.s

index 9c39af3..8fccb76 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
-        <options />\r
-        <configurations />\r
-        <files />\r
-        <documentation help="" />\r
-        <offline-documentation help="" />\r
-        <dependencies>\r
-          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.21.0" />\r
-        </dependencies>\r
-      </framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
index f7261e3..d4dbcc0 100644 (file)
@@ -229,7 +229,7 @@ int main(void){
                         if (testSW()) {\r
                                 am2302_hum= humidityRH*10.0;\r
                                 am2302_temp=temperatureC*25.6;\r
-                                am2302_temp=am2302_temp-20;\r
+                                //am2302_temp=am2302_temp-20;\r
                                 config_info2[5]=8;\r
                                 \r
                                 }else{\r
@@ -238,13 +238,13 @@ int main(void){
                                 //am2302_hum=0.318*hhum +76.0;\r
                                 am2302_hum=0.31*hhum +80;\r
                                 am2302_temp=temperatureC*25.6;\r
-                                am2302_temp=am2302_temp-20;\r
+                                //am2302_temp=am2302_temp-20;\r
                                 config_info2[5]=7;\r
                         }\r
                        wdcounter=0;\r
                }\r
        \r
-               if (gcontrol==1) {\r
+               if ((gcontrol&1)==1) {\r
                        \r
                                bmp280ConvertInt(&t,&P,1);\r
                                P=P-70000;\r
index 6584971..b5f25f3 100644 (file)
     <BootSegment>2</BootSegment>\r
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
-      <framework-data xmlns="">\r
-        <options />\r
-        <configurations />\r
-        <files />\r
-        <documentation help="" />\r
-        <offline-documentation help="" />\r
-        <dependencies>\r
-          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.19.0" />\r
-        </dependencies>\r
-      </framework-data>\r
+      <framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-        <avrgcc.compiler.symbols.DefSymbols>\r
-          <ListValues>\r
-            <Value>DEBUG</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.symbols.DefSymbols>\r
-        <avrgcc.compiler.directories.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
-        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
-        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-        <avrgcc.linker.libraries.Libraries>\r
-          <ListValues>\r
-            <Value>libm</Value>\r
-          </ListValues>\r
-        </avrgcc.linker.libraries.Libraries>\r
-        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
-      </AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>DEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-        <avrgcc.compiler.symbols.DefSymbols>\r
-          <ListValues>\r
-            <Value>DEBUG</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.symbols.DefSymbols>\r
-        <avrgcc.compiler.directories.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
-        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
-        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-        <avrgcc.linker.libraries.Libraries>\r
-          <ListValues>\r
-            <Value>libm</Value>\r
-          </ListValues>\r
-        </avrgcc.linker.libraries.Libraries>\r
-        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
-      </AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>DEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
index 6ed9a03..447e694 100644 (file)
@@ -174,7 +174,7 @@ inline int16_t ow_fconvert(uint8_t b1, uint8_t b2) {
 volatile double V,ktemp;\r
 \r
 uint16_t ADmess() {\r
-        ADMUX=0b10001101;\r
+        ADMUX=0b10101101;\r
         ADCSRA|=(1<<ADSC);\r
         while ((ADCSRA&(1<<ADSC)));\r
        return ADC;\r
index 32390b0..a12b106 100644 (file)
     <BootSegment>2</BootSegment>\r
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
-      <framework-data xmlns="">\r
-        <options />\r
-        <configurations />\r
-        <files />\r
-        <documentation help="" />\r
-        <offline-documentation help="" />\r
-        <dependencies>\r
-          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.19.0" />\r
-        </dependencies>\r
-      </framework-data>\r
+      <framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-        <avrgcc.compiler.symbols.DefSymbols>\r
-          <ListValues>\r
-            <Value>DEBUG</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.symbols.DefSymbols>\r
-        <avrgcc.compiler.directories.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
-        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
-        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-        <avrgcc.linker.libraries.Libraries>\r
-          <ListValues>\r
-            <Value>libm</Value>\r
-          </ListValues>\r
-        </avrgcc.linker.libraries.Libraries>\r
-        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
-      </AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>DEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-        <avrgcc.compiler.symbols.DefSymbols>\r
-          <ListValues>\r
-            <Value>DEBUG</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.symbols.DefSymbols>\r
-        <avrgcc.compiler.directories.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
-        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
-        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-        <avrgcc.linker.libraries.Libraries>\r
-          <ListValues>\r
-            <Value>libm</Value>\r
-          </ListValues>\r
-        </avrgcc.linker.libraries.Libraries>\r
-        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
-      </AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>DEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
diff --git a/DS18B20_Thermocouble_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_Thermocouble_DS2438_SHT/DS18B20_DS2438.c
new file mode 100644 (file)
index 0000000..e78a682
--- /dev/null
@@ -0,0 +1,315 @@
+
+// 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/SHT2x.h"
+
+
+extern void OWINIT();
+extern void EXTERN_SLEEP();
+
+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(&(k_rs[iv]));
+       float t1=pgm_read_float(&(k_rs[iv+1]));
+       return t0+(t1-t0)/1*(V-iv);
+}
+
+
+
+
+
+uint8_t owid1[8]={0x28, 0xA6, 0xD9, 0x84, 0x00, 0x00, 0x03, 0x68};/**/
+uint8_t owid2[8]={0x26, 0xA7, 0xD9, 0x84, 0x00, 0x00, 0x03, 0x20};/**/
+uint8_t config_info1[16]={0x01,0x02 ,0x00,0x00, 0x00,0x00, 0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};        
+uint8_t config_info2[16]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};        
+       
+#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=5;
+
+
+#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
+
+}
+
+int testSW(void) {
+       uint8_t r;
+       DDRB&=~(1<<PORTB0);  //Eingang
+       __asm__ __volatile__ ("nop");
+       PORTB|=(1<<PORTB0); //Pullup
+       __asm__ __volatile__ ("nop");
+       __asm__ __volatile__ ("nop");
+       __asm__ __volatile__ ("nop");
+       __asm__ __volatile__ ("nop");
+       __asm__ __volatile__ ("nop");
+       r=PINB&(1<<PORTB0);
+       __asm__ __volatile__ ("nop");
+       PORTB&=~(1<<PORTB0);
+       __asm__ __volatile__ ("nop");
+       DDRB|=(1<<PORTB0);  //Eingang
+       return (r==0);
+       
+       
+}
+
+
+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 double V,ktemp;
+
+uint16_t ADmess() {
+       ADMUX=0b10101101;
+       ADCSRA|=(1<<ADSC);
+       while ((ADCSRA&(1<<ADSC)));
+       return ADC;
+}
+
+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;
+
+uint8_t max_adr=0;
+
+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-(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
+       if (testSW()) {
+               config_info2[5]=8;
+               }else{
+               config_info2[5]=7;
+       }
+       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();
+       ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
+       //DDRB|=(1<<PINB1);
+
+       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;
+    while(1)   {
+               if ((gcontrol==2)||(gcontrol==3)) {
+                       wdcounter=1;
+                       gcontrol=0;
+                       
+               }
+               
+               if (wdcounter>0) {
+                       if (par==0) {
+                               //PORTB|=(1<<PINB1); //Dauer 440ms
+                               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-2;
+                               humidityRH = SHT2x_CalcRH(sRH)*10.0+5;
+                               if (humidityRH>1000) humidityRH=1000;
+                               if (testSW()) {
+                                       am2302_hum= humidityRH*10.0;
+                                       am2302_temp=temperatureC*25.6;
+                                       //
+                                       config_info2[5]=8;
+                               }else{
+                                       double hhum=(1.0546-0.000216*temperatureC)*(humidityRH);
+                                       //am2302_hum=0.318*hhum +76.0;
+                                       am2302_hum=0.31*hhum +80;
+                                       am2302_temp=temperatureC*25.6;
+                                       //am2302_temp=am2302_temp-45;
+                                       config_info2[5]=7;
+                               }
+                       }
+                       ares[par]=ADmess();
+                       par++;
+                       if (par>15) par=0;
+                       wdcounter=0;
+               }
+       
+               if (gcontrol==1) {
+                       gcontrol=0;
+                       sum=0;
+                       for(uint8_t i=0;i<16;i++) {
+                               sum+=ares[i];
+                       }
+                       V=sum/20.0/1024.0*1.12*1000.0/16.0;
+                       //V=sum/20.0/1024.0*1.01*1000.0/16.0;
+                       uint16_t htemp;
+                       ktemp=gettemp_rs(V);
+                       //htemp=(ktemp*16)/10;
+                       htemp=(ktemp*16+temperatureC*1.6)/10;
+
+                       uint16_t w=htemp;
+                       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();                  
+                       EXTERN_SLEEP();         
+               }
+               
+
+               
+#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/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.atsln b/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.atsln
new file mode 100644 (file)
index 0000000..2e0e72c
--- /dev/null
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Atmel Studio Solution File, Format Version 11.00
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_Thermocouble_DS2438_SHT", "DS18B20_Thermocouble_DS2438_SHT.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_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.cproj b/DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.cproj
new file mode 100644 (file)
index 0000000..adb53ac
--- /dev/null
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>7.0</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_Thermocouble_DS2438_SHT</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>
+        <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>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>
+    <ExternalProgrammingToolCommand />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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\USI_TWI_Master.c">
+      <SubType>compile</SubType>
+      <Link>USI_TWI_Master.c</Link>
+    </Compile>
+    <Compile Include="D:\oc\dev\owSlave2\common\OWDS18B20_DS2438.S">
+      <SubType>compile</SubType>
+      <Link>OWDS18B20_DS2438.S</Link>
+    </Compile>
+    <Compile Include="DS18B20_DS2438.c">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
index 68613a5..c23c14c 100644 (file)
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-        <avrgcc.compiler.symbols.DefSymbols>\r
-          <ListValues>\r
-            <Value>DEBUG</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.symbols.DefSymbols>\r
-        <avrgcc.compiler.directories.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
-        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
-        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-        <avrgcc.linker.libraries.Libraries>\r
-          <ListValues>\r
-            <Value>libm</Value>\r
-          </ListValues>\r
-        </avrgcc.linker.libraries.Libraries>\r
-        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
-      </AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>DEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-        <avrgcc.compiler.symbols.DefSymbols>\r
-          <ListValues>\r
-            <Value>DEBUG</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.symbols.DefSymbols>\r
-        <avrgcc.compiler.directories.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
-        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
-        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-        <avrgcc.linker.libraries.Libraries>\r
-          <ListValues>\r
-            <Value>libm</Value>\r
-          </ListValues>\r
-        </avrgcc.linker.libraries.Libraries>\r
-        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
-      </AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>DEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
diff --git a/DS2423_komische platine/DS2423.atsln b/DS2423_komische platine/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_komische platine/DS2423.c b/DS2423_komische platine/DS2423.c
new file mode 100644 (file)
index 0000000..8e27c78
--- /dev/null
@@ -0,0 +1,236 @@
+
+// Copyright (c) 2016, 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]={0x1D, 0xA2, 0xD9, 0x84, 0x00, 0x26, 0x02, 0x5C};/**/
+uint8_t config_info[16]={0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+       
+
+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;
+
+typedef union {
+       uint32_t c32[4];
+       uint8_t c8[16];
+} counters_t;
+
+volatile counters_t counters;
+
+volatile uint8_t istat;
+
+#define PCINT_VECTOR PCINT0_vect
+#define PIN_REG PINA
+#define PIN_DDR DDRA
+#define PIN_CH0 (1<<PINA3)
+#define PIN_CH1 (1<<PINA4)
+#define PIN_CH2 (1<<PINA1)
+#define PIN_CH3 (1<<PINA2)
+#define LPIN_CH2 (1<<PINB0)
+#define LDD_CH2 DDRB
+#define LPORT_CH2 PORTB
+#define LPIN_CH3 (1<<PINA5)
+#define LDD_CH3 DDRA
+#define LPORT_CH3 PORTA
+#define LPIN_CH0 (1<<PINA7)
+#define LDD_CH0 DDRA
+#define LPORT_CH0 PORTA
+#define LPIN_CH1 (1<<PINB1)
+#define LDD_CH1 DDRB
+#define LPORT_CH1 PORTB
+#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)
+
+
+
+ISR(PCINT0_vect) {
+       if (((PIN_REG&PIN_CH0)==0)&&((istat&PIN_CH0)==PIN_CH0)) {       counters.c32[0]++;      LPORT_CH2|=LPIN_CH2;}
+       if (((PIN_REG&PIN_CH1)==0)&&((istat&PIN_CH1)==PIN_CH1)) {       counters.c32[1]++;      LPORT_CH2|=LPIN_CH2;}
+       if (((PIN_REG&PIN_CH2)==0)&&((istat&PIN_CH2)==PIN_CH2)) {       counters.c32[2]++;      LPORT_CH2|=LPIN_CH2;}
+       if (((PIN_REG&PIN_CH3)==0)&&((istat&PIN_CH3)==PIN_CH3)) {       counters.c32[3]++;      LPORT_CH2|=LPIN_CH2;}
+
+       if (((PORT_EE&PIN_EE)==0)&&((istat&PIN_EE)==PIN_EE))  {
+               
+               _delay_ms(50);
+       if (((PORT_EE&PIN_EE)==0))  {
+
+               
+
+               LPORT_CH1|=LPIN_CH1;
+               EEARH=0;
+               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);
+               }
+               _delay_ms(250);
+               LPORT_CH1&=~LPIN_CH1;
+
+       }
+       GIFR|=(1<<PCIF0);
+       }
+       if ((((PINA&(1<<PINA6)))==0)&&((istat&(1<<PINA6))==(1<<PINA6)))   {
+               _delay_ms(100);
+               if (((PINA&(1<<PINA6)))==0) {
+                       LPORT_CH3|=LPIN_CH3;
+                       _delay_ms(100);
+
+                       counters.c32[0]=0;
+                       counters.c32[2]=0;
+                       counters.c32[1]=0;
+                       counters.c32[3]=0;
+                       LPORT_CH3&=~LPIN_CH3;
+                       }
+               GIFR|=(1<<PCIF0);
+
+       }
+       istat=PIN_REG;
+       
+}
+
+
+int main(void){
+    PRR|=(1<<PRUSI)|(1<<PRADC);  //Switch off usi and adc for save Power
+       OWINIT();
+       
+       pack.zero=0;
+       counters.c32[0]=0;
+       counters.c32[2]=0;
+       counters.c32[1]=0;
+       counters.c32[3]=0;
+       ACSR|=(1<<ACD);  //Disable Comparator
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+
+       PORTB|=0xFF-(1<<PINB2); //Make PullUp an all Pins but not OW_PIN
+       PORTA|=0xFF; 
+       PORTA&=~((1<<PINA1)|(1<<PINA2)|(1<<PINA3)|(1<<PINA4));
+                               
+       GIMSK|=(1<<PCIE0);
+       PCMSK0=(1<<PCINT1)|(1<<PCINT2)|(1<<PCINT3)|(1<<PCINT4);
+       //Spannungsdetektor
+       DDRA&=~(1<<PINA0);
+       PCMSK0|=(1<<PCINT0);
+       PORTA&=~(1<<PINA0);
+       //Taster
+       DDRA&=~(1<<PINA6);
+       PCMSK0|=(1<<PCINT6);
+       PORTA|=(1<<PINA6); //Pullup
+
+
+
+       LDD_CH0|=LPIN_CH0;
+       LPORT_CH0&=~LPIN_CH0;
+       LDD_CH1|=LPIN_CH1;
+       LPORT_CH1&=~LPIN_CH1;
+       LDD_CH2|=LPIN_CH2;
+       LPORT_CH2&=~LPIN_CH2;
+       LDD_CH3|=LPIN_CH3;
+       LPORT_CH3&=~LPIN_CH3;
+
+
+
+       LPORT_CH0|=LPIN_CH0;
+       _delay_ms(500);
+       LPORT_CH0&=~LPIN_CH0;
+       
+       istat=PINA;
+       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;
+       }
+
+   
+       sei();
+    while(1)   {
+           if (LPORT_CH2&LPIN_CH2) {
+                       _delay_ms(50);
+                       LPORT_CH2&=~LPIN_CH2;
+               }
+               //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_komische platine/DS2423.cproj b/DS2423_komische platine/DS2423.cproj
new file mode 100644 (file)
index 0000000..8958294
--- /dev/null
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>7.0</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>
+          <IspClock>125000</IspClock>
+        </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>
+    <ExternalProgrammingToolCommand />
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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.general.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>
+          </ListValues>
+        </avrgcc.assembler.general.IncludePaths>
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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.general.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>
+          </ListValues>
+        </avrgcc.assembler.general.IncludePaths>
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
+      </AvrGcc>
+    </ToolchainSettings>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="..\common\OWDS2423.S">
+      <SubType>compile</SubType>
+      <Link>OWDS2423.S</Link>
+    </Compile>
+    <Compile Include="DS2423.c">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
index cf7d407..8631da1 100644 (file)
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-        <avrgcc.compiler.symbols.DefSymbols>\r
-          <ListValues>\r
-            <Value>NDEBUG</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.symbols.DefSymbols>\r
-        <avrgcc.compiler.directories.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
-        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-        <avrgcc.linker.libraries.Libraries>\r
-          <ListValues>\r
-            <Value>libm</Value>\r
-          </ListValues>\r
-        </avrgcc.linker.libraries.Libraries>\r
-      </AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>NDEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-        <avrgcc.compiler.symbols.DefSymbols>\r
-          <ListValues>\r
-            <Value>DEBUG</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.symbols.DefSymbols>\r
-        <avrgcc.compiler.directories.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
-        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
-        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-        <avrgcc.linker.libraries.Libraries>\r
-          <ListValues>\r
-            <Value>libm</Value>\r
-          </ListValues>\r
-        </avrgcc.linker.libraries.Libraries>\r
-        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
-      </AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>DEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
diff --git a/DS2438_HDC1080/DS2438_HDC1080.atsln b/DS2438_HDC1080/DS2438_HDC1080.atsln
new file mode 100644 (file)
index 0000000..da1d586
--- /dev/null
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Atmel Studio Solution File, Format Version 11.00
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_HDC1080", "DS2438_HDC1080.cproj", "{91468D4F-8AE2-4C59-8A35-549C49E00934}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.ActiveCfg = Debug|AVR
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.Build.0 = Debug|AVR
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.ActiveCfg = Release|AVR
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS2438_HDC1080/DS2438_HDC1080.c b/DS2438_HDC1080/DS2438_HDC1080.c
new file mode 100644 (file)
index 0000000..9af48ec
--- /dev/null
@@ -0,0 +1,200 @@
+// Copyright (c) 2016, 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/HDC1080.h"
+#include "../common/calibr.h"
+
+extern void OWINIT();
+extern void EXTERN_SLEEP();
+
+uint8_t owid[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x00, 0x05, 0x16};/**/
+uint8_t config_info[16]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+//uint8_t config_info[16]={0x01,0x06, 0x05,0x08, 0x04,0x08, 0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+       
+
+extern uint8_t mode;
+extern uint8_t gcontrol;
+extern uint8_t reset_indicator;
+extern uint8_t alarmflag;
+
+volatile uint8_t wdcounter=5;
+
+
+typedef union {
+
+       volatile uint8_t bytes[64];
+       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
+               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
+       };
+} pack_t;
+volatile pack_t pack;
+
+
+
+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;
+
+#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 
+       wdcounter++;
+       if (reset_indicator==1) reset_indicator++;
+       else if (reset_indicator==2) mode=0;
+
+
+}
+
+int testSW(void) {
+       uint8_t r;
+       DDRB&=~(1<<PORTB0);  //Eingang
+        __asm__ __volatile__ ("nop"); 
+        PORTB|=(1<<PORTB0); //Pullup
+        __asm__ __volatile__ ("nop"); 
+        __asm__ __volatile__ ("nop"); 
+        __asm__ __volatile__ ("nop"); 
+        __asm__ __volatile__ ("nop"); 
+        __asm__ __volatile__ ("nop"); 
+        r=PINB&(1<<PORTB0);
+        __asm__ __volatile__ ("nop"); 
+        PORTB&=~(1<<PORTB0); 
+        __asm__ __volatile__ ("nop"); 
+       DDRB|=(1<<PORTB0);  //Eingang
+       return (r==0);
+        
+        
+}
+
+int main(void){
+     PRR|=(1<<PRADC);  // adc for save Power
+       PORTA=0xFF;
+       PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0
+       
+       
+       OWINIT();
+
+       ACSR|=(1<<ACD);  //Disable Comparator
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer
+       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<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds
+        if (testSW()) {
+               config_info[5]=8;
+       }else{
+               config_info[5]=7;
+        }
+       
+    uint8_t i;
+    for(i=0;i<64;i++) pack.bytes[i]=0;
+       MCUSR=0;
+       USI_TWI_Master_Initialise();
+       HDC1080_Init();
+       HDC1080_Readf(&temperatureC,&humidityRH);
+       
+       sei();
+       
+        while(1)   {
+                if (gcontrol) {
+                        wdcounter=3;
+                        gcontrol=0;
+                }
+                if (wdcounter>2) {
+                        //PORTB|=(1<<PINB1); //Dauer 440ms
+                        HDC1080_Readf(&temperatureC,&humidityRH);
+
+                        humidityRH = calibr_hum(temperatureC,-0.2,humidityRH)*10.0;
+                        temperatureC-=0.2;
+                        temperatureC*=10.0;
+                        if (testSW()) {
+                                am2302_hum= humidityRH;
+                                am2302_temp=temperatureC*25.6;
+                                //am2302_temp=am2302_temp-45;
+                                config_info[5]=12;     
+                                
+                        }else{
+                                
+                               double hhum=(1.0546-0.000216*temperatureC)*(humidityRH);
+                               //am2302_hum=0.318*hhum +76.0;
+                               am2302_hum=0.31*hhum +80;
+                               am2302_temp=temperatureC*25.6;
+                               //am2302_temp=am2302_temp-45;
+                               config_info[5]=7;
+                        }
+                        //PORTB&=~(1<<PINB1);
+                        wdcounter=0;
+                }
+
+               if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {
+                       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_HDC1080/DS2438_HDC1080.cproj b/DS2438_HDC1080/DS2438_HDC1080.cproj
new file mode 100644 (file)
index 0000000..cfd65db
--- /dev/null
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>7.0</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>{91468d4f-8ae2-4c59-8a35-549c49e00934}</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_SHT2X</AssemblyName>
+    <Name>DS2438_HDC1080</Name>
+    <RootNamespace>DS2438_SHT2X</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.26.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>
+    <ExternalProgrammingToolCommand />
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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\calibr.c">
+      <SubType>compile</SubType>
+      <Link>calibr.c</Link>
+    </Compile>
+    <Compile Include="..\common\I2C\HDC1080.c">
+      <SubType>compile</SubType>
+      <Link>HDC1080.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="D:\oc\dev\owSlave2\common\OWDS2438.S">
+      <SubType>compile</SubType>
+      <Link>OWDS2438.S</Link>
+    </Compile>
+    <Compile Include="DS2438_HDC1080.c">
+      <SubType>compile</SubType>
+    </Compile>
+  </ItemGroup>
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
+</Project>
\ No newline at end of file
index 0da9838..eef88e3 100644 (file)
@@ -41,6 +41,7 @@
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/MAX44009.h"\r
 #include "../common/I2C/SHT2x.h"\r
+#include "../common/calibr.h"\r
 \r
 extern void OWINIT();\r
 extern void EXTERN_SLEEP();\r
@@ -175,13 +176,15 @@ int main(void){
                         // --- measure temperature with "Polling Mode" (no hold master) ---\r
                         SHT2x_MeasurePoll(TEMP, &sT);\r
                         //-- calculate humidity and temperature --\r
-                        temperatureC = SHT2x_CalcTemperatureC(sT)*10.0;\r
-                        humidityRH = SHT2x_CalcRH(sRH)*10.0;\r
+                        temperatureC = SHT2x_CalcTemperatureC(sT);\r
+                        humidityRH = calibr_hum(temperatureC,-0.2,SHT2x_CalcRH(sRH))*10.0;\r
+                        temperatureC-=0.2;\r
+                        temperatureC*=10.0;\r
                         if (testSW()) {\r
-                                am2302_hum= humidityRH*10.0;\r
+                                am2302_hum= humidityRH;\r
                                 am2302_temp=temperatureC*25.6;\r
                                 //am2302_temp=am2302_temp-45;\r
-                                config_info[5]=8;      \r
+                                config_info[5]=12;     \r
                                 \r
                         }else{\r
                                 \r
index 0bdb091..42b122e 100644 (file)
         <InterfaceName>debugWIRE</InterfaceName>\r
       </ToolOptions>\r
       <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
-      <ToolNumber>J41800000779</ToolNumber>\r
+      <ToolNumber>J41800000789</ToolNumber>\r
       <ToolName>Atmel-ICE</ToolName>\r
     </com_atmel_avrdbg_tool_atmelice>\r
     <avrtoolinterface>debugWIRE</avrtoolinterface>\r
     <ExternalProgrammingToolCommand />\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
     <Compile Include="D:\oc\dev\owSlave2\common\I2C\SHT2x.c">\r
       <SubType>compile</SubType>\r
       <Link>SHT2x.c</Link>\r
diff --git a/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.atsln b/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.atsln
new file mode 100644 (file)
index 0000000..c9b2ef7
--- /dev/null
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Atmel Studio Solution File, Format Version 11.00
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SHT2X_BMP280", "DS2450_SHT2X_BMP280.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.c b/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.c
new file mode 100644 (file)
index 0000000..83b8dbc
--- /dev/null
@@ -0,0 +1,311 @@
+
+// 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/SHT2x.h"
+#include "../common/I2C/BMP280.h"
+extern void OWINIT();
+extern void EXTERN_SLEEP();
+
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/
+uint8_t config_info[16]={0x01,14,0x04,0x08,  0x06,0x09, 0x02,16,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+#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=10;
+
+
+#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 
+       wdcounter++;
+       if (reset_indicator==1) reset_indicator++;
+       else if (reset_indicator==2) mode=0;
+}
+
+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;
+
+
+
+volatile int16_t am2302_temp;
+volatile uint16_t am2302_hum;
+
+
+uint8_t userRegister[1];
+int16_t sRH,sT;
+volatile double temperatureC,humidityRH;
+uint32_t P;
+int32_t t;
+
+
+
+
+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;
+    PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0
+       PORTA=0xFF;  //All Pull up;
+        PRR|=(1<<PRADC);  // adc for save Power
+
+       ACSR|=(1<<ACD);  //Disable Comparator
+       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<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds
+       
+       gcontrol=1;
+       
+       USI_TWI_Master_Initialise();
+       bmp280Init();
+       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);
+       
+       sei();
+       
+       //DDRB|=(1<<PINB1);
+
+    while(1)   {
+       
+       if (wdcounter>3) {      
+               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);
+               bmp280ConvertInt(&t,&P,1);
+               wdcounter=0;
+       }
+       
+
+               
+               
+
+
+               if (gcontrol) {
+                       //PORTB|=(1<<PINB1);
+                       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_us(100);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.A=ADC;sei();*/
+                               uint16_t ct=(temperatureC*100.0)+32767;
+                               cli();pack.A=ct;sei();
+                               wdcounter=10;
+                               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_us(100);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.B=ADC;sei();*/
+                               wdcounter=10;
+                               cli();pack.B=humidityRH*100;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_us(100);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.C=ADC;sei();*/
+                               wdcounter=10;
+                               cli();pack.C=0;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_us(100);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.D=ADC;sei();*/
+                               wdcounter=10;
+                               cli();pack.D=P/100.0*32.0;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;}
+                       }
+                       
+                       EXTERN_SLEEP();
+                       //PORTB&=~(1<<PINB1);
+               }
+
+               /*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_SHT2X_BMP280/DS2450_SHT2X_BMP280.cproj b/DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.cproj
new file mode 100644 (file)
index 0000000..101ac51
--- /dev/null
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>7.0</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</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_SHT2X_BMP280</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>
+    <ExternalProgrammingToolCommand />
+    <AsfFrameworkConfig>
+      <framework-data xmlns="">
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.27.3" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <avrtoolserialnumber>J41800000779</avrtoolserialnumber>
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>
+    <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.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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\BMP280.c">
+      <SubType>compile</SubType>
+      <Link>BMP280.c</Link>
+    </Compile>
+    <Compile Include="D:\oc\dev\owSlave2\common\I2C\SHT2x.c">
+      <SubType>compile</SubType>
+      <Link>SHT2x.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="DS2450_SHT2X_BMP280.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_SHT2X_BMP280/OWDS2450.S b/DS2450_SHT2X_BMP280/OWDS2450.S
new file mode 100644 (file)
index 0000000..aec56b7
--- /dev/null
@@ -0,0 +1,247 @@
+
+// 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/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
+               rjmp h_convert_conv
+.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
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12
+
+;---------------------------------------------------
+;      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
+       FW_CONFIG_INFO
+#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_CONVERT_CONV
+       ;clr r_sendflag
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling
+h_convert_conv:
+       ldi r_bcount,0
+       ldi r_rwbyte,0
+       rjmp handle_end_no_bcount       
+
+
+
+
+#include "../common/OWPinInterrupt.s"
+.end
\ No newline at end of file
diff --git a/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.atsln b/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.atsln
new file mode 100644 (file)
index 0000000..542967c
--- /dev/null
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Atmel Studio Solution File, Format Version 11.00
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SHT2X_MAX44009", "DS2450_SHT2X_MAX44009.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|AVR = Debug|AVR
+               Release|AVR = Release|AVR
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.c b/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.c
new file mode 100644 (file)
index 0000000..8afb2e0
--- /dev/null
@@ -0,0 +1,316 @@
+
+// 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/SHT2x.h"
+#include "../common/I2C/MAX44009.h"
+extern void OWINIT();
+extern void EXTERN_SLEEP();
+
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/
+uint8_t config_info[16]={0x01,14,0x04,0x08, 0x03,15, 0x06,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+#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=10;
+
+
+#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 
+       wdcounter++;
+       if (reset_indicator==1) reset_indicator++;
+       else if (reset_indicator==2) mode=0;
+}
+
+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;
+
+
+
+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;
+uint32_t P;
+int32_t t;
+uint8_t max_adr=0;
+
+
+
+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;
+    PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0
+       PORTA=0xFF;  //All Pull up;
+        PRR|=(1<<PRADC);  // adc for save Power
+
+       ACSR|=(1<<ACD);  //Disable Comparator
+       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<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds
+       
+       gcontrol=1;
+       
+       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);
+       if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;
+       
+       sei();
+       
+       //DDRB|=(1<<PINB1);
+
+    while(1)   {
+       
+       if (wdcounter>3) {      
+               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);
+
+               l=MAX44009getlux(max_adr);
+               if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045
+               //double l=1000;
+               l=(log(l)*1000)+32767.0;
+               wdcounter=0;
+       }
+       
+
+               
+               
+
+
+               if (gcontrol) {
+                       //PORTB|=(1<<PINB1);
+                       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_us(100);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.A=ADC;sei();*/
+                               uint16_t ct=(temperatureC*100.0)+32767;
+                               cli();pack.A=ct;sei();
+                               wdcounter=10;
+                               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_us(100);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.B=ADC;sei();*/
+                               wdcounter=10;
+                               cli();pack.B=humidityRH*100;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_us(100);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.C=ADC;sei();*/
+                               wdcounter=10;
+                               cli();pack.C=l;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_us(100);
+                               ADCSRA|=(1<<ADSC);
+                               while ((ADCSRA&(1<<ADSC)));
+                               cli();pack.D=ADC;sei();*/
+                               wdcounter=10;
+                               cli();pack.D=0;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;}
+                       }
+                       
+                       EXTERN_SLEEP();
+                       //PORTB&=~(1<<PINB1);
+               }
+
+               /*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_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.cproj b/DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.cproj
new file mode 100644 (file)
index 0000000..7924bc2
--- /dev/null
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectVersion>7.0</ProjectVersion>
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
+    <ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</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_SHT2X_MAX44009</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>
+    <ExternalProgrammingToolCommand />
+    <AsfFrameworkConfig>
+      <framework-data xmlns="">
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.27.3" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <avrtoolserialnumber>J41800000779</avrtoolserialnumber>
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>
+    <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.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>
+        <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.directories.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>
+          </ListValues>
+        </avrgcc.compiler.directories.IncludePaths>
+        <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\SHT2x.c">
+      <SubType>compile</SubType>
+      <Link>SHT2x.c</Link>
+    </Compile>
+    <Compile Include="D:\oc\dev\owSlave2\common\I2C\TSL256x.c">
+      <SubType>compile</SubType>
+      <Link>TSL256x.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="DS2450_SHT2X_MAX44009.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_SHT2X_MAX44009/OWDS2450.S b/DS2450_SHT2X_MAX44009/OWDS2450.S
new file mode 100644 (file)
index 0000000..aec56b7
--- /dev/null
@@ -0,0 +1,247 @@
+
+// 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/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
+               rjmp h_convert_conv
+.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
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12
+
+;---------------------------------------------------
+;      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
+       FW_CONFIG_INFO
+#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_CONVERT_CONV
+       ;clr r_sendflag
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling
+h_convert_conv:
+       ldi r_bcount,0
+       ldi r_rwbyte,0
+       rjmp handle_end_no_bcount       
+
+
+
+
+#include "../common/OWPinInterrupt.s"
+.end
\ No newline at end of file
diff --git a/DS2450_VOC_SHT_BMP/DS2450_VOC_SHT_BMP.c b/DS2450_VOC_SHT_BMP/DS2450_VOC_SHT_BMP.c
new file mode 100644 (file)
index 0000000..cc9f16f
--- /dev/null
@@ -0,0 +1,464 @@
+
+// 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 "../common/I2C/USI_TWI_Master.h"
+#include "../common/I2C/MAX1164x.h"
+#include "../common/I2C/SHT2x.h"
+#include "../common/calibr.h"
+#include "../common/I2C/BMP280.h"
+
+
+
+extern void OWINIT();
+extern void EXTERN_SLEEP();
+
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/
+uint8_t config_info[16]={0x01,14, 0x04,0x08, 0x08,1, 0x02,16,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+#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=1;
+
+
+#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 
+       wdcounter++;
+       if (reset_indicator==1) reset_indicator++;
+       else if (reset_indicator==2) mode=0;
+
+
+}
+
+volatile uint16_t _temp;
+volatile uint16_t _hum;
+
+
+uint8_t userRegister[1];
+int16_t sRH,sT;
+double temperatureC,humidityRH,hhum;
+double l;
+
+double R0;
+uint16_t mr;
+uint8_t startup=10;
+double ip;
+
+uint32_t bmp_P;
+int32_t bmp_t;
+
+uint8_t max_adr=0;
+#define CH0_M MAX1164x_C_SCAN0|MAX1164x_C_SGL
+#define CH1_M MAX1164x_C_SCAN0|MAX1164x_C_SGL|MAX1164x_C_CS0
+#define CH0_CH1 MAX1164x_C_SCAN0
+//|MAX1164x_C_CS0
+
+uint16_t weekmaxarr[8];
+
+
+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;
+
+
+typedef struct {
+       int16_t current;  //6
+       uint16_t R0;
+       //uint16_t VS;
+       uint8_t cmode;
+       int16_t ip;
+       //uint8_t free;
+       uint16_t tol_s8;
+       uint16_t tol_d;
+       uint16_t r_day_max;
+       uint16_t r_week_max;
+} pack2_t;
+volatile pack2_t pack2;
+
+
+//Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte
+inline double interp(double t, double h) {
+       double h2;
+        double t2;
+       h2=h*h;
+       t2=t*t;
+       return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591;
+}
+
+#define EEPROM_R0 0
+#define EEPROM_R0d 2
+#define EEPROM_R0w 4
+#define EEPROM_dol 6
+
+
+uint16_t readEEPROM(uint8_t addr,uint16_t def) {
+       uint16_t hr;
+       while(EECR & (1<<EEPE));
+       EEARL=addr+1;
+       EECR |= (1<<EERE);
+       hr=EEDR;
+       if (hr!=0xFF) {
+               hr=hr<<8;
+               while(EECR & (1<<EEPE));
+               EEARL=addr;
+               EECR |= (1<<EERE);
+               hr|=EEDR;
+               return hr;
+       }
+       return def;
+}
+
+void writeEEPROM(uint8_t addr,uint16_t val) {
+       while(EECR & (1<<EEPE));
+       EECR = (0<<EEPM1)|(0<<EEPM0);
+       EEARL = addr;
+       EEDR = val&0xFF;
+       EECR |= (1<<EEMPE);
+       EECR |= (1<<EEPE);
+       while(EECR & (1<<EEPE));
+       EECR = (0<<EEPM1)|(0<<EEPM0);
+       EEARL = addr+1;
+       EEDR = val>>8;
+       EECR |= (1<<EEMPE);
+       EECR |= (1<<EEPE);
+}
+
+
+
+
+
+int main(void){
+       PRR|=(1<<PRADC);  // adc for save Power
+       PORTA=0xFF;
+       PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0
+       OWINIT();
+       DDRB|=(1<<PINB1);//Ausgang und 1
+       DDRA|=(1<<PINA0);
+       
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt
+       //(1<<WDP0) |(1<<WDP2) | (1<<WDP1);    // Set Timeout to ~2 seconds
+       (1<<WDP3) | (1<<WDP0);    // Set Timeout to ~8 seconds
+
+       MCUSR=0;
+       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;
+
+       pack2.cmode=0;
+       pack2.R0=readEEPROM(EEPROM_R0,1);
+       R0=pack2.R0/100.0;
+               
+       pack2.r_day_max=readEEPROM(EEPROM_R0d,1);
+       pack2.r_week_max=readEEPROM(EEPROM_R0w,1);
+       pack2.tol_d=readEEPROM(EEPROM_dol,0); 
+       pack2.tol_s8=0;  //Tag faengt mit Einschalten an
+       for(uint8_t i=0;i<7;i++) {
+               weekmaxarr[i]=pack2.r_week_max;
+       }
+
+       USI_TWI_Master_Initialise();
+       bmp280Init();
+       SHT2x_SoftReset();
+       SHT2x_ReadUserRegister(userRegister);
+       SHT2x_WriteUserRegister(userRegister); //write changed user reg
+       MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M);//#define MAX1164x_C_CS0
+       _delay_ms(30); //Internal Referenz start
+       //2970 -> 1,5V  
+       gcontrol=1;
+       sei();
+       
+
+    while(1)   {
+
+               /*if (pack1.config==0x1F) {
+                       pack1.config=0x7F;
+                       R0=1;
+                       pack2.R0=0;
+                       writeEEPROM(EEPROM_R0,0);
+               } 
+               if (pack1.config==0x05) {
+                       pack1.config=0x7F;                              
+                       pack2.r_day_max=1;
+                       pack2.r_week_max=1;
+                       pack2.tol_d=0;
+                       pack2.tol_s8=0;  //Tag faengt mit Einschalten an        
+                       R0=1;   
+                       writeEEPROM(EEPROM_R0,0xFF);
+                       writeEEPROM(EEPROM_R0d,0xFF);  //Maximum des Tages
+                       writeEEPROM(EEPROM_R0w,0xFF); //Maximum der Letzten 7 Tage
+                       writeEEPROM(EEPROM_dol,0xFF); //Anzahl der Betriebstage         
+                       for(uint8_t i=0;i<7;i++) {
+                               weekmaxarr[i]=1;
+                       }                               
+               } */
+               if (wdcounter>0) {
+                       pack2.tol_s8++;
+                       if (pack2.tol_s8>(10000))  {//10800 ist theortisch der Tag aber meistens zu lang
+                               pack2.tol_s8=0;
+                               pack2.tol_d++;  //rund 180 Jahre :-)
+                               pack2.r_week_max=0;
+                               weekmaxarr[7]=pack2.r_day_max;
+                               for(uint8_t i=0;i<7;i++) {
+                                       weekmaxarr[i]=weekmaxarr[i+1];
+                                       if (weekmaxarr[i]>pack2.r_week_max) pack2.r_week_max=weekmaxarr[i];
+                               }
+                               if (pack2.tol_d>7) {
+                                       pack2.R0=pack2.r_week_max;
+                               } else {
+                                       pack2.R0=pack2.r_day_max;
+                               }
+                               //R0=pack2.R0/100.0-0.5*(pack2.R0/100.0-R0);
+                               R0=R0-(R0-pack2.R0/100.0)*0.5   ;
+                               pack2.R0=R0*100;
+                               writeEEPROM(EEPROM_R0,pack2.R0);
+                               writeEEPROM(EEPROM_R0d,pack2.r_day_max);  //Maximum des Tages
+                               writeEEPROM(EEPROM_R0w,pack2.r_week_max); //Maximum der Letzten 7 Tage
+                               writeEEPROM(EEPROM_dol,pack2.tol_d); //Anzahl der Betriebstage
+                               pack2.r_day_max=0;
+                       }
+                       if (startup!=0) startup--;
+                       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);
+                       ip=interp(temperatureC,humidityRH);
+                       pack2.ip=ip*1000;
+                       //humidityRH=calibr_hum(temperatureC,-0.45,humidityRH);
+                       //temperatureC =temperatureC -0.45;
+                       _hum= humidityRH*100.0;
+                       _temp=(temperatureC*100.0)+32767;
+                       //PORTB&=~(1<<PINB1);
+                       mr=0;
+//Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________
+                       PORTB&=~(1<<PINB1); //Auf 0 Ziehen
+                       _delay_us(150);
+                       mr+=MAX1164x_read();
+                       _delay_us(150);
+                       mr+=MAX1164x_read();
+                       PORTB|=(1<<PINB1);
+//ENDE Kritische Sektion !______________________________
+                       //l=mr/2.0*2.048/4096; 
+                       // l maximal 2  mr max 4096  //mr 2V=8000 
+                       
+                       if (pack2.cmode) { //cmode=0 V 0..2 V cmode=1 V 1.5..3.5V
+                               //l+=1.5; //Spannung real
+                               mr+=6000;
+                       } 
+                       //if (l>1.8) {
+                       if (mr>7200) {                          
+                               if (pack2.cmode==0) {
+                                       MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_CH1);
+                                       pack2.cmode=1;
+                               }
+                       }
+                       //if (l<1.6) {
+                       if (mr<6400) {  
+                               if (pack2.cmode==1) {
+                                       MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M);
+                                       pack2.cmode=0;
+                               }
+                               
+                               
+                       }
+                       //pack2.VS=mr*5/2;
+                       l=mr/4000.0;
+                       l=( 3/l- 1) *30;
+                       pack2.current=l*100;
+                       
+                       l=l/ip;
+                       
+                       if (startup==0){
+                               if (l>R0) {
+                                       R0=l;
+                                       pack2.R0=R0*100;
+                                       writeEEPROM(EEPROM_R0,pack2.R0);
+
+                               }
+                               if (l*100>pack2.r_day_max) {
+                                       pack2.r_day_max=l*100;
+                               }
+                       } else if (l<R0) l=R0; //negative Werte am Anfang verhintern
+                       l=R0/l;
+                       l=log(l);
+                       l=l*160*4; //fuer DS18B20
+                       bmp280ConvertIntP1(&bmp_P);
+                       bmp_P=bmp_P/3;    // /100.0*32.0;
+                       wdcounter=0;
+                       
+               }
+
+               if (gcontrol) {
+                       //PORTB|=(1<<PINB1);
+                       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) {
+                               cli();pack.A=_temp;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) {
+                               cli();pack.B=_hum;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) {
+                               cli();pack.C=l;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) {
+                               cli();pack.D=bmp_P;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;}
+                       }
+                       
+                       EXTERN_SLEEP();
+                       //PORTB&=~(1<<PINB1);
+               }
+
+               
+#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");
+   }
+
+
+}
index 6d23946..97ab51d 100644 (file)
@@ -206,14 +206,14 @@ void bmp280ConvertIntP(int32_t temp256,uint32_t *pressure) {
 }              \r
                \r
 void bmp280ConvertIntP1(uint32_t *pressure) {\r
-       int32_t var1,var2,T,t_fine;\r
+       int32_t var1,var2,t_fine;\r
        \r
        \r
        int32_t adc_T=bmp280ReadTemp();\r
        var1 = ((((adc_T>>3) - ((int32_t)dig_T1<<1))) * ((int32_t)dig_T2)) >> 11;\r
        var2 = ((((((adc_T>>4) - ((int32_t)dig_T1)) * ((adc_T>>4) - (int32_t)dig_T1))) >> 12) *((int32_t)dig_T3)) >> 14;\r
        t_fine = var1 + var2;\r
-       T = (t_fine * 5 + 128) >> 8;\r
+       //T = (t_fine * 5 + 128) >> 8;\r
        int32_t adc_P= bmp280ReadPressure_simple();\r
        uint32_t p;\r
        var1 = (((int32_t)t_fine)>>1) - (int32_t)64000;\r
diff --git a/common/I2C/HDC1080.c b/common/I2C/HDC1080.c
new file mode 100644 (file)
index 0000000..3a55ddb
--- /dev/null
@@ -0,0 +1,295 @@
+// Copyright (c) 2016, 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.
+
+//---------- 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 "HDC1080.h"
+typedef enum{
+       I2C_ADR_W = 128, // sensor I2C address + write bit
+       I2C_ADR_R = 129 // sensor I2C address + read bit
+}etI2cHeader;
+
+uint8_t HDC1080_Init() {
+       volatile uint8_t error=0;
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr
+       error |= I2c_WriteByte (0x02); // Config
+       error |= I2c_WriteByte (0x0); // 14 bit
+       error |= I2c_WriteByte (0x0); // 
+       I2c_StopCondition();
+       return error;
+
+}
+
+uint8_t HDC1080_Readf(double * temperature, double * hum) {    
+       int16_t t;
+       uint16_t h;
+       uint8_t error=0;
+       error=HDC1080_Readi(&t,&h);
+       *temperature=(double)t/65536.0*165.0-40.0;
+       *hum=(double)h/65536.0*100;
+       return error;
+
+}
+uint8_t HDC1080_Readi(int16_t * temperature, uint16_t * hum) {
+       volatile uint8_t error=0;
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr
+       error |= I2c_WriteByte (0x0); //
+       I2c_StopCondition();
+       _delay_ms(10);
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_R); //I2C address
+       *temperature=0;
+       *temperature |= I2c_ReadByte(ACK)<<8;
+       *temperature |= I2c_ReadByte(ACK); 
+       I2c_StopCondition();
+
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr
+       error |= I2c_WriteByte (0x01); //
+       I2c_StopCondition();
+       _delay_ms(10);
+       I2c_StartCondition();
+       error |= I2c_WriteByte (I2C_ADR_R); //I2C address
+       *hum=0;
+       *hum|= I2c_ReadByte(ACK)<<8; 
+       *hum|= I2c_ReadByte(NO_ACK); 
+       I2c_StopCondition();
+       return error;
+       }
+
+/*
+
+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(200); //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(void)
+//===========================================================================
+{
+       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/HDC1080.h b/common/I2C/HDC1080.h
new file mode 100644 (file)
index 0000000..801cca1
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef HDC1080_H
+#define HDC1080_H
+// Copyright (c) 2016, 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.
+
+
+uint8_t HDC1080_Init();
+
+uint8_t HDC1080_Readf(double * temperature, double * hum);
+uint8_t HDC1080_Readi(int16_t * temperature, uint16_t * hum);
+
+
+#endif
index 4ad7394..3694b11 100644 (file)
@@ -33,6 +33,7 @@
 \r
 #define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
+#define _HANDLE_CC_COMMAND_\r
 //#define _DB_\r
 \r
 #include "../common/OWConfig.s"\r
@@ -99,6 +100,14 @@ Init_EEPROM_read:
 ;      READ COMMAND and start operation\r
 ;---------------------------------------------------\r
 \r
+#ifdef _HANDLE_CC_COMMAND_\r
+h_readcommand12:\r
+       clr r_bytep\r
+       cjmp 0x44,hrc_set_convertT12\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+#endif\r
+\r
 \r
 h_readcommand1:\r
        clr r_bytep\r
@@ -132,12 +141,21 @@ hrc_recall_eeprom1:
        rcall hrc_recall_eeprom_func1\r
        rjmp handle_end\r
 \r
-\r
+#ifdef _HANDLE_CC_COMMAND_\r
+hrc_set_convertT12:\r
+       ldi r_temp,3\r
+       sts gcontrol,r_temp\r
+       lds r_temp,am2302_temp\r
+       sts pack2+1,r_temp\r
+       lds r_temp,am2302_temp+1\r
+       sts pack2+2,r_temp\r
+       rjmp hrc_set_convertT12b\r
+#endif\r
 \r
 hrc_set_convertT1:\r
        ldi r_temp,1\r
        sts gcontrol,r_temp\r
-\r
+hrc_set_convertT12b:\r
        ldi r_mode,OW_CONVERT_RUN1\r
        ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
 h_convert_run1:\r
@@ -146,6 +164,7 @@ h_convert_run1:
        rjmp handle_end_no_bcount       \r
 \r
 \r
+\r
 hrc_copy_scratchpad1:\r
        ldi r_bytep,2\r
        configZ pack1,r_bytep\r
index e5c007b..eac94b9 100644 (file)
@@ -185,6 +185,8 @@ hrc_set_searchrom:
        lds r_rwbyte,owid ;erstes Byte lesen\r
        rjmp h_searchrom_next_bit\r
 \r
+\r
+\r
 hrc_start_read_command: ;Skip rom und Matchrom ok...\r
        ldi r_mode,OW_READ_COMMAND\r
        CRCInit1\r
index 9bbf71d..cb4ac7f 100644 (file)
 #define OW_SEARCHROMR 4  ; next resive master answer\r
 #define OW_READ_COMMAND1 5\r
 #define OW_READ_COMMAND2 6\r
-#define OW_FWCONFIGINFO1 7\r
-#define OW_FWCONFIGINFO2 8\r
+#define OW_READ_COMMAND12 7 ;Skip ROM.... eigentlich nicht mit mehreren geraeten, aber bei loxone schon (CC 44)\r
+#define OW_FWCONFIGINFO1 8\r
+#define OW_FWCONFIGINFO2 9\r
 \r
 .comm idtable,64\r
 \r
 #ifdef _CHANGEABLE_ID_\r
-#define OW_WRITE_NEWID 9\r
-#define OW_READ_NEWID 10\r
-#define OW_SET_NEWID 11\r
-#define OW_FIRST_COMMAND 12\r
+#define OW_WRITE_NEWID 10\r
+#define OW_READ_NEWID 11\r
+#define OW_SET_NEWID 12\r
+#define OW_FIRST_COMMAND 13\r
 .comm newid,8\r
-       \r
+\r
+   \r
 .macro CHANGE_ID_COMMANDS\r
        cset 0x75,OW_WRITE_NEWID\r
        cljmp 0xA7,hrc_set_readid\r
@@ -81,7 +83,7 @@
 \r
 \r
 #else\r
-#define OW_FIRST_COMMAND 9\r
+#define OW_FIRST_COMMAND 10\r
 #endif\r
 \r
 #ifndef _DIS_FLASH_\r
@@ -153,6 +155,11 @@ handle_stable:
                rjmp h_searchromr\r
                rjmp h_readcommand1 \r
                rjmp h_readcommand2\r
+#ifdef _HANDLE_CC_COMMAND_\r
+               rjmp h_readcommand12\r
+#else\r
+               rjmp handle_end_no_bcount\r
+#endif\r
                rjmp h_fwconfiginfo1\r
                rjmp h_fwconfiginfo2\r
 #ifdef _CHANGEABLE_ID_\r
@@ -169,7 +176,9 @@ h_readromcommand:
        cjmp 0x55,hrc_set_matchrom\r
        cjmp 0xF0,hrc_set_searchrom\r
        cjmp 0xEC,hrc_set_alarm_search\r
-       \r
+#ifdef _HANDLE_CC_COMMAND_\r
+       cjmp 0xCC,hrc_start_read_command12\r
+#endif\r
        rjmp handle_end_sleep\r
 \r
 #ifndef _DIS_FLASH_\r
@@ -218,6 +227,11 @@ hrc_start_read_command2:
        ldi r_mode,OW_READ_COMMAND2\r
        rjmp handle_end\r
 \r
+#ifdef _HANDLE_CC_COMMAND_\r
+hrc_start_read_command12:\r
+       ldi r_mode,OW_READ_COMMAND12\r
+       rjmp handle_end\r
+#endif\r
 \r
 hrc_set_alarm_search:\r
        lds r_temp,alarmflag\r