New I2C devices
authorTobias Müller <muto@wsk.tu-chemnitz.de>
Tue, 24 Oct 2017 14:57:54 +0000 (16:57 +0200)
committerTobias Müller <muto@wsk.tu-chemnitz.de>
Tue, 24 Oct 2017 14:57:54 +0000 (16:57 +0200)
Correction of dual devices

38 files changed:
DS18B20_BMP280/DS18B20_BMP280.cproj
DS18B20_CDM7160/DS18B20_CDM7160.atsln
DS18B20_CDM7160/DS18B20_CDM7160.c
DS18B20_CDM7160/DS18B20_CDM7160.cproj
DS18B20_MAX44009/DS18B20_MAX44009.cproj
DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c
DS18B20_MAX44009_DS2438_SHT/DS18B20_MAX44009_DS2438_SHT.cproj
DS18B20_Thermocouble/convthermocouple.py
DS18B20_Thermocouble_DS2438_SHT/DS18B20_DS2438.c
DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.cproj
DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c
DS18B20_VOC_DS2438_SHT/DS18B20_DS2438.c
DS2423_DS2413/Makefile
DS2438_SHT3X/DS2438_SHT3X.cproj
DS2438_VOC_DS2438_SHT_Wiregate/DS2438_DS2438.c
DS2450/DS2450.c
DS2450/DS2450.cproj
DS2450/OWDS2450.S
DS2450_APDS9960/DS2450_APDS9960.atsln [new file with mode: 0644]
DS2450_APDS9960/DS2450_APDS9960.c [new file with mode: 0644]
DS2450_APDS9960/DS2450_APDS9960.cproj [new file with mode: 0644]
DS2450_IAQCORE/DS2450_IAQCORE.atsln [new file with mode: 0644]
DS2450_IAQCORE/DS2450_IAQCORE.c [new file with mode: 0644]
DS2450_IAQCORE/DS2450_IAQCORE.cproj [new file with mode: 0644]
common/I2C/APDS9960.c [new file with mode: 0644]
common/I2C/APDS9960.h [new file with mode: 0644]
common/I2C/BME680.c [new file with mode: 0644]
common/I2C/BME680.h [new file with mode: 0644]
common/I2C/IAQCORE.c [new file with mode: 0644]
common/I2C/IAQCORE.h [new file with mode: 0644]
common/I2C/SGP30.c [new file with mode: 0644]
common/I2C/SGP30.h [new file with mode: 0644]
common/I2C/USI_TWI_Master.h
common/OWDS18B20_DS2438.S
common/OWDS2438.S
common/OWDS2438_DS2438.S
common/OWDS2450.S
common/OWSet_ATTINYX4.s

index 25b04ce..3acd3b5 100644 (file)
@@ -34,7 +34,7 @@
   <documentation help="" />\r
   <offline-documentation help="" />\r
   <dependencies>\r
-    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
   </dependencies>\r
 </framework-data>\r
     </AsfFrameworkConfig>\r
     </Compile>\r
   </ItemGroup>\r
   <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
-</Project>\r
+</Project>
\ No newline at end of file
index bb4e41c..e205eb6 100644 (file)
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Atmel Studio Solution File, Format Version 11.00\r
 VisualStudioVersion = 14.0.23107.0\r
 MinimumVisualStudioVersion = 10.0.40219.1\r
-Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_CDM7160", "DS18B20_CDM7160.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_CDM7160", "DS18B20_CDM7160.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
 EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
@@ -11,10 +11,10 @@ Global
                Release|AVR = Release|AVR\r
        EndGlobalSection\r
        GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
-               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR\r
-               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR\r
-               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR\r
-               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR\r
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR\r
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR\r
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR\r
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR\r
        EndGlobalSection\r
        GlobalSection(SolutionProperties) = preSolution\r
                HideSolutionNode = FALSE\r
index b46797c..1c18216 100644 (file)
@@ -47,7 +47,7 @@ extern void EXTERN_SLEEP();
 \r
 \r
 uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/\r
-uint8_t config_info[26]={10,13, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+uint8_t config_info[26]={10,21, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
        \r
 #if (owid>128) \r
 #error "Variable not correct"\r
@@ -76,7 +76,7 @@ uint8_t max_adr=0;
 typedef union {\r
        volatile uint8_t bytes[8];\r
        struct {\r
-               uint16_t temp;  //0\r
+               int16_t temp;  //0\r
                uint8_t TH;  //2\r
                uint8_t TL;  //3\r
                uint8_t config;  //4\r
@@ -95,6 +95,8 @@ volatile pack_t pack;
 \r
 \r
 int main(void){\r
+       PORTB&=~(1<<PINB1);\r
+       DDRB|=(1<<PINB1);\r
     PRR|=(1<<PRADC);  // adc for save Power\r
        pack.temp=0x0550;\r
        pack.config=0x7F;\r
@@ -106,8 +108,10 @@ int main(void){
        PORTA=0xFF;\r
        PORTB=0xFF;\r
        OWINIT();\r
-       DDRB|=(1<<PINB1);\r
        PORTB&=~(1<<PINB1);\r
+       DDRB|=(1<<PINB1);\r
+       \r
+\r
        PORTA&=~(1<<PINA0);\r
 \r
        MCUCR &=~(1<<PUD); //All Pins Pullup...\r
@@ -118,15 +122,18 @@ int main(void){
        (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
 \r
        MCUSR=0;\r
+       _delay_ms(100);\r
        USI_TWI_Master_Initialise();\r
-       //CDM7160softReset();\r
-       //_delay_ms(100);\r
-\r
+       CDM7160softReset();\r
+       _delay_ms(200);\r
+       \r
        CDM7160setMode(0); //Power Down Mode\r
+       _delay_ms(200);\r
        CDM7160setAvCount(0x3F);\r
        CDM7160setFMode(1);\r
        pack.temp=CDM7160getCO2();\r
        CDM7160setMode(1);\r
+       _delay_ms(200);\r
        gcontrol=1;\r
        //DDRB|=(1<<PINB1);\r
        //while (1)                     {volatile double l=CDM7160getCO2();}\r
@@ -145,10 +152,10 @@ int main(void){
                if (wdcounter>(PBR+1)) {\r
                        wdcounter=0;\r
                        //PORTB|=(1<<PINB1); //Dauer 2.3ms\r
-                       volatile uint16_t l=CDM7160getCO2();    \r
-                       uint16_t w=l;\r
-                       uint8_t t8=w>>4;\r
-                       uint8_t af=0;\r
+                       volatile int16_t l=(int16_t)CDM7160getCO2()-1280;       \r
+                       int16_t w=l;\r
+                       int8_t t8=w/16;\r
+                       int8_t af=0;\r
                        if (t8>pack.TH) af=1;\r
                        if (t8<=pack.TL) af=1; \r
                        cli();\r
index 9ae17e6..228ac1d 100644 (file)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>\r
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">\r
   <PropertyGroup>\r
     <SchemaVersion>2.0</SchemaVersion>\r
     <ProjectVersion>7.0</ProjectVersion>\r
     <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>\r
-    <ProjectGuid>{7a5672fe-8226-4158-b931-e1f36b9a8858}</ProjectGuid>\r
+    <ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
     <avrdevice>ATtiny84A</avrdevice>\r
     <avrdeviceseries>none</avrdeviceseries>\r
     <OutputType>Executable</OutputType>\r
     <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
     <OutputFileExtension>.elf</OutputFileExtension>\r
     <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
-    <AssemblyName>DS18B20_MAX44009</AssemblyName>\r
+    <AssemblyName>DS18B20_CDM7160</AssemblyName>\r
     <Name>DS18B20_CDM7160</Name>\r
-    <RootNamespace>DS18B20_MAX44009</RootNamespace>\r
+    <RootNamespace>DS18B20_CDM7160</RootNamespace>\r
     <ToolchainFlavour>Native</ToolchainFlavour>\r
     <KeepTimersRunning>true</KeepTimersRunning>\r
     <OverrideVtor>false</OverrideVtor>\r
     <CacheFlash>true</CacheFlash>\r
     <ProgFlashFromRam>true</ProgFlashFromRam>\r
-    <RamSnippetAddress>0x20000000</RamSnippetAddress>\r
+    <RamSnippetAddress />\r
     <UncachedRange />\r
     <preserveEEPROM>true</preserveEEPROM>\r
-    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <OverrideVtorValue />\r
     <BootSegment>2</BootSegment>\r
-    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <eraseonlaunchrule>0</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.22.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.28.1" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
-    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
-    <com_atmel_avrdbg_tool_atmelice>\r
-      <ToolOptions>\r
-        <InterfaceProperties>\r
-        </InterfaceProperties>\r
-        <InterfaceName>debugWIRE</InterfaceName>\r
-      </ToolOptions>\r
-      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
-      <ToolNumber>J41800000789</ToolNumber>\r
-      <ToolName>Atmel-ICE</ToolName>\r
-    </com_atmel_avrdbg_tool_atmelice>\r
-    <avrtoolinterface>debugWIRE</avrtoolinterface>\r
-    <com_atmel_avrdbg_tool_simulator>\r
-      <ToolOptions>\r
-        <InterfaceProperties>\r
-        </InterfaceProperties>\r
-        <InterfaceName>\r
-        </InterfaceName>\r
-      </ToolOptions>\r
-      <ToolType>com.atmel.avrdbg.tool.simulator</ToolType>\r
-      <ToolNumber>\r
-      </ToolNumber>\r
-      <ToolName>Simulator</ToolName>\r
-    </com_atmel_avrdbg_tool_simulator>\r
-    <ExternalProgrammingToolCommand />\r
-    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
-    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\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.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\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.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
         <avrgcc.compiler.symbols.DefSymbols>\r
           <ListValues>\r
-            <Value>DEBUG</Value>\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
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
           </ListValues>\r
         </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\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.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
         </avrgcc.linker.libraries.Libraries>\r
         <avrgcc.assembler.general.IncludePaths>\r
           <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\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.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\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.compiler.symbols.DefSymbols>\r
         <avrgcc.compiler.directories.IncludePaths>\r
           <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
           </ListValues>\r
         </avrgcc.compiler.directories.IncludePaths>\r
         <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\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
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
           </ListValues>\r
         </avrgcc.assembler.general.IncludePaths>\r
         <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
       <SubType>compile</SubType>\r
       <Link>CDM7160.c</Link>\r
     </Compile>\r
-    <Compile Include="..\common\OWDS18B20.S">\r
-      <SubType>compile</SubType>\r
-      <Link>OWDS18B20.S</Link>\r
-    </Compile>\r
     <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
       <SubType>compile</SubType>\r
       <Link>USI_TWI_Master.c</Link>\r
     </Compile>\r
+    <Compile Include="..\common\OWDS18B20.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS18B20.S</Link>\r
+    </Compile>\r
     <Compile Include="DS18B20_CDM7160.c">\r
       <SubType>compile</SubType>\r
     </Compile>\r
index ae5ad14..a63a3cf 100644 (file)
@@ -34,7 +34,7 @@
   <documentation help="" />\r
   <offline-documentation help="" />\r
   <dependencies>\r
-    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
   </dependencies>\r
 </framework-data>\r
     </AsfFrameworkConfig>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\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
+        <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.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
+        <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 c7ff34c..4e8d28b 100644 (file)
@@ -207,9 +207,9 @@ int main(void){
        sei();\r
        //DDRB|=(1<<PINB1);\r
     while(1)   {\r
-               if ((gcontrol==2)||(gcontrol==3)) {\r
+               if ((gcontrol&2)==2){\r
                        wdcounter=3;\r
-                       gcontrol=0;\r
+                       \r
                        \r
                }\r
                \r
@@ -240,7 +240,7 @@ int main(void){
                        wdcounter=0;\r
                }\r
        \r
-               if (gcontrol==1) {\r
+               if ((gcontrol&1)==1) {\r
                        gcontrol=0;\r
                        l=MAX44009getlux(max_adr);              \r
                        if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045\r
index f17ec23..c14dc8d 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.28.1" />\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.28.1" />\r
+        </dependencies>\r
+      </framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
         <InterfaceProperties>\r
           <IspClock>125000</IspClock>\r
         </InterfaceProperties>\r
-        <InterfaceName>ISP</InterfaceName>\r
+        <InterfaceName>debugWIRE</InterfaceName>\r
       </ToolOptions>\r
       <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
       <ToolNumber>J41800000789</ToolNumber>\r
       <ToolName>Atmel-ICE</ToolName>\r
     </com_atmel_avrdbg_tool_atmelice>\r
-    <avrtoolinterface>ISP</avrtoolinterface>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\r
     <com_atmel_avrdbg_tool_simulator>\r
       <ToolOptions>\r
         <InterfaceProperties>\r
index c11c3dd..2d17bde 100644 (file)
@@ -1,4 +1,4 @@
-fi=open("Typ-J.csv","r")\r
+fi=open("Typ-K.csv","r")\r
 lastv=0\r
 v=0\r
 lastt=0\r
@@ -7,25 +7,36 @@ rs=""
 wc=0\r
 for l in fi.readlines():\r
        #print(l)\r
+       l=l.replace(",",".")\r
        ll=l.split(";")\r
        i=0\r
        for n in ll[1:10]:\r
-               s=ll[0]+"."+str(i)\r
+               s=ll[0][:-1]+""+str(i)\r
                lastv=v\r
                lastt=t\r
                v=float(n)\r
                t=float(s)\r
                if (int(v)!=int(lastv)):\r
-                       interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv)\r
-                       print int(v),interp\r
+                       #print v,lastv\r
+                       #print t,lastt\r
+                       if (lastt<0):\r
+                               interp=lastt+(t-lastt)/(v-lastv)*(int(v-1)-lastv)\r
+                               #print (t-lastt)/(v-lastv)*(int(v-1)-lastv)\r
+                               print int(v-1),interp\r
+                       else:\r
+                               interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv)\r
+                               #print (t-lastt)/(v-lastv)*(int(v)-lastv)\r
+                               print int(v),interp\r
                        rs=rs+", %f" %(interp)\r
                        wc=wc+1\r
-               if (v==0):\r
+               if (v<=-6):\r
                        interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv)\r
                        print int(v),interp\r
-                       rs="{0"\r
-                       wc=1\r
-                       \r
+                       rs="{"\r
+                       wc=0\r
+               if (v==0):\r
+                       rs=rs+", %f" %(0)\r
+                       wc=wc+1;\r
                i=i+1\r
 print rs+"};"\r
 print wc
\ No newline at end of file
index 3cf6053..4927b99 100644 (file)
 extern void OWINIT();\r
 extern void EXTERN_SLEEP();\r
 \r
-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};\r
+//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};\r
+const float k_rs[61] PROGMEM ={ -212.538462, -166.260870, -124.892857, -97.562500, -66.888889, -34.157895, 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.192771, 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.173333, 1176.189189, 1203.472222, 1231.083333, 1259.000000, 1287.285714, 1315.941176, 1344.941176};\r
+#define k_ofs 6\r
+\r
 //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};\r
 double gettemp_rs(double V) {\r
-       uint8_t iv=(uint8_t)(V);\r
+       uint8_t iv=(uint8_t)(V+k_ofs);\r
        float t0=pgm_read_float(&(k_rs[iv]));\r
        float t1=pgm_read_float(&(k_rs[iv+1]));\r
-       return t0+(t1-t0)/1*(V-iv);\r
+       return t0+(t1-t0)/1*((V+k_ofs)-iv);\r
 }\r
 \r
 \r
@@ -161,11 +164,17 @@ volatile pack2_t pack2;
 \r
 volatile double V,ktemp;\r
 \r
-uint16_t ADmess() {\r
-       ADMUX=0b10101101;\r
+double ADmess() {\r
+       ADMUX=0b10101101;  //PA2 + //PA1 - \r
        ADCSRA|=(1<<ADSC);\r
        while ((ADCSRA&(1<<ADSC)));\r
-       return ADC;\r
+       if (ADC==0) {\r
+               ADMUX=0b10001101; //PA2 - //PA1 +\r
+               ADCSRA|=(1<<ADSC);\r
+               while ((ADCSRA&(1<<ADSC)));\r
+               return -(double)ADC;\r
+       }\r
+       return (double)ADC;\r
 }\r
 \r
 volatile int16_t am2302_temp;\r
@@ -222,7 +231,7 @@ int main(void){
        ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);\r
        //DDRB|=(1<<PINB1);\r
 \r
-       uint16_t ares[16],sum;\r
+       double ares[16],sum;\r
        uint8_t par=0;\r
        ares[0]=0;//ADmess();\r
        for (par=1;par<16;par++) {\r
@@ -272,16 +281,16 @@ int main(void){
                        for(uint8_t i=0;i<16;i++) {\r
                                sum+=ares[i];\r
                        }\r
-                       V=sum/20.0/1024.0*1.12*1000.0/16.0;\r
+                       V=sum/20.0/1024.0*1.12*1000.0/16.0;//Spannung in mV\r
                        //V=sum/20.0/1024.0*1.01*1000.0/16.0;\r
-                       uint16_t htemp;\r
+                       int16_t htemp;\r
                        ktemp=gettemp_rs(V);\r
                        //htemp=(ktemp*16)/10;\r
                        htemp=(ktemp*16+temperatureC*1.6)/10;\r
 \r
-                       uint16_t w=htemp;\r
-                       uint8_t t8=w>>4;\r
-                       uint8_t af=0;\r
+                       int16_t w=htemp;\r
+                       int8_t t8=w>>4;\r
+                       int8_t af=0;\r
                        if (t8>pack1.TH) af=1;\r
                        if (t8<=pack1.TL) af=1; \r
                        cli();\r
index 0fc1554..738bf15 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.22.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.28.1" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
index 4448c39..5b3461c 100644 (file)
@@ -63,6 +63,7 @@ extern uint8_t gcontrol;
 extern uint8_t reset_indicator;\r
 extern uint8_t alarmflag;\r
 volatile uint8_t wdcounter=1;\r
+extern uint8_t cpsp;\r
 \r
 \r
 #if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
@@ -74,8 +75,7 @@ ISR(WATCHDOG_vect) {
                if (reset_indicator==1) reset_indicator++;\r
                else if (reset_indicator==2) mode=0;\r
 \r
-\r
-       }\r
+}\r
 \r
 \r
        typedef union {\r
@@ -114,11 +114,12 @@ ISR(WATCHDOG_vect) {
                        union{\r
                                uint8_t page3[8]; //25\r
                                struct {\r
+                                       uint8_t free;\r
                                        uint16_t R0;\r
                                        uint16_t VS;\r
                                        uint8_t cmode;\r
                                        int16_t ip;\r
-                                       uint8_t free;\r
+                                       \r
                                };\r
                        };\r
                        union{\r
@@ -130,7 +131,19 @@ ISR(WATCHDOG_vect) {
                                        uint16_t r_week_max;\r
                                };\r
                        };\r
-                       uint8_t page5[8];  //41\r
+                       union{\r
+                               uint8_t page5[8];  //41\r
+                               struct {\r
+                                       uint8_t codeVOC; // immer 0x37 nach Neustart\r
+                                       uint8_t days_of_r0; //Anzahl der Tage fuer die r0 ermittelt wird\r
+                                       int8_t corr_VOC_mult; //r0 corr\r
+                                       int8_t corr_VOC_div;\r
+                                       uint16_t vv3;\r
+                                       uint8_t time_corr; //Wiregate;\r
+                                       uint8_t reset_code;\r
+                               };\r
+                               uint16_t page5d[4];\r
+                       };\r
                        uint8_t page6[8];  //49\r
                        uint8_t page7[8];  //57\r
                        \r
@@ -152,7 +165,7 @@ ISR(WATCHDOG_vect) {
        volatile double l;\r
 \r
 \r
-       uint16_t weekmaxarr[8];\r
+       uint16_t weekmaxarr[33];\r
 \r
        //Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte\r
        inline double interp(double t, double h) {\r
@@ -190,11 +203,15 @@ ISR(WATCHDOG_vect) {
                \r
        }\r
 \r
+       \r
        #define EEPROM_R0 0\r
        #define EEPROM_R0d 2\r
        #define EEPROM_R0w 4\r
        #define EEPROM_dol 6\r
-\r
+       #define EEPROM_CODE_DAYOFR0 8\r
+       #define EEPROM_CORR 10\r
+       #define EEPROM_FREE 12\r
+       #define EEPROM_TCORR_RESET 14\r
 \r
        uint16_t readEEPROM(uint8_t addr,uint16_t def) {\r
                uint16_t hr;\r
@@ -254,6 +271,7 @@ ISR(WATCHDOG_vect) {
                pack1.rr00=0;\r
                pack1.rr10=0x10;\r
 \r
+               pack2.page3[0]=0xF1;\r
                pack2.cmode=0;\r
                pack2.R0=readEEPROM(EEPROM_R0,1);\r
                R0=pack2.R0/100.0;\r
@@ -262,10 +280,17 @@ ISR(WATCHDOG_vect) {
                pack2.r_week_max=readEEPROM(EEPROM_R0w,1);\r
                pack2.tol_d=readEEPROM(EEPROM_dol,0);\r
                pack2.tol_s8=0;  //Tag faengt mit Einschalten an\r
-               for(uint8_t i=0;i<7;i++) {\r
+\r
+               pack2.page5d[0]=readEEPROM(EEPROM_CODE_DAYOFR0,0x0437);\r
+               pack2.page5d[1]=readEEPROM(EEPROM_CORR,0x0101);\r
+               pack2.page5d[2]=readEEPROM(EEPROM_FREE,0x0);\r
+               pack2.page5d[3]=readEEPROM( EEPROM_TCORR_RESET,0x0005);\r
+\r
+               for(uint8_t i=0;i<pack2.days_of_r0;i++) {\r
                        weekmaxarr[i]=pack2.r_week_max;\r
                }\r
 \r
+\r
                if (testSW()) {\r
                        config_info2[5]=12;\r
                        }else{\r
@@ -279,7 +304,7 @@ ISR(WATCHDOG_vect) {
                gcontrol=1;\r
                sei();\r
                while(1)   {\r
-                       if (pack1.config==0x1F) {  //Reset R0\r
+                       /*if (pack1.config==0x1F) {  //Reset R0\r
                                pack1.config=0x7F;\r
                                R0=1;\r
                                pack2.R0=0;\r
@@ -299,6 +324,34 @@ ISR(WATCHDOG_vect) {
                                for(uint8_t i=0;i<7;i++) {\r
                                        weekmaxarr[i]=1;\r
                                }\r
+                       }*/\r
+                       if ((cpsp&0x80)!=0) {\r
+                               if ((cpsp&0x0F)==5) {\r
+                                       if (pack2.reset_code==0x01) {\r
+                                               R0=1;\r
+                                               pack2.R0=0;\r
+                                               writeEEPROM(EEPROM_R0,0);\r
+                                       } else if (pack2.reset_code==0x05) {\r
+                                               pack2.r_day_max=1;\r
+                                               pack2.r_week_max=1;\r
+                                               pack2.tol_d=0;\r
+                                               pack2.tol_s8=0;  //Tag faengt mit Einschalten an\r
+                                               R0=1;\r
+                                               writeEEPROM(EEPROM_R0,0xFF);\r
+                                               writeEEPROM(EEPROM_R0d,0xFF);  //Maximum des Tages\r
+                                               writeEEPROM(EEPROM_R0w,0xFF); //Maximum der Letzten 7 Tage\r
+                                               writeEEPROM(EEPROM_dol,0xFF); //Anzahl der Betriebstage\r
+                                               for(uint8_t i=0;i<7;i++) {\r
+                                                       weekmaxarr[i]=1;\r
+                                               }\r
+                                       } else {\r
+                                               writeEEPROM(EEPROM_CODE_DAYOFR0,0x0037|(pack2.days_of_r0<<8));\r
+                                               writeEEPROM(EEPROM_CORR,pack2.page5d[1]);\r
+                                               writeEEPROM(EEPROM_FREE,pack2.page5d[2]);\r
+                                               writeEEPROM(EEPROM_TCORR_RESET,pack2.time_corr);\r
+                                       }\r
+                               }\r
+                               cpsp=0;\r
                        }\r
                        if (wdcounter>0) {  //8s\r
                                pack2.tol_s8++;\r
@@ -306,8 +359,8 @@ ISR(WATCHDOG_vect) {
                                        pack2.tol_s8=0;\r
                                        pack2.tol_d++;  //rund 180 Jahre :-)\r
                                        pack2.r_week_max=0;\r
-                                       weekmaxarr[7]=pack2.r_day_max;\r
-                                       for(uint8_t i=0;i<7;i++) {\r
+                                       weekmaxarr[pack2.days_of_r0]=pack2.r_day_max;\r
+                                       for(uint8_t i=0;i<pack2.days_of_r0;i++) {\r
                                                weekmaxarr[i]=weekmaxarr[i+1];\r
                                                //maximum of week\r
                                                if (weekmaxarr[i]>pack2.r_week_max) pack2.r_week_max=weekmaxarr[i];\r
@@ -330,8 +383,10 @@ ISR(WATCHDOG_vect) {
                                getSHT2xHumTemp(&temperatureC,&humidityRH);\r
                                ip=interp(temperatureC,humidityRH);\r
                                pack2.ip=ip*1000;\r
-                               double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
-                               double TC =temperatureC *10.0-2;\r
+                               //double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
+                               //double TC =temperatureC *10.0-2;\r
+                               double RH=humidityRH*10.0;\r
+                               double TC=temperatureC*10.0;\r
 \r
 \r
                                if (testSW()) {\r
@@ -387,9 +442,17 @@ ISR(WATCHDOG_vect) {
                                                pack2.r_day_max=l*100;\r
                                        }\r
                                } else if (l<R0) l=R0; //negative Werte am Anfang verhintern\r
-                               l=exp((1-(l/R0))*6.05)-1;// exp((1-($val)/55)*5.75);  (5.75 geht über 125 6.05 geht bis 240... mittlere Linie im Datenblatt)\r
-                               l=l*8.0; //fuer DS18B20*/\r
+                               //l=exp((1-(l/R0))*6.05)-1;// exp((1-($val)/55)*5.75);  (5.75 geht über 125 6.05 geht bis 240... mittlere Linie im Datenblatt)\r
+                               //l=pow(R0/l,1.8)*3-3; \r
+                               if (l!=0) {\r
+                                       l=R0/l;\r
+                                       //l=l*l*12-12;\r
+                                       l=exp((1-(1/l))*6.05)-1;\r
+                                       l=l*(double)pack2.corr_VOC_mult/(double)pack2.corr_VOC_div;\r
+                                       l=l*8.0; //fuer DS18B20*/\r
+                               }       \r
                                wdcounter=0;\r
+\r
                                \r
                        }\r
                        \r
index 3726641..09b528d 100644 (file)
@@ -62,6 +62,7 @@ extern uint8_t mode;
 extern uint8_t gcontrol;\r
 extern uint8_t reset_indicator;\r
 extern uint8_t alarmflag;\r
+extern uint8_t cpsp;\r
 volatile uint8_t wdcounter=1;\r
 \r
 \r
@@ -108,8 +109,7 @@ typedef union {
                uint8_t threshold; //8\r
                \r
                uint8_t page1[8]; //9\r
-               #if  defined(__AVR_ATtiny25__)\r
-               #else\r
+               \r
                uint8_t page2[8]; //17\r
                union{ \r
                        uint8_t page3[8]; //25\r
@@ -130,11 +130,22 @@ typedef union {
                                uint16_t r_week_max;\r
                        };\r
                };\r
-               uint8_t page5[8];  //41\r
-               uint8_t page6[8];  //49\r
+               union{\r
+                       uint8_t page5[8];  //41\r
+                       struct {\r
+                               uint8_t codeVOC; // immer 0x37 nach Neustart\r
+                               uint8_t days_of_r0; //Anzahl der Tage fuer die r0 ermittelt wird\r
+                               int8_t corr_VOC_mult; //r0 corr\r
+                               int8_t corr_VOC_div;\r
+                               uint16_t vv3;\r
+                               uint8_t time_corr; //Wiregate;\r
+                               uint8_t reset_code;\r
+                       };\r
+                       uint16_t page5d[4];\r
+               };\r
+                       uint8_t page6[8];  //49\r
                uint8_t page7[8];  //57\r
                \r
-               #endif\r
        };\r
 } pack2_t;\r
 volatile pack2_t pack2;\r
@@ -157,7 +168,7 @@ uint8_t max_adr=0;
 #define CH0_CH1 MAX1164x_C_SCAN0\r
 //|MAX1164x_C_CS0\r
 \r
-uint16_t weekmaxarr[8];\r
+uint16_t weekmaxarr[33];\r
 \r
 //Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte\r
 inline double interp(double t, double h) {\r
@@ -199,6 +210,12 @@ int testSW(void) {
 #define EEPROM_R0w 4\r
 #define EEPROM_dol 6\r
 \r
+#define EEPROM_CODE_DAYOFR0 8\r
+#define EEPROM_CORR 10\r
+#define EEPROM_FREE 12\r
+#define EEPROM_TCORR_RESET 14\r
+\r
+\r
 \r
 uint16_t readEEPROM(uint8_t addr,uint16_t def) {\r
        uint16_t hr;\r
@@ -264,15 +281,20 @@ int main(void){
        pack2.r_week_max=readEEPROM(EEPROM_R0w,1);\r
        pack2.tol_d=readEEPROM(EEPROM_dol,0); \r
        pack2.tol_s8=0;  //Tag faengt mit Einschalten an\r
-       for(uint8_t i=0;i<7;i++) {\r
+       for(uint8_t i=0;i<32;i++) {\r
                weekmaxarr[i]=pack2.r_week_max;\r
        }\r
 \r
+       pack2.page5d[0]=readEEPROM(EEPROM_CODE_DAYOFR0,0x0437);\r
+       pack2.page5d[1]=readEEPROM(EEPROM_CORR,0x0101);\r
+       pack2.page5d[2]=readEEPROM(EEPROM_FREE,0x0);\r
+       pack2.page5d[3]=readEEPROM( EEPROM_TCORR_RESET,0x0005);\r
        if (testSW()) {\r
                config_info2[5]=12;\r
        }else{\r
                config_info2[5]=7;\r
        }\r
+       \r
 \r
        USI_TWI_Master_Initialise();\r
        \r
@@ -285,46 +307,64 @@ int main(void){
        sei();\r
        //DDRB|=(1<<PINB1);\r
     while(1)   {\r
-               if (pack1.config==0x1F) {  //Reset R0\r
+               if ((cpsp&0x80)!=0) {\r
+                       if ((cpsp&0x0F)==5) {\r
+                               if (pack2.reset_code==0x01) {\r
+                                       pack1.config=0x7F;\r
+                                       R0=1;\r
+                                       pack2.R0=0;\r
+                                       writeEEPROM(EEPROM_R0,0);\r
+                               } else if (pack2.reset_code==0x05) {\r
+                                       pack1.config=0x7F;\r
+                                       pack2.r_day_max=1;\r
+                                       pack2.r_week_max=1;\r
+                                       pack2.tol_d=0;\r
+                                       pack2.tol_s8=0;  //Tag faengt mit Einschalten an\r
+                                       R0=1;\r
+                                       writeEEPROM(EEPROM_R0,0xFF);\r
+                                       writeEEPROM(EEPROM_R0d,0xFF);  //Maximum des Tages\r
+                                       writeEEPROM(EEPROM_R0w,0xFF); //Maximum der Letzten 7 Tage\r
+                                       writeEEPROM(EEPROM_dol,0xFF); //Anzahl der Betriebstage\r
+                                       for(uint8_t i=0;i<pack2.days_of_r0;i++) {\r
+                                               weekmaxarr[i]=1;\r
+                                       }\r
+\r
+                               } else {\r
+                                       writeEEPROM(EEPROM_CODE_DAYOFR0,0x0037|(pack2.days_of_r0<<8));\r
+                                       writeEEPROM(EEPROM_CORR,pack2.page5d[1]);\r
+                                       writeEEPROM(EEPROM_FREE,pack2.page5d[2]);\r
+                                       writeEEPROM(EEPROM_TCORR_RESET,pack2.time_corr);\r
+                               }\r
+                       }\r
+                       cpsp=0;\r
+               }\r
+               /*if (pack1.config==0x1F) {  //Reset R0\r
                        pack1.config=0x7F;\r
                        R0=1;\r
                        pack2.R0=0;\r
                        writeEEPROM(EEPROM_R0,0);\r
                } \r
                if (pack1.config==0x05) {  //Reset all Data\r
-                       pack1.config=0x7F;                              \r
-                       pack2.r_day_max=1;\r
-                       pack2.r_week_max=1;\r
-                       pack2.tol_d=0;\r
-                       pack2.tol_s8=0;  //Tag faengt mit Einschalten an        \r
-                       R0=1;   \r
-                       writeEEPROM(EEPROM_R0,0xFF);\r
-                       writeEEPROM(EEPROM_R0d,0xFF);  //Maximum des Tages\r
-                       writeEEPROM(EEPROM_R0w,0xFF); //Maximum der Letzten 7 Tage\r
-                       writeEEPROM(EEPROM_dol,0xFF); //Anzahl der Betriebstage         \r
-                       for(uint8_t i=0;i<7;i++) {\r
-                               weekmaxarr[i]=1;\r
-                       }                               \r
-               } \r
+               } */\r
                if (wdcounter>0) {  //8s\r
                        pack2.tol_s8++;\r
                        if (pack2.tol_s8>(10000))  {//10800 ist theortisch der Tag aber meistens zu lang\r
                                pack2.tol_s8=0;\r
                                pack2.tol_d++;  //rund 180 Jahre :-)\r
                                pack2.r_week_max=0;\r
-                               weekmaxarr[7]=pack2.r_day_max;\r
-                               for(uint8_t i=0;i<7;i++) {\r
+                               weekmaxarr[pack2.days_of_r0]=pack2.r_day_max;\r
+                               for(uint8_t i=0;i<pack2.days_of_r0;i++) {\r
                                        weekmaxarr[i]=weekmaxarr[i+1];\r
                                        //maximum of week\r
                                        if (weekmaxarr[i]>pack2.r_week_max) pack2.r_week_max=weekmaxarr[i];\r
                                }\r
-                               if (pack2.tol_d>7) {\r
+                               if (pack2.tol_d>pack2.days_of_r0) {\r
                                        pack2.R0=pack2.r_week_max;\r
                                } else {\r
                                        pack2.R0=pack2.r_day_max;\r
                                }\r
                                //R0=//R0-0.5*(pack2.R0/100-R0);\r
-                               R0=R0-(R0-pack2.R0/100.0)*0.5   ;\r
+                               R0=pack2.R0/100.0;\r
                                pack2.R0=R0*100;\r
                                writeEEPROM(EEPROM_R0,pack2.R0);\r
                                writeEEPROM(EEPROM_R0d,pack2.r_day_max);  //Maximum des Tages\r
@@ -401,9 +441,17 @@ int main(void){
                                        pack2.r_day_max=l*100;\r
                                }\r
                        } else if (l<R0) l=R0; //negative Werte am Anfang verhintern\r
-                       l=exp((1-(l/R0))*6.05)-1;// exp((1-($val)/55)*5.75);  (5.75 geht über 125 6.05 geht bis 240... mittlere Linie im Datenblatt)\r
-                       //l=(l/R0*100.0);\r
-                       l=l*8; //fuer DS18B20\r
+                       //l=exp((1-(l/R0))*6.05)-1;// exp((1-($val)/55)*5.75);  (5.75 geht über 125 6.05 geht bis 240... mittlere Linie im Datenblatt)\r
+                       //l=l*(double)pack2.corr_VOC_mult/(double)pack2.corr_VOC_div;\r
+                       //l=pow(R0/l,1.8)*3-3;\r
+                       if (l!=0) {\r
+                               l=R0/l;\r
+                               l=l*l*12-12;\r
+                               l=l*(double)pack2.corr_VOC_mult/(double)pack2.corr_VOC_div;\r
+                               l=l*8.0; //fuer DS18B20*/\r
+                       }\r
+\r
+                       //l=(l/R0*100.0); \r
                        wdcounter=0;\r
                        \r
                }\r
index a8708ea..dc1e00d 100644 (file)
@@ -7,9 +7,9 @@
 
 MCU = attiny84
 FORMAT = ihex
-TARGET =DS2423_DS2423
-SRC = DS2423_DS2423.c
-ASRC = ../common/OWDS2423_DS2423.S
+TARGET =DS2423_DS2413
+SRC = DS2423_DS2413.c
+ASRC = ../common/OWDS2423_DS2413.S
 
 # Name of this Makefile (used for "make depend").
 MAKEFILE = Makefile
index 5fc62de..bcc5eb3 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.28.1" />\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.28.1" />\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.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>__4MHZ__</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
     </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.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
+      <Value>__4MHZ__</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
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
       <SubType>compile</SubType>\r
       <Link>calibr.c</Link>\r
     </Compile>\r
-    <Compile Include="..\common\I2C\SHT3X.c">\r
+    <Compile Include="..\common\I2C\SHT3x.c">\r
       <SubType>compile</SubType>\r
-      <Link>SHT3X.c</Link>\r
+      <Link>SHT3x.c</Link>\r
     </Compile>\r
     <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
       <SubType>compile</SubType>\r
index 00a58ef..05b8a28 100644 (file)
@@ -63,6 +63,7 @@ extern uint8_t gcontrol;
 extern uint8_t reset_indicator;\r
 extern uint8_t alarmflag;\r
 volatile uint8_t wdcounter=1;\r
+extern uint8_t cpsp2;\r
 \r
 \r
 typedef union {\r
@@ -125,23 +126,50 @@ typedef union {
                uint8_t threshold; //8\r
                \r
                uint8_t page1[8]; //9\r
-               #if  defined(__AVR_ATtiny25__)\r
-               #else\r
+               \r
                uint8_t page2[8]; //17\r
                uint8_t page3[8]; //25\r
                \r
-               uint8_t page4[8];  //33\r
-               uint8_t page5[8];  //41\r
-               uint8_t page6[8];  //49\r
+               union{\r
+                       uint8_t page4[8];  //33\r
+                       struct {\r
+                               uint16_t tol_s8;\r
+                               uint16_t tol_d;\r
+                               uint16_t r_day_max;\r
+                               uint16_t r_week_max;\r
+                       };\r
+               };\r
+               union{\r
+                       uint8_t page5[8];  //41\r
+                       struct {\r
+                               uint8_t codeVOC; // immer 0x37 nach Neustart\r
+                               uint8_t days_of_r0; //Anzahl der Tage fuer die r0 ermittelt wird\r
+                               int8_t corr_VOC_mult; //r0 corr\r
+                               int8_t corr_VOC_div;\r
+                               uint16_t vv3;\r
+                               uint8_t time_corr; //Wiregate;\r
+                               uint8_t reset_code;\r
+                       };\r
+                       uint16_t page5d[4];\r
+               };\r
+               union{\r
+                       uint8_t page6[8]; //25\r
+                       struct {\r
+                               uint16_t R0;\r
+                               uint16_t VS;\r
+                               uint8_t cmode;\r
+                               int16_t ip;\r
+                               uint8_t free;\r
+                       };\r
+               };\r
                uint8_t page7[8];  //57\r
                \r
-               #endif\r
        };\r
 } pack2_t;\r
 volatile pack2_t pack2;\r
 \r
-#define TIME_CORR 5\r
-volatile int8_t time_corr_count=TIME_CORR;\r
+//#define TIME_CORR 3\r
+volatile int8_t time_corr_count;//=TIME_CORR;\r
 \r
 #if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
 ISR(WATCHDOG_vect) {\r
@@ -156,7 +184,7 @@ ISR(WATCHDOG_vect) {
                        if (time_corr_count<=0) {\r
                                //wdcounter++;\r
                                pack1.etm+=1;\r
-                               time_corr_count=TIME_CORR;\r
+                               time_corr_count=pack2.time_corr;\r
                        }\r
        /*      if ((pack1.page1[0]&0x0F)==0) {\r
                         pack1.etm+=2;\r
@@ -174,15 +202,6 @@ ISR(WATCHDOG_vect) {
 \r
 \r
 \r
-uint16_t pR0;\r
-uint16_t pVS;\r
-uint8_t pcmode;\r
-int16_t pip;\r
-\r
-uint16_t ptol_s8;\r
-uint16_t ptol_d;\r
-uint16_t pr_day_max;\r
-uint16_t pr_week_max;\r
 \r
 \r
 volatile int16_t DS2438_1_TEMP;\r
@@ -202,7 +221,7 @@ uint8_t max_adr=0;
 #define CH0_CH1 MAX1164x_C_SCAN0\r
 //|MAX1164x_C_CS0\r
 \r
-uint16_t weekmaxarr[8];\r
+uint16_t weekmaxarr[33];\r
 \r
 //Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte\r
 inline double interp(double t, double h) {\r
@@ -243,6 +262,10 @@ int testSW(void) {
 #define EEPROM_R0d 2\r
 #define EEPROM_R0w 4\r
 #define EEPROM_dol 6\r
+#define EEPROM_CODE_DAYOFR0 8\r
+#define EEPROM_CORR 10\r
+#define EEPROM_FREE 12\r
+#define EEPROM_TCORR_RESET 14\r
 \r
 \r
 uint16_t readEEPROM(uint8_t addr,uint16_t def) {\r
@@ -295,18 +318,25 @@ int main(void){
 \r
        pack1.temp=0x0550;\r
        pack2.page3[0]=0xF1;\r
-       pcmode=0;\r
-       pR0=readEEPROM(EEPROM_R0,1);\r
-       R0=pR0/100.0;\r
+       pack2.cmode=0;\r
+       pack2.R0=readEEPROM(EEPROM_R0,1);\r
+       R0=pack2.R0/100.0;\r
                \r
-       pr_day_max=readEEPROM(EEPROM_R0d,1);\r
-       pr_week_max=readEEPROM(EEPROM_R0w,1);\r
-       ptol_d=readEEPROM(EEPROM_dol,0); \r
-       ptol_s8=0;  //Tag faengt mit Einschalten an\r
-       for(uint8_t i=0;i<7;i++) {\r
-               weekmaxarr[i]=pr_week_max;\r
-       }\r
+       pack2.r_day_max=readEEPROM(EEPROM_R0d,1);\r
+       pack2.r_week_max=readEEPROM(EEPROM_R0w,1);\r
+       pack2.tol_d=readEEPROM(EEPROM_dol,0); \r
+       pack2.tol_s8=0;  //Tag faengt mit Einschalten an\r
+       \r
 \r
+       pack2.page5d[0]=readEEPROM(EEPROM_CODE_DAYOFR0,0x0437);\r
+       pack2.page5d[1]=readEEPROM(EEPROM_CORR,0x0101);\r
+       pack2.page5d[2]=readEEPROM(EEPROM_FREE,0x0);\r
+       pack2.page5d[3]=readEEPROM( EEPROM_TCORR_RESET,0x0005);\r
+       time_corr_count=pack2.time_corr;\r
+\r
+       for(uint8_t i=0;i<pack2.days_of_r0;i++) {\r
+               weekmaxarr[i]=pack2.r_week_max;\r
+       }\r
        if (testSW()) {\r
                config_info2[5]=12;\r
        }else{\r
@@ -323,60 +353,69 @@ int main(void){
        sei();\r
        //DDRB|=(1<<PINB1);\r
     while(1)   {\r
-/*             if (pack1.config==0x1F) {  //Reset R0\r
-                       pack1.config=0x7F;\r
-                       R0=1;\r
-                       pR0=0;\r
-                       writeEEPROM(EEPROM_R0,0);\r
-               } \r
-               if (pack1.config==0x05) {  //Reset all Data\r
-                       pack1.config=0x7F;                              \r
-                       pr_day_max=1;\r
-                       pr_week_max=1;\r
-                       ptol_d=0;\r
-                       ptol_s8=0;  //Tag faengt mit Einschalten an     \r
-                       R0=1;   \r
-                       writeEEPROM(EEPROM_R0,0xFF);\r
-                       writeEEPROM(EEPROM_R0d,0xFF);  //Maximum des Tages\r
-                       writeEEPROM(EEPROM_R0w,0xFF); //Maximum der Letzten 7 Tage\r
-                       writeEEPROM(EEPROM_dol,0xFF); //Anzahl der Betriebstage         \r
-                       for(uint8_t i=0;i<7;i++) {\r
-                               weekmaxarr[i]=1;\r
-                       }                               \r
-               } */\r
+                       if ((cpsp2&0x80)!=0) {\r
+                               if ((cpsp2&0x0F)==5) {\r
+                                       if (pack2.reset_code==0x01) {\r
+                                               R0=1;\r
+                                               pack2.R0=0;\r
+                                               writeEEPROM(EEPROM_R0,0);\r
+                                       } else if (pack2.reset_code==0x05) {\r
+                                               pack2.r_day_max=1;\r
+                                               pack2.r_week_max=1;\r
+                                               pack2.tol_d=0;\r
+                                               pack2.tol_s8=0;  //Tag faengt mit Einschalten an\r
+                                               R0=1;\r
+                                               writeEEPROM(EEPROM_R0,0xFF);\r
+                                               writeEEPROM(EEPROM_R0d,0xFF);  //Maximum des Tages\r
+                                               writeEEPROM(EEPROM_R0w,0xFF); //Maximum der Letzten 7 Tage\r
+                                               writeEEPROM(EEPROM_dol,0xFF); //Anzahl der Betriebstage\r
+                                               for(uint8_t i=0;i<7;i++) {\r
+                                                       weekmaxarr[i]=1;\r
+                                               }\r
+\r
+                                       } else {\r
+                                               writeEEPROM(EEPROM_CODE_DAYOFR0,0x0037|(pack2.days_of_r0<<8));\r
+                                               writeEEPROM(EEPROM_CORR,pack2.page5d[1]);\r
+                                               writeEEPROM(EEPROM_FREE,pack2.page5d[2]);\r
+                                               writeEEPROM(EEPROM_TCORR_RESET,pack2.time_corr);\r
+                                       }\r
+                               }\r
+                               cpsp2=0;\r
+               }\r
                if (wdcounter>0) {  //8s\r
-                       ptol_s8++;\r
+                       pack2.tol_s8++;\r
                        \r
                        //pack1.dis+=8;\r
                        //pack1.eoc+=8;\r
-                       if (ptol_s8>(10000))  {//10800 ist theortisch der Tag aber meistens zu lang\r
-                               ptol_s8=0;\r
-                               ptol_d++;  //rund 180 Jahre :-)\r
-                               pr_week_max=0;\r
-                               weekmaxarr[7]=pr_day_max;\r
-                               for(uint8_t i=0;i<7;i++) {\r
+                       if (pack2.tol_s8>(10000))  {//10800 ist theortisch der Tag aber meistens zu lang\r
+                               pack2.tol_s8=0;\r
+                               pack2.tol_d++;  //rund 180 Jahre :-)\r
+                               pack2.r_week_max=0;\r
+                               weekmaxarr[pack2.days_of_r0]=pack2.r_day_max;\r
+                               for(uint8_t i=0;i<pack2.days_of_r0;i++) {\r
                                        weekmaxarr[i]=weekmaxarr[i+1];\r
                                        //maximum of week\r
-                                       if (weekmaxarr[i]>pr_week_max) pr_week_max=weekmaxarr[i];\r
+                                       if (weekmaxarr[i]>pack2.r_week_max) pack2.r_week_max=weekmaxarr[i];\r
                                }\r
-                               if (ptol_d>7) {\r
-                                       pR0=pr_week_max;\r
+                               if (pack2.tol_d>pack2.days_of_r0) {\r
+                                       pack2.R0=pack2.r_week_max;\r
                                } else {\r
-                                       pR0=pr_day_max;\r
+                                       pack2.R0=pack2.r_day_max;\r
                                }\r
                                //R0=//R0-0.5*(pack2.R0/100-R0);\r
-                               R0=R0-(R0-pR0/100.0)*0.5        ;\r
-                               pR0=R0*100;\r
-                               writeEEPROM(EEPROM_R0,pR0);\r
-                               writeEEPROM(EEPROM_R0d,pr_day_max);  //Maximum des Tages\r
-                               writeEEPROM(EEPROM_R0w,pr_week_max); //Maximum der Letzten 7 Tage\r
-                               writeEEPROM(EEPROM_dol,ptol_d); //Anzahl der Betriebstage\r
-                               pr_day_max=0;\r
+                               //R0=R0-(R0-pack2.R0/100.0)*0.5 ;\r
+                               R0=pack2.R0/100.0;\r
+                               pack2.R0=R0*100;\r
+                               writeEEPROM(EEPROM_R0,pack2.R0);\r
+                               writeEEPROM(EEPROM_R0d,pack2.r_day_max);  //Maximum des Tages\r
+                               writeEEPROM(EEPROM_R0w,pack2.r_week_max); //Maximum der Letzten 7 Tage\r
+                               writeEEPROM(EEPROM_dol,pack2.tol_d); //Anzahl der Betriebstage\r
+                               pack2.r_day_max=0;\r
                        }\r
                        if (startup!=0) startup--;\r
                        getSHT2xHumTemp(&temperatureC,&humidityRH);\r
                        ip=interp(temperatureC,humidityRH);\r
-                       pip=ip*1000;\r
+                       pack2.ip=ip*1000;\r
                        double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
                        double TC =temperatureC *10.0-2;\r
 \r
@@ -406,27 +445,27 @@ int main(void){
                        //l=mr/2.0*2.048/4096; \r
                        // l maximal 2  mr max 4096  //mr 2V=8000 \r
                        \r
-                       if (pcmode) { //cmode=0 V 0..2 V cmode=1 V 1.5..3.5V\r
+                       if (pack2.cmode) { //cmode=0 V 0..2 V cmode=1 V 1.5..3.5V\r
                                //l+=1.5; //Spannung real\r
                                mr+=6000;\r
                        } \r
                        //if (l>1.8) {\r
                        if (mr>7200) {                          \r
-                               if (pcmode==0) {\r
+                               if (pack2.cmode==0) {\r
                                        MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_CH1);\r
-                                       pcmode=1;\r
+                                       pack2.cmode=1;\r
                                }\r
                        }\r
                        //if (l<1.6) {\r
                        if (mr<6400) {  \r
-                               if (pcmode==1) {\r
+                               if (pack2.cmode==1) {\r
                                        MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M);\r
-                                       pcmode=0;\r
+                                       pack2.cmode=0;\r
                                }\r
                                \r
                                \r
                        }\r
-                       pVS=mr*5/2;\r
+                       pack2.VS=mr*5/2;\r
                        l=mr/4000.0;\r
                        l=( 3/l- 1) *30;\r
                        pack2.current=l*100;\r
@@ -436,17 +475,18 @@ int main(void){
                        if (startup==0){\r
                                if (l>R0) {\r
                                        R0=l;\r
-                                       pR0=R0*100;\r
-                                       writeEEPROM(EEPROM_R0,pR0);\r
+                                       pack2.R0=R0*100;\r
+                                       writeEEPROM(EEPROM_R0,pack2.R0);\r
 \r
                                }\r
-                               if (l*100>pr_day_max) {\r
-                                       pr_day_max=l*100;\r
+                               if (l*100>pack2.r_day_max) {\r
+                                       pack2.r_day_max=l*100;\r
                                }\r
                        } else if (l<R0) l=R0; //negative Werte am Anfang verhintern\r
                        l=exp((1-(l/R0))*6.05)-1;// exp((1-($val)/55)*5.75);  (5.75 geht über 125 6.05 geht bis 240... mittlere Linie im Datenblatt)\r
                        //l=(l/R0*100.0);\r
                        l=l*0.5*35; //fuer DS2438\r
+                       l=l*(double)pack2.corr_VOC_mult/(double)pack2.corr_VOC_div;\r
                        if (l==0) l=1;\r
                        gcontrol=1;\r
                        wdcounter=0;\r
index 945ebeb..e2fb6c3 100644 (file)
@@ -125,11 +125,16 @@ int main(void){
        pack.HD=0xFF;\r
        pack.LD=0x00;\r
        pack.VCCP=0;\r
+\r
+       PORTA=0xFF;\r
+       PORTB=0xFF;\r
+\r
        OWINIT();\r
 \r
        MCUCR &=~(1<<PUD); //All Pins Pullup...\r
        MCUCR |=(1<<BODS);\r
-       PORTA&=~((1<<PINA0)|(1<<PINA1)|(1<<PINA2)|(1<<PINA3));\r
+       //PORTA&=~((1<<PINA0)|(1<<PINA1)|(1<<PINA2)|(1<<PINA3));\r
+\r
        ADCSRA=(1<<ADEN)|(1<ADPS0)|(1<<ADPS2);\r
 \r
        \r
index f29fdfd..5eb8631 100644 (file)
     <ExternalProgrammingToolCommand />\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.28.1" />\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.28.1" />\r
+        </dependencies>\r
+      </framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool />\r
   </PropertyGroup>\r
index 1d81abd..61a1dad 100644 (file)
@@ -1,5 +1,5 @@
 \r
-// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de\r
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
 // All rights reserved. \r
 // \r
 // Redistribution and use in source and binary forms, with or without \r
@@ -33,6 +33,7 @@
 \r
 #define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
+#define  __4MHZ__\r
 \r
 #include "../common/OWConfig.s"\r
 #include "../common/OWCRC16.s"\r
diff --git a/DS2450_APDS9960/DS2450_APDS9960.atsln b/DS2450_APDS9960/DS2450_APDS9960.atsln
new file mode 100644 (file)
index 0000000..06d2247
--- /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_APDS9960", "DS2450_APDS9960.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_APDS9960/DS2450_APDS9960.c b/DS2450_APDS9960/DS2450_APDS9960.c
new file mode 100644 (file)
index 0000000..4ded72e
--- /dev/null
@@ -0,0 +1,283 @@
+
+// Copyright (c) 2017, 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/APDS9960.h"
+
+extern void OWINIT();
+extern void EXTERN_SLEEP();
+
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x23, 0x20};/**/
+//uint8_t config_info[26]={0x03,13,0x03,13,0x03,13,0x3,15,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+uint8_t config_info[26]={16,15,17,15,18,15,3,15,0x02,23,23,23,23,0x00,0x00,0x00,0x00,0x00,0x00,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;
+
+
+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;
+
+
+uint16_t light[4];
+double rlight[4];
+uint8_t gain=2;
+uint8_t atime=192;
+//uint8_t atime=255;
+double r_gain;
+double r_atime;
+
+void getLight(uint8_t setparameterr) {
+       if (setparameterr) {
+               r_gain=(1<<(2*gain));
+               r_atime=(256.0-atime)*2.78;
+               APDS9960setGain(gain);
+               APDS9960setATime(atime);
+               _delay_ms(700);
+       }
+       APDS9960getRGBC(&light[0],&light[1],&light[2],&light[3]);
+}
+
+
+
+
+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;
+
+       PORTA=0xFF;
+       PORTB=0xFF;
+
+       OWINIT();
+
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+       MCUCR |=(1<<BODS);
+       //PORTA&=~((1<<PINA0)|(1<<PINA1)|(1<<PINA2)|(1<<PINA3));
+
+       ADCSRA=(1<<ADEN)|(1<ADPS0)|(1<<ADPS2);
+
+       
+       
+       gcontrol=1;
+       ADCSRB|=(1<<ADLAR); 
+       USI_TWI_Master_Initialise();
+       
+       initAPDS9960();
+       //gain=2;
+       //atime=253;
+       getLight(1);
+       sei();
+       
+       //DDRB|=(1<<PINB1);
+
+    while(1)   {
+
+
+               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) {
+                               getLight(0);
+                               while (light[3]>0xF000) {
+                               //while (light[3]>900) {
+                                       if (gain!=0) {
+                                               gain--;
+                                               getLight(1);
+                                       }  else break;
+                               } 
+                               if (light[3]<0x2222) {
+                               //if (light[3]<0x22) {
+                                       if (gain<3) {
+                                               gain++;
+                                               getLight(1);
+                                       }
+
+                               }
+                               for(uint8_t i=0;i<4;i++) {
+                                       rlight[i]=(double)light[i]/r_atime/r_gain*70.0;
+                                       rlight[i]=(log(rlight[i])*1000)+32767.0;
+                               }
+                               cli();pack.A=rlight[0];sei();
+                               //cli();pack.A=r_gain;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=rlight[1];sei();
+                               //cli();pack.B=atime;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=rlight[2];sei();
+                               //cli();pack.C=light[3];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=rlight[3];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_APDS9960/DS2450_APDS9960.cproj b/DS2450_APDS9960/DS2450_APDS9960.cproj
new file mode 100644 (file)
index 0000000..43e905b
--- /dev/null
@@ -0,0 +1,152 @@
+<?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_APDS9960</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>
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>
+    <com_atmel_avrdbg_tool_atmelice>
+      <ToolOptions>
+        <InterfaceProperties>
+        </InterfaceProperties>
+        <InterfaceName>debugWIRE</InterfaceName>
+      </ToolOptions>
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
+      <ToolNumber>J41800000789</ToolNumber>
+      <ToolName>Atmel-ICE</ToolName>
+    </com_atmel_avrdbg_tool_atmelice>
+    <avrtoolinterface>debugWIRE</avrtoolinterface>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <ToolchainSettings>
+      <AvrGcc>
+        <avrgcc.common.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>NDEBUG</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 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.assembler.general.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>
+          </ListValues>
+        </avrgcc.assembler.general.IncludePaths>
+      </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\I2C\APDS9960.c">
+      <SubType>compile</SubType>
+      <Link>APDS9960.c</Link>
+    </Compile>
+    <Compile Include="..\common\I2C\USI_TWI_Master.c">
+      <SubType>compile</SubType>
+      <Link>USI_TWI_Master.c</Link>
+    </Compile>
+    <Compile Include="DS2450_APDS9960.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_IAQCORE/DS2450_IAQCORE.atsln b/DS2450_IAQCORE/DS2450_IAQCORE.atsln
new file mode 100644 (file)
index 0000000..cd34225
--- /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_IAQCORE", "DS2450_IAQCORE.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_IAQCORE/DS2450_IAQCORE.c b/DS2450_IAQCORE/DS2450_IAQCORE.c
new file mode 100644 (file)
index 0000000..cee219c
--- /dev/null
@@ -0,0 +1,232 @@
+
+// Copyright (c) 2017, 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/IAQCORE.h"
+
+extern void OWINIT();
+extern void EXTERN_SLEEP();
+
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/
+uint8_t config_info[26]={0x06,13,0x06,13,0x06,13,0x06,13,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,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;
+
+
+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;
+
+
+
+IAQCORE_Data_t IAQCORE_Data;
+
+
+int main(void){
+       pack.A=0;
+       pack.B=0;
+       pack.C=0;
+       pack.D=0;
+       pack.CSA1=0x08;
+       pack.CSA2=0x8C;
+       pack.CSB1=0x08;
+       pack.CSB2=0x8C;
+       pack.CSC1=0x08;
+       pack.CSC2=0x8C;
+       pack.CSD1=0x08;
+       pack.CSD2=0x8C;
+       pack.HA=0xFF;
+       pack.LA=0x00;
+       pack.HB=0xFF;
+       pack.LB=0x00;
+       pack.HC=0xFF;
+       pack.LC=0x00;
+       pack.HD=0xFF;
+       pack.LD=0x00;
+       pack.VCCP=0;
+       OWINIT();
+
+       MCUCR &=~(1<<PUD); //All Pins Pullup...
+       MCUCR |=(1<<BODS);
+       PORTA&=~((1<<PINA0)|(1<<PINA1)|(1<<PINA2)|(1<<PINA3));
+       ADCSRA=(1<<ADEN)|(1<ADPS0)|(1<<ADPS2);
+
+       
+       
+       gcontrol=1;
+       USI_TWI_Master_Initialise();
+       ADCSRB|=(1<<ADLAR); 
+       sei();
+       
+       //DDRB|=(1<<PINB1);
+
+    while(1)   {
+
+
+               if (gcontrol) {
+                       readIAQCORE(&IAQCORE_Data);
+                       //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=IAQCORE_Data.CO2;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=IAQCORE_Data.TVOC;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=IAQCORE_Data.resistance/1000;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=IAQCORE_Data.state;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_IAQCORE/DS2450_IAQCORE.cproj b/DS2450_IAQCORE/DS2450_IAQCORE.cproj
new file mode 100644 (file)
index 0000000..5bb475f
--- /dev/null
@@ -0,0 +1,139 @@
+<?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_IAQCORE</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>
+        <options />
+        <configurations />
+        <files />
+        <documentation help="" />
+        <offline-documentation help="" />
+        <dependencies>
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />
+        </dependencies>
+      </framework-data>
+    </AsfFrameworkConfig>
+    <avrtool />
+  </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>NDEBUG</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 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.assembler.general.IncludePaths>
+          <ListValues>
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>
+          </ListValues>
+        </avrgcc.assembler.general.IncludePaths>
+      </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\I2C\IAQCORE.c">
+      <SubType>compile</SubType>
+      <Link>IAQCORE.c</Link>
+    </Compile>
+    <Compile Include="..\common\I2C\USI_TWI_Master.c">
+      <SubType>compile</SubType>
+      <Link>USI_TWI_Master.c</Link>
+    </Compile>
+    <Compile Include="DS2450_IAQCORE.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/common/I2C/APDS9960.c b/common/I2C/APDS9960.c
new file mode 100644 (file)
index 0000000..92df22e
--- /dev/null
@@ -0,0 +1,138 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#define F_CPU 8000000UL
+#include <avr/io.h>
+
+#include <util/delay.h>
+
+
+#include "USI_TWI_Master.h"
+#include "APDS9960.h"
+
+#define WC 0b01110010
+#define RC 0b01110011
+
+int8_t initAPDS9960() {
+       I2c_StartCondition();
+       I2c_WriteByte(WC);
+       I2c_WriteByte(0x80);
+       I2c_StartCondition();
+       I2c_WriteByte (RC);
+       uint8_t b1 =I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       if (b1==0xFF) return 0; else {
+               I2c_StartCondition();
+               I2c_WriteByte(WC);
+               I2c_WriteByte(0x80);
+               I2c_WriteByte(0x0B); //ALS Enable PowerON
+               I2c_StopCondition();
+       }
+       return 1;
+}
+void APDS9960setATime(uint8_t ATime) {
+       I2c_StartCondition();
+       I2c_WriteByte(WC);
+       I2c_WriteByte(0x81);
+       I2c_WriteByte(ATime); 
+       I2c_StopCondition();
+}
+void APDS9960setGain(uint8_t Gain) {
+       I2c_StartCondition();
+       I2c_WriteByte(WC);
+       I2c_WriteByte(0x8F);
+       I2c_WriteByte(Gain&0x03);
+       I2c_StopCondition();
+}
+uint8_t APDS9960getAVALID() {return 0;}
+uint8_t APDS9960getASAT() {return 0;}
+
+void APDS9960getRGBC(uint16_t* R,uint16_t* G,uint16_t* B,uint16_t* C) {
+       I2c_StartCondition();
+       I2c_WriteByte(WC);
+       I2c_WriteByte(0x94);
+       I2c_StartCondition();
+       I2c_WriteByte (RC);
+       *C=I2c_ReadByte(ACK)|I2c_ReadByte(ACK)<<8;
+       *R=I2c_ReadByte(ACK)|I2c_ReadByte(ACK)<<8;
+       *G=I2c_ReadByte(ACK)|I2c_ReadByte(ACK)<<8;
+       *B=I2c_ReadByte(ACK)|I2c_ReadByte(NO_ACK)<<8;
+       I2c_StopCondition();
+}
+
+
+/*
+uint8_t checkMAX44009(uint8_t nr) {
+       volatile uint8_t b1;
+       nr=(nr<<1)&0x02f;
+       
+       I2c_StartCondition();
+       I2c_WriteByte(0b10010100|nr);
+       I2c_WriteByte(0x03);
+       I2c_StartCondition();
+       I2c_WriteByte (0b10010101|nr);
+       b1 =I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       return b1!=0xFF;
+       
+}
+
+
+double MAX44009getlux(uint8_t nr)  {
+       volatile uint8_t b1,b2;
+       nr=(nr<<1)&0x02f;
+       
+       I2c_StartCondition();
+       I2c_WriteByte(0b10010100|nr);
+       I2c_WriteByte(0x03);
+       I2c_StartCondition();
+       I2c_WriteByte (0b10010101|nr);
+       b1 =I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       I2c_StartCondition();
+       I2c_WriteByte(0b10010100|nr);
+       I2c_WriteByte(0x04);
+       I2c_StartCondition();
+       I2c_WriteByte (0b10010101|nr);
+       b2 =I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       uint8_t exponent = (b1 & 0xF0) >> 4;// upper four bits of high byte register
+       uint8_t mantissa = (b1 & 0x0F) << 4;// lower four bits of high byte register =
+       // upper four bits of mantissa
+       mantissa += b2 & 0x0F;    // lower four bits of low byte register =
+       // lower four bits of mantissa
+       
+       return (double)mantissa * (double)(1 << (uint16_t)exponent) * 0.045;
+       
+       
+
+}
+*/
\ No newline at end of file
diff --git a/common/I2C/APDS9960.h b/common/I2C/APDS9960.h
new file mode 100644 (file)
index 0000000..a6ab18a
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef APDS9960_H
+#define APDS9960_H
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+int8_t initAPDS9960();
+void APDS9960setATime(uint8_t ATime);
+void APDS9960setGain(uint8_t Gain);
+uint8_t APDS9960getAVALID();
+uint8_t APDS9960getASAT();
+
+void APDS9960getRGBC(uint16_t* R,uint16_t* G,uint16_t* B,uint16_t* C);
+
+
+
+#endif
\ No newline at end of file
diff --git a/common/I2C/BME680.c b/common/I2C/BME680.c
new file mode 100644 (file)
index 0000000..3f425ba
--- /dev/null
@@ -0,0 +1,436 @@
+// 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.
+#ifdef  __4MHZ__
+#define F_CPU 4000000UL
+#else
+#define F_CPU 8000000UL
+#endif
+#include <avr/io.h>
+
+
+/** Array Index to Field data mapping for Calibration Data*/
+#define BME680_T2_LSB_REG      (1)
+#define BME680_T2_MSB_REG      (2)
+#define BME680_T3_REG          (3)
+#define BME680_P1_LSB_REG      (5)
+#define BME680_P1_MSB_REG      (6)
+#define BME680_P2_LSB_REG      (7)
+#define BME680_P2_MSB_REG      (8)
+#define BME680_P3_REG          (9)
+#define BME680_P4_LSB_REG      (11)
+#define BME680_P4_MSB_REG      (12)
+#define BME680_P5_LSB_REG      (13)
+#define BME680_P5_MSB_REG      (14)
+#define BME680_P7_REG          (15)
+#define BME680_P6_REG          (16)
+#define BME680_P8_LSB_REG      (19)
+#define BME680_P8_MSB_REG      (20)
+#define BME680_P9_LSB_REG      (21)
+#define BME680_P9_MSB_REG      (22)
+#define BME680_P10_REG         (23)
+#define BME680_H2_MSB_REG      (25)
+#define BME680_H2_LSB_REG      (26)
+#define BME680_H1_LSB_REG      (26)
+#define BME680_H1_MSB_REG      (27)
+#define BME680_H3_REG          (28)
+#define BME680_H4_REG          (29)
+#define BME680_H5_REG          (30)
+#define BME680_H6_REG          (31)
+#define BME680_H7_REG          (32)
+#define BME680_T1_LSB_REG      (33)
+#define BME680_T1_MSB_REG      (34)
+#define BME680_GH2_LSB_REG     (35)
+#define BME680_GH2_MSB_REG     (36)
+#define BME680_GH1_REG         (37)
+#define BME680_GH3_REG (38)
+
+
+#include <util/delay.h>
+#include <avr/pgmspace.h>
+
+#include "USI_TWI_Master.h"
+#include "BME680.h"
+
+#define WC 0b11101100
+#define RC 0b11101101
+typedef union {
+       volatile uint8_t d[41];
+       struct {
+               uint8_t fr1;
+               int16_t t2;
+               int8_t t3;
+               uint8_t fr2; //4
+               uint16_t p1;
+               int16_t p2; //7
+               int8_t p3;
+               uint8_t fr3; //10
+               int16_t p4;
+               int16_t p5;
+               int8_t p7;
+               int8_t p6;
+               uint8_t fr4[2]; //17-18
+               int16_t p8;
+               int16_t p9;
+               uint8_t p10;
+               uint8_t fr5; //24
+               uint16_t h2_; //25 +26
+               uint8_t h1_;  //halb und halb 26+27
+               int8_t h3;
+               int8_t h4;
+               int8_t h5;
+               uint8_t h6;
+               int8_t h7;//32
+               uint16_t t1;
+               int16_t gh2;
+               int8_t gh1;
+               int8_t gh3; //38
+               int8_t fr6;// 39;
+               int8_t fr7; //40;
+               uint16_t h2; //Berechnung
+               uint16_t h1; //Berechnung       
+               int32_t t_fine; //Berechnung bei Temperaturmessung      
+               uint8_t  res_heat_range;/**<resistance calculation*/
+               int8_t  res_heat_val; /**<correction factor*/
+               int8_t  range_switching_error;/**<range switching error*/
+               int8_t ltemp; //letzte Temperatur
+       };
+} calib_t;
+
+volatile calib_t calib;
+
+
+#define BME680_CALIB_I2C_ADDR_1                                (0x89)
+#define BME680_CALIB_I2C_ADDR_2                                (0xE1)
+#define BME680_PAGE0_I2C_ID_REG                                (0xD0)
+#define BME680_CALIB_DATA_LENGTH_GAS                   (25)
+#define BME680_CALIB_DATA_LENGTH                       (16)
+
+
+#define BME680_MAX_HUMIDITY_VALUE              (102400)
+#define BME680_MIN_HUMIDITY_VALUE              (0)
+
+
+//ME680_CALIB_I2C_ADDR_1,
+//                                             a_data_u8,
+//                                             BME680_CALIB_DATA_LENGTH_GAS);
+                               /* read the humidity and gas
+                               calibration data*/
+/*                             com_status = (enum bme680_return_type)
+                                            bme680->bme680_bus_read(
+                                            bme680->dev_addr,
+                                            BME680_CALIB_I2C_ADDR_2,
+                                           (a_data_u8 +
+                                           BME680_CALIB_DATA_LENGTH_GAS),
+                                           BME680_CALIB_DATA_LENGTH);
+
+
+
+                                               */
+
+
+void setup_read(uint8_t addr) {
+       I2c_StartCondition();
+       I2c_WriteByte(WC);
+       I2c_WriteByte(addr);  //Ctrl hum
+       I2c_StartCondition();
+       I2c_WriteByte (RC);
+       
+}
+
+void setup_write(uint8_t addr) {
+       I2c_StartCondition();
+       I2c_WriteByte(WC);
+       I2c_WriteByte(addr);  //Ctrl hum
+}
+
+
+uint8_t readone(uint8_t addr) {
+       setup_read(addr);
+       uint8_t b=I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       return b;
+}
+
+void writeone(uint8_t addr,uint8_t b) {
+       setup_write(addr);
+       I2c_WriteByte(b);  //Ctrl hum
+       I2c_StopCondition();
+}
+
+int8_t initBME680() {
+       uint8_t b1=readone(0xD0);
+       setup_read(BME680_CALIB_I2C_ADDR_1);
+       for(uint8_t i=0;i<BME680_CALIB_DATA_LENGTH_GAS-1;i++) {
+               calib.d[i]=I2c_ReadByte(ACK);
+       }
+       calib.d[BME680_CALIB_DATA_LENGTH_GAS-1]=I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+
+       setup_read(BME680_CALIB_I2C_ADDR_2);
+       for(uint8_t i=BME680_CALIB_DATA_LENGTH_GAS;i<BME680_CALIB_DATA_LENGTH_GAS+BME680_CALIB_DATA_LENGTH-1;i++) {
+               calib.d[i]=I2c_ReadByte(ACK);
+       }
+       calib.d[BME680_CALIB_DATA_LENGTH_GAS+BME680_CALIB_DATA_LENGTH-1]=I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       calib.res_heat_range=(readone(0x02)&0x30)>>4;
+       calib.res_heat_val=readone(0);
+       calib.range_switching_error=(readone(0x04)& 0xF0)>>4;
+
+
+    calib.h1 = (uint16_t)(((((uint16_t)calib.d[ BME680_H1_MSB_REG]))
+               << 4) | (calib.d[ BME680_H1_LSB_REG] &0x0F));
+       calib.h2 = (uint16_t)(((((uint16_t)calib.d[ BME680_H2_MSB_REG]))
+               << 4) | ((calib.d[ BME680_H2_LSB_REG]) >> 4));
+
+       
+       /*
+       
+       I2c_StartCondition();
+       I2c_WriteByte(WC);
+       I2c_WriteByte(0x72);  //Ctrl hum
+       I2c_WriteByte(0x01); //1x oversembling hum
+       I2c_WriteByte(0x74);  //Ctrl hum
+       I2c_WriteByte(0b01010101); //2x oversembling t - 16x oversemmping p - mode cont
+       I2c_StopCondition();    
+
+       */
+       calib.ltemp=25;
+
+       return b1==0x61;
+
+}
+
+
+const float lookup_k1_range[16] PROGMEM = {
+       1, 1, 1, 1, 1,0.99, 1, 0.992,
+1, 1, 0.998, 0.995, 1, 0.99, 1, 1};
+const float lookup_k2_range[16] PROGMEM = {
+       8e6, 4e6, 2e6, 1e6,499500.4995, 248262.1648, 125000, 63004.03226,
+31281.28128, 15625, 7812.5, 3906.25,1953.125,976.5625, 488.28125, 244.140625};
+
+double bme680_compensate_gas_double(uint16_t gas_adc_u16, uint8_t gas_range_u8)
+{
+       double gas_res_d = 0;
+
+       
+       
+       int8_t range_switching_error_val = 0;
+
+       double var1 = 0;
+       float a1= pgm_read_float(&(lookup_k1_range[gas_range_u8]));
+       float a2= pgm_read_float(&(lookup_k2_range[gas_range_u8]));
+
+       range_switching_error_val =     calib.range_switching_error;
+
+
+       var1 = (1340.0 + (5.0 * range_switching_error_val))*a1;
+       gas_res_d = var1*a2/(gas_adc_u16-512.0+var1);
+       return gas_res_d;
+}
+
+
+void readBMP680(int16_t *T,uint16_t *H,uint32_t *P,uint16_t *G){
+
+
+       
+       int32_t var1 ;
+       int32_t var2 ;
+       int32_t var3 ;
+       int32_t var4 ;
+       int32_t var5 ;
+       int32_t res_heat_x100 = 0;
+       uint8_t res_heat = 0;
+       uint16_t heater_temp_u16=350;
+       int16_t ambient_temp_s16=calib.ltemp;
+       if ((heater_temp_u16 >= 200) && (heater_temp_u16 <= 400)) {
+               var1 = (((int32_t)ambient_temp_s16 *
+               calib.gh3) / 10) << 8;
+               var2 = (calib.gh1 + 784) *
+               (((((calib.gh2 + 154009) *
+               heater_temp_u16 * 5) / 100) + 3276800) / 10);
+               var3 = var1 + (var2 >> 1);
+               var4 = (var3 / (calib.res_heat_range + 4));
+
+               var5 = (131 * calib.res_heat_val) + 65536;
+
+               res_heat_x100 = (int32_t)(((var4 / var5) - 250) * 34);
+               res_heat = (uint8_t) ((res_heat_x100 + 50) / 100);
+       }
+       uint16_t duration=100;
+       uint8_t factor = 0;
+
+       while ((duration) > 0x3F) {
+               (duration) = (duration) >> 2;
+               factor += 1;
+       }
+       (duration) = (duration) + (factor * 64);
+
+       //I2c_WriteByte(0x74);  //Ctrl hum
+       //I2c_WriteByte(0b01010101); //2x oversembling t - 16x oversemmping p - mode cont
+       // [71] <- 10;  [72] <- 04;  [73] <- 0C;  [74] <- 91;  [75] <- 00;
+       // [70] <- 00     [71] <- 10;  [72] <- 04;  [73] <- 0C;  [74] <- 91;  [75] <- 00;
+       setup_write(0x70);
+       I2c_WriteByte(0x00);
+       I2c_WriteByte(0x71);
+       I2c_WriteByte(0x10);
+       I2c_WriteByte(0x72);
+       I2c_WriteByte(0x04);
+       I2c_WriteByte(0x73);
+       I2c_WriteByte(0x0C);
+       I2c_WriteByte(0x74);
+       I2c_WriteByte(0x90);
+       I2c_WriteByte(0x75);
+       I2c_WriteByte(0x00);
+
+       I2c_WriteByte(0x5A);
+       I2c_WriteByte(res_heat);
+       I2c_WriteByte(0x64);
+       I2c_WriteByte(duration);
+       I2c_StopCondition();
+
+
+       writeone(0x74,0x91);
+       _delay_ms(1000);
+       
+       uint8_t bx=0x91;
+       while ((bx&0x01)==0x01) {
+               bx=readone(0x74);
+               _delay_ms(5);
+       }
+
+       //volatile uint8_t rs=readone(0x2B);
+       uint32_t Th,Hh,Ph;
+       setup_read(0x1F);
+       Ph=I2c_ReadByte(ACK);Ph=Ph<<8;
+       Ph|=I2c_ReadByte(ACK);Ph=Ph<<4;
+       Ph|=I2c_ReadByte(ACK)>>4;
+       Th=I2c_ReadByte(ACK);Th=Th<<8;
+       Th|=I2c_ReadByte(ACK);Th=Th<<4;
+       Th|=I2c_ReadByte(ACK)>>4;       
+       Hh=I2c_ReadByte(ACK);Hh=Hh<<8;
+       Hh|=I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       setup_read(0x2A);
+       volatile uint8_t g1=I2c_ReadByte(ACK);
+       volatile uint8_t g2=I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       *G=(((uint16_t)g1)<<2)|(g2>>6);
+       *P=*G;
+       *G= bme680_compensate_gas_double(*G,g2&0xF)/10.0;
+
+       int32_t temp_comp = 0;
+
+       var1 = ((int32_t)Th >> 3) -
+       ((int32_t)calib.t1 << 1);
+       var2 = (var1 * (int32_t)calib.t2) >> 11;
+       var3 = ((((var1 >> 1) * (var1 >> 1)) >> 12) *
+       ((int32_t)calib.t3 << 4)) >> 14;
+       calib.t_fine = var2 + var3;
+       temp_comp = ((calib.t_fine * 5) + 128) >> 8;
+
+       int32_t temp_scaled = 0;
+       int32_t var6    = 0;
+       int32_t humidity_comp = 0;
+
+       temp_scaled = (((int32_t)calib.t_fine * 5) + 128) >> 8;
+       var1 = (int32_t)Hh -
+               ((int32_t)((int32_t)calib.h1 << 4)) -
+               (((temp_scaled * (int32_t)calib.h3) /
+               ((int32_t)100)) >> 1);
+
+       var2 = ((int32_t)calib.h2 *
+               (((temp_scaled * (int32_t)calib.h4) /
+               ((int32_t)100)) + (((temp_scaled *
+               ((temp_scaled * (int32_t)calib.h5) /
+               ((int32_t)100))) >> 6) / ((int32_t)100)) + (int32_t)(1 << 14))) >> 10;
+
+       var3 = var1 * var2;
+
+       var4 = ((((int32_t)calib.h6) << 7) +
+               ((temp_scaled * (int32_t)calib.h7) /
+               ((int32_t)100))) >> 4;
+
+       var5 = ((var3 >> 14) * (var3 >> 14)) >> 10;
+       var6 = (var4 * var5) >> 1;
+
+       humidity_comp = (var3 + var6) >> 12;
+       if (humidity_comp > BME680_MAX_HUMIDITY_VALUE)
+               humidity_comp = BME680_MAX_HUMIDITY_VALUE;
+               else if (humidity_comp < BME680_MIN_HUMIDITY_VALUE)
+               humidity_comp = BME680_MIN_HUMIDITY_VALUE;
+
+    int32_t pressure_comp = 0;//int -> 5684
+
+    var1 = (((int32_t)calib.t_fine) >> 1) - (int32_t)64000;
+    var2 = ((((var1 >> 2) * (var1 >> 2)) >> 11) *
+    (int32_t)calib.p6) >> 2;
+    var2 = var2 + ((var1 * (int32_t)calib.p5) << 1);
+    var2 = (var2 >> 2) + ((int32_t)calib.p4 << 16);
+    var1 = (((((var1 >> 2) * (var1 >> 2)) >> 13) *
+    ((int32_t)calib.p3 << 5)) >> 3) +
+    (((int32_t)calib.p2 * var1) >> 1);
+    var1 = var1 >> 18;
+    var1 = (((int32_t)32768 + var1) * (int32_t)calib.p1) >> 15;
+    pressure_comp = (int32_t)1048576 - Ph;
+    pressure_comp = (int32_t)((pressure_comp - (var2 >> 12)) * ((uint32_t)3125));
+    var4 = ((int32_t)1 << 31);
+    if (pressure_comp >= var4)
+    pressure_comp = ((pressure_comp / (uint32_t)var1) << 1);
+    else
+    pressure_comp = ((pressure_comp << 1) / (uint32_t)var1);
+    var1 = ((int32_t)calib.p9 * (int32_t)(((pressure_comp >> 3) *
+    (pressure_comp >> 3)) >> 13)) >> 12;
+    var2 = ((int32_t)(pressure_comp >> 2) *
+    (int32_t)calib.p8) >> 13;
+    var3 = ((int32_t)(pressure_comp >> 8) * (int32_t)(pressure_comp >> 8) *
+    (int32_t)(pressure_comp >> 8) *
+    (int32_t)calib.p10) >> 17;
+
+    pressure_comp = (int32_t)(pressure_comp) + ((var1 + var2 + var3 +
+    ((int32_t)calib.p7 << 7)) >> 4);
+
+
+
+
+       
+       *T=(int16_t)temp_comp;
+       calib.ltemp=temp_comp/100;
+       //*P=pressure_comp;
+       *H=(uint16_t)(humidity_comp/10);
+       //*P=rs;
+       *T=g1;
+       *H=g2;
+       //*P=
+
+
+}
+
diff --git a/common/I2C/BME680.h b/common/I2C/BME680.h
new file mode 100644 (file)
index 0000000..159d3f3
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef BME680_H
+#define BME680_H
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+int8_t initBME680();
+void readBMP680(int16_t *T,uint16_t *H,uint32_t *P,uint16_t *G);
+/*void APDS9960setATime(uint8_t ATime);
+void APDS9960setGain(uint8_t Gain);
+uint8_t APDS9960getAVALID();
+uint8_t APDS9960getASAT();
+
+void APDS9960getRGBC(uint16_t* R,uint16_t* G,uint16_t* B,uint16_t* C);
+*/
+
+
+#endif
\ No newline at end of file
diff --git a/common/I2C/IAQCORE.c b/common/I2C/IAQCORE.c
new file mode 100644 (file)
index 0000000..357912d
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#define F_CPU 8000000UL
+#include <avr/io.h>
+
+#include <util/delay.h>
+
+
+#include "USI_TWI_Master.h"
+#include "IAQCORE.h"
+
+
+uint8_t readIAQCORE(IAQCORE_Data_t *d) {
+       uint8_t *da=(uint8_t*)d;
+       I2c_StartCondition();
+       I2c_WriteByte(0b10110101);
+       da[1]=I2c_ReadByte(ACK);
+       da[0]=I2c_ReadByte(ACK);
+       da[2]=I2c_ReadByte(ACK);
+       da[6]=I2c_ReadByte(ACK);
+       da[5]=I2c_ReadByte(ACK);
+       da[4]=I2c_ReadByte(ACK);
+       da[3]=I2c_ReadByte(ACK);
+       da[8]=I2c_ReadByte(ACK);
+       da[7]=I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+       return 0;
+}
diff --git a/common/I2C/IAQCORE.h b/common/I2C/IAQCORE.h
new file mode 100644 (file)
index 0000000..12c538b
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef IAQCORE_H
+#define IAQCORE_H
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the
+//    distribution.
+//  * All advertising materials mentioning features or use of this
+//    software must display the following acknowledgement: This product
+//    includes software developed by tm3d.de and its contributors.
+//  * Neither the name of tm3d.de nor the names of its contributors may
+//    be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+typedef struct  {
+uint16_t CO2;
+int8_t state;
+int32_t resistance;
+uint16_t TVOC;
+} IAQCORE_Data_t;
+
+uint8_t readIAQCORE(IAQCORE_Data_t *d);
+
+#endif
\ No newline at end of file
diff --git a/common/I2C/SGP30.c b/common/I2C/SGP30.c
new file mode 100644 (file)
index 0000000..ee19d6a
--- /dev/null
@@ -0,0 +1,228 @@
+// Copyright (c) 2017, 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.
+#ifdef  __4MHZ__
+#define F_CPU 4000000UL
+#else
+#define F_CPU 8000000UL
+#endif
+#include <avr/io.h>
+
+
+#include <util/delay.h>
+#include <avr/pgmspace.h>
+
+#include "USI_TWI_Master.h"
+#include "SGP30.h"
+//0x58
+#define WC 0b10110000
+#define RC 0b10110001
+#define CRC8_POLYNOMIAL             0x31
+#define CRC8_INIT                   0xFF
+#define CRC8_LEN                    1
+
+
+uint8_t sensirion_common_generate_crc(uint8_t *data, uint8_t count)
+{
+       uint16_t current_byte;
+       uint8_t crc = CRC8_INIT;
+       uint8_t crc_bit;
+
+       /* calculates 8-Bit checksum with given polynomial */
+       for (current_byte = 0; current_byte < count; ++current_byte) {
+               crc ^= (data[current_byte]);
+               for (crc_bit = 8; crc_bit > 0; --crc_bit) {
+                       if (crc & 0x80)
+                       crc = (crc << 1) ^ CRC8_POLYNOMIAL;
+                       else
+                       crc = (crc << 1);
+               }
+       }
+       return crc;
+}
+
+int8_t sensirion_common_check_crc(uint8_t *data, uint8_t count, uint8_t checksum)
+{
+       if (sensirion_common_generate_crc(data, count) != checksum)
+       return 0;
+       return 1;
+}
+
+void readSGPXX(uint16_t com, uint8_t* data, uint8_t len) {
+       I2c_StartCondition();
+       I2c_WriteByte(WC);
+       I2c_WriteByte(com>>8);  //Ctrl hum
+       I2c_WriteByte(com&0x00FF);  //Ctrl hum
+       _delay_ms(100);
+       I2c_StartCondition();
+       I2c_WriteByte (RC);
+       for(uint8_t i=0;i<len-1;i++) {
+               data[i]=I2c_ReadByte(ACK);
+       }
+       data[len-1]=I2c_ReadByte(NO_ACK);
+       I2c_StopCondition();
+}
+
+void writeSGPXX(uint16_t com, uint8_t* data, uint8_t len) {
+       I2c_StartCondition();
+       I2c_WriteByte(WC);
+       I2c_WriteByte(com>>8);  //Ctrl hum
+       I2c_WriteByte(com&0x00FF);  //Ctrl hum
+       for(uint8_t i=0;i<len;i++) {
+               I2c_WriteByte(data[i]);
+       }
+       I2c_StopCondition();
+}
+
+
+
+
+
+uint16_t bl1S=0,bl2S=0;
+
+uint16_t getbl=1000;
+
+
+int8_t check_convert_buf(uint8_t *b,uint16_t *v1,uint16_t *v2) {
+       int8_t ret=1;
+       if (sensirion_common_check_crc(b,2,b[2])) {     *v1=((int16_t)b[0])<<8|b[1];} else {*v1=0;ret=0;}
+       if (sensirion_common_check_crc(b+3,2,b[5])) {*v2=((int16_t)b[3])<<8|b[4];} else {*v2=0;ret=0;}
+       return ret;
+}
+
+
+
+uint16_t readEEPROM(uint8_t addr,uint16_t def) {
+       uint16_t hr;
+       EEARH=0;
+       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) {
+       EEARH=0;
+       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);
+}
+
+void save_baseline(uint16_t b1,uint16_t b2 ) {
+       writeEEPROM(0,b1);
+       writeEEPROM(2,b2);
+}
+
+void read_baseline(uint16_t *b1,uint16_t *b2) {
+       *b1=readEEPROM(0,0xFFFF);
+       *b2=readEEPROM(2,0xFFFF);
+}
+
+void set_baseline(uint16_t b1,uint16_t b2) {
+       uint8_t b[10];
+       b[3]=(uint16_t)b1>>8;  //irgendwie werden die Werte vertauscht zwischen lesen und schreiben
+       b[4]=(uint16_t)b1&0x00FF;
+       b[5]=sensirion_common_generate_crc(b+3,2);
+       b[0]=(uint16_t)b2>>8;
+       b[1]=(uint16_t)b2&0x00FF;
+       b[2]=sensirion_common_generate_crc(b,2);
+       writeSGPXX(0x201e,b,6);
+       bl1S=b1;
+       bl2S=b2;
+}
+
+int8_t initSGP30() {
+       uint8_t b[10];
+       readSGPXX(0x2032,b,3);
+       _delay_ms(300);
+       writeSGPXX(0x2003,0,0);
+       _delay_ms(10);
+       uint16_t b1=0,b2=0;
+       //set_baseline(0x2210,0x3320);
+       //readSGPXX(0x2015,b,6);
+       read_baseline(&b1,&b2);
+       if (b1!=0xFFFF) {
+               set_baseline(b1,b2);
+               //readSGPXX(0x2015,b,6);
+               //uint16_t bl1,bl2;
+               //check_convert_buf(b,&bl1,&bl2);
+               
+       }
+       return 0x1;
+
+}
+
+void runSGP30(uint16_t *CO2,uint16_t *VOC,uint16_t *ETH,uint16_t *H2){
+       uint8_t b[10];
+       readSGPXX(0x2008,b,6);
+       check_convert_buf(b,CO2,VOC);
+       getbl--;
+       if (getbl==0) {
+               uint8_t eq=1;
+               readSGPXX(0x2015,b,6);
+               uint16_t bl1,bl2;
+               check_convert_buf(b,&bl1,&bl2);
+               int8_t bl1d=bl1-bl1S;
+               int8_t bl2d=bl2-bl2S;
+               if (bl1d<0) bl1d=-bl1d;
+               if (bl2d<0) bl2d=-bl2d;
+               if (bl1d>4) {bl1S=bl1;eq=0;}
+               if (bl2d>4) {bl2S=bl2;eq=0;}
+               getbl=200;  //Naechste bruefunf in 100 s
+               if (eq==0) {
+                       *VOC+=1000;
+                       save_baseline(bl1,bl2);
+               } 
+       }
+       readSGPXX(0x2050,b,6);
+       check_convert_buf(b,ETH,H2);
+
+}
+
+
diff --git a/common/I2C/SGP30.h b/common/I2C/SGP30.h
new file mode 100644 (file)
index 0000000..c285008
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef SGP30_H
+#define SGP30_H
+// Copyright (c) 2017, 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.
+
+int8_t initSGP30();
+void runSGP30(uint16_t *CO2,uint16_t *VOC,uint16_t *ETH,uint16_t *H2);
+
+
+#endif
\ No newline at end of file
index f91c41b..d6b1f85 100644 (file)
 \r
 // Defines controlling timing limits\r
 #define TWI_FAST_MODE\r
-\r
+#ifdef  __4MHZ__\r
+#define SYS_CLK  4000.0  // [kHz]\r
+#else\r
 #define SYS_CLK   8000.0  // [kHz]\r
+#endif\r
+\r
+\r
 \r
 #ifdef TWI_FAST_MODE               // TWI FAST mode timing limits. SCL = 100-400kHz\r
   #define T2_TWI    ((SYS_CLK *1300) /1000000) +1 // >1,3us\r
index 109891d..73fd42e 100644 (file)
@@ -34,6 +34,7 @@
 #define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
 #define _HANDLE_CC_COMMAND_\r
+               \r
 //#define _DB_\r
 \r
 #include "../common/OWConfig.s"\r
 #else\r
 .extern pack2,64\r
 #endif\r
-.extern  am2302_temp,2\r
-.extern  am2302_hum,2\r
+//.extern  am2302_temp,2\r
+//.extern  am2302_hum,2\r
 .comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)\r
+.comm cpsp,1 ; Copy Scratchpad marker\r
 \r
 \r
 .macro CHIP_INIT       ;r_temp is pushed other Registers should be saved\r
+       ldi r_temp,0\r
+       sts cpsp,r_temp\r
 Init_EEPROM_read:\r
        push r_bytep\r
        push r_rwbyte\r
@@ -79,6 +83,7 @@ Init_EEPROM_read:
                rjmp h_readscratchpad2\r
                rjmp h_writescratchpad_adr2\r
                rjmp h_writescratchpad2\r
+               rjmp h_copyscratchpad_adr2\r
 .endm\r
 \r
 #include "../common/OWRomFunctionsDual.s"\r
@@ -94,6 +99,7 @@ Init_EEPROM_read:
 #define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+4\r
 #define OW_WRITE_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+5\r
 #define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+6\r
+#define OW_COPY_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+7\r
 \r
 \r
 ;---------------------------------------------------\r
@@ -270,6 +276,7 @@ h_readcommand2:
        cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2\r
        cjmp 0x44,hrc_set_convertT2\r
        cjmp 0xB4,hrc_set_convertV2\r
+       cset 0x48,OW_COPY_SCRATCHPAD_ADR2\r
        FW_CONFIG_INFO2\r
        //cljmp 0x85,hrc_fw_configinfo2\r
 #ifdef _CHANGEABLE_ID_\r
@@ -367,7 +374,10 @@ h_writescratchpad_all2:
        rjmp handle_end_sleep\r
 \r
 \r
-\r
+h_copyscratchpad_adr2:\r
+       ori r_rwbyte,0x80 ;hoechstes bit ist 1 zum Testen\r
+       sts cpsp,r_rwbyte\r
+       rjmp handle_end_sleep\r
 \r
 \r
 \r
index a7d92fa..e268f53 100644 (file)
@@ -34,6 +34,7 @@
 //#define _DIS_FLASH_\r
 #define _ZERO_POLLING_\r
 //#define _DB_\r
+//#define __4MHZ__\r
 \r
 #include "../common/OWConfig.s"\r
 #include "../common/OWCRC8.s"\r
index 3c00e1b..2d2c891 100644 (file)
@@ -33,7 +33,7 @@
 \r
 #define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
-//#define _HANDLE_CC_COMMAND_\r
+#define _HANDLE_CC_COMMAND_\r
 //#define _DB_\r
 \r
 #include "../common/OWConfig.s"\r
 .extern  DS2438_2_TEMP,2\r
 .extern  DS2438_2_VAD,2\r
 .comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)\r
-\r
+.comm cpsp2,1 ; Copy Scratchpad marker\r
 \r
 .macro CHIP_INIT       ;r_temp is pushed other Registers should be saved\r
+       ldi r_temp,0\r
+       sts cpsp2,r_temp\r
 .endm\r
 \r
 .macro COMMAND_TABLE\r
@@ -66,6 +68,7 @@
                rjmp h_readscratchpad2\r
                rjmp h_writescratchpad_adr2\r
                rjmp h_writescratchpad2\r
+               rjmp h_copyscratchpad_adr2\r
 .endm\r
 \r
 #include "../common/OWRomFunctionsDual.s"\r
@@ -82,6 +85,7 @@
 #define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+5\r
 #define OW_WRITE_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+6\r
 #define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+7\r
+#define OW_COPY_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+8\r
 \r
 \r
 ;---------------------------------------------------\r
@@ -91,7 +95,8 @@
 #ifdef _HANDLE_CC_COMMAND_\r
 h_readcommand12:\r
        clr r_bytep\r
-       cset 0x44,hrc_set_convertT12\r
+       cljmp 0x44,hrc_set_convertT12\r
+       cljmp 0xB4,hrc_set_convertV12\r
        ldi r_mode,OW_SLEEP\r
        rjmp handle_end\r
 #endif\r
@@ -114,14 +119,23 @@ h_readcommand1:
 \r
 \r
 hrc_set_convertT1:\r
+       rcall chrc_set_convertT1\r
+       rjmp handle_end_sleep\r
+\r
+chrc_set_convertT1:\r
        ldi r_temp,1\r
        sts gcontrol,r_temp\r
        lds r_temp,DS2438_1_TEMP\r
        sts pack1+1,r_temp\r
        lds r_temp,DS2438_1_TEMP+1\r
        sts pack1+2,r_temp\r
-       rjmp handle_end_sleep\r
+       ret\r
+\r
 hrc_set_convertV1:\r
+       rcall chrc_set_convertV1\r
+       rjmp handle_end_sleep\r
+\r
+chrc_set_convertV1:\r
        lds r_temp,pack1\r
        sbrs r_temp,3\r
        rjmp hrc_set_convertVV1\r
@@ -131,14 +145,14 @@ hrc_set_convertV1:
        sts pack1+4,r_temp\r
        rjmp hrc_set_convertend1\r
 hrc_set_convertVV1:\r
-       ldi r_temp,3\r
+       ldi r_temp,2\r
        sts gcontrol,r_temp\r
        lds r_temp,DS2438_1_VAD\r
        sts pack1+3,r_temp\r
        lds r_temp,DS2438_1_VAD+1\r
        sts pack1+4,r_temp\r
 hrc_set_convertend1:\r
-       rjmp handle_end_sleep\r
+       ret\r
 \r
 \r
 \r
@@ -210,16 +224,13 @@ h_writescratchpad_all1:
 \r
 #ifdef _HANDLE_CC_COMMAND_\r
 hrc_set_convertT12:\r
-       ldi r_temp,3\r
-       sts gcontrol,r_temp\r
-       lds r_temp,DS2438_2_TEMP\r
-       sts pack2+1,r_temp\r
-       lds r_temp,DS2438_2_TEMP+1\r
-       sts pack2+2,r_temp\r
-       lds r_temp,DS2438_1_TEMP\r
-       sts pack1+1,r_temp\r
-       lds r_temp,DS2438_1_TEMP+1\r
-       sts pack1+2,r_temp\r
+       rcall chrc_set_convertT1\r
+       rcall chrc_set_convertT2\r
+       rjmp handle_end_sleep\r
+\r
+hrc_set_convertV12:\r
+       rcall chrc_set_convertV1\r
+       rcall chrc_set_convertV2\r
        rjmp handle_end_sleep\r
 #endif\r
 \r
@@ -243,6 +254,7 @@ h_readcommand2:
        cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2\r
        cjmp 0x44,hrc_set_convertT2\r
        cjmp 0xB4,hrc_set_convertV2\r
+       cset 0x48,OW_COPY_SCRATCHPAD_ADR2\r
        FW_CONFIG_INFO2\r
        //cljmp 0x85,hrc_fw_configinfo2\r
 #ifdef _CHANGEABLE_ID_\r
@@ -250,16 +262,25 @@ h_readcommand2:
 #endif\r
        rjmp handle_end_sleep\r
 \r
-\r
 hrc_set_convertT2:\r
-       ldi r_temp,2\r
+       rcall chrc_set_convertT2\r
+       rjmp handle_end_sleep\r
+\r
+hrc_set_convertV2:\r
+       rcall chrc_set_convertV2\r
+       rjmp handle_end_sleep\r
+\r
+\r
+chrc_set_convertT2:\r
+       ldi r_temp,3\r
        sts gcontrol,r_temp\r
        lds r_temp,DS2438_2_TEMP\r
        sts pack2+1,r_temp\r
        lds r_temp,DS2438_2_TEMP+1\r
        sts pack2+2,r_temp\r
-       rjmp handle_end_sleep\r
-hrc_set_convertV2:\r
+       ret\r
+\r
+chrc_set_convertV2:\r
        lds r_temp,pack2\r
        sbrs r_temp,3\r
        rjmp hrc_set_convertVV2\r
@@ -269,14 +290,14 @@ hrc_set_convertV2:
        sts pack2+4,r_temp\r
        rjmp hrc_set_convertend2\r
 hrc_set_convertVV2:\r
-       ldi r_temp,3\r
+       ldi r_temp,4\r
        sts gcontrol,r_temp\r
        lds r_temp,DS2438_2_VAD\r
        sts pack2+3,r_temp\r
        lds r_temp,DS2438_2_VAD+1\r
        sts pack2+4,r_temp\r
 hrc_set_convertend2:\r
-       rjmp handle_end_sleep\r
+       ret\r
 \r
 \r
 \r
@@ -341,7 +362,10 @@ h_writescratchpad_all2:
 \r
 \r
 \r
-\r
+h_copyscratchpad_adr2:\r
+       ori r_rwbyte,0x80 ;hoechstes bit ist 1 zum Testen\r
+       sts cpsp2,r_rwbyte\r
+       rjmp handle_end_sleep\r
 \r
 \r
 \r
index 40e3907..9a8d50f 100644 (file)
@@ -31,7 +31,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
 \r
-//#define _CHANGEABLE_ID_\r
+#define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
 \r
 #include "../common/OWConfig.s"\r
index 1810047..b50fde5 100644 (file)
@@ -67,7 +67,7 @@
 //#define OWT_READ 4\r
 #ifdef __4MHZ__\r
 #define OWT_MIN_RESET 80\r
-#define OWT_RESET2 17\r
+#define OWT_RESET2 30\r
 #define OWT_RESET_PRESENT 15\r
 #define OWT_PRESENT 60\r
 #define OWT_WRITE 16\r