Many changes from 2018 master
authorTobias <tm@tm3d.de>
Wed, 7 Nov 2018 10:17:14 +0000 (11:17 +0100)
committerTobias <tm@tm3d.de>
Wed, 7 Nov 2018 10:17:14 +0000 (11:17 +0100)
182 files changed:
DS18B20_ADC/DS18B20_ADC.atsln [new file with mode: 0644]
DS18B20_ADC/DS18B20_ADC.c [new file with mode: 0644]
DS18B20_ADC/DS18B20_ADC.cproj [new file with mode: 0644]
DS18B20_BMP280/DS18B20_BMP280.c
DS18B20_BMP280_DS2438_SHT/DS18B20_BMP280_DS2438_SHT.cproj
DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c
DS18B20_CDM7160/DS18B20_CDM7160.c
DS18B20_CDM7160_DS18B20_BMP280/DS18B20_CDM7160_DS18B20_BMP280.atsln [new file with mode: 0644]
DS18B20_CDM7160_DS18B20_BMP280/DS18B20_CDM7160_DS18B20_BMP280.cproj [new file with mode: 0644]
DS18B20_CDM7160_DS18B20_BMP280/DS18B20_DS18B20.c [new file with mode: 0644]
DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.atsln [new file with mode: 0644]
DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.c [new file with mode: 0644]
DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.cproj [new file with mode: 0644]
DS18B20_DS2408/DS18B20_DS2408.atsln [new file with mode: 0644]
DS18B20_DS2408/DS18B20_DS2408.c [new file with mode: 0644]
DS18B20_DS2408/DS18B20_DS2408.cproj [new file with mode: 0644]
DS18B20_LPS225HB_DS2438_SHT/DS18B20_DS2438.c [new file with mode: 0644]
DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.atsln [new file with mode: 0644]
DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.cproj [new file with mode: 0644]
DS18B20_MAX44009/DS18B20_MAX44009.c
DS18B20_MAX44009/DS18B20_MAX44009.cproj
DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c
DS18B20_MAX44009_DS2438_SHT/DS18B20_MAX44009_DS2438_SHT.cproj
DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_DS18B20.c [new file with mode: 0644]
DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.atsln [new file with mode: 0644]
DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.cproj [new file with mode: 0644]
DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_DS18B20.c [new file with mode: 0644]
DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.atsln [new file with mode: 0644]
DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.cproj [new file with mode: 0644]
DS18B20_Thermocouble/DS18B20_TC.cproj
DS18B20_Thermocouble_DS2438_SHT/DS18B20_DS2438.c
DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.atsln
DS18B20_Thermocouble_DS2438_SHT/DS18B20_Thermocouble_DS2438_SHT.cproj
DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c
DS18B20_VOC_DS2438_SHT direct/DS18B20_VOC_DS2438_SHT.atsln [new file with mode: 0644]
DS18B20_VOC_DS2438_SHT direct/DS18B20_VOC_DS2438_SHT.cproj [new file with mode: 0644]
DS18B20_VOC_DS2438_SHT/DS18B20_DS2438.c
DS2408/DS2408.atsln [new file with mode: 0644]
DS2408/DS2408.c [new file with mode: 0644]
DS2408/DS2408.cproj [new file with mode: 0644]
DS2413_DS2413/DS2413_DS2413.atsln [new file with mode: 0644]
DS2413_DS2413/DS2413_DS2413.c [new file with mode: 0644]
DS2413_DS2413/DS2413_DS2413.cproj [new file with mode: 0644]
DS2423_DS2413/DS2423_DS2413.c
DS2423_DS2423/DS2423_DS2423.c
DS2438_ADC/DS2438_ADC.atsln [new file with mode: 0644]
DS2438_ADC/DS2438_ADC.c [new file with mode: 0644]
DS2438_ADC/DS2438_ADC.cproj [new file with mode: 0644]
DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.atsln [new file with mode: 0644]
DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.cproj [new file with mode: 0644]
DS2438_ADC_DS2438_ADC/DS2438_DS2438.c [new file with mode: 0644]
DS2438_CDM7160/DS2438_CDM7160.atsln [new file with mode: 0644]
DS2438_CDM7160/DS2438_CDM7160.c [new file with mode: 0644]
DS2438_CDM7160/DS2438_CDM7160.cproj [new file with mode: 0644]
DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.atsln [new file with mode: 0644]
DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.componentinfo.xml [new file with mode: 0644]
DS2438_CDM7160_DS2438_BMP280/DS2438_DS2438.c [new file with mode: 0644]
DS2438_DHT11/DS2438_DHT22.atsln [new file with mode: 0644]
DS2438_DHT11/DS2438_DHT22.c [new file with mode: 0644]
DS2438_DHT11/DS2438_DHT22.cproj [new file with mode: 0644]
DS2438_DHT22/DS2438_DHT22.cproj
DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.atsln [new file with mode: 0644]
DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.c [new file with mode: 0644]
DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.cproj [new file with mode: 0644]
DS2438_Fenster_Kontakt/OWDS2438.S [new file with mode: 0644]
DS2438_HDC1080/DS2438_HDC1080.atsln
DS2438_HDC2010/DS2438_HDC2010.atsln [new file with mode: 0644]
DS2438_HDC2010/DS2438_HDC2010.c [new file with mode: 0644]
DS2438_HDC2010/DS2438_HDC2010.cproj [new file with mode: 0644]
DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_DS2438.c [new file with mode: 0644]
DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_MAX44009_VOC_DS2438_HDC.atsln [new file with mode: 0644]
DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_MAX44009_VOC_DS2438_HDC.cproj [new file with mode: 0644]
DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_DS2438.c [new file with mode: 0644]
DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_MAX44009_VOC_DS2438_SHT.atsln [new file with mode: 0644]
DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_MAX44009_VOC_DS2438_SHT.cproj [new file with mode: 0644]
DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_DS2438.c [new file with mode: 0644]
DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.atsln [new file with mode: 0644]
DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj [new file with mode: 0644]
DS2438_SHT2X_DS2438_LPS225HB/DS2438_DS2438.c [new file with mode: 0644]
DS2438_SHT2X_DS2438_LPS225HB/DS2438_SHT2X_DS2438_LPS225HB.atsln [new file with mode: 0644]
DS2438_SHT2X_DS2438_LPS225HB/DS2438_SHT2X_DS2438_LPS225HB.cproj [new file with mode: 0644]
DS2438_SHT3X/DS2438_SHT3X.c
DS2438_SHT3X/DS2438_SHT3X.cproj
DS2450/DS2450.c
DS2450/DS2450.cproj
DS2450/OWDS2450.S
DS2450_ADC/DS2450.c [new file with mode: 0644]
DS2450_ADC/DS2450_ADC.atsln [new file with mode: 0644]
DS2450_ADC/DS2450_ADC.cproj [new file with mode: 0644]
DS2450_ADC/OWDS2450.S [new file with mode: 0644]
DS2450_ADC_JOE2/DS2450.c [new file with mode: 0644]
DS2450_ADC_JOE2/DS2450_ADC.atsln [new file with mode: 0644]
DS2450_ADC_JOE2/DS2450_ADC_JOE2.cproj [new file with mode: 0644]
DS2450_ADC_JOE2/OWDS2450.S [new file with mode: 0644]
DS2450_APDS9960/DS2450_APDS9960.atsln
DS2450_APDS9960/DS2450_APDS9960.cproj
DS2450_APDS9960/OWDS2450.S [new file with mode: 0644]
DS2450_BME680/DS2450_BME680.atsln [new file with mode: 0644]
DS2450_BME680/DS2450_BME680.c [new file with mode: 0644]
DS2450_BME680/DS2450_BME680.cproj [new file with mode: 0644]
DS2450_BME680/OWDS2450.S [new file with mode: 0644]
DS2450_BMP280/OWDS2450.S [new file with mode: 0644]
DS2450_CDM7160/DS2450_CDM7160.atsln [new file with mode: 0644]
DS2450_CDM7160/DS2450_CDM7160.c [new file with mode: 0644]
DS2450_CDM7160/DS2450_CDM7160.cproj [new file with mode: 0644]
DS2450_CDM7160/OWDS2450.S [new file with mode: 0644]
DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.atsln [new file with mode: 0644]
DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.c [new file with mode: 0644]
DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.cproj [new file with mode: 0644]
DS2450_DSM501A/DS2450_DSM501A.atsln [new file with mode: 0644]
DS2450_DSM501A/DS2450_DSM501A.c [new file with mode: 0644]
DS2450_DSM501A/DS2450_DSM501A.cproj [new file with mode: 0644]
DS2450_IAQCORE/DS2450_IAQCORE.atsln
DS2450_IAQCORE/DS2450_IAQCORE.c
DS2450_IAQCORE/DS2450_IAQCORE.cproj
DS2450_LPS225HB/DS2450_LPS225HB.atsln [new file with mode: 0644]
DS2450_LPS225HB/DS2450_LPS225HB.c [new file with mode: 0644]
DS2450_LPS225HB/DS2450_LPS225HB.cproj [new file with mode: 0644]
DS2450_LPS225HB/OWDS2450.S [new file with mode: 0644]
DS2450_MAX44008/DS2450_MAX44008.atsln [new file with mode: 0644]
DS2450_MAX44008/DS2450_MAX44008.c [new file with mode: 0644]
DS2450_MAX44008/DS2450_MAX44008.cproj [new file with mode: 0644]
DS2450_MAX44008/OWDS2450.S [new file with mode: 0644]
DS2450_SGP30/DS2450_SGP30.atsln [new file with mode: 0644]
DS2450_SGP30/DS2450_SGP30.c [new file with mode: 0644]
DS2450_SGP30/DS2450_SGP30.cproj [new file with mode: 0644]
DS2450_SGP30/OWDS2450.S [new file with mode: 0644]
DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.atsln
DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.c
DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.cproj
DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.atsln
DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.c
DS2450_SHT2X_MAX44009/DS2450_SHT2X_MAX44009.cproj
DS2450_SHT3X/DS2450_SHT3X.atsln [new file with mode: 0644]
DS2450_SHT3X/DS2450_SHT3X.c [new file with mode: 0644]
DS2450_SHT3X/DS2450_SHT3X.cproj [new file with mode: 0644]
DS2450_SHT3X/OWDS2450.S [new file with mode: 0644]
DS2450_VOC_SHT/DS2450_VOC_SHT.atsln [new file with mode: 0644]
DS2450_VOC_SHT/DS2450_VOC_SHT.c [new file with mode: 0644]
DS2450_VOC_SHT/DS2450_VOC_SHT.cproj [new file with mode: 0644]
DS2450_VOC_SHT/OWDS2450.S [new file with mode: 0644]
common/I2C/BME680.c
common/I2C/BMP280.c
common/I2C/BMP280.h
common/I2C/CDM7160.c
common/I2C/HDC2010.c [new file with mode: 0644]
common/I2C/HDC2010.h [new file with mode: 0644]
common/I2C/LPS225HB.c [new file with mode: 0644]
common/I2C/LPS225HB.h [new file with mode: 0644]
common/I2C/MAX44009.c
common/I2C/SGP30.c
common/I2C/SHT2x.c
common/I2C/SHT2xV2.c
common/I2C/SHT3x.c
common/I2C/TSL256x.c
common/I2C/TWI_Master.c [new file with mode: 0644]
common/I2C/TWI_Master.h [new file with mode: 0644]
common/I2C/USI_TWI_Master.c
common/I2C/USI_TWI_Master.h
common/OWCRC8_16.s [new file with mode: 0644]
common/OWConfig.s
common/OWDS18B20_DS18B20.S [new file with mode: 0644]
common/OWDS18B20_DS2408.S [new file with mode: 0644]
common/OWDS18B20_DS2438.S
common/OWDS2408.S [new file with mode: 0644]
common/OWDS2413_DS2413.S [new file with mode: 0644]
common/OWDS2438_DS2438.S
common/OWDS2450_DS2423.S [new file with mode: 0644]
common/OWDS2450_DS2450.S [new file with mode: 0644]
common/OWPinInterrupt.s
common/OWRomFunctions.s
common/OWRomFunctionsDual.s
common/OWSet_ATMEGA168.s [new file with mode: 0644]
common/OWSet_ATTINYX4.s
common/calibr.c
common/calibr.h
common/owSlave_tools.h [new file with mode: 0644]
programmer/programmer/programmer.asmproj
programmer/programmer/programmer_8MHz_2017.asm [new file with mode: 0644]
programmer_atmega328/programmer_atmega328/programmer_atmega328.asm [new file with mode: 0644]
programmer_atmega328/programmer_atmega328/programmer_atmega328.asmproj [new file with mode: 0644]
programmer_atmega328/programmer_atmega328/programmer_atmega328.atsln [new file with mode: 0644]

diff --git a/DS18B20_ADC/DS18B20_ADC.atsln b/DS18B20_ADC/DS18B20_ADC.atsln
new file mode 100644 (file)
index 0000000..ace6033
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_ADC", "DS18B20_ADC.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS18B20_ADC/DS18B20_ADC.c b/DS18B20_ADC/DS18B20_ADC.c
new file mode 100644 (file)
index 0000000..36bd271
--- /dev/null
@@ -0,0 +1,201 @@
+\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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+\r
+\r
+uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0xAC};/**/\r
+uint8_t config_info[26]={0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x02,6,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
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+\r
+\r
+volatile uint8_t wdcounter;\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[8];\r
+       struct {\r
+               uint16_t temp;  //0\r
+               uint8_t TH;  //2\r
+               uint8_t TL;  //3\r
+               uint8_t config;  //4\r
+               uint8_t rrFF; //5\r
+               uint8_t rr00; //6\r
+               uint8_t rr10; //7\r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+\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
+#else\r
+ISR(WDT_vect) {\r
+#endif \r
+       //sleep_disable();          // Disable Sleep on Wakeup\r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+/*     if (timeout==2) {\r
+               DIS_TIMER;\r
+               EN_OWINT;\r
+               mode=OWM_SLEEP;\r
+       }\r
+       timeout++;*/\r
+       //sleep_enable();           // Enable Sleep Mode\r
+\r
+}\r
+\r
+\r
+volatile double V,ktemp;\r
+\r
+uint16_t ADmess() {\r
+        ADMUX=0b00101100;  //3V  ADC2+  ADC1- 1x\r
+        ADCSRA|=(1<<ADSC);\r
+        while ((ADCSRA&(1<<ADSC)));\r
+       return ADC;\r
+}\r
+\r
+int main(void){\r
+    //PRR|=(1<<PRUSI)|(1<<PRADC);  //Switch off usi and adc for save Power\r
+       pack.temp=0x0550;\r
+       pack.config=0x7F;\r
+       pack.TH=75;\r
+       pack.TL=70;\r
+       pack.rrFF=0xFF;\r
+       pack.rr00=0;\r
+       pack.rr10=0x10;\r
+       PORTA=0xFF-(1<<PINA1)-(1<<PINA2);\r
+       PORTB=0xFF;\r
+       OWINIT();\r
+\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+       MCUCR |=(1<<BODS);\r
+\r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~1 seconds\r
+       MCUSR=0;\r
+       sei();\r
+       ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1);//|(1<<ADPS0);\r
+       \r
+       \r
+       uint16_t ares[16],sum;\r
+       uint8_t par=0;\r
+       sum=0;\r
+       for(uint8_t i=0;i<16;i++) {\r
+               //sum+=ares[i];\r
+               sum+=ADmess();\r
+       }\r
+       par=0;\r
+       wdcounter=0;\r
+       gcontrol=1;\r
+\r
+    while(1)   {\r
+               if (wdcounter>0) {\r
+//                     ares[par]=ADmess();\r
+                       par++;\r
+                       if (par>15) par=0;\r
+                       wdcounter=0;\r
+                       sum=0;\r
+                       for(uint8_t i=0;i<16;i++) {\r
+                               //sum+=ares[i];\r
+                               sum+=ADmess();\r
+                       }\r
+\r
+\r
+               }\r
+               if (gcontrol) {\r
+                       PORTB|=(1<<PORTB0);\r
+                       //V=sum/20.0/1024.0*1.12*1000.0/16.0;\r
+                       //V=sum/20.0/1024.0*1.01*1000.0/16.0;\r
+                       V=sum/1024.0*182-55*16-16;\r
+                       if (V>125*16) V=125*16;\r
+                       if (V<-55*16) V=-55*16;\r
+               \r
+                       uint16_t htemp=V;\r
+               \r
+                       uint8_t t8=pack.temp>>4;\r
+                       uint8_t af=0;\r
+                       if (t8>pack.TH) af=1;\r
+                       if (t8<=pack.TL) af=1;\r
+                       cli();\r
+                       pack.temp=htemp;\r
+                       alarmflag=af;\r
+                       sei();\r
+                       EXTERN_SLEEP();\r
+                       PORTB&=~(1<<PORTB0);\r
+               }\r
+\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+//                     CLKPR=(1<<CLKPCE);\r
+       //              CLKPR=(1<<CLKPS2); /*0.5Mhz*/\r
+//                     PORTB&=~(1<<PINB1);\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+               asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS18B20_ADC/DS18B20_ADC.cproj b/DS18B20_ADC/DS18B20_ADC.cproj
new file mode 100644 (file)
index 0000000..26f10fe
--- /dev/null
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_TC</AssemblyName>\r
+    <Name>DS18B20_ADC</Name>\r
+    <RootNamespace>DS18B20_TC</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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
+    <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.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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\OWDS18B20.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS18B20.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS18B20_ADC.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
index 78bb7d6..8cfc5a6 100644 (file)
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/BMP280.h"\r
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/BMP280.h"\r
+#include "../common/owSlave_tools.h"\r
 \r
 \r
 \r
 \r
-extern void OWINIT();\r
-extern void EXTERN_SLEEP();\r
+#define OWST_EXTERN_VARS\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -54,10 +54,7 @@ uint8_t config_info[26]={0x02,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,14,0x0
 #error "Variable not correct"\r
 #endif\r
 \r
 #error "Variable not correct"\r
 #endif\r
 \r
-extern uint8_t mode;\r
-extern uint8_t gcontrol;\r
-extern uint8_t reset_indicator;\r
-extern uint8_t alarmflag;\r
+\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -84,7 +81,8 @@ volatile pack_t pack;
 \r
 \r
 int main(void){\r
 \r
 \r
 int main(void){\r
-    PRR|=(1<<PRADC);  // adc for save Power\r
+    OWST_INIT_USI_ON\r
+       \r
        pack.temp=0x0550;\r
        pack.config=0x7F;\r
        pack.TH=75;\r
        pack.temp=0x0550;\r
        pack.config=0x7F;\r
        pack.TH=75;\r
@@ -92,15 +90,14 @@ int main(void){
        pack.rrFF=0xFF;\r
        pack.rr00=0;\r
        pack.rr10=0x10;\r
        pack.rrFF=0xFF;\r
        pack.rr00=0;\r
        pack.rr10=0x10;\r
-       PORTA=0xFF;\r
-       PORTB=0xFF;\r
+       \r
        OWINIT();\r
 \r
        OWINIT();\r
 \r
-       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-       MCUCR |=(1<<BODS);\r
-\r
-       MCUSR=0;\r
+       OWST_EN_PULLUP\r
        USI_TWI_Master_Initialise();\r
        USI_TWI_Master_Initialise();\r
+       _delay_ms(500);\r
+       bmp280Init();\r
+       _delay_ms(50);\r
        bmp280Init();\r
        //DDRB|=(1<<PINB1);\r
        gcontrol=1;\r
        bmp280Init();\r
        //DDRB|=(1<<PINB1);\r
        gcontrol=1;\r
@@ -128,23 +125,8 @@ int main(void){
                        //PORTB&=~(1<<PINB1);\r
                }\r
 \r
                        //PORTB&=~(1<<PINB1);\r
                }\r
 \r
-               \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
-#endif                 \r
-#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
-                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
-#endif\r
-                         {\r
+               OWST_MAIN_END\r
 \r
 \r
-                       MCUCR|=(1<<SE)|(1<<SM1);\r
-                       MCUCR&=~(1<<ISC01);\r
-               } else {\r
-                       MCUCR|=(1<<SE);\r
-                       MCUCR&=~(1<<SM1);\r
-               }\r
-               //MCUCR&=~(1<<ISC01);\r
-               asm("SLEEP");\r
    }\r
 \r
 \r
    }\r
 \r
 \r
index 68c6f87..005cf10 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
     <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
     </AsfFrameworkConfig>\r
-    <avrtool>custom</avrtool>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
       <ToolOptions>\r
         <InterfaceProperties>\r
     <com_atmel_avrdbg_tool_atmelice>\r
       <ToolOptions>\r
         <InterfaceProperties>\r
@@ -62,8 +62,7 @@
       <ToolName>Simulator</ToolName>\r
     </com_atmel_avrdbg_tool_simulator>\r
     <ExternalProgrammingToolCommand />\r
       <ToolName>Simulator</ToolName>\r
     </com_atmel_avrdbg_tool_simulator>\r
     <ExternalProgrammingToolCommand />\r
-    <avrtoolserialnumber>\r
-    </avrtoolserialnumber>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
     <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
     <custom>\r
       <ToolOptions xmlns="">\r
     <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
     <custom>\r
       <ToolOptions xmlns="">\r
@@ -76,6 +75,8 @@
       </ToolNumber>\r
       <ToolName xmlns="">Custom Programming Tool</ToolName>\r
     </custom>\r
       </ToolNumber>\r
       <ToolName xmlns="">Custom Programming Tool</ToolName>\r
     </custom>\r
+    <ResetRule>0</ResetRule>\r
+    <EraseKey />\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
-    <Compile Include="..\common\I2C\SHT2x.c">\r
-      <SubType>compile</SubType>\r
-      <Link>SHT2x.c</Link>\r
-    </Compile>\r
     <Compile Include="..\common\calibr.c">\r
       <SubType>compile</SubType>\r
       <Link>calibr.c</Link>\r
     <Compile Include="..\common\calibr.c">\r
       <SubType>compile</SubType>\r
       <Link>calibr.c</Link>\r
       <SubType>compile</SubType>\r
       <Link>BMP280.c</Link>\r
     </Compile>\r
       <SubType>compile</SubType>\r
       <Link>BMP280.c</Link>\r
     </Compile>\r
-    <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
       <SubType>compile</SubType>\r
       <SubType>compile</SubType>\r
-      <Link>USI_TWI_Master.c</Link>\r
+      <Link>TWI_Master.c</Link>\r
     </Compile>\r
     <Compile Include="..\common\OWDS18B20_DS2438.S">\r
       <SubType>compile</SubType>\r
     </Compile>\r
     <Compile Include="..\common\OWDS18B20_DS2438.S">\r
       <SubType>compile</SubType>\r
index e379db8..4dc0ba0 100644 (file)
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
-#include "../common/I2C/USI_TWI_Master.h"\r
-#include "../common/I2C/SHT2x.h"\r
+#include "../common/I2C/TWI_Master.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
 #include "../common/I2C/BMP280.h"\r
 #include "../common/calibr.h"\r
 #include "../common/I2C/BMP280.h"\r
 #include "../common/calibr.h"\r
+#include "../common/owSlave_tools.h"\r
 \r
 \r
-extern void OWINIT();\r
-extern void EXTERN_SLEEP();\r
+OWST_EXTERN_VARS\r
 \r
 \r
 uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/\r
 \r
 \r
 uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/\r
@@ -53,37 +53,8 @@ uint8_t config_info1[26]={0x02,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,14,0x
 uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
 \r
        \r
 uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
 \r
        \r
-#if (owid>128) \r
-#error "Variable not correct"\r
-#endif\r
-\r
-extern uint8_t mode;\r
-extern uint8_t gcontrol;\r
-extern uint8_t reset_indicator;\r
-extern uint8_t alarmflag;\r
-volatile uint8_t wdcounter=3;\r
-\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
-       #else\r
-       ISR(WDT_vect) {\r
-       \r
-#endif \r
-       //sleep_disable();          // Disable Sleep on Wakeup\r
-       wdcounter++;\r
-       if (reset_indicator==1) reset_indicator++;\r
-       else if (reset_indicator==2) mode=0;\r
-/*     if (timeout==2) {\r
-               DIS_TIMER;\r
-               EN_OWINT;\r
-               mode=OWM_SLEEP;\r
-       }\r
-       timeout++;*/\r
-       //sleep_enable();           // Enable Sleep Mode\r
-\r
-}\r
 \r
 \r
+OWST_WDT_ISR\r
 \r
 typedef union {\r
        volatile uint8_t bytes[8];\r
 \r
 typedef union {\r
        volatile uint8_t bytes[8];\r
@@ -132,43 +103,23 @@ volatile pack2_t pack2;
 \r
 \r
 \r
 \r
 \r
 \r
-volatile int16_t am2302_temp;\r
-volatile uint16_t am2302_hum;\r
+volatile int16_t DS2438_2_TEMP;\r
+volatile uint16_t DS2438_2_VAD;\r
+volatile uint16_t DS2438_2_VDD=0x01F4;\r
 \r
 \r
+OWST_TESTSW\r
 \r
 \r
-int testSW(void) {\r
-       uint8_t r;\r
-       DDRB&=~(1<<PORTB0);  //Eingang\r
-       __asm__ __volatile__ ("nop");\r
-       PORTB|=(1<<PORTB0); //Pullup\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       r=PINB&(1<<PORTB0);\r
-       __asm__ __volatile__ ("nop");\r
-       PORTB&=~(1<<PORTB0);\r
-       __asm__ __volatile__ ("nop");\r
-       DDRB|=(1<<PORTB0);  //Eingang\r
-       return (r==0);\r
-       \r
-       \r
-}\r
 \r
 uint8_t userRegister[1];\r
 int16_t sRH,sT;\r
 \r
 uint8_t userRegister[1];\r
 int16_t sRH,sT;\r
-volatile double temperatureC,humidityRH;\r
+double temperatureC,humidityRH;\r
 volatile double l;\r
        uint32_t P;\r
        int32_t t;\r
 \r
 int main(void){\r
 volatile double l;\r
        uint32_t P;\r
        int32_t t;\r
 \r
 int main(void){\r
-    PRR|=(1<<PRADC);  // adc for save Power\r
-       PORTA=0xFF;\r
-       PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
-       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
-       \r
+        OWST_INIT_USI_ON\r
+   \r
        pack1.temp=0x0550;\r
        pack1.config=0x7F;\r
        pack1.TH=75;\r
        pack1.temp=0x0550;\r
        pack1.config=0x7F;\r
        pack1.TH=75;\r
@@ -179,69 +130,53 @@ int main(void){
        PORTA=0xFF;\r
        PORTB=0xFF;\r
        OWINIT();\r
        PORTA=0xFF;\r
        PORTB=0xFF;\r
        OWINIT();\r
+       OWST_EN_PULLUP\r
 \r
 \r
-       ACSR|=(1<<ACD);  //Disable Comparator\r
-       ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
-       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-       //MCUCR &=~(1<<BODS);\r
-\r
+       OWST_WDR_CONFIG8\r
        \r
        \r
-       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
-       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
-       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
        if (testSW()) {\r
        if (testSW()) {\r
-               config_info2[5]=8;\r
+               config_info2[5]=12;\r
                }else{\r
                config_info2[5]=7;\r
        }\r
        pack2.page3[0]=0xF1;\r
 \r
        MCUSR=0;\r
                }else{\r
                config_info2[5]=7;\r
        }\r
        pack2.page3[0]=0xF1;\r
 \r
        MCUSR=0;\r
-       USI_TWI_Master_Initialise();\r
+       TWI_Master_Initialise();\r
        \r
        \r
-       SHT2x_SoftReset();\r
-       SHT2x_ReadUserRegister(userRegister);\r
-       //(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT;\r
-       SHT2x_WriteUserRegister(userRegister); //write changed user reg\r
-       // --- measure humidity with "Hold Master Mode (HM)" ---\r
-       //SHT2x_MeasurePoll(HUMIDITY, &sRH);\r
-       // --- measure temperature with "Polling Mode" (no hold master) ---\r
-       //SHT2x_MeasurePoll(TEMP, &sT);\r
-       //-- calculate humidity and temperature --\r
-       //temperatureC = SHT2x_CalcTemperatureC(sT);\r
-       //humidityRH = SHT2x_CalcRH(sRH);\r
+       initSHT2x();\r
+       _delay_ms(10);\r
        bmp280Init();\r
        gcontrol=1;\r
        sei();\r
     while(1)   {\r
        bmp280Init();\r
        gcontrol=1;\r
        sei();\r
     while(1)   {\r
+                \r
                if (gcontrol) {\r
                if (gcontrol) {\r
-                       wdcounter=3;\r
+                       wdcounter=2;\r
                        \r
                }\r
 \r
                if (wdcounter>2) {\r
                        \r
                }\r
 \r
                if (wdcounter>2) {\r
-                       SHT2x_MeasurePoll(HUMIDITY, &sRH);\r
-                       // --- measure temperature with "Polling Mode" (no hold master) ---\r
-                       SHT2x_MeasurePoll(TEMP, &sT);\r
-                       //-- calculate humidity and temperature --\r
-                       temperatureC = SHT2x_CalcTemperatureC(sT);\r
-                       humidityRH = SHT2x_CalcRH(sRH);\r
-                       humidityRH=calibr_hum(temperatureC,-0.45,humidityRH)*10.0;\r
-                       temperatureC=temperatureC*10.0-4.5;\r
+                               getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                               double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
+                               double TC =temperatureC *10.0-2;\r
+\r
                         if (testSW()) {\r
                         if (testSW()) {\r
-                                am2302_hum= humidityRH*10.0;\r
-                                am2302_temp=temperatureC*25.6;\r
+                                       DS2438_2_VAD=RH;\r
+                                       DS2438_2_TEMP=(double)TC*25.6;\r
                                 //am2302_temp=am2302_temp-20;\r
                                 //am2302_temp=am2302_temp-20;\r
-                                config_info2[5]=8;\r
+                                config_info2[5]=12;\r
+                                DS2438_2_VDD=0x01F4;\r
                                 \r
                                 }else{\r
                                 \r
                                 \r
                                 }else{\r
                                 \r
-                                double hhum=(1.0546-0.000216*temperatureC)*(humidityRH);\r
+                                double hhum=(1.0546-0.000216*TC)*(RH);\r
                                 //am2302_hum=0.318*hhum +76.0;\r
                                 //am2302_hum=0.318*hhum +76.0;\r
-                                am2302_hum=0.31*hhum +80;\r
-                                am2302_temp=temperatureC*25.6;\r
+                                DS2438_2_VAD=0.31*hhum +80;\r
+                                DS2438_2_TEMP=TC*25.6;\r
                                 //am2302_temp=am2302_temp-20;\r
                                 config_info2[5]=7;\r
                                 //am2302_temp=am2302_temp-20;\r
                                 config_info2[5]=7;\r
+                                DS2438_2_VDD=0x01F4;\r
                         }\r
                        wdcounter=0;\r
                }\r
                         }\r
                        wdcounter=0;\r
                }\r
@@ -269,23 +204,7 @@ int main(void){
                        \r
                }\r
 \r
                        \r
                }\r
 \r
-               \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
-#endif                 \r
-#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
-                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
-#endif\r
-                         {\r
-\r
-                       MCUCR|=(1<<SE)|(1<<SM1);\r
-                       MCUCR&=~(1<<ISC01);\r
-               } else {\r
-                       MCUCR|=(1<<SE);\r
-                       MCUCR&=~(1<<SM1);\r
-               }\r
-               //MCUCR&=~(1<<ISC01);\r
-               asm("SLEEP");\r
+               OWST_MAIN_END   \r
    }\r
 \r
 \r
    }\r
 \r
 \r
index 1c18216..c9e90b3 100644 (file)
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
+#include "../common/owSlave_tools.h"\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/CDM7160.h"\r
 \r
 \r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/CDM7160.h"\r
 \r
 \r
-extern void OWINIT();\r
-\r
-extern void EXTERN_SLEEP();\r
-\r
+OWST_EXTERN_VARS\r
 \r
 uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/\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
 \r
 uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/\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
-#endif\r
-\r
-extern uint8_t mode;\r
-extern uint8_t gcontrol;\r
-extern uint8_t reset_indicator;\r
-extern uint8_t alarmflag;\r
-volatile uint8_t wdcounter=5;\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
-#else\r
-ISR(WDT_vect) {\r
-#endif \r
-       wdcounter++;\r
-       if (reset_indicator==1) reset_indicator++;\r
-       else if (reset_indicator==2) mode=0;\r
 \r
 \r
-\r
-}\r
-\r
-uint8_t max_adr=0;\r
+OWST_WDT_ISR\r
 \r
 typedef union {\r
        volatile uint8_t bytes[8];\r
 \r
 typedef union {\r
        volatile uint8_t bytes[8];\r
@@ -94,10 +71,10 @@ volatile pack_t pack;
 \r
 \r
 \r
 \r
 \r
 \r
-int main(void){\r
-       PORTB&=~(1<<PINB1);\r
-       DDRB|=(1<<PINB1);\r
-    PRR|=(1<<PRADC);  // adc for save Power\r
+int main(void) {\r
+       OWST_INIT_USI_ON\r
+\r
+\r
        pack.temp=0x0550;\r
        pack.config=0x7F;\r
        pack.TH=75;\r
        pack.temp=0x0550;\r
        pack.config=0x7F;\r
        pack.TH=75;\r
@@ -110,18 +87,11 @@ int main(void){
        OWINIT();\r
        PORTB&=~(1<<PINB1);\r
        DDRB|=(1<<PINB1);\r
        OWINIT();\r
        PORTB&=~(1<<PINB1);\r
        DDRB|=(1<<PINB1);\r
-       \r
-\r
        PORTA&=~(1<<PINA0);\r
 \r
        PORTA&=~(1<<PINA0);\r
 \r
-       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-       MCUCR |=(1<<BODS);\r
-\r
-       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
-       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
-       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+       OWST_EN_PULLUP\r
+       OWST_WDR_CONFIG8\r
 \r
 \r
-       MCUSR=0;\r
        _delay_ms(100);\r
        USI_TWI_Master_Initialise();\r
        CDM7160softReset();\r
        _delay_ms(100);\r
        USI_TWI_Master_Initialise();\r
        CDM7160softReset();\r
@@ -170,22 +140,7 @@ int main(void){
                }\r
 \r
                \r
                }\r
 \r
                \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
-#endif                 \r
-#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
-                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
-#endif\r
-                         {\r
-\r
-                       MCUCR|=(1<<SE)|(1<<SM1);\r
-                       MCUCR&=~(1<<ISC01);\r
-               } else {\r
-                       MCUCR|=(1<<SE);\r
-                       MCUCR&=~(1<<SM1);\r
-               }\r
-               //MCUCR&=~(1<<ISC01);\r
-               asm("SLEEP");\r
+               OWST_MAIN_END\r
    }\r
 \r
 \r
    }\r
 \r
 \r
diff --git a/DS18B20_CDM7160_DS18B20_BMP280/DS18B20_CDM7160_DS18B20_BMP280.atsln b/DS18B20_CDM7160_DS18B20_BMP280/DS18B20_CDM7160_DS18B20_BMP280.atsln
new file mode 100644 (file)
index 0000000..63b74f5
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_CDM7160_DS18B20_BMP280", "DS18B20_CDM7160_DS18B20_BMP280.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS18B20_CDM7160_DS18B20_BMP280/DS18B20_CDM7160_DS18B20_BMP280.cproj b/DS18B20_CDM7160_DS18B20_BMP280/DS18B20_CDM7160_DS18B20_BMP280.cproj
new file mode 100644 (file)
index 0000000..ec53186
--- /dev/null
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS18B20_CDM7160_DS18B20_BMP280</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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>debugWIRE</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
+    <custom>\r
+      <ToolOptions xmlns="">\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>debugWIRE</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType xmlns="">custom</ToolType>\r
+      <ToolNumber xmlns="">\r
+      </ToolNumber>\r
+      <ToolName xmlns="">Custom Programming Tool</ToolName>\r
+    </custom>\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.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
+    </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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\I2C\BMP280.c">\r
+      <SubType>compile</SubType>\r
+      <Link>BMP280.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\CDM7160.c">\r
+      <SubType>compile</SubType>\r
+      <Link>CDM7160.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\OWDS18B20_DS18B20.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS18B20_DS18B20.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS18B20_DS18B20.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS18B20_CDM7160_DS18B20_BMP280/DS18B20_DS18B20.c b/DS18B20_CDM7160_DS18B20_BMP280/DS18B20_DS18B20.c
new file mode 100644 (file)
index 0000000..60adf1e
--- /dev/null
@@ -0,0 +1,180 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/TWI_Master.h"\r
+#include "../common/I2C/CDM7160.h"\r
+#include "../common/I2C/BMP280.h"\r
+#include "../common/owSlave_tools.h"\r
+\r
+OWST_EXTERN_VARS\r
+\r
+\r
+uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x26, 0x05, 0x35};/**/\r
+uint8_t owid2[8]={0x28, 0xA4, 0xD9, 0x84, 0x00, 0x26, 0x05, 0xB0};/**/\r
+\r
+uint8_t config_info1[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
+uint8_t config_info2[26]={0x02,0x03,0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,14,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+       \r
+\r
+OWST_WDT_ISR\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[8];\r
+       struct {\r
+               uint16_t temp;  //0\r
+               uint8_t TH;  //2\r
+               uint8_t TL;  //3\r
+               uint8_t config;  //4\r
+               uint8_t rrFF; //5\r
+               uint8_t rr00; //6\r
+               uint8_t rr10; //7\r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1,pack2;\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+OWST_TESTSW\r
+\r
+\r
+uint8_t userRegister[1];\r
+uint16_t CO2,BMP;\r
+\r
+int main(void){\r
+        OWST_INIT_USI_ON\r
+   \r
+       pack1.temp=0x0550;\r
+       pack1.config=0x7F;\r
+       pack1.TH=75;\r
+       pack1.TL=70;\r
+       pack1.rrFF=0xFF;\r
+       pack1.rr00=0;\r
+       pack1.rr10=0x10;\r
+       PORTA=0xFF;\r
+       PORTB=0xFF;\r
+       OWINIT();\r
+       OWST_EN_PULLUP\r
+\r
+       OWST_WDR_CONFIG8\r
+       \r
+       if (testSW()) {\r
+               config_info2[5]=12;\r
+               }else{\r
+               config_info2[5]=7;\r
+       }\r
+\r
+       MCUSR=0;\r
+       TWI_Master_Initialise();\r
+               bmp280Init();\r
+               _delay_ms(50);\r
+               bmp280Init();\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
+       CO2=CDM7160getCO2();\r
+       CDM7160setMode(1);\r
+       _delay_ms(200);\r
+       gcontrol=1;\r
+       _delay_ms(10);\r
+       gcontrol=1;\r
+       sei();\r
+    while(1)   {\r
+                \r
+               if (gcontrol) {\r
+                       wdcounter=3;\r
+                       \r
+               }\r
+\r
+               if (wdcounter>2) {\r
+                               volatile int16_t l=(int16_t)CDM7160getCO2()-1280;\r
+\r
+                               uint16_t w1=l;\r
+                               uint32_t P;\r
+                               int32_t t;\r
+                               bmp280ConvertInt(&t,&P,1);\r
+                               P=P-70000;\r
+                               P=P/20;\r
+                               uint16_t w2=P;\r
+                               uint8_t t81=w1>>4;\r
+                               uint8_t af1=0;\r
+                               if (t81>pack1.TH) af1=1;\r
+                               if (t81<=pack1.TL) af1=1;\r
+\r
+                               cli();\r
+                               pack1.temp=w1;\r
+                               //pack.temp++;\r
+                               alarmflag=af1;\r
+                               sei();\r
+\r
+\r
+               \r
+                               cli();\r
+                               pack2.temp=w2;\r
+                               sei();\r
+                               //pack.temp++;\r
+                               gcontrol=0;\r
+\r
+                               \r
+\r
+                       wdcounter=0;\r
+               }\r
+       \r
+               if (gcontrol) {\r
+                       gcontrol=0;\r
+                       EXTERN_SLEEP();\r
+                       \r
+               }\r
+\r
+               OWST_MAIN_END   \r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.atsln b/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.atsln
new file mode 100644 (file)
index 0000000..e158f97
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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_DS2438_HDC1080", "DS18B20_CDM7160_DS2438_HDC1080.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.c b/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.c
new file mode 100644 (file)
index 0000000..2c4c57d
--- /dev/null
@@ -0,0 +1,249 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/HDC1080.h"\r
+#include "../common/calibr.h"\r
+#include "../common/I2C/CDM7160.h"\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+\r
+uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x17, 0x05, 0xDC};/**/\r
+uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x17, 0x05, 0xA3};/**/\r
+uint8_t config_info1[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_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,11,0x00,11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+       \r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+\r
+volatile uint8_t wdcounter=5;\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[8];\r
+       struct {\r
+               uint16_t temp;  //0\r
+               uint8_t TH;  //2\r
+               uint8_t TL;  //3\r
+               uint8_t config;  //4\r
+               uint8_t rrFF; //5\r
+               uint8_t rr00; //6\r
+               uint8_t rr10; //7\r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1;\r
+\r
+typedef union {\r
+\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               uint16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               uint8_t page2[8]; //17\r
+               uint8_t page3[8]; //25\r
+               uint8_t page4[8];  //33\r
+               uint8_t page5[8];  //41\r
+               uint8_t page6[8];  //49\r
+               uint8_t page7[8];  //57\r
+               //uint8_t crc;  //65\r
+       };\r
+} pack2_t;\r
+volatile pack2_t pack2;\r
+\r
+\r
+\r
+volatile int16_t am2302_temp;\r
+volatile uint16_t am2302_hum;\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+double temperatureC,humidityRH;\r
+volatile double l;\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
+#else\r
+ISR(WDT_vect) {\r
+#endif \r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+\r
+\r
+}\r
+\r
+int testSW(void) {\r
+       uint8_t r;\r
+       DDRB&=~(1<<PORTB0);  //Eingang\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB|=(1<<PORTB0); //Pullup\r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        r=PINB&(1<<PORTB0);\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB&=~(1<<PORTB0); \r
+        __asm__ __volatile__ ("nop"); \r
+       DDRB|=(1<<PORTB0);  //Eingang\r
+       return (r==0);\r
+        \r
+        \r
+}\r
+\r
+int main(void){\r
+     PRR|=(1<<PRADC);  // adc for save Power\r
+       PORTA=0xFF;\r
+       PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+       \r
+       \r
+       OWINIT();\r
+\r
+       DDRB|=(1<<PINB1);\r
+       PORTB&=~(1<<PINB1);\r
+       PORTA&=~(1<<PINA0);\r
+\r
+       ACSR|=(1<<ACD);  //Disable Comparator\r
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+       MCUCR |=(1<<BODS);\r
+\r
+       \r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+        if (testSW()) {\r
+               config_info2[5]=8;\r
+       }else{\r
+               config_info2[5]=7;\r
+        }\r
+       \r
+    uint8_t i;\r
+    for(i=0;i<64;i++) pack2.bytes[i]=0;\r
+       MCUSR=0;\r
+       USI_TWI_Master_Initialise();\r
+       HDC1080_Init();\r
+       HDC1080_Readf(&temperatureC,&humidityRH);\r
+       \r
+       CDM7160setMode(0); //Power Down Mode\r
+       CDM7160setAvCount(0x3F);\r
+       CDM7160setFMode(1);\r
+       pack1.temp=CDM7160getCO2();\r
+       CDM7160setMode(1);\r
+       gcontrol=1;\r
+       \r
+       sei();\r
+       \r
+        while(1)   {\r
+                if (gcontrol) {\r
+                        wdcounter=3;\r
+                        //gcontrol=0;\r
+                }\r
+                if (wdcounter>2) {\r
+                        //PORTB|=(1<<PINB1); //Dauer 440ms\r
+                        HDC1080_Readf(&temperatureC,&humidityRH);\r
+\r
+                       // humidityRH = calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
+                       // temperatureC-=0.2;\r
+                       humidityRH*=10.0;\r
+                        temperatureC*=10.0;\r
+                       /* if (testSW()) {*/\r
+                                am2302_hum= humidityRH;\r
+                                am2302_temp=temperatureC*25.6;\r
+                                //am2302_temp=am2302_temp-45;\r
+                                config_info2[5]=12;    \r
+                                \r
+/*                      }else{*/\r
+                                \r
+                       /*      double hhum=(1.0546-0.000216*temperatureC)*(humidityRH);\r
+                               //am2302_hum=0.318*hhum +76.0;\r
+                               am2302_hum=0.31*hhum +80;\r
+                               am2302_temp=temperatureC*25.6;\r
+                               //am2302_temp=am2302_temp-45;\r
+                               config_info2[5]=7;*/\r
+                        //}\r
+                        //PORTB&=~(1<<PINB1);\r
+                        wdcounter=0;\r
+                }\r
+\r
+                if ((gcontrol&1)==1) {\r
+                        \r
+                       volatile uint16_t l=CDM7160getCO2();    \r
+                       uint16_t w=l;\r
+                       uint8_t t8=w>>4;\r
+                       uint8_t af=0;\r
+                       if (t8>pack1.TH) af=1;\r
+                       if (t8<=pack1.TL) af=1;\r
+                       cli();\r
+                       pack1.temp=w;\r
+                       //pack.temp++;\r
+                       alarmflag=af;\r
+                       sei();\r
+                       //CDM7160setMode(0);\r
+                       //EXTERN_SLEEP();\r
+                }\r
+                if (gcontrol) {\r
+                        gcontrol=0;\r
+                        \r
+                }\r
+\r
+               if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+               asm("SLEEP");\r
+       }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.cproj b/DS18B20_CDM7160_DS2438_HDC1080/DS18B20_CDM7160_DS2438_HDC1080.cproj
new file mode 100644 (file)
index 0000000..6fa9976
--- /dev/null
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_MAX44009</AssemblyName>\r
+    <Name>DS18B20_CDM7160_DS2438_HDC1080</Name>\r
+    <RootNamespace>DS18B20_MAX44009</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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.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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\CDM7160.c">\r
+      <SubType>compile</SubType>\r
+      <Link>CDM7160.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\HDC1080.c">\r
+      <SubType>compile</SubType>\r
+      <Link>HDC1080.c</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_DS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS18B20_DS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS18B20_CDM7160_DS2438_HDC1080.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS18B20_DS2408/DS18B20_DS2408.atsln b/DS18B20_DS2408/DS18B20_DS2408.atsln
new file mode 100644 (file)
index 0000000..90bc8f1
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_DS2408", "DS18B20_DS2408.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS18B20_DS2408/DS18B20_DS2408.c b/DS18B20_DS2408/DS18B20_DS2408.c
new file mode 100644 (file)
index 0000000..315c589
--- /dev/null
@@ -0,0 +1,245 @@
+\r
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/TWI_Master.h"\r
+#include "../common/owSlave_tools.h"\r
+#include "../common/I2C/SHT3x.h"\r
+#include "../common/calibr.h"\r
+\r
+\r
+#include <math.h>\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+extern uint8_t stat_to_sample;\r
+\r
+uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/\r
+uint8_t owid2[8]={0x29, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x01, 0x73};/**/\r
+uint8_t config_info1[26]={0x01,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+uint8_t config_info2[26]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0,0,0,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+OWST_EXTERN_VARS\r
+\r
+OWST_WDT_ISR\r
+\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[8];\r
+       struct {\r
+               int16_t temp;  //0\r
+               uint8_t TH;  //2\r
+               uint8_t TL;  //3\r
+               uint8_t config;  //4\r
+               uint8_t rrFF; //5\r
+               uint8_t rr00; //6\r
+               uint8_t rr10; //7\r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1;\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               uint8_t PIO_Logic_State;     //         0088h\r
+               uint8_t PIO_Output_Latch_State;\r
+               uint8_t PIO_Activity_Latch_State;\r
+               uint8_t Conditional_Search_Channel_Selection_Mask;\r
+               uint8_t Conditional_Search_Channel_Polarity_Selection;\r
+               uint8_t Status; //008D\r
+               uint8_t FF1;\r
+               uint8_t FF2;\r
+               \r
+       };\r
+} pack2_t;\r
+volatile pack2_t pack2;\r
+\r
+uint8_t values[10];\r
+uint8_t ap=1;\r
+\r
+uint8_t crc8_f() {\r
+       uint8_t lscrc=0x0;\r
+       for(uint8_t i=0;i<5;i++) {\r
+               uint8_t v=values[i];\r
+               //if (v==0) v=0xFF;\r
+               uint8_t bit=1;\r
+               uint8_t lb;\r
+               for(uint8_t j=0;j<8;j++) {\r
+                       if ((v&bit)==bit) lb=1; else lb=0;\r
+                       if ((lscrc&1)!=lb)      lscrc=(lscrc>>1)^0x8c; else     lscrc=(lscrc>>1);\r
+                       bit=bit*2;\r
+               \r
+               \r
+               }\r
+       }\r
+       return lscrc;\r
+}\r
+\r
+\r
+//Umstellung\r
+\r
+//rh=(T-25)*(0,01+0,00008*x)-2,0468+0,0367*x-0,0000015955*x*x\r
+//d1 for 3V\r
+#define d1 -39.7  \r
+#define d2 0.01\r
+inline uint16_t calcSHT75_T(double real_t) {\r
+       return (real_t-d1)/d2;\r
+}\r
+\r
+inline uint16_t calcSHT75RH_lin(double real_RHlin) {\r
+       return 11501.1-0.280297*sqrt(1667284153.0-7977500.0*real_RHlin);\r
+}\r
+\r
+inline double calcSHT75H_tcorr(double real_t,double real_RHtrue) {\r
+       return real_RHtrue-(real_t-25)*(0.01+0.00008*calcSHT75RH_lin(real_RHtrue));\r
+\r
+}\r
+\r
+\r
+double T=20.0;\r
+double RH=60;\r
+\r
+int main(void){\r
+       OWST_INIT_USI_ON;\r
+       pack2.FF1=0xFF;\r
+       pack2.FF2=0xFF;\r
+        //0x0E 0x19 0x48 0x00\r
+        if (RH<8) RH=8;\r
+        uint16_t lt=calcSHT75_T(T);\r
+               double lfc=calcSHT75H_tcorr(T,RH);\r
+        uint16_t lf=calcSHT75RH_lin(lfc);\r
+       values[0]=0x00;\r
+       values[1]=lt&0xFF; if (values[1]==0) values[1]=1;\r
+       values[2]=lt>>8; if (values[2]==0) values[2]=1;\r
+       values[3]=lf&0xFF; if (values[3]==0) values[3]=1;\r
+       values[4]=lf>>8; if (values[4]==0) values[4]=1;\r
+       values[5]=0x5D; \r
+       values[6]=0x00;\r
+       values[7]=0x00;\r
+       values[5]=crc8_f();     \r
+       \r
+       OWINIT();\r
+\r
+       TWI_Master_Initialise();\r
+       initSHT3x(0);\r
+       _delay_ms(100);\r
+\r
+\r
+       getSHT3xHumTemp(0,&T,&RH);\r
+       OWST_WDR_CONFIG8;\r
+       sei();\r
+       stat_to_sample=0x55;\r
+       while (1) {\r
+               //stat_to_sample=0;\r
+               if (reset_indicator) {\r
+               //      ap=0;\r
+               //      stat_to_sample=0;\r
+               //      reset_indicator=0;\r
+               }\r
+               if (wdcounter>3) {\r
+                       \r
+                       wdcounter=0;\r
+                       RH=RH+0.2;\r
+                       getSHT3xHumTemp(0,&T,&RH);\r
+                       //pack1.temp=T*16.0;\r
+                       lt=calcSHT75_T(T);\r
+                       lfc=calcSHT75H_tcorr(T,RH);\r
+                       lf=calcSHT75RH_lin(lfc);\r
+               values[0]=0x00;\r
+               values[1]=lt&0xFF; if (values[1]==0) values[1]=1;\r
+               values[2]=lt>>8; if (values[2]==0) values[2]=1;\r
+               values[3]=lf&0xFF; if (values[3]==0) values[3]=1;\r
+               values[4]=lf>>8; if (values[4]==0) values[4]=1;\r
+                values[5]=crc8_f();\r
+                if (values[5]==0) values[3]=values[3]+1;  //CRC darf nicht 0 sein ... warum auch immer\r
+                values[5]=crc8_f();\r
+               }\r
+               pack2.Status|=0x80;\r
+               if (gcontrol&1) {\r
+                       uint8_t bb=1;\r
+                       for(uint8_t i=0;i<8;i++) {\r
+                               if ((pack2.PIO_Logic_State&bb)!=(pack2.PIO_Output_Latch_State&bb)) pack2.PIO_Activity_Latch_State|=bb;\r
+                               bb=bb*2;\r
+                       }\r
+            pack2.PIO_Logic_State=pack2.PIO_Output_Latch_State;\r
+                       gcontrol&=~0x01;\r
+               }\r
+               if (gcontrol&2) {\r
+                       pack2.PIO_Activity_Latch_State=0;\r
+            gcontrol&=~0x02;\r
+               }\r
+               if (gcontrol&4) {\r
+                       stat_to_sample=values[ap];\r
+                       ap++;           \r
+                       if (ap>5) {\r
+                                       ap=0;\r
+                       }\r
+                       gcontrol&=~0x04;\r
+               }               \r
+               if (gcontrol&8) {\r
+                       ap=1;\r
+                       stat_to_sample=values[ap];\r
+                       ap++;\r
+                       //if (ap>5) ap=1;\r
+                       gcontrol&=~0x08;\r
+               } \r
+               if ((gcontrol&16)==16) {\r
+                       \r
+       \r
+                       uint16_t w=T*16.0;\r
+                       uint8_t t8=w>>4;\r
+                       uint8_t af=0;\r
+                       if (t8>pack1.TH) af=1;\r
+                       if (t8<=pack1.TL) af=1;\r
+                       cli();\r
+                       pack1.temp=w;\r
+                       //pack.temp++;\r
+                       alarmflag=af;\r
+                       sei();\r
+                       gcontrol=0;\r
+                       EXTERN_SLEEP();\r
+               }\r
+\r
+               OWST_MAIN_END\r
+       }\r
+\r
+\r
+\r
+}\r
diff --git a/DS18B20_DS2408/DS18B20_DS2408.cproj b/DS18B20_DS2408/DS18B20_DS2408.cproj
new file mode 100644 (file)
index 0000000..733515c
--- /dev/null
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS18B20_DS2408</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\r
+    <ResetRule>0</ResetRule>\r
+    <EraseKey />\r
+    <com_atmel_avrdbg_tool_simulator>\r
+      <ToolOptions xmlns="">\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>ISP</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType xmlns="">com.atmel.avrdbg.tool.simulator</ToolType>\r
+      <ToolNumber xmlns="">\r
+      </ToolNumber>\r
+      <ToolName xmlns="">Simulator</ToolName>\r
+    </com_atmel_avrdbg_tool_simulator>\r
+    <custom>\r
+      <ToolOptions xmlns="">\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>ISP</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType xmlns="">custom</ToolType>\r
+      <ToolNumber xmlns="">\r
+      </ToolNumber>\r
+      <ToolName xmlns="">Custom Programming Tool</ToolName>\r
+    </custom>\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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT3x.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT3x.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\OWDS18B20_DS2408.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS18B20_DS2408.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS18B20_DS2408.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS18B20_LPS225HB_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_LPS225HB_DS2438_SHT/DS18B20_DS2438.c
new file mode 100644 (file)
index 0000000..a663f2f
--- /dev/null
@@ -0,0 +1,209 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/I2C/LPS225HB.h"\r
+#include "../common/calibr.h"\r
+#include "../common/owSlave_tools.h"\r
+\r
+OWST_EXTERN_VARS\r
+\r
+\r
+uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/\r
+uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/\r
+\r
+uint8_t config_info1[26]={0x02,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+       \r
+\r
+OWST_WDT_ISR\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[8];\r
+       struct {\r
+               uint16_t temp;  //0\r
+               uint8_t TH;  //2\r
+               uint8_t TL;  //3\r
+               uint8_t config;  //4\r
+               uint8_t rrFF; //5\r
+               uint8_t rr00; //6\r
+               uint8_t rr10; //7\r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1;\r
+\r
+\r
+\r
+typedef union {\r
+       #if  defined(__AVR_ATtiny25__)\r
+       volatile uint8_t bytes[16];\r
+       #else\r
+       volatile uint8_t bytes[64];\r
+       #endif\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               uint16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               #if  defined(__AVR_ATtiny25__)\r
+               #else\r
+               uint8_t page2[8]; //17\r
+               uint8_t page3[8]; //25\r
+               uint8_t page4[8];  //33\r
+               uint8_t page5[8];  //41\r
+               uint8_t page6[8];  //49\r
+               uint8_t page7[8];  //57\r
+               //uint8_t crc;  //65\r
+               #endif\r
+       };\r
+} pack2_t;\r
+volatile pack2_t pack2;\r
+\r
+\r
+\r
+\r
+volatile int16_t DS2438_2_TEMP;\r
+volatile uint16_t DS2438_2_VAD;\r
+volatile uint16_t DS2438_2_VDD=0x01F4;\r
+\r
+OWST_TESTSW\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+double temperatureC,humidityRH;\r
+volatile double l;\r
+       uint32_t P;\r
+       int16_t t;\r
+\r
+int main(void){\r
+        OWST_INIT_USI_ON\r
+   \r
+       pack1.temp=0x0550;\r
+       pack1.config=0x7F;\r
+       pack1.TH=75;\r
+       pack1.TL=70;\r
+       pack1.rrFF=0xFF;\r
+       pack1.rr00=0;\r
+       pack1.rr10=0x10;\r
+       PORTA=0xFF;\r
+       PORTB=0xFF;\r
+       OWINIT();\r
+       OWST_EN_PULLUP\r
+\r
+       OWST_WDR_CONFIG8\r
+       \r
+       if (testSW()) {\r
+               config_info2[5]=12;\r
+               }else{\r
+               config_info2[5]=7;\r
+       }\r
+       pack2.page3[0]=0xF1;\r
+\r
+       MCUSR=0;\r
+       USI_TWI_Master_Initialise();\r
+       \r
+       initSHT2x();\r
+       _delay_ms(10);\r
+       LPS225HB_Init();\r
+       gcontrol=1;\r
+       sei();\r
+    while(1)   {\r
+                \r
+               if (gcontrol) {\r
+                       wdcounter=3;\r
+                       \r
+               }\r
+\r
+               if (wdcounter>2) {\r
+                               getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                               double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
+                               double TC =temperatureC *10.0-2;\r
+\r
+                        if (testSW()) {\r
+                                       DS2438_2_VAD=RH;\r
+                                       DS2438_2_TEMP=(double)TC*25.6;\r
+                                //am2302_temp=am2302_temp-20;\r
+                                config_info2[5]=12;\r
+                                \r
+                                }else{\r
+                                \r
+                                double hhum=(1.0546-0.000216*TC)*(RH);\r
+                                //am2302_hum=0.318*hhum +76.0;\r
+                                DS2438_2_VAD=0.31*hhum +80;\r
+                                DS2438_2_TEMP=TC*25.6;\r
+                                //am2302_temp=am2302_temp-20;\r
+                                config_info2[5]=7;\r
+                        }\r
+                       wdcounter=0;\r
+               }\r
+       \r
+               if ((gcontrol&1)==1) {\r
+                       \r
+                                LPS225HB_Readi(&t,&P);\r
+                               P=P-(uint32_t)700*4096;\r
+                               P=(double)P/819.2;\r
+                               uint16_t w=P;\r
+                               uint8_t t8=w>>4;\r
+                               uint8_t af=0;\r
+                               if (t8>pack1.TH) af=1;\r
+                               if (t8<=pack1.TL) af=1;\r
+                               cli();\r
+                               pack1.temp=w;\r
+                               //pack.temp++;\r
+                               alarmflag=af;\r
+                               sei();\r
+                               gcontrol=0;\r
+                               EXTERN_SLEEP(); \r
+               }\r
+               if (gcontrol) {\r
+                       gcontrol=0;\r
+                       \r
+               }\r
+\r
+               OWST_MAIN_END   \r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.atsln b/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.atsln
new file mode 100644 (file)
index 0000000..467ee29
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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_LPS225HB_DS2438_SHT", "DS18B20_LPS225HB_DS2438_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.cproj b/DS18B20_LPS225HB_DS2438_SHT/DS18B20_LPS225HB_DS2438_SHT.cproj
new file mode 100644 (file)
index 0000000..35eade1
--- /dev/null
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS18B20_LPS225HB_DS2438_SHT</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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>debugWIRE</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
+    <custom>\r
+      <ToolOptions xmlns="">\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>debugWIRE</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType xmlns="">custom</ToolType>\r
+      <ToolNumber xmlns="">\r
+      </ToolNumber>\r
+      <ToolName xmlns="">Custom Programming Tool</ToolName>\r
+    </custom>\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.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
+    </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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\LPS225HB.c">\r
+      <SubType>compile</SubType>\r
+      <Link>LPS225HB.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</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_DS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS18B20_DS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS18B20_DS2438.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
index 4aeb0e8..1ebcf7c 100644 (file)
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/MAX44009.h"\r
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/MAX44009.h"\r
+#include "../common/owSlave_tools.h"\r
 \r
 \r
-\r
-extern void OWINIT();\r
-\r
-extern void EXTERN_SLEEP();\r
-\r
-\r
+OWST_EXTERN_VARS\r
+//-D__4MHZ__\r
 uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/\r
 uint8_t config_info[26]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
        \r
 uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/\r
 uint8_t config_info[26]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,15,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
-#endif\r
-\r
-extern uint8_t mode;\r
-extern uint8_t gcontrol;\r
-extern uint8_t reset_indicator;\r
-extern uint8_t alarmflag;\r
-\r
 \r
 uint8_t max_adr=0;\r
 \r
 \r
 uint8_t max_adr=0;\r
 \r
@@ -84,7 +72,7 @@ volatile pack_t pack;
 \r
 \r
 int main(void){\r
 \r
 \r
 int main(void){\r
-    PRR|=(1<<PRADC);  // adc for save Power\r
+       OWST_INIT_USI_ON\r
        pack.temp=0x0550;\r
        pack.config=0x7F;\r
        pack.TH=75;\r
        pack.temp=0x0550;\r
        pack.config=0x7F;\r
        pack.TH=75;\r
@@ -92,14 +80,9 @@ int main(void){
        pack.rrFF=0xFF;\r
        pack.rr00=0;\r
        pack.rr10=0x10;\r
        pack.rrFF=0xFF;\r
        pack.rr00=0;\r
        pack.rr10=0x10;\r
-       PORTA=0xFF;\r
-       PORTB=0xFF;\r
-       OWINIT();\r
-\r
-       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-       MCUCR |=(1<<BODS);\r
 \r
 \r
-       MCUSR=0;\r
+       OWINIT();\r
+       OWST_EN_PULLUP\r
        USI_TWI_Master_Initialise();\r
        if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;\r
        \r
        USI_TWI_Master_Initialise();\r
        if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;\r
        \r
@@ -108,7 +91,7 @@ int main(void){
        sei();\r
     while(1)   {\r
        \r
        sei();\r
     while(1)   {\r
        \r
-               if (gcontrol) {\r
+               if ((gcontrol&1)==1) {\r
                        //PORTB|=(1<<PINB1); //Dauer 2.3ms\r
                        volatile double l=MAX44009getlux(max_adr);              \r
                        if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045\r
                        //PORTB|=(1<<PINB1); //Dauer 2.3ms\r
                        volatile double l=MAX44009getlux(max_adr);              \r
                        if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045\r
@@ -124,27 +107,13 @@ int main(void){
                        //pack.temp++;\r
                        alarmflag=af;\r
                        sei();  \r
                        //pack.temp++;\r
                        alarmflag=af;\r
                        sei();  \r
+                       gcontrol=0;\r
                        EXTERN_SLEEP();         \r
                        //PORTB&=~(1<<PINB1);\r
                }\r
 \r
                \r
                        EXTERN_SLEEP();         \r
                        //PORTB&=~(1<<PINB1);\r
                }\r
 \r
                \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
-#endif                 \r
-#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
-                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
-#endif\r
-                         {\r
-\r
-                       MCUCR|=(1<<SE)|(1<<SM1);\r
-                       MCUCR&=~(1<<ISC01);\r
-               } else {\r
-                       MCUCR|=(1<<SE);\r
-                       MCUCR&=~(1<<SM1);\r
-               }\r
-               //MCUCR&=~(1<<ISC01);\r
-               asm("SLEEP");\r
+               OWST_MAIN_END\r
    }\r
 \r
 \r
    }\r
 \r
 \r
index a63a3cf..a7f4f2b 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
     <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
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
@@ -46,7 +46,7 @@
         <InterfaceName>debugWIRE</InterfaceName>\r
       </ToolOptions>\r
       <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
         <InterfaceName>debugWIRE</InterfaceName>\r
       </ToolOptions>\r
       <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
-      <ToolNumber>J41800000779</ToolNumber>\r
+      <ToolNumber>J41800000789</ToolNumber>\r
       <ToolName>Atmel-ICE</ToolName>\r
     </com_atmel_avrdbg_tool_atmelice>\r
     <avrtoolinterface>debugWIRE</avrtoolinterface>\r
       <ToolName>Atmel-ICE</ToolName>\r
     </com_atmel_avrdbg_tool_atmelice>\r
     <avrtoolinterface>debugWIRE</avrtoolinterface>\r
       <ToolName>Simulator</ToolName>\r
     </com_atmel_avrdbg_tool_simulator>\r
     <ExternalProgrammingToolCommand />\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
   </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.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
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
index 4e8d28b..efd0454 100644 (file)
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/MAX44009.h"\r
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/MAX44009.h"\r
-#include "../common/I2C/SHT2x.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/calibr.h"\r
+#include "../common/owSlave_tools.h"\r
 \r
 \r
 \r
 \r
-extern void OWINIT();\r
-extern void EXTERN_SLEEP();\r
-\r
+OWST_EXTERN_VARS\r
 \r
 uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/\r
 uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/\r
 uint8_t config_info1[26]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
 uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
 \r
 \r
 uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/\r
 uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/\r
 uint8_t config_info1[26]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
 uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
 \r
-\r
-       \r
-#if (owid>128) \r
-#error "Variable not correct"\r
-#endif\r
-\r
-extern uint8_t mode;\r
-extern uint8_t gcontrol;\r
-extern uint8_t reset_indicator;\r
-extern uint8_t alarmflag;\r
-volatile uint8_t wdcounter=5;\r
-\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
-#else\r
-ISR(WDT_vect) {\r
-#endif \r
-       //sleep_disable();          // Disable Sleep on Wakeup\r
-       wdcounter++;\r
-       if (reset_indicator==1) reset_indicator++;\r
-       else if (reset_indicator==2) mode=0;\r
-/*     if (timeout==2) {\r
-               DIS_TIMER;\r
-               EN_OWINT;\r
-               mode=OWM_SLEEP;\r
-       }\r
-       timeout++;*/\r
-       //sleep_enable();           // Enable Sleep Mode\r
-\r
-}\r
-\r
-int testSW(void) {\r
-       uint8_t r;\r
-       DDRB&=~(1<<PORTB0);  //Eingang\r
-       __asm__ __volatile__ ("nop");\r
-       PORTB|=(1<<PORTB0); //Pullup\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       r=PINB&(1<<PORTB0);\r
-       __asm__ __volatile__ ("nop");\r
-       PORTB&=~(1<<PORTB0);\r
-       __asm__ __volatile__ ("nop");\r
-       DDRB|=(1<<PORTB0);  //Eingang\r
-       return (r==0);\r
-       \r
+OWST_WDT_ISR\r
        \r
        \r
-}\r
+OWST_TESTSW\r
 \r
 \r
 typedef union {\r
 \r
 \r
 typedef union {\r
@@ -150,21 +102,17 @@ typedef union {
 volatile pack2_t pack2;\r
 \r
 \r
 volatile pack2_t pack2;\r
 \r
 \r
+volatile int16_t DS2438_2_TEMP;\r
+volatile uint16_t DS2438_2_VAD;\r
+volatile uint16_t DS2438_2_VDD=0x01F4;\r
 \r
 \r
-\r
-volatile int16_t am2302_temp;\r
-volatile uint16_t am2302_hum;\r
-\r
-\r
-uint8_t userRegister[1];\r
-int16_t sRH,sT;\r
-volatile double temperatureC,humidityRH;\r
-volatile double l;\r
+double temperatureC,humidityRH;\r
+double l;\r
 \r
 uint8_t max_adr=0;\r
 \r
 int main(void){\r
 \r
 uint8_t max_adr=0;\r
 \r
 int main(void){\r
-    PRR|=(1<<PRADC);  // adc for save Power\r
+    OWST_INIT_USI_ON\r
        pack1.temp=0x0550;\r
        pack1.config=0x7F;\r
        pack1.TH=75;\r
        pack1.temp=0x0550;\r
        pack1.config=0x7F;\r
        pack1.TH=75;\r
@@ -172,40 +120,22 @@ int main(void){
        pack1.rrFF=0xFF;\r
        pack1.rr00=0;\r
        pack1.rr10=0x10;\r
        pack1.rrFF=0xFF;\r
        pack1.rr00=0;\r
        pack1.rr10=0x10;\r
-       PORTA=0xFF;\r
-       PORTB=0xFF;\r
        OWINIT();\r
        OWINIT();\r
-\r
-       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-       MCUCR |=(1<<BODS);\r
-\r
-       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
-       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
-       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+       OWST_EN_PULLUP\r
+       OWST_WDR_CONFIG8\r
        if (testSW()) {\r
        if (testSW()) {\r
-               config_info2[5]=8;\r
+               config_info2[5]=12;\r
                }else{\r
                config_info2[5]=7;\r
        }\r
                }else{\r
                config_info2[5]=7;\r
        }\r
-       MCUSR=0;\r
        sei();\r
        USI_TWI_Master_Initialise();\r
        if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;\r
        sei();\r
        USI_TWI_Master_Initialise();\r
        if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;\r
-       SHT2x_SoftReset();\r
-       SHT2x_ReadUserRegister(userRegister);\r
-       //(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT;\r
-       SHT2x_WriteUserRegister(userRegister); //write changed user reg\r
-       // --- measure humidity with "Hold Master Mode (HM)" ---\r
-       SHT2x_MeasurePoll(HUMIDITY, &sRH);\r
-       // --- measure temperature with "Polling Mode" (no hold master) ---\r
-       SHT2x_MeasurePoll(TEMP, &sT);\r
-       //-- calculate humidity and temperature --\r
-       //temperatureC = SHT2x_CalcTemperatureC(sT);\r
-       //humidityRH = SHT2x_CalcRH(sRH);\r
+       _delay_ms(10);\r
        \r
        \r
+       initSHT2x();\r
        gcontrol=1;\r
        sei();\r
        gcontrol=1;\r
        sei();\r
-       //DDRB|=(1<<PINB1);\r
     while(1)   {\r
                if ((gcontrol&2)==2){\r
                        wdcounter=3;\r
     while(1)   {\r
                if ((gcontrol&2)==2){\r
                        wdcounter=3;\r
@@ -214,28 +144,26 @@ int main(void){
                }\r
                \r
                if (wdcounter>2) {\r
                }\r
                \r
                if (wdcounter>2) {\r
-                       //PORTB|=(1<<PINB1); //Dauer 440ms\r
-                       SHT2x_MeasurePoll(HUMIDITY, &sRH);\r
-                       // --- measure temperature with "Polling Mode" (no hold master) ---\r
-                       SHT2x_MeasurePoll(TEMP, &sT);\r
-                       //-- calculate humidity and temperature --\r
-                       temperatureC = SHT2x_CalcTemperatureC(sT)*10.0-2;\r
-                       humidityRH = SHT2x_CalcRH(sRH)*10.0+5;\r
-                       if (humidityRH>1000) humidityRH=1000;\r
-                       if (testSW()) {\r
-                               am2302_hum= humidityRH*10.0;\r
-                               am2302_temp=temperatureC*25.6;\r
-                               //\r
-                               config_info2[5]=8;\r
-                               \r
-                       }else{\r
-                               \r
-                               double hhum=(1.0546-0.000216*temperatureC)*(humidityRH);\r
-                               //am2302_hum=0.318*hhum +76.0;\r
-                               am2302_hum=0.31*hhum +80;\r
-                               am2302_temp=temperatureC*25.6;\r
-                               //am2302_temp=am2302_temp-45;\r
-                               config_info2[5]=7;\r
+                               getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                               double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
+                               double TC =temperatureC *10.0-2;\r
+\r
+                               if (testSW()) {\r
+                                       DS2438_2_VAD=RH;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
+                                       //am2302_temp=am2302_temp-20;\r
+                                       config_info2[5]=12;\r
+                                       DS2438_2_VDD=0x01F4;\r
+                                       \r
+                               }else{\r
+                                       \r
+                                        double hhum=(1.0546-0.000216*TC)*(RH);\r
+                                       //am2302_hum=0.318*hhum +76.0;\r
+                                       DS2438_2_VAD=0.31*hhum +80;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
+                                       //am2302_temp=am2302_temp-20;\r
+                                       config_info2[5]=7;\r
+                                       DS2438_2_VDD=0x01F4;\r
                        }\r
                        wdcounter=0;\r
                }\r
                        }\r
                        wdcounter=0;\r
                }\r
@@ -258,24 +186,7 @@ int main(void){
                        sei();                  \r
                        EXTERN_SLEEP();         \r
                }\r
                        sei();                  \r
                        EXTERN_SLEEP();         \r
                }\r
-               \r
-\r
-               \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
-#endif                 \r
-#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
-                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
-#endif\r
-                         {\r
-\r
-                       MCUCR|=(1<<SE)|(1<<SM1);\r
-                       MCUCR&=~(1<<ISC01);\r
-               } else {\r
-                       MCUCR|=(1<<SE);\r
-                       MCUCR&=~(1<<SM1);\r
-               }\r
-               asm("SLEEP");\r
+               OWST_MAIN_END\r
    }\r
 \r
 \r
    }\r
 \r
 \r
index c14dc8d..f7036ac 100644 (file)
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
-    <Compile Include="..\common\I2C\SHT2x.c">\r
+    <Compile Include="..\common\calibr.c">\r
       <SubType>compile</SubType>\r
       <SubType>compile</SubType>\r
-      <Link>SHT2x.c</Link>\r
+      <Link>calibr.c</Link>\r
     </Compile>\r
     <Compile Include="..\common\I2C\MAX44009.c">\r
       <SubType>compile</SubType>\r
       <Link>MAX44009.c</Link>\r
     </Compile>\r
     </Compile>\r
     <Compile Include="..\common\I2C\MAX44009.c">\r
       <SubType>compile</SubType>\r
       <Link>MAX44009.c</Link>\r
     </Compile>\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</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 Include="..\common\I2C\USI_TWI_Master.c">\r
       <SubType>compile</SubType>\r
       <Link>USI_TWI_Master.c</Link>\r
diff --git a/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_DS18B20.c b/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_DS18B20.c
new file mode 100644 (file)
index 0000000..562a5f8
--- /dev/null
@@ -0,0 +1,168 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/I2C/BMP280.h"\r
+#include "../common/calibr.h"\r
+#include "../common/owSlave_tools.h"\r
+\r
+OWST_EXTERN_VARS\r
+\r
+\r
+uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x26, 0x05, 0x35};/**/\r
+uint8_t owid2[8]={0x28, 0xA4, 0xD9, 0x84, 0x00, 0x26, 0x05, 0xB0};/**/\r
+\r
+uint8_t config_info1[26]={0x01,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+uint8_t config_info2[26]={0x04,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,7,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+       \r
+\r
+OWST_WDT_ISR\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[8];\r
+       struct {\r
+               uint16_t temp;  //0\r
+               uint8_t TH;  //2\r
+               uint8_t TL;  //3\r
+               uint8_t config;  //4\r
+               uint8_t rrFF; //5\r
+               uint8_t rr00; //6\r
+               uint8_t rr10; //7\r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1,pack2;\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+OWST_TESTSW\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+double temperatureC,humidityRH;\r
+volatile double l;\r
+       uint32_t P;\r
+       int32_t t;\r
+\r
+int main(void){\r
+        OWST_INIT_USI_ON\r
+   \r
+       pack1.temp=0x0550;\r
+       pack1.config=0x7F;\r
+       pack1.TH=75;\r
+       pack1.TL=70;\r
+       pack1.rrFF=0xFF;\r
+       pack1.rr00=0;\r
+       pack1.rr10=0x10;\r
+       PORTA=0xFF;\r
+       PORTB=0xFF;\r
+       OWINIT();\r
+       OWST_EN_PULLUP\r
+\r
+       OWST_WDR_CONFIG8\r
+       \r
+       if (testSW()) {\r
+               config_info2[5]=12;\r
+               }else{\r
+               config_info2[5]=7;\r
+       }\r
+\r
+       MCUSR=0;\r
+       USI_TWI_Master_Initialise();\r
+       \r
+       initSHT2x();\r
+       _delay_ms(10);\r
+       gcontrol=1;\r
+       sei();\r
+    while(1)   {\r
+                \r
+               if (gcontrol) {\r
+                       wdcounter=3;\r
+                       \r
+               }\r
+\r
+               if (wdcounter>2) {\r
+                               getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                               double RH=calibr_hum(temperatureC,-0.2,humidityRH)*16.0;\r
+                               double TC =(temperatureC+0.2) *16.0;\r
+                               uint16_t w1=TC;\r
+                               uint8_t t81=w1>>4;\r
+                               uint8_t af1=0;\r
+                               if (t81>pack1.TH) af1=1;\r
+                               if (t81<=pack1.TL) af1=1;\r
+\r
+                               cli();\r
+                               pack1.temp=w1;\r
+                               //pack.temp++;\r
+                               alarmflag=af1;\r
+                               sei();\r
+\r
+\r
+                               uint16_t w2=RH;\r
+               \r
+                               cli();\r
+                               pack2.temp=w2;\r
+                               sei();\r
+                               //pack.temp++;\r
+                               gcontrol=0;\r
+\r
+                               \r
+\r
+                       wdcounter=0;\r
+               }\r
+       \r
+               if (gcontrol) {\r
+                       gcontrol=0;\r
+                       EXTERN_SLEEP();\r
+                       \r
+               }\r
+\r
+               OWST_MAIN_END   \r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.atsln b/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.atsln
new file mode 100644 (file)
index 0000000..4a55022
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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_SHT_DS18B20_SHT", "DS18B20_SHT_DS18B20_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.cproj b/DS18B20_SHT2X_DS18B20_SHT2X/DS18B20_SHT_DS18B20_SHT.cproj
new file mode 100644 (file)
index 0000000..9ed54df
--- /dev/null
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS18B20_SHT_DS18B20_SHT</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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>debugWIRE</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
+    <custom>\r
+      <ToolOptions xmlns="">\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>debugWIRE</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType xmlns="">custom</ToolType>\r
+      <ToolNumber xmlns="">\r
+      </ToolNumber>\r
+      <ToolName xmlns="">Custom Programming Tool</ToolName>\r
+    </custom>\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.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
+    </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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</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_DS18B20.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS18B20_DS18B20.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS18B20_DS18B20.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_DS18B20.c b/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_DS18B20.c
new file mode 100644 (file)
index 0000000..cc06287
--- /dev/null
@@ -0,0 +1,167 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/SHT3x.h"\r
+#include "../common/calibr.h"\r
+#include "../common/owSlave_tools.h"\r
+\r
+OWST_EXTERN_VARS\r
+\r
+\r
+uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x26, 0x05, 0x35};/**/\r
+uint8_t owid2[8]={0x28, 0xA4, 0xD9, 0x84, 0x00, 0x26, 0x05, 0xB0};/**/\r
+\r
+uint8_t config_info1[26]={0x01,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+uint8_t config_info2[26]={0x04,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,7,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+       \r
+\r
+OWST_WDT_ISR\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[8];\r
+       struct {\r
+               uint16_t temp;  //0\r
+               uint8_t TH;  //2\r
+               uint8_t TL;  //3\r
+               uint8_t config;  //4\r
+               uint8_t rrFF; //5\r
+               uint8_t rr00; //6\r
+               uint8_t rr10; //7\r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1,pack2;\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+OWST_TESTSW\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+double temperatureC,humidityRH;\r
+volatile double l;\r
+       uint32_t P;\r
+       int32_t t;\r
+\r
+int main(void){\r
+        OWST_INIT_USI_ON\r
+   \r
+       pack1.temp=0x0550;\r
+       pack1.config=0x7F;\r
+       pack1.TH=75;\r
+       pack1.TL=70;\r
+       pack1.rrFF=0xFF;\r
+       pack1.rr00=0;\r
+       pack1.rr10=0x10;\r
+       PORTA=0xFF;\r
+       PORTB=0xFF;\r
+       OWINIT();\r
+       OWST_EN_PULLUP\r
+\r
+       OWST_WDR_CONFIG8\r
+       \r
+       if (testSW()) {\r
+               config_info2[5]=12;\r
+               }else{\r
+               config_info2[5]=7;\r
+       }\r
+\r
+       MCUSR=0;\r
+       USI_TWI_Master_Initialise();\r
+       \r
+       initSHT3x(0);\r
+       _delay_ms(10);\r
+       gcontrol=1;\r
+       sei();\r
+    while(1)   {\r
+                \r
+               if (gcontrol) {\r
+                       wdcounter=3;\r
+                       \r
+               }\r
+\r
+               if (wdcounter>2) {\r
+                               getSHT3xHumTemp(0,&temperatureC,&humidityRH);\r
+                               double RH=calibr_hum(temperatureC,-0.2,humidityRH)*16.0;\r
+                               double TC =(temperatureC+0.2) *16.0;\r
+                               uint16_t w1=TC;\r
+                               uint8_t t81=w1>>4;\r
+                               uint8_t af1=0;\r
+                               if (t81>pack1.TH) af1=1;\r
+                               if (t81<=pack1.TL) af1=1;\r
+\r
+                               cli();\r
+                               pack1.temp=w1;\r
+                               //pack.temp++;\r
+                               alarmflag=af1;\r
+                               sei();\r
+\r
+\r
+                               uint16_t w2=RH;\r
+               \r
+                               cli();\r
+                               pack2.temp=w2;\r
+                               sei();\r
+                               //pack.temp++;\r
+                               gcontrol=0;\r
+\r
+                               \r
+\r
+                       wdcounter=0;\r
+               }\r
+       \r
+               if (gcontrol) {\r
+                       gcontrol=0;\r
+                       EXTERN_SLEEP();\r
+                       \r
+               }\r
+\r
+               OWST_MAIN_END   \r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.atsln b/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.atsln
new file mode 100644 (file)
index 0000000..4a55022
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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_SHT_DS18B20_SHT", "DS18B20_SHT_DS18B20_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.cproj b/DS18B20_SHT3X_DS18B20_SHT3X/DS18B20_SHT_DS18B20_SHT.cproj
new file mode 100644 (file)
index 0000000..f4f3054
--- /dev/null
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS18B20_SHT_DS18B20_SHT</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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>debugWIRE</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
+    <custom>\r
+      <ToolOptions xmlns="">\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>debugWIRE</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType xmlns="">custom</ToolType>\r
+      <ToolNumber xmlns="">\r
+      </ToolNumber>\r
+      <ToolName xmlns="">Custom Programming Tool</ToolName>\r
+    </custom>\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.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
+    </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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT3x.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT3x.c</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_DS18B20.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS18B20_DS18B20.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS18B20_DS18B20.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
index a12b106..d3dd73d 100644 (file)
@@ -34,7 +34,7 @@
   <documentation help="" />\r
   <offline-documentation help="" />\r
   <dependencies>\r
   <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
   </dependencies>\r
 </framework-data>\r
     </AsfFrameworkConfig>\r
         <InterfaceName>debugWIRE</InterfaceName>\r
       </ToolOptions>\r
       <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
         <InterfaceName>debugWIRE</InterfaceName>\r
       </ToolOptions>\r
       <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
-      <ToolNumber>J41800000779</ToolNumber>\r
+      <ToolNumber>J41800000789</ToolNumber>\r
       <ToolName>Atmel-ICE</ToolName>\r
     </com_atmel_avrdbg_tool_atmelice>\r
     <avrtoolinterface>debugWIRE</avrtoolinterface>\r
     <ExternalProgrammingToolCommand />\r
       <ToolName>Atmel-ICE</ToolName>\r
     </com_atmel_avrdbg_tool_atmelice>\r
     <avrtoolinterface>debugWIRE</avrtoolinterface>\r
     <ExternalProgrammingToolCommand />\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\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.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
     </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
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
index 4927b99..8ffaa53 100644 (file)
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
-#include "../common/I2C/SHT2x.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/owSlave_tools.h"\r
 \r
 \r
+OWST_EXTERN_VARS\r
 \r
 \r
-extern void OWINIT();\r
-extern void EXTERN_SLEEP();\r
+//#define K_Type\r
+#define J_Type\r
 \r
 \r
+#ifdef K_Type\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
 //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
+#endif\r
+#ifdef J_Type\r
+#define k_ofs 0\r
+//J-Type\r
+const float k_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
+#endif\r
 \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+k_ofs);\r
        float t0=pgm_read_float(&(k_rs[iv]));\r
 double gettemp_rs(double V) {\r
        uint8_t iv=(uint8_t)(V+k_ofs);\r
        float t0=pgm_read_float(&(k_rs[iv]));\r
@@ -66,55 +74,8 @@ uint8_t owid2[8]={0x26, 0xA7, 0xD9, 0x84, 0x00, 0x00, 0x03, 0x20};/**/
 uint8_t config_info1[26]={0x01,0x02 ,0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; \r
 uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};    \r
        \r
 uint8_t config_info1[26]={0x01,0x02 ,0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; \r
 uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,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
-#endif\r
-\r
-extern uint8_t mode;\r
-extern uint8_t gcontrol;\r
-extern uint8_t reset_indicator;\r
-extern uint8_t alarmflag;\r
-volatile uint8_t wdcounter=5;\r
-\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
-#else\r
-ISR(WDT_vect) {\r
-#endif \r
-       //sleep_disable();          // Disable Sleep on Wakeup\r
-       wdcounter++;\r
-       if (reset_indicator==1) reset_indicator++;\r
-       else if (reset_indicator==2) mode=0;\r
-/*     if (timeout==2) {\r
-               DIS_TIMER;\r
-               EN_OWINT;\r
-               mode=OWM_SLEEP;\r
-       }\r
-       timeout++;*/\r
-       //sleep_enable();           // Enable Sleep Mode\r
-\r
-}\r
-\r
-int testSW(void) {\r
-       uint8_t r;\r
-       DDRB&=~(1<<PORTB0);  //Eingang\r
-       __asm__ __volatile__ ("nop");\r
-       PORTB|=(1<<PORTB0); //Pullup\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       __asm__ __volatile__ ("nop");\r
-       r=PINB&(1<<PORTB0);\r
-       __asm__ __volatile__ ("nop");\r
-       PORTB&=~(1<<PORTB0);\r
-       __asm__ __volatile__ ("nop");\r
-       DDRB|=(1<<PORTB0);  //Eingang\r
-       return (r==0);\r
-       \r
-       \r
-}\r
+OWST_WDT_ISR\r
+OWST_TESTSW\r
 \r
 \r
 typedef union {\r
 \r
 \r
 typedef union {\r
@@ -177,20 +138,19 @@ double ADmess() {
        return (double)ADC;\r
 }\r
 \r
        return (double)ADC;\r
 }\r
 \r
-volatile int16_t am2302_temp;\r
-volatile uint16_t am2302_hum;\r
+volatile int16_t DS2438_2_TEMP;\r
+volatile uint16_t DS2438_2_VAD;\r
+volatile uint16_t DS2438_2_VDD=0x01F4;\r
 \r
 \r
 \r
 \r
-uint8_t userRegister[1];\r
-int16_t sRH,sT;\r
-volatile double temperatureC,humidityRH;\r
-volatile double l;\r
 \r
 \r
-uint8_t max_adr=0;\r
+double temperatureC,humidityRH;\r
+double TC;\r
+double l;\r
 \r
 int main(void){\r
 \r
 int main(void){\r
-    //PRR|=(1<<PRADC);  // adc for save Power\r
-       pack1.temp=0x0550;\r
+       OWST_INIT_ALL_ON\r
+       pack1.temp=0x0550;\r
        pack1.config=0x7F;\r
        pack1.TH=75;\r
        pack1.TL=70;\r
        pack1.config=0x7F;\r
        pack1.TH=75;\r
        pack1.TL=70;\r
@@ -198,35 +158,22 @@ int main(void){
        pack1.rr00=0;\r
        pack1.rr10=0x10;\r
        PORTA=0xFF-(1<<PINA1)-(1<<PINA2);\r
        pack1.rr00=0;\r
        pack1.rr10=0x10;\r
        PORTA=0xFF-(1<<PINA1)-(1<<PINA2);\r
-       PORTB=0xFF;\r
        OWINIT();\r
 \r
        OWINIT();\r
 \r
-       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-       MCUCR |=(1<<BODS);\r
+       OWST_EN_PULLUP\r
+       OWST_WDR_CONFIG1        \r
 \r
 \r
-       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
-       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
-       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~1 seconds\r
        if (testSW()) {\r
        if (testSW()) {\r
-               config_info2[5]=8;\r
+               config_info2[5]=12;\r
                }else{\r
                config_info2[5]=7;\r
        }\r
                }else{\r
                config_info2[5]=7;\r
        }\r
-       MCUSR=0;\r
        USI_TWI_Master_Initialise();\r
        USI_TWI_Master_Initialise();\r
-       SHT2x_SoftReset();\r
-       SHT2x_ReadUserRegister(userRegister);\r
-       //(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT;\r
-       SHT2x_WriteUserRegister(userRegister); //write changed user reg\r
-       // --- measure humidity with "Hold Master Mode (HM)" ---\r
-       SHT2x_MeasurePoll(HUMIDITY, &sRH);\r
-       // --- measure temperature with "Polling Mode" (no hold master) ---\r
-       SHT2x_MeasurePoll(TEMP, &sT);\r
-       //-- calculate humidity and temperature --\r
-       //temperatureC = SHT2x_CalcTemperatureC(sT);\r
-       //humidityRH = SHT2x_CalcRH(sRH);\r
-       \r
+       initSHT2x();\r
+               \r
        gcontrol=1;\r
        gcontrol=1;\r
+       for(uint8_t i=0;i<8;i++) pack2.page6[i]=owid1[i];\r
+       pack2.page3[0]=0xF1;\r
        sei();\r
        ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);\r
        //DDRB|=(1<<PINB1);\r
        sei();\r
        ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);\r
        //DDRB|=(1<<PINB1);\r
@@ -247,46 +194,43 @@ int main(void){
                \r
                if (wdcounter>0) {\r
                        if (par==0) {\r
                \r
                if (wdcounter>0) {\r
                        if (par==0) {\r
-                               //PORTB|=(1<<PINB1); //Dauer 440ms\r
-                               SHT2x_MeasurePoll(HUMIDITY, &sRH);\r
-                               // --- measure temperature with "Polling Mode" (no hold master) ---\r
-                               SHT2x_MeasurePoll(TEMP, &sT);\r
-                               //-- calculate humidity and temperature --\r
-                               temperatureC = SHT2x_CalcTemperatureC(sT)*10.0-2;\r
-                               humidityRH = SHT2x_CalcRH(sRH)*10.0+5;\r
-                               if (humidityRH>1000) humidityRH=1000;\r
+                               getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                               double RH=humidityRH*10.0;\r
+                                TC =temperatureC *10.0;\r
+\r
                                if (testSW()) {\r
                                if (testSW()) {\r
-                                       am2302_hum= humidityRH*10.0;\r
-                                       am2302_temp=temperatureC*25.6;\r
-                                       //\r
-                                       config_info2[5]=8;\r
-                               }else{\r
-                                       double hhum=(1.0546-0.000216*temperatureC)*(humidityRH);\r
-                                       //am2302_hum=0.318*hhum +76.0;\r
-                                       am2302_hum=0.31*hhum +80;\r
-                                       am2302_temp=temperatureC*25.6;\r
-                                       //am2302_temp=am2302_temp-45;\r
+                                       DS2438_2_VAD=RH;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
+               \r
+                                       config_info2[5]=12;\r
+                                       \r
+                                       }else{\r
+                                       \r
+                                       double hhum=(1.0546-0.000216*TC)*(RH);\r
+                                       DS2438_2_VAD=0.31*hhum +80;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
                                        config_info2[5]=7;\r
                                }\r
                        }\r
                                        config_info2[5]=7;\r
                                }\r
                        }\r
+                       DS2438_2_VDD=0x01F4;\r
                        ares[par]=ADmess();\r
                        par++;\r
                        if (par>15) par=0;\r
                        wdcounter=0;\r
                }\r
        \r
                        ares[par]=ADmess();\r
                        par++;\r
                        if (par>15) par=0;\r
                        wdcounter=0;\r
                }\r
        \r
-               if (gcontrol==1) {\r
+               if ((gcontrol&1)==1) {\r
                        gcontrol=0;\r
                        sum=0;\r
                        for(uint8_t i=0;i<16;i++) {\r
                                sum+=ares[i];\r
                        }\r
                        gcontrol=0;\r
                        sum=0;\r
                        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;//Spannung in mV\r
+                       V=sum/20.0/1024.0*1.18*1000.0/16.0;//Spannung in mV\r
                        //V=sum/20.0/1024.0*1.01*1000.0/16.0;\r
                        int16_t htemp;\r
                        ktemp=gettemp_rs(V);\r
                        //htemp=(ktemp*16)/10;\r
                        //V=sum/20.0/1024.0*1.01*1000.0/16.0;\r
                        int16_t htemp;\r
                        ktemp=gettemp_rs(V);\r
                        //htemp=(ktemp*16)/10;\r
-                       htemp=(ktemp*16+temperatureC*1.6)/10;\r
+                       htemp=(ktemp*16+TC*1.6)/10;\r
 \r
                        int16_t w=htemp;\r
                        int8_t t8=w>>4;\r
 \r
                        int16_t w=htemp;\r
                        int8_t t8=w>>4;\r
index 2e0e72c..1dd9222 100644 (file)
@@ -1,22 +1,22 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Atmel Studio Solution File, Format Version 11.00
-VisualStudioVersion = 14.0.23107.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS18B20_Thermocouble_DS2438_SHT", "DS18B20_Thermocouble_DS2438_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|AVR = Debug|AVR
-               Release|AVR = Release|AVR
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR
-               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR
-               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR
-               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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_Thermocouble_DS2438_SHT", "DS18B20_Thermocouble_DS2438_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
index 738bf15..752c526 100644 (file)
@@ -34,7 +34,7 @@
   <documentation help="" />\r
   <offline-documentation help="" />\r
   <dependencies>\r
   <documentation help="" />\r
   <offline-documentation help="" />\r
   <dependencies>\r
-    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.34.1" />\r
   </dependencies>\r
 </framework-data>\r
     </AsfFrameworkConfig>\r
   </dependencies>\r
 </framework-data>\r
     </AsfFrameworkConfig>\r
@@ -63,6 +63,8 @@
       <ToolName>Simulator</ToolName>\r
     </com_atmel_avrdbg_tool_simulator>\r
     <ExternalProgrammingToolCommand />\r
       <ToolName>Simulator</ToolName>\r
     </com_atmel_avrdbg_tool_simulator>\r
     <ExternalProgrammingToolCommand />\r
+    <ResetRule>0</ResetRule>\r
+    <EraseKey />\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
-    <Compile Include="..\common\I2C\SHT2x.c">\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
       <SubType>compile</SubType>\r
       <SubType>compile</SubType>\r
-      <Link>SHT2x.c</Link>\r
+      <Link>SHT2xV2.c</Link>\r
     </Compile>\r
     <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
       <SubType>compile</SubType>\r
     </Compile>\r
     <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
       <SubType>compile</SubType>\r
index 5b3461c..2522a0e 100644 (file)
@@ -42,9 +42,9 @@
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/SHT2xV2.h"\r
 #include "../common/calibr.h"\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include "../common/I2C/SHT2xV2.h"\r
 #include "../common/calibr.h"\r
+#include "../common/owSlave_tools.h"\r
 \r
 \r
-extern void OWINIT(void);\r
-extern void EXTERN_SLEEP(void);\r
+OWST_EXTERN_VARS\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -58,24 +58,11 @@ volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 11,0x08, 0x0
 #error "Variable not correct"\r
 #endif\r
 \r
 #error "Variable not correct"\r
 #endif\r
 \r
-extern uint8_t mode;\r
-extern uint8_t gcontrol;\r
-extern uint8_t reset_indicator;\r
-extern uint8_t alarmflag;\r
-volatile uint8_t wdcounter=1;\r
 extern uint8_t cpsp;\r
 \r
 extern uint8_t cpsp;\r
 \r
+OWST_WDT_ISR\r
 \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
-       #else\r
-       ISR(WDT_vect) {\r
-               #endif\r
-               wdcounter++;\r
-               if (reset_indicator==1) reset_indicator++;\r
-               else if (reset_indicator==2) mode=0;\r
 \r
 \r
-}\r
 \r
 \r
        typedef union {\r
 \r
 \r
        typedef union {\r
@@ -155,12 +142,13 @@ ISR(WATCHDOG_vect) {
 \r
 \r
 \r
 \r
 \r
 \r
-       volatile int16_t am2302_temp;\r
-       volatile uint16_t am2302_hum;\r
+       volatile int16_t DS2438_2_TEMP;\r
+       volatile uint16_t DS2438_2_VAD;\r
+       volatile uint16_t DS2438_2_VDD=0x01F4;\r
+\r
+       OWST_TESTSW\r
 \r
 \r
 \r
 \r
-       uint8_t userRegister[1];\r
-       int16_t sRH,sT;\r
        double temperatureC,humidityRH,hhum;\r
        volatile double l;\r
 \r
        double temperatureC,humidityRH,hhum;\r
        volatile double l;\r
 \r
@@ -183,25 +171,6 @@ ISR(WATCHDOG_vect) {
        double la[4];\r
        uint8_t lainit=1;\r
 \r
        double la[4];\r
        uint8_t lainit=1;\r
 \r
-       int testSW(void) {\r
-               uint8_t r;\r
-               DDRB&=~(1<<PORTB0);  //Eingang\r
-               __asm__ __volatile__ ("nop");\r
-               PORTB|=(1<<PORTB0); //Pullup\r
-               __asm__ __volatile__ ("nop");\r
-               __asm__ __volatile__ ("nop");\r
-               __asm__ __volatile__ ("nop");\r
-               __asm__ __volatile__ ("nop");\r
-               __asm__ __volatile__ ("nop");\r
-               r=PINB&(1<<PORTB0);\r
-               __asm__ __volatile__ ("nop");\r
-               PORTB&=~(1<<PORTB0);\r
-               __asm__ __volatile__ ("nop");\r
-               DDRB|=(1<<PORTB0);  //Eingang\r
-               return (r==0);  //Offen mal HIH4030\r
-               \r
-               \r
-       }\r
 \r
        \r
        #define EEPROM_R0 0\r
 \r
        \r
        #define EEPROM_R0 0\r
@@ -290,7 +259,7 @@ ISR(WATCHDOG_vect) {
                        weekmaxarr[i]=pack2.r_week_max;\r
                }\r
 \r
                        weekmaxarr[i]=pack2.r_week_max;\r
                }\r
 \r
-\r
+               for(uint8_t i=0;i<8;i++) pack2.page6[i]=owid1[i];\r
                if (testSW()) {\r
                        config_info2[5]=12;\r
                        }else{\r
                if (testSW()) {\r
                        config_info2[5]=12;\r
                        }else{\r
@@ -304,27 +273,7 @@ ISR(WATCHDOG_vect) {
                gcontrol=1;\r
                sei();\r
                while(1)   {\r
                gcontrol=1;\r
                sei();\r
                while(1)   {\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 ((cpsp&0x80)!=0) {\r
                                if ((cpsp&0x0F)==5) {\r
                                        if (pack2.reset_code==0x01) {\r
                        if ((cpsp&0x80)!=0) {\r
                                if ((cpsp&0x0F)==5) {\r
                                        if (pack2.reset_code==0x01) {\r
@@ -390,14 +339,13 @@ ISR(WATCHDOG_vect) {
 \r
 \r
                                if (testSW()) {\r
 \r
 \r
                                if (testSW()) {\r
-                                       am2302_hum=RH;\r
-                                       am2302_temp=TC*25.6;\r
+                                       DS2438_2_VAD=RH;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
                                        config_info2[5]=12;     //10V = 100%\r
                                }else{\r
                                        hhum=(1.0546-0.000216*TC)*(RH);\r
                                        config_info2[5]=12;     //10V = 100%\r
                                }else{\r
                                        hhum=(1.0546-0.000216*TC)*(RH);\r
-                                       //am2302_hum=0.318*hhum +76.0;\r
-                                       am2302_hum=0.31*hhum +80;\r
-                                       am2302_temp=TC*25.6;\r
+                                       DS2438_2_VAD=0.31*hhum +80;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
                                        config_info2[5]=7;\r
                                }\r
                                mr=0;\r
                                        config_info2[5]=7;\r
                                }\r
                                mr=0;\r
@@ -456,7 +404,7 @@ ISR(WATCHDOG_vect) {
                                \r
                        }\r
                        \r
                                \r
                        }\r
                        \r
-                       if (gcontrol==1) {\r
+                       if ((gcontrol&1)==1) {\r
                                uint16_t w=l;\r
                                uint8_t t8=w>>4;\r
                                uint8_t af=0;\r
                                uint16_t w=l;\r
                                uint8_t t8=w>>4;\r
                                uint8_t af=0;\r
@@ -469,27 +417,13 @@ ISR(WATCHDOG_vect) {
                                sei();\r
                                EXTERN_SLEEP();\r
                        }\r
                                sei();\r
                                EXTERN_SLEEP();\r
                        }\r
-                       if ((gcontrol==2)||(gcontrol==3)) {\r
+                       if (gcontrol) {\r
                                gcontrol=0;\r
                                \r
                        }\r
 \r
                        \r
                                gcontrol=0;\r
                                \r
                        }\r
 \r
                        \r
-                       #if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
-                       #endif\r
-                       #if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
-                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
-                       #endif\r
-                       {\r
-\r
-                               MCUCR|=(1<<SE)|(1<<SM1);\r
-                               MCUCR&=~(1<<ISC01);\r
-                       } else {\r
-                               MCUCR|=(1<<SE);\r
-                               MCUCR&=~(1<<SM1);\r
-                       }\r
-                       asm("SLEEP");\r
+                       OWST_MAIN_END\r
                }\r
 \r
 \r
                }\r
 \r
 \r
diff --git a/DS18B20_VOC_DS2438_SHT direct/DS18B20_VOC_DS2438_SHT.atsln b/DS18B20_VOC_DS2438_SHT direct/DS18B20_VOC_DS2438_SHT.atsln
new file mode 100644 (file)
index 0000000..7a42d6d
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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_VOC_DS2438_SHT", "DS18B20_VOC_DS2438_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS18B20_VOC_DS2438_SHT direct/DS18B20_VOC_DS2438_SHT.cproj b/DS18B20_VOC_DS2438_SHT direct/DS18B20_VOC_DS2438_SHT.cproj
new file mode 100644 (file)
index 0000000..24ea432
--- /dev/null
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS18B20_VOC_DS2438_SHT</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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
+    <ResetRule>0</ResetRule>\r
+    <EraseKey />\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.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.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.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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</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_DS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS18B20_DS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS18B20_DS2438.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
index 09b528d..03d0e68 100644 (file)
@@ -456,7 +456,7 @@ int main(void){
                        \r
                }\r
        \r
                        \r
                }\r
        \r
-               if (gcontrol==1) {\r
+               if ((gcontrol&1)==1) {\r
                        uint16_t w=l;\r
                        uint8_t t8=w>>4;\r
                        uint8_t af=0;\r
                        uint16_t w=l;\r
                        uint8_t t8=w>>4;\r
                        uint8_t af=0;\r
diff --git a/DS2408/DS2408.atsln b/DS2408/DS2408.atsln
new file mode 100644 (file)
index 0000000..a06ac81
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2408", "DS2408.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2408/DS2408.c b/DS2408/DS2408.c
new file mode 100644 (file)
index 0000000..fa738a4
--- /dev/null
@@ -0,0 +1,216 @@
+\r
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/TWI_Master.h"\r
+#include "../common/owSlave_tools.h"\r
+#include "../common/I2C/SHT3x.h"\r
+#include "../common/calibr.h"\r
+\r
+\r
+#include <math.h>\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+extern uint8_t stat_to_sample;\r
+\r
+uint8_t owid[8]={0x29, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x01, 0x73};/**/\r
+uint8_t config_info[26]={0x06,0x09,0x06,0x09,0x06,0x09,0x06,0x09,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+OWST_EXTERN_VARS\r
+\r
+OWST_WDT_ISR\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               uint8_t PIO_Logic_State;     //         0088h\r
+               uint8_t PIO_Output_Latch_State;\r
+               uint8_t PIO_Activity_Latch_State;\r
+               uint8_t Conditional_Search_Channel_Selection_Mask;\r
+               uint8_t Conditional_Search_Channel_Polarity_Selection;\r
+               uint8_t Status; //008D\r
+               uint8_t FF1;\r
+               uint8_t FF2;\r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+uint8_t values[10];\r
+uint8_t ap=1;\r
+\r
+uint8_t crc8() {\r
+       uint8_t lscrc=0x0;\r
+       for(uint8_t i=0;i<5;i++) {\r
+               uint8_t v=values[i];\r
+               //if (v==0) v=0xFF;\r
+               uint8_t bit=1;\r
+               uint8_t lb;\r
+               for(uint8_t j=0;j<8;j++) {\r
+                       if ((v&bit)==bit) lb=1; else lb=0;\r
+                       if ((lscrc&1)!=lb)      lscrc=(lscrc>>1)^0x8c; else     lscrc=(lscrc>>1);\r
+                       bit=bit*2;\r
+               \r
+               \r
+               }\r
+       }\r
+       return lscrc;\r
+}\r
+\r
+//Umstellung\r
+\r
+//rh=(T-25)*(0,01+0,00008*x)-2,0468+0,0367*x-0,0000015955*x*x\r
+//d1 for 3V\r
+#define d1 -39.7  \r
+#define d2 0.01\r
+inline uint16_t calcSHT75_T(double real_t) {\r
+       return (real_t-d1)/d2;\r
+}\r
+\r
+inline uint16_t calcSHT75RH_lin(double real_RHlin) {\r
+       return 11501.1-0.280297*sqrt(1667284153.0-7977500.0*real_RHlin);\r
+}\r
+\r
+inline double calcSHT75H_tcorr(double real_t,double real_RHtrue) {\r
+       return real_RHtrue-(real_t-25)*(0.01+0.00008*calcSHT75RH_lin(real_RHtrue));\r
+\r
+}\r
+\r
+\r
+double T=20.0;\r
+double RH=60;\r
+\r
+int main(void){\r
+       OWST_INIT_USI_ON;\r
+       pack.FF1=0xFF;\r
+       pack.FF2=0xFF;\r
+        //0x0E 0x19 0x48 0x00\r
+        if (RH<8) RH=8;\r
+        uint16_t lt=calcSHT75_T(T);\r
+               double lfc=calcSHT75H_tcorr(T,RH);\r
+        uint16_t lf=calcSHT75RH_lin(lfc);\r
+       values[0]=0x00;\r
+       values[1]=lt&0xFF; if (values[1]==0) values[1]=1;\r
+       values[2]=lt>>8; if (values[2]==0) values[2]=1;\r
+       values[3]=lf&0xFF; if (values[3]==0) values[3]=1;\r
+       values[4]=lf>>8; if (values[4]==0) values[4]=1;\r
+       values[5]=0x5D; \r
+               values[1]=8;\r
+               values[2]=26;\r
+               values[3]=0;\r
+               values[4]=5;\r
+               values[5]=0x5D;\r
+       values[6]=0x00;\r
+       values[7]=0x00;\r
+       values[5]=crc8();       \r
+       OWINIT();\r
+\r
+       TWI_Master_Initialise();\r
+       initSHT3x(0);\r
+       _delay_ms(100);\r
+\r
+\r
+       getSHT3xHumTemp(0,&T,&RH);\r
+       OWST_WDR_CONFIG8;\r
+       sei();\r
+       stat_to_sample=0x55;\r
+       while (1) {\r
+               //stat_to_sample=0;\r
+               if (reset_indicator) {\r
+               //      ap=0;\r
+               //      stat_to_sample=0;\r
+               //      reset_indicator=0;\r
+               }\r
+               if (wdcounter>3) {\r
+                       \r
+                       wdcounter=0;\r
+                       RH=RH+0.2;\r
+                       getSHT3xHumTemp(0,&T,&RH);\r
+                       lt=calcSHT75_T(T);\r
+                       lfc=calcSHT75H_tcorr(T,RH);\r
+                       lf=calcSHT75RH_lin(lfc);\r
+               values[0]=0x00;\r
+               values[1]=lt&0xFF; if (values[1]==0) values[1]=1;\r
+               values[2]=lt>>8; if (values[2]==0) values[2]=1;\r
+               values[3]=lf&0xFF; if (values[3]==0) values[3]=1;\r
+               values[4]=lf>>8; if (values[4]==0) values[4]=1;\r
+               values[1]=8;\r
+               values[2]=26;\r
+               values[3]=0;\r
+               values[4]=5;\r
+               values[5]=0x5D;\r
+                values[5]=crc8();\r
+               }\r
+               pack.Status|=0x80;\r
+               if (gcontrol&1) {\r
+                       uint8_t bb=1;\r
+                       for(uint8_t i=0;i<8;i++) {\r
+                               if ((pack.PIO_Logic_State&bb)!=(pack.PIO_Output_Latch_State&bb)) pack.PIO_Activity_Latch_State|=bb;\r
+                               bb=bb*2;\r
+                       }\r
+            pack.PIO_Logic_State=pack.PIO_Output_Latch_State;\r
+                       gcontrol&=~0x01;\r
+               }\r
+               if (gcontrol&2) {\r
+                       pack.PIO_Activity_Latch_State=0;\r
+            gcontrol&=~0x02;\r
+               }\r
+               if (gcontrol&4) {\r
+                       stat_to_sample=values[ap];\r
+                       ap++;           \r
+                       if (ap>5) {\r
+                                       ap=0;\r
+                       }\r
+                       gcontrol&=~0x04;\r
+               }               \r
+               if (gcontrol&8) {\r
+                       ap=1;\r
+                       stat_to_sample=values[ap];\r
+                       ap++;\r
+                       //if (ap>5) ap=1;\r
+                       gcontrol&=~0x08;\r
+               } \r
+\r
+               OWST_MAIN_END\r
+       }\r
+\r
+\r
+\r
+}\r
diff --git a/DS2408/DS2408.cproj b/DS2408/DS2408.cproj
new file mode 100644 (file)
index 0000000..e840c97
--- /dev/null
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2408</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\r
+    <ResetRule>0</ResetRule>\r
+    <EraseKey />\r
+    <com_atmel_avrdbg_tool_simulator>\r
+      <ToolOptions xmlns="">\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>ISP</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType xmlns="">com.atmel.avrdbg.tool.simulator</ToolType>\r
+      <ToolNumber xmlns="">\r
+      </ToolNumber>\r
+      <ToolName xmlns="">Simulator</ToolName>\r
+    </com_atmel_avrdbg_tool_simulator>\r
+    <custom>\r
+      <ToolOptions xmlns="">\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>ISP</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType xmlns="">custom</ToolType>\r
+      <ToolNumber xmlns="">\r
+      </ToolNumber>\r
+      <ToolName xmlns="">Custom Programming Tool</ToolName>\r
+    </custom>\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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT3x.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT3x.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\OWDS2408.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2408.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2408.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2413_DS2413/DS2413_DS2413.atsln b/DS2413_DS2413/DS2413_DS2413.atsln
new file mode 100644 (file)
index 0000000..b201cf3
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2413_DS2413", "DS2413_DS2413.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2413_DS2413/DS2413_DS2413.c b/DS2413_DS2413/DS2413_DS2413.c
new file mode 100644 (file)
index 0000000..75a63a9
--- /dev/null
@@ -0,0 +1,209 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//!!!!!Max Program size 7551 Byte\r
+#define _CPULLUP_\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>  \r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/owSlave_tools.h"\r
+\r
+\r
+//#define FHEM_PLATINE\r
+#define W1DAQ\r
+//#define JOE_M\r
+volatile uint8_t owid1[8]={0x3A, 0x01, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xA3};/**/\r
+volatile uint8_t owid2[8]={0x3A, 0x02, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xFA};/**/\r
+uint8_t config_info1[26]={0,0,0,0,0,0,0,0,0x02,0,0,0,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //+2 for CRC\r
+uint8_t config_info2[26]={0,0,0,0,0,0,0,0,0x02,0,0,0,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //+2 for CRC\r
+       \r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+OWST_EXTERN_VARS\r
+\r
+uint8_t pin_state1;\r
+uint8_t pin_set1;\r
+uint8_t pin_state2;\r
+uint8_t pin_set2;\r
+\r
+OWST_WDT_ISR\r
+\r
+\r
+#if  defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+#define PCINT_VECTOR PCINT0_vect\r
+#define PIN_REG PINA\r
+#define PIN_DDR DDRA\r
+\r
+#ifdef FHEM_PLATINE\r
+#define PIN_PIOA1 (1<<PINA2)\r
+#define PIN_PIOB1 (1<<PINA1)\r
+#define PIN_PIOA2 (1<<PINA3)\r
+#define PIN_PIOB2 (1<<PINA4)\r
+//LEDS\r#define LPIN_CH2 (1<<PINB0)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LPIN_CH3 (1<<PINA5)\r#define LDD_CH3 DDRA\r#define LPORT_CH3 PORTA\r#define LPIN_CH0 (1<<PINA7)\r#define LDD_CH0 DDRA\r#define LPORT_CH0 PORTA\r#define LPIN_CH1 (1<<PINB1)\r#define LDD_CH1 DDRB\r#define LPORT_CH1 PORTB\r
+\r
+#define LED2_ON LPORT_CH2|=LPIN_CH2;\r
+#endif\r
+\r
+#ifdef JOE_M\r
+#define LED2_ON\r
+#define PIN_PIOA1 (1<<PINA4)\r
+#define PIN_PIOB1 (1<<PINA5)\r
+#define PIN_PIOA2 (1<<PINA6)\r
+#define PIN_PIOB2 (1<<PINA7)\r
+#endif\r
+\r
+#ifdef W1DAQ\r
+#define PIN_PIOB1 (1<<PINA1)\r
+#define PIN_PIOA1 (1<<PINA0)\r
+#define PIN_PIOB2 (1<<PINA7)\r
+#define PIN_PIOA2 (1<<PINA3)\r
+//LEDS\r#define LPIN_CH0 (1<<PINB1)\r#define LDD_CH0 DDRB\r#define LPORT_CH0 PORTB\r#define LPIN_CH1 (1<<PINB1)\r#define LDD_CH1 DDRB\r#define LPORT_CH1 PORTB\r#define LPIN_CH2 (1<<PINB1)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LPIN_CH3 (1<<PINB1)\r#define LDD_CH3 DDRB\r#define LPORT_CH3 PORTB\r\r
+#define LED2_ON LPORT_CH2&=~LPIN_CH2;\r
+#endif\r
+\r
+\r
+\r
+#endif\r
+\r
+\r
+ISR(PCINT0_vect) {\r
+//     if (((PIN_REG&PIN_CH2)==0)&&((istat&PIN_CH2)==PIN_CH2)) {       counters1.c32[2]++;     LED2_ON}\r
+       //if (((PIN_REG&PIN_CH3)==0)&&((istat&PIN_CH3)==PIN_CH3)) {     counters1.c32[3]++;LED2_ON      }\r
+       if ((PIN_REG&PIN_PIOA1)==0)     {pin_state1&=~0x1;LED2_ON} else { pin_state1|=0x01;}\r
+       if ((PIN_REG&PIN_PIOB1)==0)     {pin_state1&=~0x4;LED2_ON} else {pin_state1|=0x04;}\r
+       if ((PIN_REG&PIN_PIOA2)==0)     {pin_state2&=~0x1;LED2_ON} else {pin_state2|=0x01;}\r
+       if ((PIN_REG&PIN_PIOB2)==0)     {pin_state2&=~0x4;LED2_ON} else {pin_state2|=0x04;}\r
+       //Reset Switch on the FHEM_BOARD\r
+               GIFR|=(1<<PCIF0);\r\r\r\r
+}\r
+\r
+\r
+\r
+\r
+\r
+int main(void){\r
+       OWST_INIT_ALL_OFF\r
+       OWINIT();\r
+       \r
+\r
+#if  defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+\r
+    OWST_WDR_CONFIG4\r
+       \r
+#ifndef _CPULLUP_  // pullup\r
+       PORTA&=~(PIN_PIOA1|PIN_PIOB1);\r
+       PORTA&=~(PIN_PIOA2|PIN_PIOB2);\r
+#endif\r
+\r
+#ifdef FHEM_PLATINE  //LEDs\r
+       LDD_CH0|=LPIN_CH0;\r     LPORT_CH0&=~LPIN_CH0;\r  LDD_CH1|=LPIN_CH1;\r     LPORT_CH1&=~LPIN_CH1;\r  LDD_CH2|=LPIN_CH2;\r     LPORT_CH2&=~LPIN_CH2;\r  LDD_CH3|=LPIN_CH3;\r     LPORT_CH3&=~LPIN_CH3;\r
+#endif\r
+#ifdef W1DAQ\r
+       LDD_CH2|=LPIN_CH2;\r     LPORT_CH2&=~LPIN_CH2;\r#endif\r
+\r
+\r
+       GIMSK|=(1<<PCIE0);\r
+       PCMSK0=(PIN_PIOA1|PIN_PIOB1|PIN_PIOA2|PIN_PIOB2); //Nicht ganz korrekt aber die Bits liegen gleich\r
+\r
+       \r
+       \r
+       #endif\r
+       \r
+       OWST_EN_PULLUP\r
+       \r
+       \r
+#ifdef FHEM_PLATINE\r
+\r
+       LPORT_CH0|=LPIN_CH0;\r   _delay_ms(500);\r        LPORT_CH0&=~LPIN_CH0;\r
+#endif\r
+       pin_set1=0x0F;\r
+       pin_set2=0x0F;\r
+       //pin_state1=0x00;\r
+       //pin_state2=0x00;\r
+       sei();\r
+       while(1)   {\r
+\r
+               if (pin_set1&1) {\r
+                       DDRA&=~(PIN_PIOA1); //Eingang\r
+                       PORTA|=(PIN_PIOA1); //Pullup\r
+                       pin_state1|=2;\r
+               } else {\r
+                       DDRA|=(PIN_PIOA1); //Ausgang\r
+                       PORTA&=~(PIN_PIOA1); //Gegen masse\r
+                       pin_state1&=~2;\r
+               }\r
+               if (pin_set1&2) {\r
+                       pin_state1|=8;\r
+                       DDRA&=~(PIN_PIOB1); //Eingang\r
+                       PORTA|=(PIN_PIOB1); //Pullup\r
+                       } else {\r
+                       DDRA|=(PIN_PIOB1); //Ausgang\r
+                       PORTA&=~(PIN_PIOB1); //Gegen masse\r
+                       pin_state1&=~8;\r
+               }\r
+               if (pin_set2&1) {\r
+                       pin_state2|=2;\r
+                       DDRA&=~(PIN_PIOA2); //Eingang\r
+                       PORTA|=(PIN_PIOA2); //Pullup\r
+                       } else {\r
+                       DDRA|=(PIN_PIOA2); //Ausgang\r
+                       PORTA&=~(PIN_PIOA2); //Gegen masse\r
+                       pin_state2&=~2;\r
+               }\r
+               if (pin_set2&2) {\r
+                       DDRA&=~(PIN_PIOB2); //Eingang\r
+                       PORTA|=(PIN_PIOB2); //Pullup\r
+                       pin_state2|=8;\r
+                       } else {\r
+                       DDRA|=(PIN_PIOB2); //Ausgang\r
+                       PORTA&=~(PIN_PIOB2); //Gegen masse\r
+                       pin_state2&=~8;\r
+               }\r
+#ifdef FHEM_PLATINE\r
+               if (LPORT_CH2&LPIN_CH2) {\r                      _delay_ms(50);\r                 LPORT_CH2&=~LPIN_CH2;\r          }\r
+               if (LPORT_CH1&LPIN_CH1) {\r                      _delay_ms(50);\r                 LPORT_CH1&=~LPIN_CH1;\r          }\r
+#endif\r
+#ifdef W1DAQ\r
+               if ((LPORT_CH2&LPIN_CH2)==0) {\r                 _delay_ms(50);\r                 LPORT_CH2|=LPIN_CH2;\r           }\r
+#endif\r
+               OWST_MAIN_END \r
+       }\r
+\r
+\r
+}\r
+\r
diff --git a/DS2413_DS2413/DS2413_DS2413.cproj b/DS2413_DS2413/DS2413_DS2413.cproj
new file mode 100644 (file)
index 0000000..b5269f4
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS2413_DS2413</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\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.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
+          <IspClock>125000</IspClock>\r
+        </InterfaceProperties>\r
+        <InterfaceName>ISP</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
+    <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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\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.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.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.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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\OWDS2413_DS2413.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2413_DS2413.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2413_DS2413.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
index a44b62b..bac5365 100644 (file)
@@ -42,7 +42,9 @@
 \r
 extern void OWINIT(void);\r
 extern void EXTERN_SLEEP(void);\r
 \r
 extern void OWINIT(void);\r
 extern void EXTERN_SLEEP(void);\r
-#define FHEM_PLATINE\r
+//#define FHEM_PLATINE\r
+//#define JOE_M\r
+#define W1DAQ\r
 \r
 volatile uint8_t owid1[8]={0x1D, 0x1D, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xD9};/**/\r
 volatile uint8_t owid2[8]={0x3A, 0x3A, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xB6};/**/\r
 \r
 volatile uint8_t owid1[8]={0x1D, 0x1D, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xD9};/**/\r
 volatile uint8_t owid2[8]={0x3A, 0x3A, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xB6};/**/\r
@@ -102,12 +104,28 @@ volatile uint8_t changefromeeprom;
 //LEDS\r#define LPIN_CH2 (1<<PINB0)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LPIN_CH3 (1<<PINA5)\r#define LDD_CH3 DDRA\r#define LPORT_CH3 PORTA\r#define LPIN_CH0 (1<<PINA7)\r#define LDD_CH0 DDRA\r#define LPORT_CH0 PORTA\r#define LPIN_CH1 (1<<PINB1)\r#define LDD_CH1 DDRB\r#define LPORT_CH1 PORTB\r
 \r
 #define LED2_ON LPORT_CH2|=LPIN_CH2;\r
 //LEDS\r#define LPIN_CH2 (1<<PINB0)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LPIN_CH3 (1<<PINA5)\r#define LDD_CH3 DDRA\r#define LPORT_CH3 PORTA\r#define LPIN_CH0 (1<<PINA7)\r#define LDD_CH0 DDRA\r#define LPORT_CH0 PORTA\r#define LPIN_CH1 (1<<PINB1)\r#define LDD_CH1 DDRB\r#define LPORT_CH1 PORTB\r
 \r
 #define LED2_ON LPORT_CH2|=LPIN_CH2;\r
-#else\r
+\r
+#endif\r
+\r
+#ifdef JOE_M\r
 #define LED2_ON\r
 #define PIN_CH2 (1<<PINA4)\r
 #define PIN_CH3 (1<<PINA5)\r
 #define LED2_ON\r
 #define PIN_CH2 (1<<PINA4)\r
 #define PIN_CH3 (1<<PINA5)\r
-#define PIN_PIOA (1<<PINA6)\r
-#define PIN_PIOB (1<<PINA7)\r
+#define PIN_CH0 (1<<PINA6)\r
+#define PIN_CH1 (1<<PINA7)\r
+#define PIN_PIOA PIN_CH0\r
+#define PIN_PIOB  PIN_CH1\r
+#endif\r
+\r
+#ifdef W1DAQ\r
+#define PIN_CH3 (1<<PINA1)\r
+#define PIN_CH2 (1<<PINA0)\r
+#define PIN_CH1 (1<<PINA7)\r
+#define PIN_CH0 (1<<PINA3)\r
+#define PIN_PIOA PIN_CH0\r
+#define PIN_PIOB  PIN_CH1\r
+//LEDS\r#define LPIN_CH0 (1<<PINB1)\r#define LDD_CH0 DDRB\r#define LPORT_CH0 PORTB\r#define LPIN_CH1 (1<<PINB1)\r#define LDD_CH1 DDRB\r#define LPORT_CH1 PORTB\r#define LPIN_CH2 (1<<PINB1)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LPIN_CH3 (1<<PINB1)\r#define LDD_CH3 DDRB\r#define LPORT_CH3 PORTB\r\r
+#define LED2_ON LPORT_CH2&=~LPIN_CH2;\r
 #endif\r
 \r
 #define TEST_TIMER  ((TIMSK0 & (1<<TOIE0))==0)\r
 #endif\r
 \r
 #define TEST_TIMER  ((TIMSK0 & (1<<TOIE0))==0)\r
@@ -187,7 +205,7 @@ int main(void){
        PORTA&=~(PIN_CH2|PIN_CH3);\r
        #endif\r
 \r
        PORTA&=~(PIN_CH2|PIN_CH3);\r
        #endif\r
 \r
-       #ifdef FHEM_PLATINE  //LEDs\r
+       #if defined(FHEM_PLATINE) || defined(W1DAQ)  //LEDs\r
        LDD_CH0|=LPIN_CH0;\r     LPORT_CH0&=~LPIN_CH0;\r  LDD_CH1|=LPIN_CH1;\r     LPORT_CH1&=~LPIN_CH1;\r  LDD_CH2|=LPIN_CH2;\r     LPORT_CH2&=~LPIN_CH2;\r  LDD_CH3|=LPIN_CH3;\r     LPORT_CH3&=~LPIN_CH3;\r
        #endif\r
 \r
        LDD_CH0|=LPIN_CH0;\r     LPORT_CH0&=~LPIN_CH0;\r  LDD_CH1|=LPIN_CH1;\r     LPORT_CH1&=~LPIN_CH1;\r  LDD_CH2|=LPIN_CH2;\r     LPORT_CH2&=~LPIN_CH2;\r  LDD_CH3|=LPIN_CH3;\r     LPORT_CH3&=~LPIN_CH3;\r
        #endif\r
 \r
@@ -240,7 +258,11 @@ int main(void){
 \r
        LPORT_CH0|=LPIN_CH0;\r   _delay_ms(500);\r        LPORT_CH0&=~LPIN_CH0;\r
 #endif\r
 \r
        LPORT_CH0|=LPIN_CH0;\r   _delay_ms(500);\r        LPORT_CH0&=~LPIN_CH0;\r
 #endif\r
+#ifdef W1DAQ\r
+LPORT_CH0&=~LPIN_CH0;\r
+_delay_ms(500);\rLPORT_CH0|=LPIN_CH0;\r#endif\r
        pin_state=0x0F;\r
        pin_state=0x0F;\r
+       pin_set=0;\r
        sei();\r
        while(1)   {\r
 \r
        sei();\r
        while(1)   {\r
 \r
@@ -265,6 +287,9 @@ int main(void){
                if (LPORT_CH2&LPIN_CH2) {\r                      _delay_ms(50);\r                 LPORT_CH2&=~LPIN_CH2;\r          }\r
                if (LPORT_CH1&LPIN_CH1) {\r                      _delay_ms(50);\r                 LPORT_CH1&=~LPIN_CH1;\r          }\r
 #endif\r
                if (LPORT_CH2&LPIN_CH2) {\r                      _delay_ms(50);\r                 LPORT_CH2&=~LPIN_CH2;\r          }\r
                if (LPORT_CH1&LPIN_CH1) {\r                      _delay_ms(50);\r                 LPORT_CH1&=~LPIN_CH1;\r          }\r
 #endif\r
+#ifdef W1DAQ\r
+if ((LPORT_CH2&LPIN_CH2)==0) {\r        _delay_ms(50);\r LPORT_CH2|=LPIN_CH2;\r}\r
+#endif\r
 #ifndef FHEM_PLATINE\r
                if ((PINB&(1<<PORTB0))==0) {  //Jumper gesetzt ->Ruecksetzen\r
                        for (uint8_t i=2;i<4;i++) {\r
 #ifndef FHEM_PLATINE\r
                if ((PINB&(1<<PORTB0))==0) {  //Jumper gesetzt ->Ruecksetzen\r
                        for (uint8_t i=2;i<4;i++) {\r
index 1dbd395..9166850 100644 (file)
 extern void OWINIT(void);\r
 extern void EXTERN_SLEEP(void);\r
 \r
 extern void OWINIT(void);\r
 extern void EXTERN_SLEEP(void);\r
 \r
+\r
 //#define FHEM_PLATINE\r
 //#define FHEM_PLATINE\r
+//#define JOE_M\r
+#define W1DAQ\r
 \r
 volatile uint8_t owid1[8]={0x1D, 0x40, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xBD};/**/\r
 volatile uint8_t owid2[8]={0x1D, 0x41, 0xDA, 0x84, 0x00, 0x00, 0x05, 0x8A};/**/\r
 \r
 volatile uint8_t owid1[8]={0x1D, 0x40, 0xDA, 0x84, 0x00, 0x00, 0x05, 0xBD};/**/\r
 volatile uint8_t owid2[8]={0x1D, 0x41, 0xDA, 0x84, 0x00, 0x00, 0x05, 0x8A};/**/\r
@@ -102,7 +105,9 @@ volatile uint8_t changefromeeprom;
 //LEDS\r#define LPIN_CH2 (1<<PINB0)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LPIN_CH3 (1<<PINA5)\r#define LDD_CH3 DDRA\r#define LPORT_CH3 PORTA\r#define LPIN_CH0 (1<<PINA7)\r#define LDD_CH0 DDRA\r#define LPORT_CH0 PORTA\r#define LPIN_CH1 (1<<PINB1)\r#define LDD_CH1 DDRB\r#define LPORT_CH1 PORTB\r
 \r
 #define LED2_ON LPORT_CH2|=LPIN_CH2;\r
 //LEDS\r#define LPIN_CH2 (1<<PINB0)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LPIN_CH3 (1<<PINA5)\r#define LDD_CH3 DDRA\r#define LPORT_CH3 PORTA\r#define LPIN_CH0 (1<<PINA7)\r#define LDD_CH0 DDRA\r#define LPORT_CH0 PORTA\r#define LPIN_CH1 (1<<PINB1)\r#define LDD_CH1 DDRB\r#define LPORT_CH1 PORTB\r
 \r
 #define LED2_ON LPORT_CH2|=LPIN_CH2;\r
-#else\r
+#endif\r
+\r
+#ifdef JOE_M\r
 #define LED2_ON\r
 #define PIN_CH2 (1<<PINA4)\r
 #define PIN_CH3 (1<<PINA5)\r
 #define LED2_ON\r
 #define PIN_CH2 (1<<PINA4)\r
 #define PIN_CH3 (1<<PINA5)\r
@@ -110,6 +115,16 @@ volatile uint8_t changefromeeprom;
 #define PIN_CH1 (1<<PINA7)\r
 #endif\r
 \r
 #define PIN_CH1 (1<<PINA7)\r
 #endif\r
 \r
+#ifdef W1DAQ\r
+#define PIN_CH3 (1<<PINA1)\r
+#define PIN_CH2 (1<<PINA0)\r
+#define PIN_CH1 (1<<PINA7)\r
+#define PIN_CH0 (1<<PINA3)\r
+//LEDS\r#define LPIN_CH0 (1<<PINB1)\r#define LDD_CH0 DDRB\r#define LPORT_CH0 PORTB\r#define LPIN_CH1 (1<<PINB1)\r#define LDD_CH1 DDRB\r#define LPORT_CH1 PORTB\r#define LPIN_CH2 (1<<PINB1)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LPIN_CH3 (1<<PINB1)\r#define LDD_CH3 DDRB\r#define LPORT_CH3 PORTB\r\r
+#define LED2_ON LPORT_CH2&=~LPIN_CH2;\r
+#endif\r
+\r
+\r
 #define TEST_TIMER  ((TIMSK0 & (1<<TOIE0))==0)\r
 \r
 #endif\r
 #define TEST_TIMER  ((TIMSK0 & (1<<TOIE0))==0)\r
 \r
 #endif\r
@@ -164,6 +179,9 @@ ISR(ANA_COMP_vect) {
                        CLKPR=0;\r
 #ifdef FHEM_PLATINE\r
                        LPORT_CH1|=LPIN_CH1;\r
                        CLKPR=0;\r
 #ifdef FHEM_PLATINE\r
                        LPORT_CH1|=LPIN_CH1;\r
+#endif\r
+#ifdef W1DAQ\r
+                       LPORT_CH1&=~LPIN_CH1;\r
 #endif\r
                        GIFR|=(1<<INTF0);\r
                }\r
 #endif\r
                        GIFR|=(1<<INTF0);\r
                }\r
@@ -202,7 +220,7 @@ int main(void){
        PORTA&=~(PIN_CH2|PIN_CH3);\r
        #endif\r
 \r
        PORTA&=~(PIN_CH2|PIN_CH3);\r
        #endif\r
 \r
-       #ifdef FHEM_PLATINE  //LEDs\r
+       #if defined(FHEM_PLATINE) || defined(W1DAQ)  //LEDs\r
        LDD_CH0|=LPIN_CH0;\r     LPORT_CH0&=~LPIN_CH0;\r  LDD_CH1|=LPIN_CH1;\r     LPORT_CH1&=~LPIN_CH1;\r  LDD_CH2|=LPIN_CH2;\r     LPORT_CH2&=~LPIN_CH2;\r  LDD_CH3|=LPIN_CH3;\r     LPORT_CH3&=~LPIN_CH3;\r
        #endif\r
 \r
        LDD_CH0|=LPIN_CH0;\r     LPORT_CH0&=~LPIN_CH0;\r  LDD_CH1|=LPIN_CH1;\r     LPORT_CH1&=~LPIN_CH1;\r  LDD_CH2|=LPIN_CH2;\r     LPORT_CH2&=~LPIN_CH2;\r  LDD_CH3|=LPIN_CH3;\r     LPORT_CH3&=~LPIN_CH3;\r
        #endif\r
 \r
@@ -249,16 +267,16 @@ int main(void){
        //ACSR|=(1<<ACD);  //Disable Comparator\r
        ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
        MCUCR &=~(1<<PUD); //All Pins Pullup...\r
        //ACSR|=(1<<ACD);  //Disable Comparator\r
        ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
        MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-       #ifdef FHEM_PLATINE\r
+#ifdef FHEM_PLATINE\r
        DIDR0|=(1<<ADC0D);\r
        PORTA&=~(1<<PINA0);//Disable Pullup\r
        DIDR0|=(1<<ADC0D);\r
        PORTA&=~(1<<PINA0);//Disable Pullup\r
-       #else\r
+#else\r
        DIDR0|=(1<<ADC2D)|(1<<ADC1D); // Disable Digital input on Analog AIN0/AIN1  (PINA1 / PINA2)\r
        PORTA&=~(1<<PINA2); //AIN1\r
        DIDR0|=(1<<ADC2D)|(1<<ADC1D); // Disable Digital input on Analog AIN0/AIN1  (PINA1 / PINA2)\r
        PORTA&=~(1<<PINA2); //AIN1\r
-       #endif\r
+#endif\r
        ACSR&=~(1<<ACD);\r
        ACSR|=(1<<ACIE)|(1<<ACIS1)|(1<<ACIS0)|(1<<ACBG); //Enabble comperator interrupt Rising edge....(1<<ACIS0) -> minus of Comperator falls down -> output of Comperator rises\r
        ACSR&=~(1<<ACD);\r
        ACSR|=(1<<ACIE)|(1<<ACIS1)|(1<<ACIS0)|(1<<ACBG); //Enabble comperator interrupt Rising edge....(1<<ACIS0) -> minus of Comperator falls down -> output of Comperator rises\r
-       #ifdef FHEM_PLATINE\r
+#ifdef FHEM_PLATINE\r
        //Switch std AIN1 to A0\r
        ADCSRA&=~(1<<ADEN);\r
        ADCSRB=(1<<ACME);\r
        //Switch std AIN1 to A0\r
        ADCSRA&=~(1<<ADEN);\r
        ADCSRB=(1<<ACME);\r
@@ -268,14 +286,20 @@ int main(void){
 \r
 \r
        LPORT_CH0|=LPIN_CH0;\r   _delay_ms(500);\r        LPORT_CH0&=~LPIN_CH0;\r
 \r
 \r
        LPORT_CH0|=LPIN_CH0;\r   _delay_ms(500);\r        LPORT_CH0&=~LPIN_CH0;\r
-       #endif\r
+#endif\r
+#ifdef W1DAQ\r
+       LPORT_CH0&=~LPIN_CH0;\r
+       _delay_ms(500);\r        LPORT_CH0|=LPIN_CH0;\r#endif\r
        sei();\r
        while(1)   {\r
        sei();\r
        while(1)   {\r
-               #ifdef FHEM_PLATINE\r
+#ifdef FHEM_PLATINE\r
                if (LPORT_CH2&LPIN_CH2) {\r                      _delay_ms(50);\r                 LPORT_CH2&=~LPIN_CH2;\r          }\r
                if (LPORT_CH1&LPIN_CH1) {\r                      _delay_ms(50);\r                 LPORT_CH1&=~LPIN_CH1;\r          }\r
                if (LPORT_CH2&LPIN_CH2) {\r                      _delay_ms(50);\r                 LPORT_CH2&=~LPIN_CH2;\r          }\r
                if (LPORT_CH1&LPIN_CH1) {\r                      _delay_ms(50);\r                 LPORT_CH1&=~LPIN_CH1;\r          }\r
-               #endif\r
-               #ifndef FHEM_PLATINE\r
+#endif\r
+#ifdef W1DAQ\r
+               if ((LPORT_CH2&LPIN_CH2)==0) {\r                 _delay_ms(50);\r                 LPORT_CH2|=LPIN_CH2;\r           }\r
+#endif\r
+#ifndef FHEM_PLATINE\r
                if ((PINB&(1<<PORTB0))==0) {  //Jumper gesetzt ->Ruecksetzen\r
                        if ((counters1.c32[2]!=0)||(counters1.c32[3]!=0)||(counters2.c32[2]!=0)||(counters2.c32[3]!=0)) {\r
                                counters1.c32[0]++;\r                            counters2.c32[0]++;\r                            for (uint8_t i=2;i<4;i++) {\r
                if ((PINB&(1<<PORTB0))==0) {  //Jumper gesetzt ->Ruecksetzen\r
                        if ((counters1.c32[2]!=0)||(counters1.c32[3]!=0)||(counters2.c32[2]!=0)||(counters2.c32[3]!=0)) {\r
                                counters1.c32[0]++;\r                            counters2.c32[0]++;\r                            for (uint8_t i=2;i<4;i++) {\r
@@ -286,9 +310,20 @@ int main(void){
                        }\r
                }\r
                #endif\r
                        }\r
                }\r
                #endif\r
+               if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       \r
+                       MCUCR&=~(1<<ISC01);\r
+                       } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+               asm("SLEEP");\r
+\r
+/*\r
                MCUCR|=(1<<SE);\r
                MCUCR&=~(1<<SM1);\r
                MCUCR|=(1<<SE);\r
                MCUCR&=~(1<<SM1);\r
-               asm("SLEEP");\r
+               asm("SLEEP");*/\r
        }\r
 \r
 \r
        }\r
 \r
 \r
diff --git a/DS2438_ADC/DS2438_ADC.atsln b/DS2438_ADC/DS2438_ADC.atsln
new file mode 100644 (file)
index 0000000..380f865
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_ADC", "DS2438_ADC.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_ADC/DS2438_ADC.c b/DS2438_ADC/DS2438_ADC.c
new file mode 100644 (file)
index 0000000..625dd0b
--- /dev/null
@@ -0,0 +1,191 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x26, 0xA3, 0xD9, 0x84, 0xDD, 0xDD, 0x05, 0xF9};/**/\r
+uint8_t config_info[26]={0x01,0x06, 0x05,0x08, 0x06,0x08, 0x00,0x00, 0x02,0x09,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+\r
+volatile uint8_t wdcounter;\r
+\r
+\r
+typedef union {\r
+\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               uint16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               uint8_t page2[8]; //17\r
+               uint8_t page3[8]; //25\r
+               uint8_t page4[8];  //33\r
+               uint8_t page5[8];  //41\r
+               uint8_t page6[8];  //49\r
+               uint8_t page7[8];  //57\r
+               //uint8_t crc;  //65\r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+volatile int16_t am2302_temp;\r
+volatile uint16_t am2302_hum;\r
+\r
+\r
+\r
+volatile uint8_t am2302_mode=0;\r
+volatile uint8_t timeout=0;\r
+\r
+\r
+\r
+\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+volatile double temperatureC,humidityRH;\r
+volatile double l;\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
+       #else\r
+ISR(WDT_vect) {\r
+       #endif\r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+}\r
+       \r
+int testSW(void) {\r
+       uint8_t r;\r
+       DDRB&=~(1<<PORTB0);  //Eingang\r
+       __asm__ __volatile__ ("nop");\r
+       PORTB|=(1<<PORTB0); //Pullup\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       r=PINB&(1<<PORTB0);\r
+       __asm__ __volatile__ ("nop");\r
+       PORTB&=~(1<<PORTB0);\r
+       __asm__ __volatile__ ("nop");\r
+       DDRB|=(1<<PORTB0);  //Eingang\r
+       return (r==0);\r
+}\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+       int main(void){\r
+               PRR|=(1<<PRUSI);   //  usi for save Power\r
+               PORTA=0xFF-(1<<PORTA5);  \r
+               PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+               DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+               \r
+               \r
+               OWINIT();\r
+\r
+               ACSR|=(1<<ACD);  //Disable Comparator\r
+               //ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
+               MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+               MCUCR |=(1<<BODS);\r
+               ADCSRA=(1<<ADEN)|(1<ADPS0)|(1<<ADPS2);\r
+               DIDR0|=(1<<ADC5D);\r
+               ADMUX=5; //VCC as ref\r
+               PORTA&=~(1<<PORTA5);  \r
+               // Set up Watch Dog Timer for Inactivity\r
+               WDTCSR |= (1<<WDCE) ;   // Enable the WD Change Bit\r
+               WDTCSR =   (1<<WDIE) |              // Enable WDT Interrupt\r
+                       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~2 seconds           \r
+               \r
+               \r
+               sei();\r
+               \r
+               while(1)   {\r
+                       if (gcontrol) {\r
+                               wdcounter=16;\r
+                               gcontrol=0;\r
+                       }\r
+                       if (wdcounter>=16) {\r
+                               uint16_t sum=0;\r
+                               for(uint8_t i=0;i<16;i++) {\r
+                                       ADCSRA|=(1<<ADSC);\r
+                                       while ((ADCSRA&(1<<ADSC)));\r
+                                       sum=sum+ADC;\r
+                               }\r
+                               //5V=0x03FF0 (16 x 0x3FF)  5V=50C 50C = 50*256\r
+                               am2302_temp=sum*0.782;\r
+                               am2302_hum=sum/32.736;\r
+                               wdcounter=0;\r
+                       }\r
+                       \r
+                       \r
+\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {\r
+                               MCUCR|=(1<<SE)|(1<<SM1);\r
+                               MCUCR&=~(1<<ISC01);\r
+                               } else {\r
+                               MCUCR|=(1<<SE);\r
+                               MCUCR&=~(1<<SM1);\r
+                       }\r
+                       asm("SLEEP");\r
+               }\r
+\r
+\r
+       }
\ No newline at end of file
diff --git a/DS2438_ADC/DS2438_ADC.cproj b/DS2438_ADC/DS2438_ADC.cproj
new file mode 100644 (file)
index 0000000..b7770fe
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2438_DHT22</AssemblyName>\r
+    <Name>DS2438_ADC</Name>\r
+    <RootNamespace>DS2438_DHT22</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\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
+  </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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="..\common\OWDS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_ADC.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.atsln b/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.atsln
new file mode 100644 (file)
index 0000000..0427374
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_ADC_DS2438_ADC", "DS2438_ADC_DS2438_ADC.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.cproj b/DS2438_ADC_DS2438_ADC/DS2438_ADC_DS2438_ADC.cproj
new file mode 100644 (file)
index 0000000..c3e44e3
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS2438_ADC_DS2438_ADC</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\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.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.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.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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\OWDS2438_DS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438_DS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_DS2438.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2438_ADC_DS2438_ADC/DS2438_DS2438.c b/DS2438_ADC_DS2438_ADC/DS2438_DS2438.c
new file mode 100644 (file)
index 0000000..b9a7040
--- /dev/null
@@ -0,0 +1,241 @@
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//!!!!!Max Program size 7551 Byte\r
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>  \r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/owSlave_tools.h"\r
+\r
+\r
+OWST_EXTERN_VARS\r
+OWST_WDT_ISR\r
+\r
+\r
+//#define W1DAQ\r
+#define JOE_M\r
+volatile uint8_t owid1[8]={0x26, 0x61, 0xDA, 0x84, 0x00, 0x00, 0x03, 0x43};/**/\r
+volatile uint8_t owid2[8]={0x26, 0x62, 0xDA, 0x84, 0x00, 0x00, 0x03, 0x1A};/**/\r
+volatile uint8_t config_info1[26]={6,6,6,0x08, 6,8, 0x00,0x00, 0x02,20,20,20,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};  \r
+volatile uint8_t config_info2[26]={6,6, 6,0x08,6,8, 0,0, 0x02,20,20,20,0,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};   \r
+       \r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+#ifdef JOE_M\r
+#define PIN_PIOA1 (1<<PINA4)\r
+#define ADMA1 PINA4\r
+#define PIN_PIOB1 (1<<PINA5)\r
+#define ADMB1 PINA5\r
+#define PIN_PIOA2 (1<<PINA6)\r
+#define ADMA2 PINA6\r
+#define PIN_PIOB2 (1<<PINA7)\r
+#define ADMB2 PINA7\r
+#define ADDIFF1 0b011010\r
+#define ADDIFF1G 0b011011\r
+#define ADDIFF2 0b011110\r
+#define ADDIFF2G 0b011111\r
+#endif\r
+\r
+#ifdef W1DAQ\r
+#define PIN_PIOB1 (1<<PINA1)\r
+#define ADMB1 PINA1\r
+#define PIN_PIOA1 (1<<PINA0)\r
+#define ADMA1 PINA0\r
+#define PIN_PIOB2 (1<<PINA7)\r
+#define ADMB2 PINA7\r
+#define PIN_PIOA2 (1<<PINA3)\r
+#define ADMA2 PINA3\r
+#define ADDIFF1 0b001000\r
+#define ADDIFF1G 0b001001\r
+#define ADDIFF2 0b011000\r
+#define ADDIFF2G 0b011001\r
+\r
+#endif\r
+\r
+\r
+\r
+\r
+\r
+typedef union {\r
+       #if  defined(__AVR_ATtiny25__)\r
+       volatile uint8_t bytes[16];\r
+       #else\r
+       volatile uint8_t bytes[64];\r
+       #endif\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               int16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               #if  defined(__AVR_ATtiny25__)\r
+               #else\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
+               uint8_t page7[8];  //57\r
+               \r
+               #endif\r
+       };\r
+} pack_t;\r
+volatile pack_t pack2,pack1;\r
+\r
+\r
+\r
+volatile int16_t DS2438_1_TEMP;\r
+volatile uint16_t DS2438_1_VAD;\r
+volatile uint16_t DS2438_1_VDD;\r
+volatile int16_t DS2438_2_TEMP;\r
+volatile uint16_t DS2438_2_VAD;\r
+volatile uint16_t DS2438_2_VDD;\r
+\r
+OWST_ADC_CONF16_FUNC\r
+OWST_ADC_CONF16_OSS_FUNC\r
+OWST_TESTSW\r
+\r
+\r
+int main(void){\r
+        OWST_INIT_ADC_ON \r
+       pack2.page3[0]=0xF4;//Spannung\r
+       pack1.page3[0]=0xF4; //Spannung\r
+       OWINIT();\r
+       OWST_WDR_CONFIG4\r
+       OWST_EN_PULLUP\r
+       \r
+       PORTA&=~((PIN_PIOA1)|(PIN_PIOB1)|(PIN_PIOA2)|(PIN_PIOB2));\r
+       OWST_INIT_ADC\r
+       DIDR0=(PIN_PIOA1)|(PIN_PIOB1)|(PIN_PIOA2)|(PIN_PIOB2);\r
+\r
+       //ADCSRB|=(1<<ADLAR);   Adiust left\r
+       volatile double VCC;\r
+       volatile double VAD_A,VAD_B,VAD_C,VAD_D;\r
+       \r
+       gcontrol=1;\r
+       sei();\r
+    while(1)   {\r
+               if (gcontrol) {\r
+                       wdcounter=3;\r
+                       gcontrol=0;\r
+                               \r
+               }\r
+               if (wdcounter>2) { \r
+                       \r
+                       wdcounter=0;\r
+                       ADMUX=OWST_ADCIN_REFINT;\r
+                       _delay_us(100);\r
+                       VCC=owst_ADC_runf();\r
+                       VCC=(1.079*65472.0)/VCC;\r
+                       DS2438_2_VDD=VCC*100;\r
+                       DS2438_1_VDD=VCC*100;\r
+\r
+                       if (testSW()) {\r
+                               ADMUX= ADDIFF1; //ADC0 + ADC1 - Gain 1\r
+                               _delay_us(100);\r
+                               VAD_A=owst_ADC_runf();\r
+                               if (VAD_A<3100) {\r
+                                       ADMUX= ADDIFF1G; //ADC0 + ADC1 - Gain 20\r
+                                       _delay_us(100);\r
+                                       VAD_A=owst_ADC_runf();\r
+                                       VAD_A=VCC/20.0*VAD_A/65472.0;\r
+                               } else {\r
+                                       VAD_A=owst_ADC_OSS_runf();\r
+                                       VAD_A=VCC*VAD_A/65472.0;\r
+                               }\r
+                               DS2438_1_VAD=VAD_A*100;\r
+                               DS2438_1_TEMP=VAD_A*256;\r
+\r
+                               ADMUX= ADDIFF2; //ADC0 + ADC1 - Gain 1\r
+                               _delay_us(100);\r
+                               VAD_B=owst_ADC_runf();\r
+                               if (VAD_B<3100) {\r
+                                       ADMUX= ADDIFF2G; //ADC0 + ADC1 - Gain 20\r
+                                       _delay_us(100);\r
+                                       VAD_B=owst_ADC_runf();\r
+                                       VAD_B=VCC/20.0*VAD_B/65472.0;\r
+                                       } else {\r
+                                       VAD_B=owst_ADC_OSS_runf();\r
+                                       VAD_B=VCC*VAD_B/65472.0;\r
+                               }\r
+                               DS2438_2_VAD=VAD_B*100;\r
+                               DS2438_2_TEMP=VAD_B*256;\r
+\r
+\r
+\r
+                       } else {\r
+                               ADMUX=ADMA1;\r
+                               _delay_us(100);\r
+                               VAD_A=owst_ADC_OSS_runf();\r
+                               VAD_A=VCC*VAD_A/65472.0;\r
+                               DS2438_1_TEMP=VAD_A*256;\r
+                               \r
+                               ADMUX=ADMB1;\r
+                               _delay_us(100);\r
+                               VAD_B=owst_ADC_OSS_runf();\r
+                               VAD_B=VCC*VAD_B/65472.0;\r
+                               DS2438_1_VAD=VAD_B*100;\r
+                               \r
+                               ADMUX=ADMA2;\r
+                               _delay_us(100);\r
+                               VAD_C=owst_ADC_OSS_runf();\r
+                               VAD_C=VCC*VAD_C/65472.0;\r
+                               DS2438_2_TEMP=VAD_C*256;\r
+                               \r
+                               ADMUX=ADMB2;\r
+                               _delay_us(100);\r
+                               VAD_D=owst_ADC_OSS_runf();\r
+                               VAD_D=VCC*VAD_D/65472.0;\r
+                               DS2438_2_VAD=VAD_D*100;\r
+                       }\r
+                       \r
+               \r
+\r
+                       \r
+               }\r
+       \r
+               \r
+               OWST_MAIN_END\r
+   }\r
+\r
+\r
+}\r
diff --git a/DS2438_CDM7160/DS2438_CDM7160.atsln b/DS2438_CDM7160/DS2438_CDM7160.atsln
new file mode 100644 (file)
index 0000000..6121562
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_CDM7160", "DS2438_CDM7160.cproj", "{91468D4F-8AE2-4C59-8A35-549C49E00934}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.ActiveCfg = Debug|AVR\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.Build.0 = Debug|AVR\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.ActiveCfg = Release|AVR\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.Build.0 = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_CDM7160/DS2438_CDM7160.c b/DS2438_CDM7160/DS2438_CDM7160.c
new file mode 100644 (file)
index 0000000..7fc2e0a
--- /dev/null
@@ -0,0 +1,180 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/CDM7160.h"\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x26, 0xA2, 0xD9, 0x88, 0x00, 0x00, 0x05, 0x04};/**/\r
+uint8_t config_info[26]={10,13, 0x05,0x08, 10,22, 0x00,0x00, 0x02,0x07,0x00,0x07,0x00,0x00,0x00,0x00, 0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+       \r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+\r
+volatile uint8_t wdcounter=5;\r
+\r
+\r
+typedef union {\r
+\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               uint16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               uint8_t page2[8]; //17\r
+               uint8_t page3[8]; //25\r
+               uint8_t page4[8];  //33\r
+               uint8_t page5[8];  //41\r
+               uint8_t page6[8];  //49\r
+               uint8_t page7[8];  //57\r
+               //uint8_t crc;  //65\r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+\r
+volatile int16_t am2302_temp;\r
+volatile uint16_t am2302_hum;\r
+\r
+uint8_t userRegister[1];\r
+double temperatureC,humidityRH;\r
+volatile double l;\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
+#else\r
+ISR(WDT_vect) {\r
+#endif \r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+\r
+\r
+}\r
+\r
+int testSW(void) {\r
+       uint8_t r;\r
+       DDRB&=~(1<<PORTB0);  //Eingang\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB|=(1<<PORTB0); //Pullup\r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        r=PINB&(1<<PORTB0);\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB&=~(1<<PORTB0); \r
+        __asm__ __volatile__ ("nop"); \r
+       DDRB|=(1<<PORTB0);  //Eingang\r
+       return (r==0);\r
+        \r
+        \r
+}\r
+\r
+int main(void){\r
+     PRR|=(1<<PRADC);  // adc for save Power\r
+       PORTA=0xFF;\r
+       PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+       \r
+       \r
+       OWINIT();\r
+\r
+       ACSR|=(1<<ACD);  //Disable Comparator\r
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+       MCUCR |=(1<<BODS);\r
+\r
+       \r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+\r
+    uint8_t i;\r
+    for(i=0;i<64;i++) pack.bytes[i]=0;\r
+       pack.page3[0]=0xF4;\r
+       MCUSR=0;\r
+       USI_TWI_Master_Initialise();\r
+       CDM7160softReset();\r
+       _delay_ms(200);\r
+\r
+       CDM7160setMode(0); //Power Down Mode\r
+       _delay_ms(200);\r
+       CDM7160setAvCount(0x3F);\r
+       CDM7160setFMode(1);\r
+       am2302_temp=CDM7160getCO2();\r
+       CDM7160setMode(1);\r
+       _delay_ms(200); \r
+       sei();\r
+       \r
+        while(1)   { \r
+                if (gcontrol) {\r
+                        wdcounter=3;\r
+                        gcontrol=0;\r
+                }\r
+                if (wdcounter>2) {\r
+                       am2302_temp=CDM7160getCO2();\r
+                       am2302_hum=am2302_temp/10;\r
+                        wdcounter=0;\r
+                }\r
+\r
+               if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+               asm("SLEEP");\r
+       }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2438_CDM7160/DS2438_CDM7160.cproj b/DS2438_CDM7160/DS2438_CDM7160.cproj
new file mode 100644 (file)
index 0000000..988dc8e
--- /dev/null
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectVersion>7.0</ProjectVersion>\r
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>\r
+    <ProjectGuid>{91468d4f-8ae2-4c59-8a35-549c49e00934}</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2438_SHT2X</AssemblyName>\r
+    <Name>DS2438_CDM7160</Name>\r
+    <RootNamespace>DS2438_SHT2X</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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
+    <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.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
+    </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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\CDM7160.c">\r
+      <SubType>compile</SubType>\r
+      <Link>CDM7160.c</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\OWDS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_CDM7160.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.atsln b/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.atsln
new file mode 100644 (file)
index 0000000..8f8ecf9
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_CDM7160_DS2438_BMP280", "DS2438_CDM7160_DS2438_BMP280.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.componentinfo.xml b/DS2438_CDM7160_DS2438_BMP280/DS2438_CDM7160_DS2438_BMP280.componentinfo.xml
new file mode 100644 (file)
index 0000000..52c412d
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Store xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="AtmelPackComponentManagement">\r
+       <ProjectComponents />\r
+</Store>
\ No newline at end of file
diff --git a/DS2438_CDM7160_DS2438_BMP280/DS2438_DS2438.c b/DS2438_CDM7160_DS2438_BMP280/DS2438_DS2438.c
new file mode 100644 (file)
index 0000000..ffc5e8b
--- /dev/null
@@ -0,0 +1,187 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//!!!!!Max Program size 7551 Byte\r
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>  \r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/TWI_Master.h"\r
+#include "../common/I2C/BMP280.h"\r
+#include "../common/I2C/CDM7160.h"\r
+#include "../common/owSlave_tools.h"\r
+\r
+\r
+OWST_EXTERN_VARS\r
+\r
+\r
+\r
+volatile uint8_t owid1[8]={0x26, 0x01, 0x01, 0x01, 0x00, 0x00, 0x03, 0xF6};/**/\r
+volatile uint8_t owid2[8]={0x26, 0x02, 0x01, 0x01, 0x00, 0x00, 0x03, 0xAF};/**/\r
+volatile uint8_t config_info1[26]={1,6, 10,8, 10,8, 0x00,0x00, 0x02,14,16,16,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};  \r
+volatile uint8_t config_info2[26]={1,6, 2,8, 2,8, 0,0           , 0x02,14,14,14,0,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};  \r
+       \r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               int16_t current;  //6\r
+               uint8_t threshold; //8\r
+               uint8_t page1[8]; //9\r
+               uint8_t page2[8]; //17\r
+                       \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
+               uint8_t page7[8];  //57\r
+               \r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1;\r
+\r
+\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               int16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\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]; //25\r
+               uint8_t page7[8];  //57\r
+               \r
+       };\r
+} pack2_t;\r
+volatile pack2_t pack2;\r
+\r
+OWST_WDT_ISR\r
+OWST_TESTSW\r
+\r
+\r
+\r
+\r
+\r
+volatile int16_t DS2438_1_TEMP;\r
+volatile uint16_t DS2438_1_VAD;\r
+volatile uint16_t DS2438_1_VDD;\r
+volatile int16_t DS2438_2_TEMP;\r
+volatile uint16_t DS2438_2_VAD;\r
+volatile uint16_t DS2438_2_VDD;\r
+\r
+\r
+\r
+double temperatureC,humidityRH,hhum;\r
+double l;\r
+uint32_t P;\r
+int32_t t;\r
+uint8_t max_adr=0;\r
+int16_t CO2;\r
+\r
+\r
+int main(void){\r
+       OWST_INIT_USI_ON\r
+       OWINIT();\r
+       OWST_WDR_CONFIG8\r
+       OWST_EN_PULLUP\r
+       \r
+       pack1.page3[0]=0xF1;\r
+       pack2.page3[0]=0xF4;\r
+\r
+       TWI_Master_Initialise();\r
+       CDM7160softReset();\r
+       _delay_ms(200);\r
+\r
+       CDM7160setMode(0); //Power Down Mode\r
+       _delay_ms(200);\r
+       CDM7160setAvCount(0x3F);\r
+       CDM7160setFMode(1);\r
+       CO2=CDM7160getCO2();\r
+       CDM7160setMode(1);\r
+       _delay_ms(200);\r
+\r
+       bmp280Init();\r
+\r
+\r
+\r
+\r
+       gcontrol=1;\r
+       sei();\r
+\r
+    while(1)   {\r
+               if (gcontrol) wdcounter=4;\r
+               if (wdcounter>3) {  //8s\r
+                       wdcounter=0;\r
+                       bmp280ConvertInt(&t,&P,1);\r
+                       _delay_ms(100);\r
+                       CO2=CDM7160getCO2()-35;\r
+                       double cc=(double)CO2/(P/101300.0*298.0/(273.0+t/100.0));\r
+                       DS2438_2_TEMP=t/100.0*256.0;\r
+                       DS2438_1_TEMP=CO2;\r
+                       DS2438_1_VDD=cc/10;\r
+                       DS2438_1_VAD=(cc-DS2438_1_VDD*10)*100;\r
+                       DS2438_2_VDD=P/1000;\r
+                       DS2438_2_VAD=(P-DS2438_2_VDD*1000);\r
+\r
+                       \r
+               }\r
+       \r
+               if (gcontrol) {\r
+                       gcontrol=0;\r
+               }\r
+\r
+               \r
+               OWST_MAIN_END\r
+   }\r
+\r
+\r
+}\r
diff --git a/DS2438_DHT11/DS2438_DHT22.atsln b/DS2438_DHT11/DS2438_DHT22.atsln
new file mode 100644 (file)
index 0000000..ea73243
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_DHT22", "DS2438_DHT22.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_DHT11/DS2438_DHT22.c b/DS2438_DHT11/DS2438_DHT22.c
new file mode 100644 (file)
index 0000000..b120ab3
--- /dev/null
@@ -0,0 +1,316 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x26, 0xA2, 0xD9, 0x84, 0xDD, 0xDD, 0x05, 0xCE};/**/\r
+uint8_t config_info[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,0x09,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+\r
+volatile uint8_t wdcounter;\r
+\r
+\r
+typedef union {\r
+\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               uint16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               uint8_t page2[8]; //17\r
+               uint8_t page3[8]; //25\r
+               uint8_t page4[8];  //33\r
+               uint8_t page5[8];  //41\r
+               uint8_t page6[8];  //49\r
+               uint8_t page7[8];  //57\r
+               //uint8_t crc;  //65\r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+#define DDR_SENSOR   DDRA\r
+#define PORT_SENSOR  PORTA\r
+#define PIN_SENSOR   PINA\r
+#define SENSOR       PINA2\r
+\r
+#define SENSOR_sda_out         DDR_SENSOR |= (1 << SENSOR)\r
+#define SENSOR_sda_in                  DDR_SENSOR &= ~(1 << SENSOR);PORT_SENSOR |= (1 << SENSOR) // release sda => hi in consequence of pullup\r
+#define SENSOR_sda_low    PORT_SENSOR &= ~(1 << SENSOR)\r
+#define SENSOR_sda_hi    PORT_SENSOR |= (1 << SENSOR)\r
+#define SENSOR_is_hi                   PIN_SENSOR & (1 << SENSOR)\r
+#define SENSOR_is_low          !(PIN_SENSOR & (1 << SENSOR))\r
+\r
+volatile int16_t am2302_temp;\r
+volatile uint16_t am2302_hum;\r
+\r
+\r
+uint8_t am_wait(uint8_t _time,uint8_t _signal){\r
+       TCNT1=0;\r
+       while(TCNT1==0);\r
+       if (_signal)\r
+       while((SENSOR_is_hi)&&(TCNT1<_time)) {}\r
+       else\r
+       while((SENSOR_is_low)&&(TCNT1<_time)) {}\r
+       \r
+       if (TCNT1>=_time) {return 1;}\r
+       return 0;\r
+}\r
+\r
+volatile uint8_t am2302_mode=0;\r
+volatile uint8_t timeout=0;\r
+\r
+\r
+\r
+\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+volatile double temperatureC,humidityRH;\r
+volatile double l;\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
+       #else\r
+ISR(WDT_vect) {\r
+       #endif\r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+}\r
+       \r
+int testSW(void) {\r
+       uint8_t r;\r
+       DDRB&=~(1<<PORTB0);  //Eingang\r
+       __asm__ __volatile__ ("nop");\r
+       PORTB|=(1<<PORTB0); //Pullup\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       r=PINB&(1<<PORTB0);\r
+       __asm__ __volatile__ ("nop");\r
+       PORTB&=~(1<<PORTB0);\r
+       __asm__ __volatile__ ("nop");\r
+       DDRB|=(1<<PORTB0);  //Eingang\r
+       return (r==0);\r
+}\r
+\r
+uint8_t am2302() {\r
+       int16_t lam2302_temp;\r
+       uint16_t lam2302_hum;\r
+       uint8_t rSREG;\r
+       uint8_t sensor_data[5];\r
+\r
+       TCCR1B=(1<<CS11); //Clock/8 1µs\r
+\r
+       \r
+       SENSOR_sda_out;\r
+       SENSOR_sda_low; \r
+       _delay_ms(20);\r
+       SENSOR_sda_hi;  \r
+       SENSOR_sda_in;\r
+//     _delay_ms(40);\r
+       //SENSOR_sda_low;\r
+       //_delay_us(40);\r
+\r
+       //SENSOR_sda_in;\r
+       /*uint16_t loopCnt;\r
+       loopCnt=10000;\r
+       while((SENSOR_is_low)) {\r
+               if (loopCnt-- == 0) return  11;\r
+       }\r
+       loopCnt=10000;\r
+       while((SENSOR_is_hi)) {\r
+               if (loopCnt-- == 0) return  12;\r
+       }*/\r
+       if (am_wait(200,1)) return 2;\r
+       if (am_wait(100,0)) return 3;\r
+       if (am_wait(100,1)) return 4;\r
+       \r
+       for(uint8_t i = 0; i < 5; i++)  {\r
+               uint8_t sensor_byte = 0;\r
+               for(uint8_t j = 1; j <= 8; j++) {// get 8 bits from sensor\r
+                       if (am_wait(88,0)) return 5;\r
+                       \r
+                       TCNT1=0;while(TCNT1==0);;while(TCNT1<35)                ;\r
+                       sensor_byte <<= 1; // add new lower byte\r
+                       if (SENSOR_is_hi) {// if sda high after 30us => bit=1 else bit=0\r
+                               sensor_byte |= 1;\r
+                               if (am_wait(45,1)) return 6;// 30us - 75us = 45us\r
+                       }\r
+               }\r
+               sensor_data[i] = sensor_byte;\r
+       }\r
+\r
+       // checksum\r
+       if ( ((sensor_data[0]+sensor_data[1]+sensor_data[2]+sensor_data[3]) & 0xff ) != sensor_data[4])\r
+       {\r
+               PORTB&=~(1<<PINB0);\r
+               return 7;\r
+       }\r
+       if (sensor_data[2]&0x80) { //minus\r
+               sensor_data[2]&=~(0x80);\r
+               lam2302_temp=-( sensor_data[2]*10);\r
+       } else\r
+               lam2302_temp=(sensor_data[2]*10);\r
+       if (!testSW()) {\r
+               double htemp=lam2302_temp;\r
+        double hhum=(1.0546-0.000216*htemp)*(sensor_data[0]*10);\r
+               //htemp=Temperauter * 10 \r
+               //lam2302_hum=0.318*hhum +76;\r
+               lam2302_hum=0.31*hhum +80; //hhum = Hum*10 -> 5V also all *5\r
+               config_info[5]=7;\r
+       }\r
+       else {\r
+               \r
+               lam2302_hum=(sensor_data[0]*10);\r
+               config_info[5]=12;\r
+       }\r
+       lam2302_temp=lam2302_temp*25.6;\r
+       rSREG=SREG;\r
+       cli();\r
+       am2302_hum=lam2302_hum;\r
+       am2302_temp=lam2302_temp;\r
+       SREG=rSREG;\r
+       return 0;\r
+}\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+       int main(void){\r
+               PRR|=(1<<PRUSI)|(1<<PRADC);   // adc and usi for save Power\r
+               PORTA=0xFF;\r
+               PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+               DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+               \r
+               \r
+               OWINIT();\r
+\r
+               ACSR|=(1<<ACD);  //Disable Comparator\r
+               ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
+               MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+               MCUCR |=(1<<BODS);\r
+\r
+               \r
+               DDRA|=(1<<PINA1); //stromversorgung\r
+#define SENSON PORTA|=(1<<PINA1);\r
+#define SENSOFF PORTA&=~(1<<PINA1);\r
+\r
+               // Set up Watch Dog Timer for Inactivity\r
+               WDTCSR |= (1<<WDCE) ;   // Enable the WD Change Bit\r
+               WDTCSR =   (1<<WDIE) |              // Enable WDT Interrupt\r
+                       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~2 seconds           \r
+               \r
+               if (testSW()) {\r
+                       config_info[5]=12;  //hum *10\r
+                       }else{\r
+                       config_info[5]=7; //HIH4031\r
+               }\r
+               \r
+               uint8_t i;\r
+               for(i=0;i<64;i++) pack.bytes[i]=0;\r
+               pack.page3[0]=0xF1; //Wiregate Code\r
+               MCUSR=0;\r
+               \r
+               uint8_t err;\r
+               uint8_t pn=1;\r
+               SENSON\r
+               _delay_ms(4000);\r
+               err =am2302();\r
+               am2302_temp=err*256;\r
+               sei();\r
+               \r
+               while(1)   {\r
+                       if (gcontrol) {\r
+                               if (wdcounter>2) {\r
+                                       wdcounter=0;\r
+                                       SENSON\r
+                               }\r
+                               gcontrol=0;\r
+                       }\r
+                       if (wdcounter==2) {\r
+                               err=am2302();\r
+                               if (err!=0) {\r
+                                       pack.page3[pn]=err;\r
+                                       pn=pn+1;if (pn>31) pn=1;\r
+                               }\r
+                               //SENSOFF\r
+                               wdcounter=3;\r
+                       }\r
+                       if (wdcounter>=16) {\r
+                               wdcounter=0;\r
+                               SENSON\r
+                       }\r
+                       \r
+                       \r
+\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {\r
+                               MCUCR|=(1<<SE)|(1<<SM1);\r
+                               MCUCR&=~(1<<ISC01);\r
+                               } else {\r
+                               MCUCR|=(1<<SE);\r
+                               MCUCR&=~(1<<SM1);\r
+                       }\r
+                       asm("SLEEP");\r
+               }\r
+\r
+\r
+       }
\ No newline at end of file
diff --git a/DS2438_DHT11/DS2438_DHT22.cproj b/DS2438_DHT11/DS2438_DHT22.cproj
new file mode 100644 (file)
index 0000000..4986240
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2438_DHT22</AssemblyName>\r
+    <Name>DS2438_DHT22</Name>\r
+    <RootNamespace>DS2438_DHT22</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\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
+  </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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="..\common\OWDS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_DHT22.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
index 3dc3802..4986240 100644 (file)
     <ExternalProgrammingToolCommand />\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
     <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>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
diff --git a/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.atsln b/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.atsln
new file mode 100644 (file)
index 0000000..a43f92a
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_Fenster_Kontakt", "DS2438_Fenster_Kontakt.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.c b/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.c
new file mode 100644 (file)
index 0000000..7a7418c
--- /dev/null
@@ -0,0 +1,208 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x26, 0xA3, 0xD9, 0x89, 0xDD, 0xDD, 0x05, 0x64};/**/\r
+uint8_t config_info[26]={0x01,0x06, 0x05,0x08, 0x06,0x08, 0x00,0x00, 0x02,0x09,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+\r
+volatile uint8_t wdcounter;\r
+\r
+\r
+typedef union {\r
+\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               uint16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               uint8_t page2[8]; //17\r
+               uint8_t page3[8]; //25\r
+               uint8_t page4[8];  //33\r
+               uint8_t page5[8];  //41\r
+               uint8_t page6[8];  //49\r
+               uint8_t page7[8];  //57\r
+               //uint8_t crc;  //65\r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+volatile int16_t ds_temp;\r
+volatile uint16_t ds_vad;\r
+volatile uint16_t ds_vdd;\r
+\r
+#define CH1 (1<<PORTA0)\r
+#define CH2 (1<<PORTA1)\r
+#define CH3 (1<<PORTA2)\r
+#define PIN_CH1 PINA\r
+#define PIN_CH2 PINA\r
+#define PIN_CH3 PINA\r
+\r
+volatile uint8_t ch1,ch2,ch3;\r
+\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
+       #else\r
+ISR(WDT_vect) {\r
+       #endif\r
+       wdcounter++;if (wdcounter==11) wdcounter=10;\r
+       if (ch1>1) ch1++;\r
+       if (ch2>1) ch2++;\r
+       if (ch3>1) ch3++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+\r
+}\r
+       \r
+ISR(PCINT0_vect) {\r
+\r
+                               if ((PIN_CH1&CH1)==0) {if (ch1==0) ch1=1;} else {ds_temp=25600;ch1=0;}\r
+                               if ((PIN_CH2&CH2)==0) {if (ch2==0) ch2=1;} else {ds_vdd=0x1f4;ch2=0;}\r
+                               if ((PIN_CH3&CH3)==0) {if (ch3==0) ch3=1;} else {ds_vad=0x1f4;ch3=0;}\r
+       \r
+       wdcounter=10;\r
+}\r
+\r
+int testSW(void) {\r
+       uint8_t r;\r
+       DDRB&=~(1<<PORTB0);  //Eingang\r
+       __asm__ __volatile__ ("nop");\r
+       PORTB|=(1<<PORTB0); //Pullup\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       r=PINB&(1<<PORTB0);\r
+       __asm__ __volatile__ ("nop");\r
+       PORTB&=~(1<<PORTB0);\r
+       __asm__ __volatile__ ("nop");\r
+       DDRB|=(1<<PORTB0);  //Eingang\r
+       return (r==0);\r
+}\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+       int main(void){\r
+               PRR|=(1<<PRUSI);   //  usi for save Power\r
+               PORTA=0xFF;  \r
+               PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+               DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+               \r
+               \r
+               OWINIT();\r
+\r
+               ACSR|=(1<<ACD);  //Disable Comparator\r
+               //ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
+               MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+               \r
+               // Set up Watch Dog Timer for Inactivity\r
+               WDTCSR |= (1<<WDCE) ;   // Enable the WD Change Bit\r
+               WDTCSR =   (1<<WDIE) |              // Enable WDT Interrupt\r
+                       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~2 seconds           \r
+               \r
+               GIMSK|=(1<<PCIE0);\r
+               PCMSK0=(CH1)|(CH2)|(CH3);\r
+\r
+               \r
+               sei();\r
+               \r
+               while(1)   {\r
+                               if ((PIN_CH1&CH1)==0) {if (ch1==0) ch1=1;} else {ds_temp=25600;ch1=0;}\r
+                               if ((PIN_CH2&CH2)==0){if (ch2==0) ch2=1;} else {ds_vdd=0x1f4;ch2=0;}\r
+                               if ((PIN_CH3&CH3)==0) {if (ch3==0) ch3=1;} else {ds_vad=0x1f4;ch3=0;}\r
+\r
+                               if (ch1==10) {ch1=0;ds_temp=0;};\r
+                               if (ch2==10) {ch2=0;ds_vdd=0;};\r
+                               if (ch3==10) {ch3=0;ds_vad=0;};\r
+\r
+                               if ((gcontrol&1)==1) {\r
+                                       if (ch1==1) {\r
+                                               ch1=2;\r
+                                       }\r
+                               }\r
+                               if ((gcontrol&2)==2) {\r
+                                       if ((ch2==1)) {\r
+                                               ch2=2;\r
+                                       }\r
+                               }\r
+                               if ((gcontrol&4)==4) {\r
+                                       if (ch3==1) {\r
+                                               ch3=2;\r
+                                       }\r
+                               }\r
+                               gcontrol=0;\r
+       \r
+\r
+       #define TEST_TIMER  ((TIMSK0 & (1<<TOIE0))==0)\r
+       if (TEST_TIMER&&(mode==0)) {\r
+               MCUCR|=(1<<SE)|(1<<SM1); //Power Down, only low level on 1-Wire and pin change on PCINT wakes up\r
+               MCUCR&=~(1<<ISC01);\r
+               } else {\r
+               MCUCR|=(1<<SE);\r
+               MCUCR&=~(1<<SM1);\r
+       }\r
+       asm("SLEEP");\r
+\r
+               }\r
+\r
+\r
+       }
\ No newline at end of file
diff --git a/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.cproj b/DS2438_Fenster_Kontakt/DS2438_Fenster_Kontakt.cproj
new file mode 100644 (file)
index 0000000..1710f22
--- /dev/null
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2438_DHT22</AssemblyName>\r
+    <Name>DS2438_Fenster_Kontakt</Name>\r
+    <RootNamespace>DS2438_DHT22</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\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
+  </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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="DS2438_Fenster_Kontakt.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2438.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2438_Fenster_Kontakt/OWDS2438.S b/DS2438_Fenster_Kontakt/OWDS2438.S
new file mode 100644 (file)
index 0000000..eff1ad7
--- /dev/null
@@ -0,0 +1,196 @@
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _DIS_FLASH_\r
+#define _ZERO_POLLING_\r
+//#define _DB_\r
+//#define __4MHZ__\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC8.s"\r
+\r
+#if  defined(__AVR_ATtiny25__)\r
+.extern pack,16\r
+#else\r
+.extern pack,64\r
+#endif\r
+.extern  ds_temp,2\r
+.extern  ds_vdd,2\r
+.extern  ds_vad,2\r
+\r
+.comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)\r
+\r
+\r
+.macro CHIP_INIT\r
+.endm\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_SCRATCHPAD_ADR OW_FIRST_COMMAND+0\r
+#define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+1\r
+#define OW_WRITE_SCRATCHPAD_ADR OW_FIRST_COMMAND+2\r
+#define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+3\r
+\r
+\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readscratchpad_adr\r
+               rjmp h_readscratchpad\r
+               rjmp h_writescratchpad_adr\r
+               rjmp h_writescratchpad\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xBE,OW_READ_SCRATCHPAD_ADR\r
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR\r
+       cjmp 0x44,hrc_set_convertT\r
+       cjmp 0xB4,hrc_set_convertV\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       rjmp handle_end_sleep\r
+\r
+\r
+hrc_set_convertT:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       lds r_temp,ds_temp\r
+       sts pack+1,r_temp\r
+       lds r_temp,ds_temp+1\r
+       sts pack+2,r_temp\r
+       rjmp handle_end_sleep\r
+hrc_set_convertV:\r
+       lds r_temp,pack\r
+       sbrs r_temp,3\r
+       rjmp hrc_set_convertVV\r
+       ldi r_temp,2\r
+       sts gcontrol,r_temp\r
+       //ldi r_temp,0xF4#\r
+       lds r_temp,ds_vdd\r
+       sts pack+3,r_temp\r
+       //ldi r_temp,0x01\r
+       lds r_temp,ds_vdd+1\r
+       sts pack+4,r_temp\r
+       rjmp hrc_set_convertend\r
+hrc_set_convertVV:\r
+       ldi r_temp,4\r
+       sts gcontrol,r_temp\r
+       lds r_temp,ds_vad\r
+       sts pack+3,r_temp\r
+       lds r_temp,ds_vad+1\r
+       sts pack+4,r_temp\r
+hrc_set_convertend:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   READ SCRATCHPAD\r
+;---------------------------------------------------\r
+\r
+h_readscratchpad_adr:\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+#if  defined(__AVR_ATtiny25__)\r
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen\r
+#endif\r
+       sts block,r_rwbyte\r
+       ldi r_sendflag,1\r
+       ldi r_mode,OW_READ_SCRATCHPAD\r
+       ldi r_temp,8\r
+       sts gcontrol,r_temp\r
+       CRCInit2\r
+h_readscratchpad:\r
+       cpi  r_bytep,8\r
+       breq h_readscratchpad_crc\r
+       cpi  r_bytep,9\r
+       breq h_readscratchpad_all\r
+       lds  r_temp,block\r
+       add  r_temp,r_bytep\r
+       configZ pack,r_temp\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_readscratchpad_crc:\r
+       lds  r_rwbyte,crc\r
+       rjmp handle_end_inc\r
+h_readscratchpad_all:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   WRITE SCRATCHPAD\r
+;---------------------------------------------------\r
+h_writescratchpad_adr:\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+#if  defined(__AVR_ATtiny25__)\r
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen\r
+#endif\r
+       sts block,r_rwbyte\r
+       ldi r_mode,OW_WRITE_SCRATCHPAD\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end \r
+h_writescratchpad:\r
+       cpi  r_bytep,8\r
+       breq h_writescratchpad_all\r
+       lds  r_temp,block\r
+       add  r_temp,r_bytep\r
+       configZ pack,r_temp\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_writescratchpad_all:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
index da1d586..4812b38 100644 (file)
@@ -1,22 +1,22 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Atmel Studio Solution File, Format Version 11.00
-VisualStudioVersion = 14.0.23107.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_HDC1080", "DS2438_HDC1080.cproj", "{91468D4F-8AE2-4C59-8A35-549C49E00934}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|AVR = Debug|AVR
-               Release|AVR = Release|AVR
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.ActiveCfg = Debug|AVR
-               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.Build.0 = Debug|AVR
-               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.ActiveCfg = Release|AVR
-               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.Build.0 = Release|AVR
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_HDC1080", "DS2438_HDC1080.cproj", "{91468D4F-8AE2-4C59-8A35-549C49E00934}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.ActiveCfg = Debug|AVR\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.Build.0 = Debug|AVR\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.ActiveCfg = Release|AVR\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.Build.0 = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_HDC2010/DS2438_HDC2010.atsln b/DS2438_HDC2010/DS2438_HDC2010.atsln
new file mode 100644 (file)
index 0000000..92feefd
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_HDC2010", "DS2438_HDC2010.cproj", "{91468D4F-8AE2-4C59-8A35-549C49E00934}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.ActiveCfg = Debug|AVR\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Debug|AVR.Build.0 = Debug|AVR\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.ActiveCfg = Release|AVR\r
+               {91468D4F-8AE2-4C59-8A35-549C49E00934}.Release|AVR.Build.0 = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_HDC2010/DS2438_HDC2010.c b/DS2438_HDC2010/DS2438_HDC2010.c
new file mode 100644 (file)
index 0000000..d47fd90
--- /dev/null
@@ -0,0 +1,199 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/HDC1080.h"\r
+#include "../common/calibr.h"\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x00, 0x05, 0x16};/**/\r
+uint8_t config_info[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,11,0x00,11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+       \r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+\r
+volatile uint8_t wdcounter=5;\r
+\r
+\r
+typedef union {\r
+\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               uint16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               uint8_t page2[8]; //17\r
+               uint8_t page3[8]; //25\r
+               uint8_t page4[8];  //33\r
+               uint8_t page5[8];  //41\r
+               uint8_t page6[8];  //49\r
+               uint8_t page7[8];  //57\r
+               //uint8_t crc;  //65\r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+\r
+volatile int16_t am2302_temp;\r
+volatile uint16_t am2302_hum;\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+double temperatureC,humidityRH;\r
+volatile double l;\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
+#else\r
+ISR(WDT_vect) {\r
+#endif \r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+\r
+\r
+}\r
+\r
+int testSW(void) {\r
+       uint8_t r;\r
+       DDRB&=~(1<<PORTB0);  //Eingang\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB|=(1<<PORTB0); //Pullup\r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        r=PINB&(1<<PORTB0);\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB&=~(1<<PORTB0); \r
+        __asm__ __volatile__ ("nop"); \r
+       DDRB|=(1<<PORTB0);  //Eingang\r
+       return (r==0);\r
+        \r
+        \r
+}\r
+\r
+int main(void){\r
+     PRR|=(1<<PRADC);  // adc for save Power\r
+       PORTA=0xFF;\r
+       PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+       \r
+       \r
+       OWINIT();\r
+\r
+       ACSR|=(1<<ACD);  //Disable Comparator\r
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+       MCUCR |=(1<<BODS);\r
+\r
+       \r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+        if (testSW()) {\r
+               config_info[5]=8;\r
+       }else{\r
+               config_info[5]=7;\r
+        }\r
+       \r
+    uint8_t i;\r
+    for(i=0;i<64;i++) pack.bytes[i]=0;\r
+       MCUSR=0;\r
+       USI_TWI_Master_Initialise();\r
+       HDC2010_Init();\r
+       HDC2010_Readf(&temperatureC,&humidityRH);\r
+       \r
+       sei();\r
+       \r
+        while(1)   {\r
+                if (gcontrol) {\r
+                        wdcounter=3;\r
+                        gcontrol=0;\r
+                }\r
+                if (wdcounter>2) {\r
+                        //PORTB|=(1<<PINB1); //Dauer 440ms\r
+                        HDC2010_Readf(&temperatureC,&humidityRH);\r
+\r
+                        humidityRH = calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
+                        temperatureC-=0.2;\r
+                        temperatureC*=10.0;\r
+                        if (testSW()) {\r
+                                am2302_hum= humidityRH;\r
+                                am2302_temp=temperatureC*25.6;\r
+                                //am2302_temp=am2302_temp-45;\r
+                                config_info[5]=12;     \r
+                                \r
+                        }else{\r
+                                \r
+                               double hhum=(1.0546-0.000216*temperatureC)*(humidityRH);\r
+                               //am2302_hum=0.318*hhum +76.0;\r
+                               am2302_hum=0.31*hhum +80;\r
+                               am2302_temp=temperatureC*25.6;\r
+                               //am2302_temp=am2302_temp-45;\r
+                               config_info[5]=7;\r
+                        }\r
+                        //PORTB&=~(1<<PINB1);\r
+                        wdcounter=0;\r
+                }\r
+\r
+               if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+               asm("SLEEP");\r
+       }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2438_HDC2010/DS2438_HDC2010.cproj b/DS2438_HDC2010/DS2438_HDC2010.cproj
new file mode 100644 (file)
index 0000000..5a393ef
--- /dev/null
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectVersion>7.0</ProjectVersion>\r
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>\r
+    <ProjectGuid>{91468d4f-8ae2-4c59-8a35-549c49e00934}</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2438_SHT2X</AssemblyName>\r
+    <Name>DS2438_HDC2010</Name>\r
+    <RootNamespace>DS2438_SHT2X</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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
+    <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.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.compiler.miscellaneous.OtherFlags>-std=gnu99 -D__4MHZ__</avrgcc.compiler.miscellaneous.OtherFlags>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.AssemblerFlags>-D__4MHZ__</avrgcc.assembler.general.AssemblerFlags>\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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\HDC2010.c">\r
+      <SubType>compile</SubType>\r
+      <Link>HDC2010.c</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\OWDS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_HDC2010.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_DS2438.c b/DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_DS2438.c
new file mode 100644 (file)
index 0000000..f4aef4a
--- /dev/null
@@ -0,0 +1,444 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//!!!!!Max Program size 7551 Byte\r
+//#define __4MHZ__\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/TWI_Master.h"\r
+#include "../common/I2C/HDC2010.h"\r
+#include "../common/I2C/MAX44009.h"\r
+#include "../common/owSlave_tools.h"\r
+\r
+OWST_EXTERN_VARS\r
+\r
+\r
+\r
+volatile uint8_t owid1[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x50};/**/\r
+volatile uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/\r
+                                        //18\r
+volatile uint8_t config_info1[26]={3,28, 0x05,0x08, 8,27, 0x00,0x00, 0x02,17,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 11,0x08, 0x02,0x07,0x00,0x07,17,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+#if (owid>128)\r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t cpsp2;\r
+\r
+OWST_WDT_ISR\r
+\r
+/*\r
+\r
+\r
+       typedef union {\r
+               volatile uint8_t bytes[8];\r
+               struct {\r
+                       uint16_t temp;  //0\r
+                       uint8_t TH;  //2\r
+                       uint8_t TL;  //3\r
+                       uint8_t config;  //4\r
+                       uint8_t rrFF; //5\r
+                       uint8_t rr00; //6\r
+                       uint8_t rr10; //7\r
+               };\r
+       } pack1_t;\r
+       volatile pack1_t pack1;\r
+*/\r
+\r
+\r
+       typedef union {\r
+               #if  defined(__AVR_ATtiny25__)\r
+               uint8_t bytes[16];\r
+               #else\r
+               uint8_t bytes[64];\r
+               #endif\r
+               struct {\r
+                       uint8_t status;  //1\r
+                       int16_t temp;  //2\r
+                       uint16_t voltage;  //4\r
+                       int16_t current;  //6\r
+                       uint8_t threshold; //8\r
+                       \r
+                       uint8_t page1[8]; //9\r
+                       #if  defined(__AVR_ATtiny25__)\r
+                       #else\r
+                       uint8_t page2[8]; //17\r
+                       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
+                                       \r
+                               };\r
+                       };\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
+                       uint8_t page6[8];  //49\r
+                       uint8_t page7[8];  //57\r
+                       \r
+                       #endif\r
+               };\r
+       } pack2_t;\r
+       volatile pack2_t pack2,pack1;\r
+\r
+\r
+\r
+\r
+       volatile int16_t DS2438_2_TEMP;\r
+       volatile uint16_t DS2438_2_VAD;\r
+       volatile uint16_t DS2438_2_VDD=0x01F4;\r
+       volatile int16_t DS2438_1_TEMP;\r
+       volatile uint16_t DS2438_1_VAD;\r
+       volatile uint16_t DS2438_1_VDD=0x01F4;\r
+\r
+       OWST_TESTSW\r
+\r
+\r
+       double temperatureC,humidityRH,hhum;\r
+       double l;\r
+\r
+\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
+               double h2;\r
+               double t2;\r
+               h2=h*h;\r
+               t2=t*t;\r
+               return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591;\r
+       }\r
+       inline double calibr_hum05(double t,double hum) {\r
+               double y=-0.0006*t*t-0.2455*t-28.5902;\r
+               return -(hum/y)+hum;\r
+       }\r
+       inline double calibr_hum075(double t,double hum) {\r
+               double y=-0.0004*t*t-0.1636*t-18.9173;\r
+               return -(hum/y)+hum;\r
+       }\r
+       inline double calibr_hum1(double t,double hum) {\r
+               double y=-0.0003*t*t-0.1228*t-14.0808;\r
+               return -(hum/y)+hum;\r
+       }\r
+\r
+       double R0;\r
+       uint16_t mr;\r
+       uint8_t startup=10;\r
+       double ip;\r
+       double la[4];\r
+       uint8_t lainit=1;\r
+\r
+\r
+       \r
+       #define EEPROM_R0 0\r
+       #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
+       uint16_t readEEPROM(uint8_t addr,uint16_t def) {\r
+               uint16_t hr;\r
+               while(EECR & (1<<EEPE));\r
+               EEARL=addr+1;\r
+               EECR |= (1<<EERE);\r
+               hr=EEDR;\r
+               if (hr!=0xFF) {\r
+                       hr=hr<<8;\r
+                       while(EECR & (1<<EEPE));\r
+                       EEARL=addr;\r
+                       EECR |= (1<<EERE);\r
+                       hr|=EEDR;\r
+                       return hr;\r
+               }\r
+               return def;\r
+       }\r
+\r
+       void writeEEPROM(uint8_t addr,uint16_t val) {\r
+               while(EECR & (1<<EEPE));\r
+               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+               EEARL = addr;\r
+               EEDR = val&0xFF;\r
+               EECR |= (1<<EEMPE);\r
+               EECR |= (1<<EEPE);\r
+               while(EECR & (1<<EEPE));\r
+               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+               EEARL = addr+1;\r
+               EEDR = val>>8;\r
+               EECR |= (1<<EEMPE);\r
+               EECR |= (1<<EEPE);\r
+       }\r
+\r
+       int main(void){\r
+               PORTA=0xFF-(1<<PINA1);\r
+               PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+               DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+               OWINIT();\r
+               DDRB|=(1<<PINB1);//Ausgang und 1\r
+               DDRA|=(1<<PINA0);\r
+               \r
+               WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+               WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+               //(1<<WDP0) |(1<<WDP2) | (1<<WDP1);    // Set Timeout to ~2 seconds\r
+               (1<<WDP3) | (1<<WDP0);    // Set Timeout to ~8 seconds\r
+\r
+               MCUSR=0;\r
+\r
+               //ADMUX=0b00001110; //ADC1 +   ADC3 -\r
+               ADMUX=0x01 ; //PA3 single and  3V\r
+               OWST_INIT_ADC\r
+               //ADCSRA = (1<<ADEN)|(1<<ADPS1)|(1<<ADPS0);//|\r
+               \r
+               \r
+\r
+               pack2.page3[0]=0xF1;\r
+               pack2.cmode=0;\r
+               pack2.R0=readEEPROM(EEPROM_R0,1);\r
+               R0=pack2.R0/100.0;\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
+               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
+               for(uint8_t i=0;i<8;i++) pack2.page6[i]=owid1[i];\r
+               if (testSW()) {\r
+                       config_info2[5]=12;\r
+                       }else{\r
+                       config_info2[5]=7;\r
+               }\r
+\r
+               TWI_Master_Initialise();\r
+               \r
+               //initSHT2x();\r
+               HDC2010_Init();\r
+               \r
+               _delay_ms(100);\r
+               gcontrol=1;\r
+               sei();\r
+               while(1)   {\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
+                                       } 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
+                               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[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
+                                               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
+                                       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
+                                HDC2010_Readf(&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_hum075(temperatureC,humidityRH)*10.0;\r
+                               //double RH=humidityRH*10.0;\r
+                               double TC=temperatureC*10.0-7.5;\r
+\r
+\r
+                               if (testSW()) {\r
+                                       DS2438_2_VAD=RH;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
+                                       config_info2[5]=12;     //10V = 100%\r
+                               }else{\r
+                                       hhum=(1.0546-0.000216*TC)*(RH);\r
+                                       DS2438_2_VAD=0.31*hhum +80;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
+                                       config_info2[5]=7;\r
+                               }\r
+                               mr=0;\r
+                               //Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________\r
+                               PORTB&=~(1<<PINB1); //Auf 0 Ziehen\r
+                               _delay_us(300);\r
+                               for(uint8_t i=0;i<32;i++) {\r
+                                       ADCSRA|=(1<<ADSC);\r
+                                       while ((ADCSRA&(1<<ADSC)));\r
+                                       mr+=ADC;\r
+                                }\r
+                               PORTB|=(1<<PINB1);\r
+                               //ENDE Kritische Sektion !______________________________\r
+\r
+                               //pack2.VS=mr*3/128;  //VS in Volt = VS/256  --> Nur zum Debug .... Speicher reicht sonst nicht....\r
+                               l=mr*1.8/32768.0;  //Spannung in v\r
+                               l=( 1.8/l- 1) *30; //l is resistance\r
+                               if (lainit) {\r
+                                       la[0]=la[1]=la[2]=la[3]=l;  //smaller code\r
+                                       lainit=0;\r
+                               } else {\r
+                                       //for (uint8_t i=0;i<3;i++) {\r
+                                       //      la[i]=la[i+1];\r
+                                       //}\r
+                                       la[0]=la[1];\r
+                                       la[1]=la[2];\r
+                                       la[2]=la[3];\r
+                                       la[3]=l;\r
+                               }\r
+                               double lasum=la[0]+la[1]+la[2]+la[3];\r
+                               l=lasum/4.0;\r
+                               \r
+                               pack2.current=l*100;\r
+                               \r
+                               l=l/ip;\r
+                               \r
+                               if (startup==0){\r
+                                       if (l>R0) {\r
+                                               R0=l;\r
+                                               pack2.R0=R0*100;\r
+                                               writeEEPROM(EEPROM_R0,pack2.R0);\r
+\r
+                                       }\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=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
+                               DS2438_1_VAD=l;\r
+                               DS2438_1_VDD=(l-DS2438_1_VAD)*1000.0;\r
+                               \r
+                               l=MAX44009getlux(1);\r
+                               if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045\r
+                               //double l=1000;\r
+                               l=log(l)*10*256;\r
+                               DS2438_1_TEMP=l;\r
+\r
+                               \r
+                       }\r
+                       \r
+                       \r
+                       if (gcontrol) {\r
+                               gcontrol=0;\r
+                               \r
+                       }\r
+\r
+                       \r
+                       OWST_MAIN_END\r
+               }\r
+\r
+\r
+       }\r
diff --git a/DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_MAX44009_VOC_DS2438_HDC.atsln b/DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_MAX44009_VOC_DS2438_HDC.atsln
new file mode 100644 (file)
index 0000000..b70f413
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2438_MAX44009_VOC_DS2438_HDC", "DS2438_MAX44009_VOC_DS2438_HDC.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_MAX44009_VOC_DS2438_HDC.cproj b/DS2438_MAX44009_VOC_DS2438_HDC_direct/DS2438_MAX44009_VOC_DS2438_HDC.cproj
new file mode 100644 (file)
index 0000000..087566c
--- /dev/null
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS2438_MAX44009_VOC_DS2438_HDC</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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
+    <ResetRule>0</ResetRule>\r
+    <EraseKey />\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.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.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.AssemblerFlags>-D__4MHZ__</avrgcc.assembler.general.AssemblerFlags>\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
+      <Value>__4MHZ__</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.preprocessor.UndefSymbols>\r
+    <ListValues>\r
+      <Value>_CHANGEABLE_ID_</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.preprocessor.UndefSymbols>\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.general.AssemblerFlags>-D__4MHZ__</avrgcc.assembler.general.AssemblerFlags>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\I2C\HDC2010.c">\r
+      <SubType>compile</SubType>\r
+      <Link>HDC2010.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\MAX44009.c">\r
+      <SubType>compile</SubType>\r
+      <Link>MAX44009.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\OWDS2438_DS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438_DS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_DS2438.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_DS2438.c b/DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_DS2438.c
new file mode 100644 (file)
index 0000000..e4e3bbc
--- /dev/null
@@ -0,0 +1,442 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//!!!!!Max Program size 7551 Byte\r
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/TWI_Master.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/I2C/MAX44009.h"\r
+#include "../common/owSlave_tools.h"\r
+\r
+OWST_EXTERN_VARS\r
+\r
+\r
+\r
+volatile uint8_t owid1[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x50};/**/\r
+volatile uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/\r
+                                        //18\r
+volatile uint8_t config_info1[26]={3,28, 0x05,0x08, 8,27, 0x00,0x00, 0x02,17,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 11,0x08, 0x02,0x07,0x00,0x07,17,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+#if (owid>128)\r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t cpsp2;\r
+\r
+OWST_WDT_ISR\r
+\r
+/*\r
+\r
+\r
+       typedef union {\r
+               volatile uint8_t bytes[8];\r
+               struct {\r
+                       uint16_t temp;  //0\r
+                       uint8_t TH;  //2\r
+                       uint8_t TL;  //3\r
+                       uint8_t config;  //4\r
+                       uint8_t rrFF; //5\r
+                       uint8_t rr00; //6\r
+                       uint8_t rr10; //7\r
+               };\r
+       } pack1_t;\r
+       volatile pack1_t pack1;\r
+*/\r
+\r
+\r
+       typedef union {\r
+               #if  defined(__AVR_ATtiny25__)\r
+               uint8_t bytes[16];\r
+               #else\r
+               uint8_t bytes[64];\r
+               #endif\r
+               struct {\r
+                       uint8_t status;  //1\r
+                       int16_t temp;  //2\r
+                       uint16_t voltage;  //4\r
+                       int16_t current;  //6\r
+                       uint8_t threshold; //8\r
+                       \r
+                       uint8_t page1[8]; //9\r
+                       #if  defined(__AVR_ATtiny25__)\r
+                       #else\r
+                       uint8_t page2[8]; //17\r
+                       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
+                                       \r
+                               };\r
+                       };\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
+                       uint8_t page6[8];  //49\r
+                       uint8_t page7[8];  //57\r
+                       \r
+                       #endif\r
+               };\r
+       } pack2_t;\r
+       volatile pack2_t pack2,pack1;\r
+\r
+\r
+\r
+\r
+       volatile int16_t DS2438_2_TEMP;\r
+       volatile uint16_t DS2438_2_VAD;\r
+       volatile uint16_t DS2438_2_VDD=0x01F4;\r
+       volatile int16_t DS2438_1_TEMP;\r
+       volatile uint16_t DS2438_1_VAD;\r
+       volatile uint16_t DS2438_1_VDD=0x01F4;\r
+\r
+       OWST_TESTSW\r
+\r
+\r
+       double temperatureC,humidityRH,hhum;\r
+       double l;\r
+\r
+\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
+               double h2;\r
+               double t2;\r
+               h2=h*h;\r
+               t2=t*t;\r
+               return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591;\r
+       }\r
+       inline double calibr_hum05(double t,double hum) {\r
+               double y=-0.0006*t*t-0.2455*t-28.5902;\r
+               return -(hum/y)+hum;\r
+       }\r
+       inline double calibr_hum075(double t,double hum) {\r
+               double y=-0.0004*t*t-0.1636*t-18.9173;\r
+               return -(hum/y)+hum;\r
+       }\r
+       inline double calibr_hum1(double t,double hum) {\r
+               double y=-0.0003*t*t-0.1228*t-14.0808;\r
+               return -(hum/y)+hum;\r
+       }\r
+\r
+       double R0;\r
+       uint16_t mr;\r
+       uint8_t startup=10;\r
+       double ip;\r
+       double la[4];\r
+       uint8_t lainit=1;\r
+\r
+\r
+       \r
+       #define EEPROM_R0 0\r
+       #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
+       uint16_t readEEPROM(uint8_t addr,uint16_t def) {\r
+               uint16_t hr;\r
+               while(EECR & (1<<EEPE));\r
+               EEARL=addr+1;\r
+               EECR |= (1<<EERE);\r
+               hr=EEDR;\r
+               if (hr!=0xFF) {\r
+                       hr=hr<<8;\r
+                       while(EECR & (1<<EEPE));\r
+                       EEARL=addr;\r
+                       EECR |= (1<<EERE);\r
+                       hr|=EEDR;\r
+                       return hr;\r
+               }\r
+               return def;\r
+       }\r
+\r
+       void writeEEPROM(uint8_t addr,uint16_t val) {\r
+               while(EECR & (1<<EEPE));\r
+               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+               EEARL = addr;\r
+               EEDR = val&0xFF;\r
+               EECR |= (1<<EEMPE);\r
+               EECR |= (1<<EEPE);\r
+               while(EECR & (1<<EEPE));\r
+               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+               EEARL = addr+1;\r
+               EEDR = val>>8;\r
+               EECR |= (1<<EEMPE);\r
+               EECR |= (1<<EEPE);\r
+       }\r
+\r
+       int main(void){\r
+               PORTA=0xFF-(1<<PINA1);\r
+               PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+               DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+               OWINIT();\r
+               DDRB|=(1<<PINB1);//Ausgang und 1\r
+               DDRA|=(1<<PINA0);\r
+               \r
+               WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+               WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+               //(1<<WDP0) |(1<<WDP2) | (1<<WDP1);    // Set Timeout to ~2 seconds\r
+               (1<<WDP3) | (1<<WDP0);    // Set Timeout to ~8 seconds\r
+\r
+               MCUSR=0;\r
+\r
+               //ADMUX=0b00001110; //ADC1 +   ADC3 -\r
+               ADMUX=0x01 ; //PA3 single and  3V\r
+               OWST_INIT_ADC\r
+               //ADCSRA = (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);//|\r
+               \r
+               \r
+\r
+               pack2.page3[0]=0xF1;\r
+               pack2.cmode=0;\r
+               pack2.R0=readEEPROM(EEPROM_R0,1);\r
+               R0=pack2.R0/100.0;\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
+               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
+               for(uint8_t i=0;i<8;i++) pack2.page6[i]=owid1[i];\r
+               if (testSW()) {\r
+                       config_info2[5]=12;\r
+                       }else{\r
+                       config_info2[5]=7;\r
+               }\r
+\r
+               TWI_Master_Initialise();\r
+               \r
+               initSHT2x();\r
+               \r
+               _delay_ms(100);\r
+               gcontrol=1;\r
+               sei();\r
+               while(1)   {\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
+                                       } 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
+                               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[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
+                                               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
+                                       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
+                               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_hum075(temperatureC,humidityRH)*10.0;\r
+                               //double RH=humidityRH*10.0;\r
+                               double TC=temperatureC*10.0-7.5;\r
+\r
+\r
+                               if (testSW()) {\r
+                                       DS2438_2_VAD=RH;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
+                                       config_info2[5]=12;     //10V = 100%\r
+                               }else{\r
+                                       hhum=(1.0546-0.000216*TC)*(RH);\r
+                                       DS2438_2_VAD=0.31*hhum +80;\r
+                                       DS2438_2_TEMP=TC*25.6;\r
+                                       config_info2[5]=7;\r
+                               }\r
+                               mr=0;\r
+                               //Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________\r
+                               PORTB&=~(1<<PINB1); //Auf 0 Ziehen\r
+                               _delay_us(500);\r
+                               for(uint8_t i=0;i<32;i++) {\r
+                                       ADCSRA|=(1<<ADSC);\r
+                                       while ((ADCSRA&(1<<ADSC)));\r
+                                       mr+=ADC;\r
+                                }\r
+                               PORTB|=(1<<PINB1);\r
+                               //ENDE Kritische Sektion !______________________________\r
+\r
+                               //pack2.VS=mr*3/128;  //VS in Volt = VS/256  --> Nur zum Debug .... Speicher reicht sonst nicht....\r
+                               l=mr*3.0/32768.0;  //Spannung in v\r
+                               l=( 3/l- 1) *30; //l is resistance\r
+                               if (lainit) {\r
+                                       la[0]=la[1]=la[2]=la[3]=l;  //smaller code\r
+                                       lainit=0;\r
+                               } else {\r
+                                       //for (uint8_t i=0;i<3;i++) {\r
+                                       //      la[i]=la[i+1];\r
+                                       //}\r
+                                       la[0]=la[1];\r
+                                       la[1]=la[2];\r
+                                       la[2]=la[3];\r
+                                       la[3]=l;\r
+                               }\r
+                               double lasum=la[0]+la[1]+la[2]+la[3];\r
+                               l=lasum/4.0;\r
+                               \r
+                               pack2.current=l*100;\r
+                               \r
+                               l=l/ip;\r
+                               \r
+                               if (startup==0){\r
+                                       if (l>R0) {\r
+                                               R0=l;\r
+                                               pack2.R0=R0*100;\r
+                                               writeEEPROM(EEPROM_R0,pack2.R0);\r
+\r
+                                       }\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=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
+                               DS2438_1_VAD=l;\r
+                               DS2438_1_VDD=(l-DS2438_1_VAD)*1000.0;\r
+                               \r
+                               l=MAX44009getlux(1);\r
+                               if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045\r
+                               //double l=1000;\r
+                               l=log(l)*10*256;\r
+                               DS2438_1_TEMP=l;\r
+\r
+                               \r
+                       }\r
+                       \r
+                       \r
+                       if (gcontrol) {\r
+                               gcontrol=0;\r
+                               \r
+                       }\r
+\r
+                       \r
+                       OWST_MAIN_END\r
+               }\r
+\r
+\r
+       }\r
diff --git a/DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_MAX44009_VOC_DS2438_SHT.atsln b/DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_MAX44009_VOC_DS2438_SHT.atsln
new file mode 100644 (file)
index 0000000..51074a8
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_MAX44009_VOC_DS2438_SHT", "DS2438_MAX44009_VOC_DS2438_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_MAX44009_VOC_DS2438_SHT.cproj b/DS2438_MAX44009_VOC_DS2438_SHT_direct/DS2438_MAX44009_VOC_DS2438_SHT.cproj
new file mode 100644 (file)
index 0000000..c0dbf44
--- /dev/null
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS2438_MAX44009_VOC_DS2438_SHT</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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
+    <ResetRule>0</ResetRule>\r
+    <EraseKey />\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.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.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.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.preprocessor.UndefSymbols>\r
+    <ListValues>\r
+      <Value>_CHANGEABLE_ID_</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.preprocessor.UndefSymbols>\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.general.AssemblerFlags>-U_CHANGEABLE_ID_</avrgcc.assembler.general.AssemblerFlags>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\I2C\MAX44009.c">\r
+      <SubType>compile</SubType>\r
+      <Link>MAX44009.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\OWDS2438_DS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438_DS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_DS2438.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_DS2438.c b/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_DS2438.c
new file mode 100644 (file)
index 0000000..eb3ad1e
--- /dev/null
@@ -0,0 +1,189 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//!!!!!Max Program size 7551 Byte\r
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>  \r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/calibr.h"\r
+#include "../common/I2C/BMP280.h"\r
+#include "../common/I2C/MAX44009.h"\r
+#include "../common/owSlave_tools.h"\r
+\r
+\r
+OWST_EXTERN_VARS\r
+\r
+\r
+\r
+volatile uint8_t owid1[8]={0x26, 0x01, 0x01, 0x01, 0x00, 0x00, 0x03, 0xF6};/**/\r
+volatile uint8_t owid2[8]={0x26, 0x02, 0x01, 0x01, 0x00, 0x00, 0x03, 0xAF};/**/\r
+volatile uint8_t config_info1[26]={0x01,0x06, 0x05,0x08, 4,7, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};        \r
+volatile uint8_t config_info2[26]={3,4, 0x05,0x08, 2,20, 0,0           , 0x02,15,0x00,14,0,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; \r
+       \r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               int16_t current;  //6\r
+               uint8_t threshold; //8\r
+               uint8_t page1[8]; //9\r
+               uint8_t page2[8]; //17\r
+                       \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
+               uint8_t page7[8];  //57\r
+               \r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1;\r
+\r
+\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[64];\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               int16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\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]; //25\r
+               uint8_t page7[8];  //57\r
+               \r
+       };\r
+} pack2_t;\r
+volatile pack2_t pack2;\r
+\r
+OWST_WDT_ISR\r
+OWST_TESTSW\r
+\r
+\r
+\r
+\r
+\r
+volatile int16_t DS2438_1_TEMP;\r
+volatile uint16_t DS2438_1_VAD;\r
+volatile int16_t DS2438_2_TEMP;\r
+volatile uint16_t DS2438_2_VAD;\r
+\r
+\r
+\r
+double temperatureC,humidityRH,hhum;\r
+double l;\r
+uint32_t P;\r
+int32_t t;\r
+uint8_t max_adr=0;\r
+\r
+\r
+int main(void){\r
+       OWST_INIT_USI_ON\r
+       OWINIT();\r
+       OWST_WDR_CONFIG8\r
+       OWST_EN_PULLUP\r
+       \r
+       pack1.page3[0]=0xF1;\r
+       pack2.page3[0]=0xF4;\r
+\r
+\r
+       USI_TWI_Master_Initialise();\r
+       _delay_ms(10);\r
+       bmp280Init();\r
+       _delay_ms(10);\r
+       initSHT2x();\r
+       _delay_ms(100);\r
+       if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;\r
+       gcontrol=1;\r
+       sei();\r
+\r
+    while(1)   {\r
+               if (gcontrol) wdcounter=1;\r
+               if (wdcounter>0) {  //8s\r
+                       getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                       double RH=humidityRH*10.0;\r
+                       double TC =temperatureC *10.0;\r
+                       if (testSW()) {\r
+                               DS2438_1_VAD=RH;\r
+                               DS2438_1_TEMP=TC*25.6;\r
+                               config_info1[5]=12;     //10V = 100%\r
+                       }else{\r
+                               hhum=(1.0546-0.000216*TC)*(RH);\r
+                               //am2302_hum=0.318*hhum +76.0;\r
+                               DS2438_1_VAD=0.31*hhum +80;\r
+                               DS2438_1_TEMP=TC*25.6;\r
+                               config_info1[5]=7;\r
+                       }\r
+                       wdcounter=0;\r
+                       bmp280ConvertInt(&t,&P,1);\r
+                       uint16_t Pu=P/50;\r
+                       Pu=Pu-1400;\r
+                       DS2438_2_VAD=Pu;\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
+                       //double l=1000;\r
+                       l=log(l)*10*16;\r
+                       DS2438_2_TEMP=l;\r
+                       \r
+               }\r
+       \r
+               if (gcontrol) {\r
+                       gcontrol=0;\r
+               }\r
+\r
+               \r
+               OWST_MAIN_END\r
+   }\r
+\r
+\r
+}\r
diff --git a/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.atsln b/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.atsln
new file mode 100644 (file)
index 0000000..5103429
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_SHT2X_DS2438_BMP280_MAX44009", "DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj b/DS2438_SHT2X_DS2438_BMP280_MAX44009/DS2438_SHT2X_DS2438_BMP280_MAX44009.cproj
new file mode 100644 (file)
index 0000000..d3b09b1
--- /dev/null
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS2438_SHT2X_DS2438_BMP280_MAX44009</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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.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.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.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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\BMP280.c">\r
+      <SubType>compile</SubType>\r
+      <Link>BMP280.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\MAX44009.c">\r
+      <SubType>compile</SubType>\r
+      <Link>MAX44009.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</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\OWDS2438_DS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438_DS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_DS2438.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2438_SHT2X_DS2438_LPS225HB/DS2438_DS2438.c b/DS2438_SHT2X_DS2438_LPS225HB/DS2438_DS2438.c
new file mode 100644 (file)
index 0000000..3e71e92
--- /dev/null
@@ -0,0 +1,282 @@
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//!!!!!Max Program size 7551 Byte\r
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>  \r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/LPS225HB.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/calibr.h"\r
+\r
+extern void OWINIT(void);\r
+extern void EXTERN_SLEEP(void);\r
+\r
+\r
+\r
+volatile uint8_t owid1[8]={0x26, 0x3B, 0xDA, 0x84, 0x00, 0x00, 0x03, 0xA2};/**/\r
+volatile uint8_t owid2[8]={0x26, 0x3C, 0xDA, 0x84, 0x00, 0x00, 0x03, 0x27};/**/\r
+volatile uint8_t config_info1[26]={0x02,23, 0x05,0x08, 0x2,20, 0x00,0x00, 0x02,29,0x00,29,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};     \r
+volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0,0, 0x02,0x07,0x00,0x07,0,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};     \r
+       \r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+volatile uint8_t wdcounter=1;\r
+\r
+\r
+typedef union {\r
+       #if  defined(__AVR_ATtiny25__)\r
+       volatile uint8_t bytes[16];\r
+       #else\r
+       volatile uint8_t bytes[64];\r
+       #endif\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               int16_t current;  //6\r
+               uint8_t threshold; //8\r
+               union {\r
+               uint8_t page1[8]; //9\r
+               struct {\r
+                       uint32_t etm;\r
+                       uint8_t ica;\r
+                       uint16_t offset;\r
+                       uint8_t f1;\r
+               };\r
+               };\r
+               #if  defined(__AVR_ATtiny25__)\r
+               #else\r
+               union {\r
+                               uint8_t page2[8]; //17\r
+                               struct  {\r
+                               uint32_t dis; \r
+                               uint32_t eoc;\r
+                               };\r
+                               };\r
+                       \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
+               uint8_t page7[8];  //57\r
+               \r
+               #endif\r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1;\r
+\r
+\r
+\r
+\r
+typedef union {\r
+       #if  defined(__AVR_ATtiny25__)\r
+       volatile uint8_t bytes[16];\r
+       #else\r
+       volatile uint8_t bytes[64];\r
+       #endif\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               int16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               #if  defined(__AVR_ATtiny25__)\r
+               #else\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
+               uint8_t page7[8];  //57\r
+               \r
+               #endif\r
+       };\r
+} pack2_t;\r
+volatile pack2_t pack2;\r
+\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
+#else\r
+ISR(WDT_vect) {\r
+#endif\r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+}\r
+\r
+\r
+\r
+volatile int16_t DS2438_1_TEMP;\r
+volatile uint16_t DS2438_1_VAD;\r
+volatile int16_t DS2438_2_TEMP;\r
+volatile uint16_t DS2438_2_VAD;\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+double temperatureC,humidityRH,hhum;\r
+double l;\r
+uint32_t P;\r
+int16_t t;\r
+\r
+int testSW(void) {\r
+       uint8_t r;\r
+       DDRB&=~(1<<PORTB0);  //Eingang\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB|=(1<<PORTB0); //Pullup\r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        r=PINB&(1<<PORTB0);\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB&=~(1<<PORTB0); \r
+        __asm__ __volatile__ ("nop"); \r
+       DDRB|=(1<<PORTB0);  //Eingang\r
+       return (r==0);  //Offen mal HIH4030\r
+        \r
+        \r
+}\r
+\r
+\r
+int main(void){\r
+    PRR|=(1<<PRADC);  // adc for save Power\r
+       PORTA=0xFF;\r
+       PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+       OWINIT();\r
+       DDRB|=(1<<PINB1);//Ausgang und 1\r
+       DDRA|=(1<<PINA0);\r
+       \r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+       \r
+       MCUSR=0;\r
+\r
+       pack2.page3[0]=0xF1; //Luftfeuchte\r
+       pack1.page3[0]=0xF4; //Spannung\r
+\r
+\r
+       if (testSW()) {\r
+               config_info2[5]=12;\r
+       }else{\r
+               config_info2[5]=7;\r
+       }\r
+\r
+       USI_TWI_Master_Initialise();\r
+       initSHT2x();\r
+       _delay_ms(10);\r
+        LPS225HB_Init();\r
+       gcontrol=1;\r
+       sei();\r
+    while(1)   {\r
+               if (gcontrol) {\r
+                       //wdcounter=3;\r
+                       gcontrol=0;\r
+                               \r
+               }\r
+               if (wdcounter>3) {  \r
+                       getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                       double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
+                       double TC =temperatureC *10.0-2;\r
+\r
+\r
+                       if (testSW()) {\r
+                                DS2438_2_VAD=RH;\r
+                                DS2438_2_TEMP=TC*25.6;\r
+                                \r
+                                config_info2[5]=12;    //10V = 100%\r
+                       }else{\r
+                               hhum=(1.0546-0.000216*TC)*(RH);\r
+                               //am2302_hum=0.318*hhum +76.0;\r
+                               DS2438_2_VAD=0.31*hhum +80;\r
+                               DS2438_2_TEMP=TC*25.6;\r
+                               config_info2[5]=7;\r
+                       }\r
+                       //DS2438_1_TEMP=DS2438_2_TEMP;\r
+\r
+                       LPS225HB_Readi(&t,&P) ;\r
+                       P=P-700*(uint32_t)(4096);\r
+                       P=((double)P/102.4);\r
+                       //cli();pack.A=ADC;sei();\r
+                       //cli();DS2438_1_TEMP=P;sei();\r
+                       DS2438_1_TEMP=P;\r
+                       P=P/20;\r
+                       DS2438_1_VAD=P;\r
+\r
+               //      gcontrol=1;\r
+                       wdcounter=0;\r
+                       \r
+               }\r
+       \r
+               \r
+\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+               asm("SLEEP");\r
+   }\r
+\r
+\r
+}\r
diff --git a/DS2438_SHT2X_DS2438_LPS225HB/DS2438_SHT2X_DS2438_LPS225HB.atsln b/DS2438_SHT2X_DS2438_LPS225HB/DS2438_SHT2X_DS2438_LPS225HB.atsln
new file mode 100644 (file)
index 0000000..3272c84
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2438_SHT2X_DS2438_LPS225HB", "DS2438_SHT2X_DS2438_LPS225HB.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               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
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_SHT2X_DS2438_LPS225HB/DS2438_SHT2X_DS2438_LPS225HB.cproj b/DS2438_SHT2X_DS2438_LPS225HB/DS2438_SHT2X_DS2438_LPS225HB.cproj
new file mode 100644 (file)
index 0000000..8c358a6
--- /dev/null
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS2438_SHT2X_DS2438_LPS225HB</Name>\r
+    <RootNamespace>DS18B20_DS2438</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <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
+    </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.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.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.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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\LPS225HB.c">\r
+      <SubType>compile</SubType>\r
+      <Link>LPS225HB.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</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\OWDS2438_DS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438_DS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_DS2438.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
index d283508..a5b53e1 100644 (file)
@@ -150,7 +150,8 @@ int main(void){
        MCUSR=0;\r
        USI_TWI_Master_Initialise();\r
 \r
        MCUSR=0;\r
        USI_TWI_Master_Initialise();\r
 \r
-       \r
+       pack.page3[0]=0xF1;\r
+\r
        \r
        initSHT3x(0);\r
        _delay_ms(100);\r
        \r
        initSHT3x(0);\r
        _delay_ms(100);\r
@@ -188,6 +189,7 @@ int main(void){
 \r
                if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {\r
                        MCUCR|=(1<<SE)|(1<<SM1);\r
 \r
                if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {\r
                        MCUCR|=(1<<SE)|(1<<SM1);\r
+                       \r
                        MCUCR&=~(1<<ISC01);\r
                } else {\r
                        MCUCR|=(1<<SE);\r
                        MCUCR&=~(1<<ISC01);\r
                } else {\r
                        MCUCR|=(1<<SE);\r
index bcc5eb3..18f6e87 100644 (file)
@@ -25,7 +25,7 @@
     <preserveEEPROM>true</preserveEEPROM>\r
     <OverrideVtorValue>exception_table</OverrideVtorValue>\r
     <BootSegment>2</BootSegment>\r
     <preserveEEPROM>true</preserveEEPROM>\r
     <OverrideVtorValue>exception_table</OverrideVtorValue>\r
     <BootSegment>2</BootSegment>\r
-    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <eraseonlaunchrule>0</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
         <options />\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
         <options />\r
     <com_atmel_avrdbg_tool_atmelice>\r
       <ToolOptions>\r
         <InterfaceProperties>\r
     <com_atmel_avrdbg_tool_atmelice>\r
       <ToolOptions>\r
         <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\r
         </InterfaceProperties>\r
         </InterfaceProperties>\r
-        <InterfaceName>debugWIRE</InterfaceName>\r
+        <InterfaceName>ISP</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
       </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
+    <avrtoolinterface>ISP</avrtoolinterface>\r
     <ExternalProgrammingToolCommand />\r
     <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
     <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
     <ExternalProgrammingToolCommand />\r
     <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
     <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\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.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
+        <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
     </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
-      <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
+        <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
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
index e2fb6c3..0e92255 100644 (file)
@@ -38,6 +38,7 @@
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
+#include "../common/I2C/TWI_Master.h"\r
 \r
 extern void OWINIT();\r
 extern void EXTERN_SLEEP();\r
 \r
 extern void OWINIT();\r
 extern void EXTERN_SLEEP();\r
@@ -49,12 +50,25 @@ uint8_t config_info[26]={0x06,0x09,0x06,0x09,0x06,0x09,0x06,0x09,0x02,20,20,20,2
 #error "Variable not correct"\r
 #endif\r
 \r
 #error "Variable not correct"\r
 #endif\r
 \r
-extern uint8_t mode;\r
+extern volatile uint8_t mode;\r
 extern uint8_t gcontrol;\r
 extern uint8_t reset_indicator;\r
 extern uint8_t alarmflag;\r
 \r
 \r
 extern uint8_t gcontrol;\r
 extern uint8_t reset_indicator;\r
 extern uint8_t alarmflag;\r
 \r
 \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
+       #else\r
+       ISR(WDT_vect) {\r
+       // mode=0;\r
+               #endif\r
+       //wdcounter++;\r
+                       if (reset_indicator==1) reset_indicator++;\r
+               else if (reset_indicator==2) mode=0;\r
+       }\r
+\r
+\r
 typedef union {\r
        volatile uint8_t bytes[0x20];\r
        struct {\r
 typedef union {\r
        volatile uint8_t bytes[0x20];\r
        struct {\r
@@ -99,8 +113,15 @@ typedef union {
 volatile pack_t pack;\r
 \r
 \r
 volatile pack_t pack;\r
 \r
 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__)||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+#define AD_PORT PORTA\r
+#define AD_DDR DDRA\r
+#endif\r
 \r
 \r
-\r
+#if  defined(__AVR_ATmega168__)||defined(__AVR_ATmega168A__) ||defined(__AVR_ATmega328__) ||defined(__AVR_ATmega328P__) ||defined(__AVR_ATmega328PB__) \r
+#define AD_PORT PORTC\r
+#define AD_DDR DDRC\r
+#endif\r
 \r
 \r
 int main(void){\r
 \r
 \r
 int main(void){\r
@@ -125,20 +146,31 @@ int main(void){
        pack.HD=0xFF;\r
        pack.LD=0x00;\r
        pack.VCCP=0;\r
        pack.HD=0xFF;\r
        pack.LD=0x00;\r
        pack.VCCP=0;\r
+        MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+        MCUCR |=(1<<BODS);\r
+        MCUSR=0;\r
 \r
 \r
-       PORTA=0xFF;\r
-       PORTB=0xFF;\r
 \r
 \r
-       OWINIT();\r
 \r
 \r
+       OWINIT();\r
+       DDRC=0xFF;\r
+       DDRB=0xFF;\r
+       DDRD=0xFF-(1<<PIND2);\r
+       PORTB=0xFF;\r
+       PORTC=0xFF;\r
+       PORTD=0xFF-(1<<PIND2);\r
+       PRR=0xCF;\r
+               \r
        MCUCR &=~(1<<PUD); //All Pins Pullup...\r
        MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-       MCUCR |=(1<<BODS);\r
+       //MCUCR |=(1<<BODS);\r
        //PORTA&=~((1<<PINA0)|(1<<PINA1)|(1<<PINA2)|(1<<PINA3));\r
 \r
        //PORTA&=~((1<<PINA0)|(1<<PINA1)|(1<<PINA2)|(1<<PINA3));\r
 \r
-       ADCSRA=(1<<ADEN)|(1<ADPS0)|(1<<ADPS2);\r
+       //ADCSRA=(1<<ADEN)|(1<ADPS0)|(1<<ADPS2);\r
 \r
        \r
 \r
        \r
-       \r
+               WDTCSR |= (1<<WDCE) |(1<<WDE);   // Enable the WD Change Bit//| (1<<WDE)\r
+               WDTCSR  =   (1<<WDIE) |              // Enable WDT Interrupt\r
+               (1<<WDP2) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
        gcontrol=1;\r
        ADCSRB|=(1<<ADLAR); \r
        sei();\r
        gcontrol=1;\r
        ADCSRB|=(1<<ADLAR); \r
        sei();\r
@@ -215,34 +247,53 @@ int main(void){
                }\r
 \r
                uint8_t bb=1;\r
                }\r
 \r
                uint8_t bb=1;\r
-               for(uint8_t i=0;i<4;i++) {\r
+               for(volatile uint8_t i=0;i<4;i++) {\r
                        if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
                                if (pack.bytes[8+i*2]&0x40) {\r
                        if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
                                if (pack.bytes[8+i*2]&0x40) {\r
-                                       DDRA|=bb;\r
+                               //      AD_DDR|=bb;\r
                                } else {\r
                                } else {\r
-                                       DDRA&=~bb;\r
+                                       cli();\r
+                               //      AD_DDR&=~bb;\r
+                                       sei();\r
                                }\r
                        } else {\r
                                }\r
                        } else {\r
-                               DDRA&=~bb;\r
+                               cli();\r
+                       //      AD_DDR&=~bb;\r
+                               sei();\r
                        }\r
                        bb=bb*2;\r
                }\r
                \r
                        }\r
                        bb=bb*2;\r
                }\r
                \r
+\r
+#if defined(__AVR_ATmega168__)||defined(__AVR_ATmega168A__)  ||defined(__AVR_ATmega328__) ||defined(__AVR_ATmega328P__) ||defined(__AVR_ATmega328PB__) \r
+       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0)){\r
+       //if ( mode==0){\r
+               SMCR|=(1<<SE)|(1<<SM1);\r
+               EICRA&=~(1<<ISC01);\r
+       } else {\r
+               SMCR|=(1<<SE);\r
+               SMCR&=~(1<<SM1);\r
+       }\r
+       asm("SLEEP");\r
+#else\r
+\r
 #if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
                        if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
 #endif                 \r
 #if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
                        if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
 #endif                 \r
-#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__) \r
                        if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
 #endif\r
                          {\r
 \r
                        MCUCR|=(1<<SE)|(1<<SM1);\r
                        if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
 #endif\r
                          {\r
 \r
                        MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<SM0);\r
                        MCUCR&=~(1<<ISC01);\r
                } else {\r
                        MCUCR|=(1<<SE);\r
                        MCUCR&=~(1<<SM1);\r
                }\r
                        MCUCR&=~(1<<ISC01);\r
                } else {\r
                        MCUCR|=(1<<SE);\r
                        MCUCR&=~(1<<SM1);\r
                }\r
-       //      asm("SLEEP");\r
+               asm("SLEEP");\r
+#endif\r
    }\r
 \r
 \r
    }\r
 \r
 \r
index 5eb8631..bba1e99 100644 (file)
@@ -5,7 +5,7 @@
     <ProjectVersion>7.0</ProjectVersion>\r
     <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>\r
     <ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
     <ProjectVersion>7.0</ProjectVersion>\r
     <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>\r
     <ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
-    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdevice>ATmega328P</avrdevice>\r
     <avrdeviceseries>none</avrdeviceseries>\r
     <OutputType>Executable</OutputType>\r
     <Language>C</Language>\r
     <avrdeviceseries>none</avrdeviceseries>\r
     <OutputType>Executable</OutputType>\r
     <Language>C</Language>\r
@@ -25,7 +25,7 @@
     <preserveEEPROM>true</preserveEEPROM>\r
     <OverrideVtorValue>exception_table</OverrideVtorValue>\r
     <BootSegment>2</BootSegment>\r
     <preserveEEPROM>true</preserveEEPROM>\r
     <OverrideVtorValue>exception_table</OverrideVtorValue>\r
     <BootSegment>2</BootSegment>\r
-    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <eraseonlaunchrule>0</eraseonlaunchrule>\r
     <ExternalProgrammingToolCommand />\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
     <ExternalProgrammingToolCommand />\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
         </dependencies>\r
       </framework-data>\r
     </AsfFrameworkConfig>\r
         </dependencies>\r
       </framework-data>\r
     </AsfFrameworkConfig>\r
-    <avrtool />\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolinterface>ISP</avrtoolinterface>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E950F</avrdeviceexpectedsignature>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\r
+        </InterfaceProperties>\r
+        <InterfaceName>ISP</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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-        <avrgcc.compiler.symbols.DefSymbols>\r
-          <ListValues>\r
-            <Value>NDEBUG</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.symbols.DefSymbols>\r
-        <avrgcc.compiler.directories.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
-          </ListValues>\r
-        </avrgcc.compiler.directories.IncludePaths>\r
-        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
-        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-        <avrgcc.linker.libraries.Libraries>\r
-          <ListValues>\r
-            <Value>libm</Value>\r
-          </ListValues>\r
-        </avrgcc.linker.libraries.Libraries>\r
-        <avrgcc.assembler.general.IncludePaths>\r
-          <ListValues>\r
-            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
-          </ListValues>\r
-        </avrgcc.assembler.general.IncludePaths>\r
-      </AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\gcc\dev\atmega328p"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>NDEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
     </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=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\gcc\dev\atmega328p"</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\ATmega_DFP\1.1.130\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\ATmega_DFP\1.1.130\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
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>TWI_Master.c</Link>\r
+    </Compile>\r
     <Compile Include="DS2450.c">\r
       <SubType>compile</SubType>\r
     </Compile>\r
     <Compile Include="DS2450.c">\r
       <SubType>compile</SubType>\r
     </Compile>\r
index 61a1dad..a3381b4 100644 (file)
@@ -33,8 +33,8 @@
 \r
 #define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
 \r
 #define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
-#define  __4MHZ__\r
-\r
+//#define  __4MHZ__\r
+//#define _DB_\r
 #include "../common/OWConfig.s"\r
 #include "../common/OWCRC16.s"\r
 \r
 #include "../common/OWConfig.s"\r
 #include "../common/OWCRC16.s"\r
 \r
@@ -140,9 +140,9 @@ h_readmemory_init_crc:; init erstes CRC byte
        ;ldi r_bcount,1\r
        rjmp handle_end\r
 h_readmemory_end:\r
        ;ldi r_bcount,1\r
        rjmp handle_end\r
 h_readmemory_end:\r
-       ldi  r_mode,OW_SLEEP\r
-       clr r_sendflag\r
-       rjmp handle_end\r
+       //ldi  r_mode,OW_SLEEP\r
+       //clr r_sendflag\r
+       rjmp handle_end_sleep\r
 h_readmemorycrc1:;init zweites CRC Byte\r
        lds r_rwbyte,crcsave\r
        ;ldi r_bcount,1\r
 h_readmemorycrc1:;init zweites CRC Byte\r
        lds r_rwbyte,crcsave\r
        ;ldi r_bcount,1\r
diff --git a/DS2450_ADC/DS2450.c b/DS2450_ADC/DS2450.c
new file mode 100644 (file)
index 0000000..2dc7006
--- /dev/null
@@ -0,0 +1,305 @@
+\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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/owSlave_tools.h"\r
+\r
+\r
+OWST_EXTERN_VARS\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t config_info[26]={0x06,0x09,0x06,9,0x06,9,0x06,9,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+OWST_WDT_ISR\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+OWST_ADC_CONF16_FUNC\r
+OWST_ADC_CONF16_OSS_FUNC\r
+OWST_TESTSW\r
+\r
+#define LPIN_CH2 (1<<PINB1)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LED2_ON LPORT_CH2&=~LPIN_CH2;\r
+#define LED2_OFF LPORT_CH2|=LPIN_CH2;\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\r
+       OWST_INIT_ADC_ON\r
+       OWINIT();\r
+\r
+       OWST_WDR_CONFIG8\r
+       gcontrol=1;\r
+       OWST_INIT_ADC\r
+       AD_DDR&=~(1<<PINA0);\r
+       AD_PORT&=~(1<<PINA0);\r
+       AD_DDR&=~(1<<PINA1);\r
+       AD_PORT&=~(1<<PINA1);\r
+       AD_DDR&=~(1<<PINA3);\r
+       AD_PORT&=~(1<<PINA3);\r
+       AD_DDR&=~(1<<PINA7);\r
+       AD_PORT&=~(1<<PINA7);\r
+       DIDR0|=((1<<ADC7D)|(1<<ADC3D)|(1<<ADC1D)|(1<<ADC0D));\r
+       sei();\r
+       wdcounter=5;\r
+       //DDRB|=(1<<PINB1);\r
+       LDD_CH2 |=LPIN_CH2;\r
+       volatile double VCC;\r
+       volatile double VAD_A,VAD_B,VAD_C,VAD_D;\r
+    while(1)   {\r
+               if (wdcounter>3) {\r
+                       LED2_ON\r
+                       wdcounter=0;\r
+                       ADMUX=OWST_ADCIN_REFINT;\r
+                       _delay_us(100);\r
+                       VCC=owst_ADC_runf();\r
+                       VCC=(1.079*65472.0)/VCC;\r
+                       //if (VCC>5.1) VCC=5.1;\r
+                       //VAD=VCC*65535.0/5.1;\r
+                       //if (VAD>65535) VAD=65535;\r
+                       if (testSW()) {  //Zwei differential Eingaenge\r
+                               VAD_C=0;\r
+                               ADMUX=0b001000; //ADC0 + ADC1 - Gain 1\r
+                               _delay_us(100);\r
+                               VAD_A=owst_ADC_runf();\r
+                               if (VAD_A<3100) {\r
+                                       ADMUX=0b001001; //ADC0 + ADC1 - Gain 20\r
+                                       _delay_us(100);\r
+                                       VAD_A=owst_ADC_runf();\r
+                                       VAD_A=VCC/20.0*VAD_A/65472.0;\r
+                                       //VAD_A=VCC/20.0;\r
+                                       VAD_C+=12850;\r
+                               } else {\r
+                                       VAD_A=owst_ADC_OSS_runf();\r
+                                       VAD_A=VCC*VAD_A/65472.0;\r
+                                       VAD_C+=0;\r
+                               }\r
+                               if (pack.CSA2&0x01) VAD_A=VAD_A*65535.0/5.1; else VAD_A=VAD_A*65535.0/2.55;\r
+                               if (VAD_A>65535) VAD_A=65535;\r
+                               ///_------------------------ B---------------------\r
+                               ADMUX=0b011000; //ADC3 + ADC7 - Gain 1\r
+                               _delay_us(100);\r
+                               VAD_B=owst_ADC_runf();\r
+                               if (VAD_B<3100) {\r
+                                       ADMUX=0b011001; //ADC3 + ADC7 - Gain 20\r
+                                       _delay_us(100);\r
+                                       VAD_B=owst_ADC_runf();\r
+                                       VAD_B=VCC/20.0*VAD_B/65472.0;\r
+                                       //VAD_B=VAD_B20.0;\r
+                                       VAD_C+=12850*2;\r
+                               } else {\r
+                                       VAD_B=owst_ADC_OSS_runf();\r
+                                       VAD_B=VCC*VAD_B/65472.0;\r
+                                       VAD_C+=0;\r
+                               }\r
+                               if (pack.CSB2&0x01) VAD_B=VAD_B*65535.0/5.1; else VAD_B=VAD_B*65535.0/2.55;\r
+                               //VAD_B=VAD_B*65535.0/5.1;\r
+                               if (VAD_B>65535) VAD_B=65535;\r
+                               VAD_D=VCC*65535.0/5.1;\r
+                               if (VAD_D>65535) VAD_D=65535;\r
+\r
+                       } else { // 4 Eingaenge gegen Masse\r
+                               ADMUX=OWST_ADCIN_PA0;\r
+                               _delay_us(100);\r
+                               VAD_A=owst_ADC_OSS_runf();\r
+                               VAD_A=VCC*VAD_A/65472.0;\r
+                               if (pack.CSA2&0x01) VAD_A=VAD_A*65535.0/5.1; else VAD_A=VAD_A*65535.0/2.55;\r
+                               if (VAD_A>65535) VAD_A=65535;\r
+\r
+                               ADMUX=OWST_ADCIN_PA1;\r
+                               _delay_us(100);\r
+                               VAD_B=owst_ADC_OSS_runf();\r
+                               VAD_B=VCC*VAD_B/65472.0;\r
+                               if (pack.CSB2&0x01) VAD_B=VAD_B*65535.0/5.1; else VAD_B=VAD_B*65535.0/2.55;\r
+                               if (VAD_B>65535) VAD_B=65535;\r
+\r
+                               ADMUX=OWST_ADCIN_PA3;\r
+                               _delay_us(100);\r
+                               VAD_C=owst_ADC_OSS_runf();\r
+                               VAD_C=VCC*VAD_C/65472.0;\r
+                               if (pack.CSC2&0x01) VAD_C=VAD_C*65535.0/5.1; else VAD_C=VAD_C*65535.0/2.55;\r
+                               if (VAD_C>65535) VAD_C=65535;\r
+\r
+                               ADMUX=OWST_ADCIN_PA7;\r
+                               _delay_us(100);\r
+                               VAD_D=owst_ADC_OSS_runf();\r
+                               VAD_D=VCC*VAD_D/65472.0;\r
+                               if (pack.CSD2&0x01) VAD_D=VAD_D*65535.0/5.1; else VAD_D=VAD_D*65535.0/2.55;\r
+                               if (VAD_D>65535) VAD_D=65535;\r
+                       }\r
+                       LED2_OFF\r
+\r
+\r
+               }\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){ //Initialisieren mit 0 oder FF oder letzter Wert\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               //if (pack.CSA2&0x01)   ADMUX=0; else ADMUX=0x80;\r
+                               cli();pack.A=VAD_A;sei();\r
+                               alarmflag=0;\r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               //if (pack.CSB2&0x01)   ADMUX=1; else ADMUX=0x81;\r
+                               cli();pack.B=VAD_B;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               //if (pack.CSC2&0x01)   ADMUX=2; else ADMUX=0x82;\r
+                               cli();pack.C=VAD_C;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               cli();pack.D=VAD_D;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               uint8_t bb=1;\r
+               for(volatile uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                               //      AD_DDR|=bb;\r
+                               } else {\r
+                                       cli();\r
+                               //      AD_DDR&=~bb;\r
+                                       sei();\r
+                               }\r
+                       } else {\r
+                               cli();\r
+                       //      AD_DDR&=~bb;\r
+                               sei();\r
+                       }\r
+                       bb=bb*2;\r
+               }\r
+               OWST_MAIN_END \r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_ADC/DS2450_ADC.atsln b/DS2450_ADC/DS2450_ADC.atsln
new file mode 100644 (file)
index 0000000..0ca60e9
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_ADC", "DS2450_ADC.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_ADC/DS2450_ADC.cproj b/DS2450_ADC/DS2450_ADC.cproj
new file mode 100644 (file)
index 0000000..577de37
--- /dev/null
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_ADC</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\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.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.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.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.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.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.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
+  <ItemGroup>\r
+    <Compile Include="DS2450.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_ADC/OWDS2450.S b/DS2450_ADC/OWDS2450.S
new file mode 100644 (file)
index 0000000..a3381b4
--- /dev/null
@@ -0,0 +1,248 @@
+\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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+//#define  __4MHZ__\r
+//#define _DB_\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       //ldi  r_mode,OW_SLEEP\r
+       //clr r_sendflag\r
+       rjmp handle_end_sleep\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/DS2450_ADC_JOE2/DS2450.c b/DS2450_ADC_JOE2/DS2450.c
new file mode 100644 (file)
index 0000000..edf3076
--- /dev/null
@@ -0,0 +1,305 @@
+\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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/owSlave_tools.h"\r
+\r
+\r
+OWST_EXTERN_VARS\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t config_info[26]={0x06,0x09,0x06,9,0x06,9,0x06,9,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+OWST_WDT_ISR\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+OWST_ADC_CONF16_FUNC\r
+OWST_ADC_CONF16_OSS_FUNC\r
+OWST_TESTSW\r
+\r
+#define LPIN_CH2 (1<<PINB1)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LED2_ON LPORT_CH2&=~LPIN_CH2;\r
+#define LED2_OFF LPORT_CH2|=LPIN_CH2;\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\r
+       OWST_INIT_ADC_ON\r
+       OWINIT();\r
+\r
+       OWST_WDR_CONFIG8\r
+       gcontrol=1;\r
+       OWST_INIT_ADC\r
+       AD_DDR&=~(1<<PINA4);\r
+       AD_PORT&=~(1<<PINA4);\r
+       AD_DDR&=~(1<<PINA5);\r
+       AD_PORT&=~(1<<PINA5);\r
+       AD_DDR&=~(1<<PINA6);\r
+       AD_PORT&=~(1<<PINA6);\r
+       AD_DDR&=~(1<<PINA7);\r
+       AD_PORT&=~(1<<PINA7);\r
+       DIDR0|=((1<<ADC4D)|(1<<ADC5D)|(1<<ADC6D)|(1<<ADC7D));\r
+       sei();\r
+       wdcounter=5;\r
+       //DDRB|=(1<<PINB1);\r
+       LDD_CH2 |=LPIN_CH2;\r
+       volatile double VCC;\r
+       volatile double VAD_A,VAD_B,VAD_C,VAD_D;\r
+    while(1)   {\r
+               if (wdcounter>3) {\r
+                       LED2_ON\r
+                       wdcounter=0;\r
+                       ADMUX=OWST_ADCIN_REFINT;\r
+                       _delay_us(100);\r
+                       VCC=owst_ADC_runf();\r
+                       VCC=(1.079*65472.0)/VCC;\r
+                       //if (VCC>5.1) VCC=5.1;\r
+                       //VAD=VCC*65535.0/5.1;\r
+                       //if (VAD>65535) VAD=65535;\r
+                       if (testSW()) {  //Zwei differential Eingaenge\r
+                               VAD_C=0;\r
+                               ADMUX=0b0011010; //ADC4 + ADC5 - Gain 1\r
+                               _delay_us(100);\r
+                               VAD_A=owst_ADC_runf();\r
+                               if (VAD_A<3100) {\r
+                                       ADMUX=0b0011011; //ADC0 + ADC1 - Gain 20\r
+                                       _delay_us(100);\r
+                                       VAD_A=owst_ADC_runf();\r
+                                       VAD_A=VCC/20.0*VAD_A/65472.0;\r
+                                       //VAD_A=VCC/20.0;\r
+                                       VAD_C+=12850;\r
+                               } else {\r
+                                       VAD_A=owst_ADC_OSS_runf();\r
+                                       VAD_A=VCC*VAD_A/65472.0;\r
+                                       VAD_C+=0;\r
+                               }\r
+                               if (pack.CSA2&0x01) VAD_A=VAD_A*65535.0/5.1; else VAD_A=VAD_A*65535.0/2.55;\r
+                               if (VAD_A>65535) VAD_A=65535;\r
+                               ///_------------------------ B---------------------\r
+                               ADMUX=0b011110; //ADC6 + ADC7 - Gain 1\r
+                               _delay_us(100);\r
+                               VAD_B=owst_ADC_runf();\r
+                               if (VAD_B<3100) {\r
+                                       ADMUX=0b011111; //ADC6 + ADC7 - Gain 20\r
+                                       _delay_us(100);\r
+                                       VAD_B=owst_ADC_runf();\r
+                                       VAD_B=VCC/20.0*VAD_B/65472.0;\r
+                                       //VAD_B=VAD_B20.0;\r
+                                       VAD_C+=12850*2;\r
+                               } else {\r
+                                       VAD_B=owst_ADC_OSS_runf();\r
+                                       VAD_B=VCC*VAD_B/65472.0;\r
+                                       VAD_C+=0;\r
+                               }\r
+                               if (pack.CSB2&0x01) VAD_B=VAD_B*65535.0/5.1; else VAD_B=VAD_B*65535.0/2.55;\r
+                               //VAD_B=VAD_B*65535.0/5.1;\r
+                               if (VAD_B>65535) VAD_B=65535;\r
+                               VAD_D=VCC*65535.0/5.1;\r
+                               if (VAD_D>65535) VAD_D=65535;\r
+\r
+                       } else { // 4 Eingaenge gegen Masse\r
+                               ADMUX=OWST_ADCIN_PA4;\r
+                               _delay_us(100);\r
+                               VAD_A=owst_ADC_OSS_runf();\r
+                               VAD_A=VCC*VAD_A/65472.0;\r
+                               if (pack.CSA2&0x01) VAD_A=VAD_A*65535.0/5.1; else VAD_A=VAD_A*65535.0/2.55;\r
+                               if (VAD_A>65535) VAD_A=65535;\r
+\r
+                               ADMUX=OWST_ADCIN_PA5;\r
+                               _delay_us(100);\r
+                               VAD_B=owst_ADC_OSS_runf();\r
+                               VAD_B=VCC*VAD_B/65472.0;\r
+                               if (pack.CSB2&0x01) VAD_B=VAD_B*65535.0/5.1; else VAD_B=VAD_B*65535.0/2.55;\r
+                               if (VAD_B>65535) VAD_B=65535;\r
+\r
+                               ADMUX=OWST_ADCIN_PA6;\r
+                               _delay_us(100);\r
+                               VAD_C=owst_ADC_OSS_runf();\r
+                               VAD_C=VCC*VAD_C/65472.0;\r
+                               if (pack.CSC2&0x01) VAD_C=VAD_C*65535.0/5.1; else VAD_C=VAD_C*65535.0/2.55;\r
+                               if (VAD_C>65535) VAD_C=65535;\r
+\r
+                               ADMUX=OWST_ADCIN_PA7;\r
+                               _delay_us(100);\r
+                               VAD_D=owst_ADC_OSS_runf();\r
+                               VAD_D=VCC*VAD_D/65472.0;\r
+                               if (pack.CSD2&0x01) VAD_D=VAD_D*65535.0/5.1; else VAD_D=VAD_D*65535.0/2.55;\r
+                               if (VAD_D>65535) VAD_D=65535;\r
+                       }\r
+                       LED2_OFF\r
+\r
+\r
+               }\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){ //Initialisieren mit 0 oder FF oder letzter Wert\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               //if (pack.CSA2&0x01)   ADMUX=0; else ADMUX=0x80;\r
+                               cli();pack.A=VAD_A;sei();\r
+                               alarmflag=0;\r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               //if (pack.CSB2&0x01)   ADMUX=1; else ADMUX=0x81;\r
+                               cli();pack.B=VAD_B;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               //if (pack.CSC2&0x01)   ADMUX=2; else ADMUX=0x82;\r
+                               cli();pack.C=VAD_C;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               cli();pack.D=VAD_D;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               uint8_t bb=1;\r
+               for(volatile uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                               //      AD_DDR|=bb;\r
+                               } else {\r
+                                       cli();\r
+                               //      AD_DDR&=~bb;\r
+                                       sei();\r
+                               }\r
+                       } else {\r
+                               cli();\r
+                       //      AD_DDR&=~bb;\r
+                               sei();\r
+                       }\r
+                       bb=bb*2;\r
+               }\r
+               OWST_MAIN_END \r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_ADC_JOE2/DS2450_ADC.atsln b/DS2450_ADC_JOE2/DS2450_ADC.atsln
new file mode 100644 (file)
index 0000000..e78802a
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_ADC_JOE2", "DS2450_ADC_JOE2.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_ADC_JOE2/DS2450_ADC_JOE2.cproj b/DS2450_ADC_JOE2/DS2450_ADC_JOE2.cproj
new file mode 100644 (file)
index 0000000..aba66b8
--- /dev/null
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_ADC_JOE2</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\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.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.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.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.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.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.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
+  <ItemGroup>\r
+    <Compile Include="DS2450.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_ADC_JOE2/OWDS2450.S b/DS2450_ADC_JOE2/OWDS2450.S
new file mode 100644 (file)
index 0000000..a3381b4
--- /dev/null
@@ -0,0 +1,248 @@
+\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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+//#define  __4MHZ__\r
+//#define _DB_\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       //ldi  r_mode,OW_SLEEP\r
+       //clr r_sendflag\r
+       rjmp handle_end_sleep\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
index 06d2247..d6e53d6 100644 (file)
@@ -1,22 +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
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_APDS9960", "DS2450_APDS9960.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
index 43e905b..aadfa77 100644 (file)
-<?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" />
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_APDS9960</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\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
+  </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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="..\common\I2C\APDS9960.c">\r
+      <SubType>compile</SubType>\r
+      <Link>APDS9960.c</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="DS2450_APDS9960.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
 </Project>
\ No newline at end of file
 </Project>
\ No newline at end of file
diff --git a/DS2450_APDS9960/OWDS2450.S b/DS2450_APDS9960/OWDS2450.S
new file mode 100644 (file)
index 0000000..61a1dad
--- /dev/null
@@ -0,0 +1,248 @@
+\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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+#define  __4MHZ__\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/DS2450_BME680/DS2450_BME680.atsln b/DS2450_BME680/DS2450_BME680.atsln
new file mode 100644 (file)
index 0000000..0c0f0c7
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_BME680", "DS2450_BME680.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_BME680/DS2450_BME680.c b/DS2450_BME680/DS2450_BME680.c
new file mode 100644 (file)
index 0000000..c93bd56
--- /dev/null
@@ -0,0 +1,272 @@
+\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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/TWI_Master.h"\r
+#include "../common/I2C/BME680.h"\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x23, 0x20};/**/\r
+//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};\r
+//uint8_t config_info[26]={1,14,4,8,2,8,11,18,0x02,24,24,24,24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+uint8_t config_info[26]={1,13,4,13,2,8,11,8,0x02,24,24,24,24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+volatile uint8_t wdcounter=10;\r
+\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
+       #else\r
+       ISR(WDT_vect) {\r
+               #endif\r
+               wdcounter++;\r
+       //      if (reset_indicator==1) reset_indicator++;\r
+               //else if (reset_indicator==2) mode=0;\r
+       }\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x22];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+int16_t T;\r
+uint16_t H;\r
+uint32_t P;\r
+uint16_t G;\r
+\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\r
+\r
+       PORTA=0xFF;\r
+       //PORTB=0xFF;\r
+       //PORTC=0xFF;\r
+//     PORTD=0xFF;\r
+\r
+       OWINIT();\r
+\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+       MCUCR |=(1<<BODS);\r
+\r
+       //PORTA&=~((1<<PINA0)|(1<<PINA1)|(1<<PINA2)|(1<<PINA3));\r
+\r
+\r
+\r
+       WDTCSR |= (1<<WDCE) |(1<<WDE);   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR  =   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+\r
+       wdcounter=4;\r
+       \r
+       gcontrol=1;\r
+       TWI_Master_Initialise();\r
+       \r
+       initBME680();\r
+       sei();\r
+       \r
+       //DDRB|=(1<<PINB1);\r
+\r
+    while(1)   {\r
+               if (wdcounter>1) {\r
+                       readBMP680(&T,&H,&P,&G);\r
+                       wdcounter=0;\r
+               }\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               \r
+                               //cli();pack.A=rlight[0];sei();\r
+                               //cli();pack.A=r_gain;sei();\r
+                               //cli();pack.A=T+32767;sei();\r
+                               cli();pack.A=T;sei();\r
+                               alarmflag=0;\r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               //cli();pack.B=rlight[1];sei();\r
+                               //cli();pack.B=atime;sei();\r
+                               cli();pack.B=H;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               //cli();pack.C=rlight[2];sei();\r
+                               cli();pack.C=P/10;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               //cli();pack.D=rlight[3];sei();\r
+                               cli();pack.D=G;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       //DDRA|=bb;\r
+                               } else {\r
+                                       //DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               //DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__) ||defined(__AVR_ATmega168__)||defined(__AVR_ATmega168A__)  ||defined(__AVR_ATmega328__) ||defined(__AVR_ATmega328P__) ||defined(__AVR_ATmega328PB__)\r
+\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+               asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_BME680/DS2450_BME680.cproj b/DS2450_BME680/DS2450_BME680.cproj
new file mode 100644 (file)
index 0000000..d947301
--- /dev/null
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_BME680</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>0</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\r
+        </InterfaceProperties>\r
+        <InterfaceName>ISP</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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\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.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>NDEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+</AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.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.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.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.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.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
+  <ItemGroup>\r
+    <Compile Include="..\common\I2C\BME680.c">\r
+      <SubType>compile</SubType>\r
+      <Link>BME680.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="DS2450_BME680.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_BME680/OWDS2450.S b/DS2450_BME680/OWDS2450.S
new file mode 100644 (file)
index 0000000..61a1dad
--- /dev/null
@@ -0,0 +1,248 @@
+\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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+#define  __4MHZ__\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/DS2450_BMP280/OWDS2450.S b/DS2450_BMP280/OWDS2450.S
new file mode 100644 (file)
index 0000000..1d81abd
--- /dev/null
@@ -0,0 +1,247 @@
+\r
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/DS2450_CDM7160/DS2450_CDM7160.atsln b/DS2450_CDM7160/DS2450_CDM7160.atsln
new file mode 100644 (file)
index 0000000..6ee8119
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_CDM7160", "DS2450_CDM7160.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_CDM7160/DS2450_CDM7160.c b/DS2450_CDM7160/DS2450_CDM7160.c
new file mode 100644 (file)
index 0000000..f69e8b4
--- /dev/null
@@ -0,0 +1,280 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/CDM7160.h"\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+//6A02160084D9A320\r
+//uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t owid[8]={0x20, 0xB3, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x31};/**/\r
+uint8_t config_info[26]={0x10,13,0x0,0x0, 0,0, 0,0,0x02,16,0,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+volatile uint8_t wdcounter=10;\r
+\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
+#else\r
+ISR(WDT_vect) {\r
+#endif \r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+}\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+\r
+\r
+uint16_t CO2;\r
+\r
+\r
+\r
+\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\r
+ PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+ DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
\r
\r
+ OWINIT();\r
+\r
+ ACSR|=(1<<ACD);  //Disable Comparator\r
+ ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
+ MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+ MCUCR |=(1<<BODS);\r
+\r
\r
+ WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+ WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+ (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+\r
+       \r
+       gcontrol=1;\r
+       \r
+       USI_TWI_Master_Initialise();\r
+       CDM7160softReset();\r
+       _delay_ms(200);\r
+\r
+       CDM7160setMode(0); //Power Down Mode\r
+       _delay_ms(200);\r
+       CDM7160setAvCount(0x3F);\r
+       CDM7160setFMode(1);\r
+       CO2=CDM7160getCO2();\r
+       CDM7160setMode(1);\r
+       _delay_ms(200);\r
+\r
+       sei();\r
+       \r
+       //DDRB|=(1<<PINB1);\r
+\r
+    while(1)   {\r
+       \r
+       if (wdcounter>2) {      \r
+               \r
+               CO2=CDM7160getCO2();\r
+\r
+               wdcounter=0;\r
+       }\r
+       \r
+\r
+               \r
+               \r
+\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+               \r
+                               cli();pack.A=CO2;sei();\r
+                               //wdcounter=10;\r
+                               alarmflag=0;\r
+                               \r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+\r
+                               cli();pack.B=0;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+               \r
+                               cli();pack.C=0;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                       \r
+                               cli();pack.D=0;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               /*uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       DDRA|=bb;\r
+                               } else {\r
+                                       DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }*/\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+               asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_CDM7160/DS2450_CDM7160.cproj b/DS2450_CDM7160/DS2450_CDM7160.cproj
new file mode 100644 (file)
index 0000000..bfa0cb9
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_CDM7160</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000779</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\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>J41800000779</ToolNumber>\r
+      <ToolName>Atmel-ICE</ToolName>\r
+    </com_atmel_avrdbg_tool_atmelice>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\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.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -D__4MHZ__</avrgcc.compiler.miscellaneous.OtherFlags>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.AssemblerFlags>-D__4MHZ__</avrgcc.assembler.general.AssemblerFlags>\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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\I2C\CDM7160.c">\r
+      <SubType>compile</SubType>\r
+      <Link>CDM7160.c</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\OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2450.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2450_CDM7160.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_CDM7160/OWDS2450.S b/DS2450_CDM7160/OWDS2450.S
new file mode 100644 (file)
index 0000000..1d81abd
--- /dev/null
@@ -0,0 +1,247 @@
+\r
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.atsln b/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.atsln
new file mode 100644 (file)
index 0000000..8e5ac3e
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_CDM7160_BMP280", "DS2450_CDM7160_BMP280.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.c b/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.c
new file mode 100644 (file)
index 0000000..204aa20
--- /dev/null
@@ -0,0 +1,272 @@
+\r
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/TWI_Master.h"\r
+#include "../common/I2C/CDM7160.h"\r
+#include "../common/I2C/BMP280.h"\r
+#include "../common/owSlave_tools.h"\r
+\r
+OWST_EXTERN_VARS\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t config_info[26]={10,13,10,13, 2,16, 1,14,0x02,16,16,14,14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+OWST_WDT_ISR\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+\r
+\r
+\r
+ double temperatureC,humidityRH;\r
+ double l;\r
+uint32_t P;\r
+int32_t t;\r
+int16_t CO2;\r
+uint8_t max_adr=0;\r
+\r
+\r
+\r
+int main(void){\r
+       OWST_INIT_USI_ON\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\r
+\r
+       OWINIT();\r
+\r
+       OWST_WDR_CONFIG8\r
+       OWST_EN_PULLUP\r
+       \r
+       gcontrol=1;\r
+       TWI_Master_Initialise();\r
+       CDM7160softReset();\r
+       _delay_ms(200);\r
+\r
+       CDM7160setMode(0); //Power Down Mode\r
+       _delay_ms(200);\r
+       CDM7160setAvCount(0x3F);\r
+       CDM7160setFMode(1);\r
+       CO2=CDM7160getCO2();\r
+       CDM7160setMode(1);\r
+       _delay_ms(200);\r
+       \r
+       bmp280Init();\r
+       \r
+       sei();\r
+       \r
+       //DDRB|=(1<<PINB1);\r
+\r
+    while(1)   {\r
+       \r
+       if (wdcounter>3) {      \r
+               \r
+               bmp280ConvertInt(&t,&P,1);\r
+               CO2=CDM7160getCO2();\r
+               wdcounter=0;\r
+       }\r
+       \r
+\r
+               \r
+               \r
+\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               /*if (pack.CSA2&0x01)   ADMUX=0; else ADMUX=0x80;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.A=ADC;sei();*/\r
+                               double cc=(double)CO2/(P/101300.0*298.0/(273.0+t/100.0));\r
+                               cli();pack.A=cc;sei();\r
+                               wdcounter=10;\r
+                               alarmflag=0;\r
+                               \r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               /*if (pack.CSB2&0x01)   ADMUX=1; else ADMUX=0x81;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.B=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               cli();pack.B=CO2;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               /*if (pack.CSC2&0x01)   ADMUX=2; else ADMUX=0x82;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.C=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               uint16_t hd=P/100.0*32.0;\r
+                               cli();pack.C=hd;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               /*if (pack.CSD2&0x01)   ADMUX=3; else ADMUX=0x83;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.D=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               uint16_t ct=(t)+32767;\r
+                               cli();pack.D=ct;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               /*uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       DDRA|=bb;\r
+                               } else {\r
+                                       DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }*/\r
+               \r
+               OWST_MAIN_END\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.cproj b/DS2450_CDM7160_BMP280/DS2450_CDM7160_BMP280.cproj
new file mode 100644 (file)
index 0000000..7bbbdcc
--- /dev/null
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_CDM7160_BMP280</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000779</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\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>J41800000779</ToolNumber>\r
+      <ToolName>Atmel-ICE</ToolName>\r
+    </com_atmel_avrdbg_tool_atmelice>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\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.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+      </AvrGcc>\r
+    </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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\I2C\BMP280.c">\r
+      <SubType>compile</SubType>\r
+      <Link>BMP280.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\CDM7160.c">\r
+      <SubType>compile</SubType>\r
+      <Link>CDM7160.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="DS2450_CDM7160_BMP280.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_DSM501A/DS2450_DSM501A.atsln b/DS2450_DSM501A/DS2450_DSM501A.atsln
new file mode 100644 (file)
index 0000000..b65d9ec
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_DSM501A", "DS2450_DSM501A.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_DSM501A/DS2450_DSM501A.c b/DS2450_DSM501A/DS2450_DSM501A.c
new file mode 100644 (file)
index 0000000..710e9ae
--- /dev/null
@@ -0,0 +1,312 @@
+\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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t config_info[26]={0x9,13,0x06,0x09,0x06,0x013,0x06,0x013,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+\r
+volatile uint16_t ltime_list[32];\r
+volatile uint16_t pcount_list[32];\r
+volatile uint8_t wsp=0;\r
+volatile uint16_t max_count;\r
+volatile uint16_t max_ptime=0;\r
+volatile uint16_t min_ptime=0;\r
+\r
+uint16_t ds;\r
+\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+volatile uint16_t count;\r
+volatile uint16_t ltime;\r
+volatile uint16_t startt;\r
+\r
+#define SEC_TIME 31250+300\r
+\r
+ISR(TIM1_OVF_vect){\r
+       TCNT1=~(SEC_TIME);\r
+       ltime_list[wsp]=ltime;\r
+       pcount_list[wsp]=count;\r
+       wsp++;\r
+       if (wsp>=32) wsp=0;\r
+       //if (count>max) max=count;\r
+       //if (mess) \r
+       //count=(SEC_TIME)\r
+       startt=~(SEC_TIME);\r
+       count=0;\r
+       ltime=0;\r
+       \r
+}\r
+#define PIN_WIND (1<<PINA2)\r
+#define PIN_REG PINA\r
+volatile uint8_t istat;\r
+volatile uint8_t mess=0;\r
+\r
+\r
+ISR(PCINT0_vect) {\r
+       if (((PIN_REG&PIN_WIND)==0)&&((istat&PIN_WIND)==PIN_WIND)) {    \r
+        startt=TCNT1;\r
+        mess=1;\r
+       PORTB&=~(1<<PINB1);\r
+       }\r
+       if (((PIN_REG&PIN_WIND)==PIN_WIND)&&((istat&PIN_WIND)==0)) {\r
+               uint16_t duration=(+TCNT1-startt);\r
+               ltime+=duration;\r
+               count++;\r
+               if (min_ptime==0) min_ptime=duration;\r
+               if (duration>max_ptime)max_ptime=duration;\r
+               if (duration<min_ptime)min_ptime=duration;\r
+               \r
+               mess=0;\r
+       }\r
+\r
+       istat=PIN_REG;\r
+       \r
+}\r
+\r
+\r
+int main(void){\r
+       for(uint8_t i=0;i<16;i++) {ltime_list[i]=0;pcount_list[i]=0;}\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\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
+       ADCSRA=(1<<ADEN)|(1<ADPS0)|(1<<ADPS2);\r
+\r
+       \r
+       \r
+       gcontrol=1;\r
+       ADCSRB|=(1<<ADLAR); \r
+       sei();\r
+       \r
+       DDRB|=(1<<PINB1);\r
+       TCCR1B|=(1<<CS12); //8000000/256 =31250\r
+       TIMSK1|=(1<<TOIE1); \r
+       istat=PIN_REG;\r
+       GIMSK|=(1<<PCIE0);\r
+       PCMSK0=(PIN_WIND);\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+       PORTA|=0xFF; \r
+    while(1)   {\r
+               //PORTB&=~(1<<PINB1);\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               //if (pack.CSA2&0x01)   ADMUX=0; else ADMUX=0x80;\r
+                               //_delay_us(100);\r
+                               //ADCSRA|=(1<<ADSC);\r
+                               //while ((ADCSRA&(1<<ADSC)));\r
+                               //cli();pack.A=ADC;sei();\r
+                               ds=0;\r
+                               for(uint8_t i=0;i<32;i++) {\r
+                                       ds+=pcount_list[i];\r
+                                       //if (wspeed[i]>ds) ds=wspeed[i];\r
+                               }\r
+                               cli();pack.A=ds;sei();\r
+                               alarmflag=0;\r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               double fds=0;\r
+                               for(uint8_t i=0;i<32;i++) {\r
+                                       fds+=ltime_list[i];\r
+                                       //if (wspeed[i]>ds) ds=wspeed[i];\r
+                               }\r
+                               double lr=(fds/32.0)/(SEC_TIME)*65535/5.1;\r
+                               cli();pack.B=lr;sei();\r
+                               //max=0;\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               double mu_sek=(double)max_ptime/(SEC_TIME)*1e6;\r
+                               max_ptime=0;\r
+                               cli();pack.C=mu_sek;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               double mu_sek=(double)min_ptime/(SEC_TIME)*1e6;\r
+                               min_ptime=0;\r
+                               cli();pack.D=mu_sek;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //\r
+               }\r
+\r
+               uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       DDRA|=bb;\r
+                               } else {\r
+                                       DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }\r
+               if ((PORTB&(1<<PINB1))==0) {\r
+                       _delay_ms(100);\r
+                       PORTB|=(1<<PINB1);\r
+                }\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+       //      asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_DSM501A/DS2450_DSM501A.cproj b/DS2450_DSM501A/DS2450_DSM501A.cproj
new file mode 100644 (file)
index 0000000..bc44dfa
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_DSM501A</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\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
+  </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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="..\common\OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2450.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2450_DSM501A.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
index cd34225..37cfa07 100644 (file)
@@ -1,22 +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
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_IAQCORE", "DS2450_IAQCORE.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
index 750cb9b..006c9b8 100644 (file)
@@ -45,7 +45,7 @@ extern void OWINIT();
 extern void EXTERN_SLEEP();\r
 \r
 uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
 extern void EXTERN_SLEEP();\r
 \r
 uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
-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};\r
+uint8_t config_info[26]={10,13,8,13,11,13,5,13,0x02,27,27,27,27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
 \r
 #if (owid>128) \r
 #error "Variable not correct"\r
 \r
 #if (owid>128) \r
 #error "Variable not correct"\r
index 5bb475f..e17cbba 100644 (file)
-<?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" />
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_IAQCORE</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool />\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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="..\common\I2C\IAQCORE.c">\r
+      <SubType>compile</SubType>\r
+      <Link>IAQCORE.c</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="DS2450_IAQCORE.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
 </Project>
\ No newline at end of file
 </Project>
\ No newline at end of file
diff --git a/DS2450_LPS225HB/DS2450_LPS225HB.atsln b/DS2450_LPS225HB/DS2450_LPS225HB.atsln
new file mode 100644 (file)
index 0000000..73505ee
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_LPS225HB", "DS2450_LPS225HB.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_LPS225HB/DS2450_LPS225HB.c b/DS2450_LPS225HB/DS2450_LPS225HB.c
new file mode 100644 (file)
index 0000000..75dbbad
--- /dev/null
@@ -0,0 +1,292 @@
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/LPS225HB.h"\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t config_info[26]={0x02,16,0x01,14, 0,0, 0x0,0,0x02,14,14,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+volatile uint8_t wdcounter=10;\r
+\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
+#else\r
+ISR(WDT_vect) {\r
+#endif \r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+}\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+\r
+volatile int16_t am2302_temp;\r
+volatile uint16_t am2302_hum;\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+volatile double temperatureC,humidityRH;\r
+uint32_t P;\r
+int16_t t;\r
+\r
+\r
+\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\r
+    PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+       PORTA=0xFF;  //All Pull up;\r
+        PRR|=(1<<PRADC);  // adc for save Power\r
+\r
+       ACSR|=(1<<ACD);  //Disable Comparator\r
+       OWINIT();\r
+\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+       MCUCR |=(1<<BODS);\r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+       \r
+       gcontrol=1;\r
+       \r
+       USI_TWI_Master_Initialise();\r
+       LPS225HB_Init() ;\r
+       \r
+       sei();\r
+       \r
+       //DDRB|=(1<<PINB1);\r
+\r
+    while(1)   {\r
+       \r
+       if (wdcounter>3) {      \r
+               LPS225HB_Readi(&t,&P);\r
+               \r
+       \r
+               wdcounter=0;\r
+       }\r
+       \r
+\r
+               \r
+               \r
+\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               /*if (pack.CSA2&0x01)   ADMUX=0; else ADMUX=0x80;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.A=ADC;sei();*/\r
+                               cli();pack.A=P/128;sei();\r
+                               wdcounter=10;\r
+                               alarmflag=0;\r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               /*if (pack.CSB2&0x01)   ADMUX=1; else ADMUX=0x81;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.B=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               uint16_t ct=(t)+32767;\r
+                               cli();pack.B=ct;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               /*if (pack.CSC2&0x01)   ADMUX=2; else ADMUX=0x82;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.C=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               cli();pack.C=0;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               /*if (pack.CSD2&0x01)   ADMUX=3; else ADMUX=0x83;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.D=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               cli();pack.D=0;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               /*uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       DDRA|=bb;\r
+                               } else {\r
+                                       DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }*/\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+       //      asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_LPS225HB/DS2450_LPS225HB.cproj b/DS2450_LPS225HB/DS2450_LPS225HB.cproj
new file mode 100644 (file)
index 0000000..f11555c
--- /dev/null
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_LPS225HB</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000779</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\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>J41800000779</ToolNumber>\r
+      <ToolName>Atmel-ICE</ToolName>\r
+    </com_atmel_avrdbg_tool_atmelice>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\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.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+      </AvrGcc>\r
+    </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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\I2C\LPS225HB.c">\r
+      <SubType>compile</SubType>\r
+      <Link>LPS225HB.c</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="DS2450_LPS225HB.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_LPS225HB/OWDS2450.S b/DS2450_LPS225HB/OWDS2450.S
new file mode 100644 (file)
index 0000000..1d81abd
--- /dev/null
@@ -0,0 +1,247 @@
+\r
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/DS2450_MAX44008/DS2450_MAX44008.atsln b/DS2450_MAX44008/DS2450_MAX44008.atsln
new file mode 100644 (file)
index 0000000..71471d5
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_MAX44008", "DS2450_MAX44008.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_MAX44008/DS2450_MAX44008.c b/DS2450_MAX44008/DS2450_MAX44008.c
new file mode 100644 (file)
index 0000000..2741d88
--- /dev/null
@@ -0,0 +1,270 @@
+\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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t config_info[26]={0x06,0x09,0x06,0x09,0x06,0x09,0x06,0x09,0x02,20,20,20,20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+       uint8_t checkMAX44008(uint8_t nr) {\r
+               volatile uint8_t b1;\r
+               nr=(nr<<1)&0x02f;\r
+               \r
+               I2c_StartCondition();\r
+               I2c_WriteByte(0b10000000|nr);\r
+               I2c_WriteByte(0x00);\r
+               I2c_StartCondition();\r
+               I2c_WriteByte (0b10000001|nr);\r
+               b1 =I2c_ReadByte(NO_ACK);\r
+               I2c_StopCondition();\r
+               return b1!=0xFF;\r
+               \r
+       }\r
+\r
+\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       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
+\r
+       ADCSRA=(1<<ADEN)|(1<ADPS0)|(1<<ADPS2);\r
+\r
+       \r
+       \r
+       gcontrol=1;\r
+       ADCSRB|=(1<<ADLAR); \r
+       USI_TWI_Master_Initialise();\r
+       \r
+\r
+\r
+\r
+       sei();\r
+       \r
+       //DDRB|=(1<<PINB1);\r
+\r
+    while(1)   {\r
+\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               if (pack.CSA2&0x01)     ADMUX=0; else ADMUX=0x80;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.A=ADC;sei();\r
+                               pack.A= checkMAX44008(0);\r
+                               alarmflag=0;\r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               if (pack.CSB2&0x01)     ADMUX=1; else ADMUX=0x81;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.B=ADC;sei();\r
+                               pack.B= checkMAX44008(1);\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               if (pack.CSC2&0x01)     ADMUX=2; else ADMUX=0x82;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.C=ADC;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               if (pack.CSD2&0x01)     ADMUX=3; else ADMUX=0x83;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.D=ADC;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       DDRA|=bb;\r
+                               } else {\r
+                                       DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+       //      asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_MAX44008/DS2450_MAX44008.cproj b/DS2450_MAX44008/DS2450_MAX44008.cproj
new file mode 100644 (file)
index 0000000..7dff5bc
--- /dev/null
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_MAX44008</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool />\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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>USI_TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="DS2450_MAX44008.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_MAX44008/OWDS2450.S b/DS2450_MAX44008/OWDS2450.S
new file mode 100644 (file)
index 0000000..61a1dad
--- /dev/null
@@ -0,0 +1,248 @@
+\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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+#define  __4MHZ__\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/DS2450_SGP30/DS2450_SGP30.atsln b/DS2450_SGP30/DS2450_SGP30.atsln
new file mode 100644 (file)
index 0000000..5f82c4f
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_SGP30", "DS2450_SGP30.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_SGP30/DS2450_SGP30.c b/DS2450_SGP30/DS2450_SGP30.c
new file mode 100644 (file)
index 0000000..f0b881c
--- /dev/null
@@ -0,0 +1,265 @@
+\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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/SGP30.h"\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x23, 0x20};/**/\r
+//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};\r
+uint8_t config_info[26]={10,13,8,13,8,13,8,13,0x02,25,25,25,25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+volatile uint8_t wdcounter=10;\r
+\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
+       #else\r
+       ISR(WDT_vect) {\r
+               #endif\r
+               wdcounter++;\r
+               if (reset_indicator==1) reset_indicator++;\r
+               else if (reset_indicator==2) mode=0;\r
+       }\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+uint16_t CO2;\r
+uint16_t VOC;\r
+uint16_t ETH;\r
+uint16_t H2;\r
+\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       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
+\r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP2) | (1<<WDP1);   // Set Timeout to ~1 seconds\r
+\r
+       wdcounter=4;\r
+       \r
+       gcontrol=1;\r
+       USI_TWI_Master_Initialise();\r
+       initSGP30();\r
+       _delay_ms(200);\r
+       runSGP30(&CO2,&VOC,&ETH,&H2);\r
+       \r
+       sei();\r
+       \r
+       //DDRB|=(1<<PINB1);\r
+\r
+    while(1)   {\r
+               if (wdcounter>1) {\r
+                       runSGP30(&CO2,&VOC,&ETH,&H2);\r
+                       wdcounter=0;\r
+               }\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               \r
+                               //cli();pack.A=rlight[0];sei();\r
+                               //cli();pack.A=r_gain;sei();\r
+                               cli();pack.A=CO2;sei();\r
+                               alarmflag=0;\r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               //cli();pack.B=rlight[1];sei();\r
+                               //cli();pack.B=atime;sei();\r
+                               cli();pack.B=VOC;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               //cli();pack.C=rlight[2];sei();\r
+                               cli();pack.C=ETH;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               //cli();pack.D=rlight[3];sei();\r
+                               cli();pack.D=H2;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       DDRA|=bb;\r
+                               } else {\r
+                                       DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+       //      asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_SGP30/DS2450_SGP30.cproj b/DS2450_SGP30/DS2450_SGP30.cproj
new file mode 100644 (file)
index 0000000..b11d7bb
--- /dev/null
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_SGP30</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+            <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.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.AssemblerFlags>-D  __4MHZ__</avrgcc.assembler.general.AssemblerFlags>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+            <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.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.AssemblerFlags>-D __4MHZ__</avrgcc.assembler.general.AssemblerFlags>\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
+    <Compile Include="..\common\I2C\SGP30.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SGP30.c</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="DS2450_SGP30.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_SGP30/OWDS2450.S b/DS2450_SGP30/OWDS2450.S
new file mode 100644 (file)
index 0000000..0b56d13
--- /dev/null
@@ -0,0 +1,250 @@
+\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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+//#define  __4MHZ__\r
+\r
+\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
index c9b2ef7..526fac6 100644 (file)
@@ -1,22 +1,22 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Atmel Studio Solution File, Format Version 11.00
-VisualStudioVersion = 14.0.23107.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SHT2X_BMP280", "DS2450_SHT2X_BMP280.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|AVR = Debug|AVR
-               Release|AVR = Release|AVR
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR
-               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR
-               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR
-               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_SHT2X_BMP280", "DS2450_SHT2X_BMP280.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
index 683b765..2d10504 100644 (file)
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
 #include "../common/I2C/USI_TWI_Master.h"\r
-#include "../common/I2C/SHT2x.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
 #include "../common/I2C/BMP280.h"\r
 #include "../common/I2C/MAX44009.h"\r
 #include "../common/I2C/BMP280.h"\r
 #include "../common/I2C/MAX44009.h"\r
-extern void OWINIT();\r
-extern void EXTERN_SLEEP();\r
+#include "../common/owSlave_tools.h"\r
+#include "../common/calibr.h"\r
+\r
+OWST_EXTERN_VARS\r
 \r
 uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
 uint8_t config_info[26]={0x01,14,0x04,0x08, 0x03,15, 0x02,16,0x02,7,7,15,14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
 \r
 uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
 uint8_t config_info[26]={0x01,14,0x04,0x08, 0x03,15, 0x02,16,0x02,7,7,15,14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
@@ -52,22 +54,8 @@ uint8_t config_info[26]={0x01,14,0x04,0x08, 0x03,15, 0x02,16,0x02,7,7,15,14,0x00
 #error "Variable not correct"\r
 #endif\r
 \r
 #error "Variable not correct"\r
 #endif\r
 \r
-extern uint8_t mode;\r
-extern uint8_t gcontrol;\r
-extern uint8_t reset_indicator;\r
-extern uint8_t alarmflag;\r
-volatile uint8_t wdcounter=10;\r
-\r
+OWST_WDT_ISR\r
 \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
-#else\r
-ISR(WDT_vect) {\r
-#endif \r
-       wdcounter++;\r
-       if (reset_indicator==1) reset_indicator++;\r
-       else if (reset_indicator==2) mode=0;\r
-}\r
 \r
 typedef union {\r
        volatile uint8_t bytes[0x20];\r
 \r
 typedef union {\r
        volatile uint8_t bytes[0x20];\r
@@ -114,14 +102,10 @@ volatile pack_t pack;
 \r
 \r
 \r
 \r
 \r
 \r
-volatile int16_t am2302_temp;\r
-volatile uint16_t am2302_hum;\r
 \r
 \r
 \r
 \r
-uint8_t userRegister[1];\r
-int16_t sRH,sT;\r
-volatile double temperatureC,humidityRH;\r
-volatile double l;\r
+ double temperatureC,humidityRH;\r
+ double l;\r
 uint32_t P;\r
 int32_t t;\r
 uint8_t max_adr=0;\r
 uint32_t P;\r
 int32_t t;\r
 uint8_t max_adr=0;\r
@@ -129,6 +113,7 @@ uint8_t max_adr=0;
 \r
 \r
 int main(void){\r
 \r
 \r
 int main(void){\r
+       OWST_INIT_USI_ON\r
        pack.A=0;\r
        pack.B=0;\r
        pack.C=0;\r
        pack.A=0;\r
        pack.B=0;\r
        pack.C=0;\r
@@ -150,35 +135,17 @@ int main(void){
        pack.HD=0xFF;\r
        pack.LD=0x00;\r
        pack.VCCP=0;\r
        pack.HD=0xFF;\r
        pack.LD=0x00;\r
        pack.VCCP=0;\r
-    PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
-       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
-       PORTA=0xFF;  //All Pull up;\r
-        PRR|=(1<<PRADC);  // adc for save Power\r
 \r
 \r
-       ACSR|=(1<<ACD);  //Disable Comparator\r
        OWINIT();\r
 \r
        OWINIT();\r
 \r
-       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-       MCUCR |=(1<<BODS);\r
-       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
-       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
-       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+       OWST_WDR_CONFIG8\r
+       OWST_EN_PULLUP\r
        \r
        gcontrol=1;\r
        \r
        \r
        gcontrol=1;\r
        \r
-       USI_TWI_Master_Initialise();\r
+       initSHT2x();\r
+       _delay_ms(10);\r
        bmp280Init();\r
        bmp280Init();\r
-       SHT2x_SoftReset();\r
-       SHT2x_ReadUserRegister(userRegister);\r
-       //(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT;\r
-       SHT2x_WriteUserRegister(userRegister); //write changed user reg\r
-       // --- measure humidity with "Hold Master Mode (HM)" ---\r
-       //SHT2x_MeasurePoll(HUMIDITY, &sRH);\r
-       // --- measure temperature with "Polling Mode" (no hold master) ---\r
-       //SHT2x_MeasurePoll(TEMP, &sT);\r
-       //-- calculate humidity and temperature --\r
-       //temperatureC = SHT2x_CalcTemperatureC(sT);\r
-       //humidityRH = SHT2x_CalcRH(sRH);\r
        if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;\r
        \r
        sei();\r
        if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;\r
        \r
        sei();\r
@@ -188,12 +155,9 @@ int main(void){
     while(1)   {\r
        \r
        if (wdcounter>3) {      \r
     while(1)   {\r
        \r
        if (wdcounter>3) {      \r
-               SHT2x_MeasurePoll(HUMIDITY, &sRH);\r
-               // --- measure temperature with "Polling Mode" (no hold master) ---\r
-               SHT2x_MeasurePoll(TEMP, &sT);\r
-               //-- calculate humidity and temperature --\r
-               temperatureC = SHT2x_CalcTemperatureC(sT);\r
-               humidityRH = SHT2x_CalcRH(sRH);\r
+               getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+               humidityRH=calibr_hum(temperatureC,-0.2,humidityRH);\r
+               temperatureC =temperatureC -0.2;\r
                bmp280ConvertInt(&t,&P,1);\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
                bmp280ConvertInt(&t,&P,1);\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
@@ -245,7 +209,8 @@ int main(void){
                                while ((ADCSRA&(1<<ADSC)));\r
                                cli();pack.B=ADC;sei();*/\r
                                wdcounter=10;\r
                                while ((ADCSRA&(1<<ADSC)));\r
                                cli();pack.B=ADC;sei();*/\r
                                wdcounter=10;\r
-                               cli();pack.B=humidityRH*100;sei();\r
+                               uint16_t hb=humidityRH*100;\r
+                               cli();pack.B=hb;sei();\r
                                if (pack.CSB2&0x08)  //AEH\r
                                        if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
                                if (pack.CSB2&0x04)  //AEL\r
                                if (pack.CSB2&0x08)  //AEH\r
                                        if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
                                if (pack.CSB2&0x04)  //AEL\r
@@ -272,7 +237,8 @@ int main(void){
                                while ((ADCSRA&(1<<ADSC)));\r
                                cli();pack.D=ADC;sei();*/\r
                                wdcounter=10;\r
                                while ((ADCSRA&(1<<ADSC)));\r
                                cli();pack.D=ADC;sei();*/\r
                                wdcounter=10;\r
-                               cli();pack.D=P/100.0*32.0;sei();\r
+                               uint16_t hd=P/100.0*32.0;\r
+                               cli();pack.D=hd;sei();\r
                                if (pack.CSD2&0x08)  //AEH\r
                                        if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
                                if (pack.CSD2&0x04)  //AEL\r
                                if (pack.CSD2&0x08)  //AEH\r
                                        if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
                                if (pack.CSD2&0x04)  //AEL\r
@@ -297,21 +263,7 @@ int main(void){
                        bb=bb*2;\r
                }*/\r
                \r
                        bb=bb*2;\r
                }*/\r
                \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
-#endif                 \r
-#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
-                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
-#endif\r
-                         {\r
-\r
-                       MCUCR|=(1<<SE)|(1<<SM1);\r
-                       MCUCR&=~(1<<ISC01);\r
-               } else {\r
-                       MCUCR|=(1<<SE);\r
-                       MCUCR&=~(1<<SM1);\r
-               }\r
-       //      asm("SLEEP");\r
+               OWST_MAIN_END\r
    }\r
 \r
 \r
    }\r
 \r
 \r
index 2b6a417..6de6c7f 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <ExternalProgrammingToolCommand />\r
     <AsfFrameworkConfig>\r
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <ExternalProgrammingToolCommand />\r
     <AsfFrameworkConfig>\r
-      <framework-data xmlns="">\r
+      <framework-data>\r
         <options />\r
         <configurations />\r
         <files />\r
         <documentation help="" />\r
         <offline-documentation help="" />\r
         <dependencies>\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.27.3" />\r
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
         </dependencies>\r
       </framework-data>\r
     </AsfFrameworkConfig>\r
         </dependencies>\r
       </framework-data>\r
     </AsfFrameworkConfig>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
     <Compile Include="..\common\I2C\BMP280.c">\r
       <SubType>compile</SubType>\r
       <Link>BMP280.c</Link>\r
     <Compile Include="..\common\I2C\BMP280.c">\r
       <SubType>compile</SubType>\r
       <Link>BMP280.c</Link>\r
       <SubType>compile</SubType>\r
       <Link>MAX44009.c</Link>\r
     </Compile>\r
       <SubType>compile</SubType>\r
       <Link>MAX44009.c</Link>\r
     </Compile>\r
-    <Compile Include="..\common\I2C\SHT2x.c">\r
-      <SubType>compile</SubType>\r
-      <Link>SHT2x.c</Link>\r
-    </Compile>\r
-    <Compile Include="..\common\I2C\TSL256x.c">\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
       <SubType>compile</SubType>\r
       <SubType>compile</SubType>\r
-      <Link>TSL256x.c</Link>\r
+      <Link>SHT2xV2.c</Link>\r
     </Compile>\r
     <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
       <SubType>compile</SubType>\r
     </Compile>\r
     <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
       <SubType>compile</SubType>\r
index 542967c..5739ec3 100644 (file)
@@ -1,22 +1,22 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Atmel Studio Solution File, Format Version 11.00
-VisualStudioVersion = 14.0.23107.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_SHT2X_MAX44009", "DS2450_SHT2X_MAX44009.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|AVR = Debug|AVR
-               Release|AVR = Release|AVR
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR
-               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR
-               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR
-               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_SHT2X_MAX44009", "DS2450_SHT2X_MAX44009.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
index 8f5d4f9..b5ed22b 100644 (file)
@@ -38,7 +38,7 @@
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <avr/pgmspace.h>\r
-#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/TWI_Master.h"\r
 #include "../common/I2C/SHT2x.h"\r
 #include "../common/I2C/MAX44009.h"\r
 extern void OWINIT();\r
 #include "../common/I2C/SHT2x.h"\r
 #include "../common/I2C/MAX44009.h"\r
 extern void OWINIT();\r
@@ -165,7 +165,7 @@ int main(void){
        \r
        gcontrol=1;\r
        \r
        \r
        gcontrol=1;\r
        \r
-       USI_TWI_Master_Initialise();\r
+       TWI_Master_Initialise();\r
        SHT2x_SoftReset();\r
        SHT2x_ReadUserRegister(userRegister);\r
        //(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT;\r
        SHT2x_SoftReset();\r
        SHT2x_ReadUserRegister(userRegister);\r
        //(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT;\r
@@ -309,7 +309,7 @@ int main(void){
                        MCUCR|=(1<<SE);\r
                        MCUCR&=~(1<<SM1);\r
                }\r
                        MCUCR|=(1<<SE);\r
                        MCUCR&=~(1<<SM1);\r
                }\r
-       //      asm("SLEEP");\r
+               asm("SLEEP");\r
    }\r
 \r
 \r
    }\r
 \r
 \r
index 56aab1a..2ec9b25 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <ExternalProgrammingToolCommand />\r
     <AsfFrameworkConfig>\r
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <ExternalProgrammingToolCommand />\r
     <AsfFrameworkConfig>\r
-      <framework-data xmlns="">\r
-        <options />\r
-        <configurations />\r
-        <files />\r
-        <documentation help="" />\r
-        <offline-documentation help="" />\r
-        <dependencies>\r
-          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.27.3" />\r
-        </dependencies>\r
-      </framework-data>\r
+      <framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <avrtoolserialnumber>J41800000779</avrtoolserialnumber>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <avrtoolserialnumber>J41800000779</avrtoolserialnumber>\r
       <SubType>compile</SubType>\r
       <Link>TSL256x.c</Link>\r
     </Compile>\r
       <SubType>compile</SubType>\r
       <Link>TSL256x.c</Link>\r
     </Compile>\r
-    <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
+    <Compile Include="..\common\I2C\TWI_Master.c">\r
       <SubType>compile</SubType>\r
       <SubType>compile</SubType>\r
-      <Link>USI_TWI_Master.c</Link>\r
+      <Link>TWI_Master.c</Link>\r
     </Compile>\r
     <Compile Include="DS2450_SHT2X_MAX44009.c">\r
       <SubType>compile</SubType>\r
     </Compile>\r
     <Compile Include="DS2450_SHT2X_MAX44009.c">\r
       <SubType>compile</SubType>\r
diff --git a/DS2450_SHT3X/DS2450_SHT3X.atsln b/DS2450_SHT3X/DS2450_SHT3X.atsln
new file mode 100644 (file)
index 0000000..c8f5c00
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_SHT3X", "DS2450_SHT3X.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_SHT3X/DS2450_SHT3X.c b/DS2450_SHT3X/DS2450_SHT3X.c
new file mode 100644 (file)
index 0000000..26d723b
--- /dev/null
@@ -0,0 +1,298 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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 F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/SHT3x.h"\r
+#include "../common/calibr.h"\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+//6A02160084D9A320\r
+//uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t owid[8]={0x20, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x6A};/**/\r
+uint8_t config_info[26]={0x01,14,0x04,0x08, 0,0, 0,0,0x02,21,21,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+volatile uint8_t wdcounter=10;\r
+\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
+#else\r
+ISR(WDT_vect) {\r
+#endif \r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+}\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+\r
+volatile int16_t am2302_temp;\r
+volatile uint16_t am2302_hum;\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+ double temperatureC,humidityRH;\r
+uint32_t P;\r
+int32_t t;\r
+\r
+\r
+\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\r
+    PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+       PORTA=0xFF;  //All Pull up;\r
+        PRR|=(1<<PRADC);  // adc for save Power\r
+\r
+       ACSR|=(1<<ACD);  //Disable Comparator\r
+       OWINIT();\r
+\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+       MCUCR |=(1<<BODS);\r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+       \r
+       gcontrol=1;\r
+       \r
+       USI_TWI_Master_Initialise();\r
+\r
+       initSHT3x(0);\r
+       _delay_ms(100);\r
+       getSHT3xHumTemp(0,&temperatureC,&humidityRH);\r
+\r
+       sei();\r
+       \r
+       //DDRB|=(1<<PINB1);\r
+\r
+    while(1)   {\r
+       \r
+       if (wdcounter>3) {      \r
+               \r
+               getSHT3xHumTemp(0,&temperatureC,&humidityRH);\r
+\r
+               wdcounter=0;\r
+       }\r
+       \r
+\r
+               \r
+               \r
+\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               /*if (pack.CSA2&0x01)   ADMUX=0; else ADMUX=0x80;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.A=ADC;sei();*/\r
+                               uint16_t ct=(temperatureC*100.0)+32767;\r
+                               cli();pack.A=ct;sei();\r
+                               wdcounter=10;\r
+                               alarmflag=0;\r
+                               \r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               /*if (pack.CSB2&0x01)   ADMUX=1; else ADMUX=0x81;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.B=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               cli();pack.B=humidityRH*100;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               /*if (pack.CSC2&0x01)   ADMUX=2; else ADMUX=0x82;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.C=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               cli();pack.C=0;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               /*if (pack.CSD2&0x01)   ADMUX=3; else ADMUX=0x83;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.D=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               cli();pack.D=P/100.0*32.0;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               /*uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       DDRA|=bb;\r
+                               } else {\r
+                                       DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }*/\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+               asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_SHT3X/DS2450_SHT3X.cproj b/DS2450_SHT3X/DS2450_SHT3X.cproj
new file mode 100644 (file)
index 0000000..2441aed
--- /dev/null
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_SHT3X</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000779</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\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>J41800000779</ToolNumber>\r
+      <ToolName>Atmel-ICE</ToolName>\r
+    </com_atmel_avrdbg_tool_atmelice>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\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.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>NDEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -D__4MHZ__</avrgcc.compiler.miscellaneous.OtherFlags>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.AssemblerFlags>-D__4MHZ__</avrgcc.assembler.general.AssemblerFlags>\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
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT3x.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT3x.c</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="DS2450_SHT3X.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_SHT3X/OWDS2450.S b/DS2450_SHT3X/OWDS2450.S
new file mode 100644 (file)
index 0000000..1d81abd
--- /dev/null
@@ -0,0 +1,247 @@
+\r
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/DS2450_VOC_SHT/DS2450_VOC_SHT.atsln b/DS2450_VOC_SHT/DS2450_VOC_SHT.atsln
new file mode 100644 (file)
index 0000000..97e522a
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# 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}") = "DS2450_VOC_SHT", "DS2450_VOC_SHT.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\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
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_VOC_SHT/DS2450_VOC_SHT.c b/DS2450_VOC_SHT/DS2450_VOC_SHT.c
new file mode 100644 (file)
index 0000000..80c06a1
--- /dev/null
@@ -0,0 +1,519 @@
+\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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//!!!!!Max Program size 7551 Byte\r
+\r
+\r
+\r
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/MAX1164x.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/calibr.h"\r
+\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t config_info[26]={0x01,14,0x04,0x08, 8,8,11,0x08,0x02,7,7,17,17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+volatile uint8_t wdcounter=1;\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
+#else\r
+ISR(WDT_vect) {\r
+#endif\r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+}\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+\r
+\r
+\r
+volatile int16_t am2302_temp;\r
+volatile uint16_t am2302_hum;\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+double temperatureC,humidityRH,hhum;\r
+double l;\r
+double RH;\r
+double TC;\r
+\r
+\r
+uint8_t max_adr=0;\r
+#define CH0_M MAX1164x_C_SCAN0|MAX1164x_C_SGL\r
+#define CH1_M MAX1164x_C_SCAN0|MAX1164x_C_SGL|MAX1164x_C_CS0\r
+#define CH0_CH1 MAX1164x_C_SCAN0\r
+//|MAX1164x_C_CS0\r
+\r
+uint16_t weekmaxarr[8];\r
+\r
+//Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte\r
+inline double interp(double t, double h) {\r
+       double h2;\r
+       double t2;\r
+       h2=h*h;\r
+       t2=t*t;\r
+       return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591;\r
+}\r
+\r
+double R0;\r
+uint16_t mr;\r
+uint8_t startup=10;\r
+double ip;\r
+\r
+\r
+int testSW(void) {\r
+       uint8_t r;\r
+       DDRB&=~(1<<PORTB0);  //Eingang\r
+       __asm__ __volatile__ ("nop");\r
+       PORTB|=(1<<PORTB0); //Pullup\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       __asm__ __volatile__ ("nop");\r
+       r=PINB&(1<<PORTB0);\r
+       __asm__ __volatile__ ("nop");\r
+       PORTB&=~(1<<PORTB0);\r
+       __asm__ __volatile__ ("nop");\r
+       DDRB|=(1<<PORTB0);  //Eingang\r
+       return (r==0);  //Offen mal HIH4030\r
+       \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
+\r
+uint16_t readEEPROM(uint8_t addr,uint16_t def) {\r
+       uint16_t hr;\r
+       while(EECR & (1<<EEPE));\r
+       EEARL=addr+1;\r
+       EECR |= (1<<EERE);\r
+       hr=EEDR;\r
+       if (hr!=0xFF) {\r
+               hr=hr<<8;\r
+               while(EECR & (1<<EEPE));\r
+               EEARL=addr;\r
+               EECR |= (1<<EERE);\r
+               hr|=EEDR;\r
+               return hr;\r
+       }\r
+       return def;\r
+}\r
+\r
+void writeEEPROM(uint8_t addr,uint16_t val) {\r
+       while(EECR & (1<<EEPE));\r
+       EECR = (0<<EEPM1)|(0<<EEPM0);\r
+       EEARL = addr;\r
+       EEDR = val&0xFF;\r
+       EECR |= (1<<EEMPE);\r
+       EECR |= (1<<EEPE);\r
+       while(EECR & (1<<EEPE));\r
+       EECR = (0<<EEPM1)|(0<<EEPM0);\r
+       EEARL = addr+1;\r
+       EEDR = val>>8;\r
+       EECR |= (1<<EEMPE);\r
+       EECR |= (1<<EEPE);\r
+}\r
+\r
+uint16_t pR0;\r
+uint16_t pVS;\r
+uint8_t pcmode;\r
+int16_t pip;\r
+uint16_t ptol_s8;\r
+uint16_t ptol_d;\r
+uint16_t pr_day_max;\r
+uint16_t pr_week_max;\r
+uint16_t RA;\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\r
+\r
+    PRR|=(1<<PRADC);  // adc for save Power\r
+    PORTA=0xFF;\r
+    PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+    DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+    OWINIT();\r
+    DDRB|=(1<<PINB1);//Ausgang und 1\r
+    DDRA|=(1<<PINA0);\r
+    \r
+    WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+    WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+    //(1<<WDP0) |(1<<WDP2) | (1<<WDP1);    // Set Timeout to ~2 seconds\r
+    (1<<WDP3) | (1<<WDP0);    // Set Timeout to ~8 seconds\r
+\r
+    MCUSR=0;\r
+       if (testSW()) {\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
+\r
+       }\r
+\r
+\r
+       \r
+       OWINIT();\r
+       pcmode=0;\r
+       pR0=readEEPROM(EEPROM_R0,1);\r
+       R0=pR0/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
+\r
+       USI_TWI_Master_Initialise();\r
+       initSHT2x();\r
+       _delay_ms(100);\r
+       MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M);//#define MAX1164x_C_CS0\r
+       _delay_ms(30); //Internal Referenz start\r
+       //2970 -> 1,5V\r
+       gcontrol=1;\r
\r
+       sei();\r
+       \r
+       //DDRB|=(1<<PINB1);\r
+\r
+    while(1)   {\r
+               if (testSW()) {\r
+                       R0=1;\r
+                       pR0=0;\r
+                       writeEEPROM(EEPROM_R0,0);\r
+               }\r
+\r
+\r
+               if (wdcounter>0) {  //8s\r
+                       ptol_s8++;\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
+                                       weekmaxarr[i]=weekmaxarr[i+1];\r
+                                       //maximum of week\r
+                                       if (weekmaxarr[i]>pr_week_max) pr_week_max=weekmaxarr[i];\r
+                               }\r
+                               if (ptol_d>7) {\r
+                                       pR0=pr_week_max;\r
+                                       } else {\r
+                                       pR0=pr_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
+                       }\r
+                       if (startup!=0) startup--;\r
+                       getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                       ip=interp(temperatureC,humidityRH);\r
+                       pip=ip*1000;\r
+                       RH=calibr_hum(temperatureC,-0.2,humidityRH);\r
+                       TC =temperatureC -0.2;\r
+                       mr=0;\r
+                       //Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________\r
+                       PORTB&=~(1<<PINB1); //Auf 0 Ziehen\r
+                       _delay_us(150);\r
+                       mr+=MAX1164x_read();\r
+                       _delay_us(150);\r
+                       mr+=MAX1164x_read();\r
+                       PORTB|=(1<<PINB1);\r
+                       //ENDE Kritische Sektion !______________________________\r
+                       //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
+                               //l+=1.5; //Spannung real\r
+                               mr+=6000;\r
+                       }\r
+                       //if (l>1.8) {\r
+                       if (mr>7200) {\r
+                               if (pcmode==0) {\r
+                                       MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_CH1);\r
+                                       pcmode=1;\r
+                               }\r
+                       }\r
+                       //if (l<1.6) {\r
+                       if (mr<6400) {\r
+                               if (pcmode==1) {\r
+                                       MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M);\r
+                                       pcmode=0;\r
+                               }\r
+                               \r
+                               \r
+                       }\r
+                       pVS=mr*5/2;\r
+                       l=mr/4000.0;\r
+                       l=( 3/l- 1) *30;\r
+                       RA=l*100;\r
+                       \r
+                       l=l/ip;\r
+                       \r
+                       if (startup==0){\r
+                               if (l>R0) {\r
+                                       R0=l;\r
+                                       pR0=R0*100;\r
+                                       writeEEPROM(EEPROM_R0,pR0);\r
+\r
+                               }\r
+                               if (l*100>pr_day_max) {\r
+                                       pr_day_max=l*100;\r
+                               }\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*100; //fuer DS2450\r
+\r
+                       } \r
+                       else l=0; //negative Werte am Anfang verhintern\r
+                       wdcounter=0;\r
+                       \r
+               }\r
+\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               uint16_t ct=(temperatureC*100.0)+32767;\r
+                               cli();pack.A=ct;sei();\r
+                               alarmflag=0;\r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               cli();pack.B=humidityRH*100;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               cli();pack.C=l;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               if (pack.CSD2&0x01)     ADMUX=3; else ADMUX=0x83;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.D=RA;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       DDRA|=bb;\r
+                               } else {\r
+                                       DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+       //      asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_VOC_SHT/DS2450_VOC_SHT.cproj b/DS2450_VOC_SHT/DS2450_VOC_SHT.cproj
new file mode 100644 (file)
index 0000000..33bd70e
--- /dev/null
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="utf-8"?>\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>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_VOC_SHT</Name>\r
+    <RootNamespace>DS2450</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
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <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
+    </AsfFrameworkConfig>\r
+    <avrtool />\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.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.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
+    <Compile Include="..\common\calibr.c">\r
+      <SubType>compile</SubType>\r
+      <Link>calibr.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\MAX1164x.c">\r
+      <SubType>compile</SubType>\r
+      <Link>MAX1164x.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</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="DS2450_VOC_SHT.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_VOC_SHT/OWDS2450.S b/DS2450_VOC_SHT/OWDS2450.S
new file mode 100644 (file)
index 0000000..1d81abd
--- /dev/null
@@ -0,0 +1,247 @@
+\r
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycrc1\r
+               rjmp h_readmemorycrc2\r
+               rjmp h_writememoryaddr\r
+               rjmp h_writememory\r
+               rjmp h_writememorycrc1\r
+               rjmp h_writememorycrc2\r
+               rjmp h_writememoryreadback\r
+               rjmp h_convert\r
+               rjmp h_convertcrc1\r
+               rjmp h_convertcrc2\r
+               rjmp h_convert_conv\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8\r
+#define OW_CONVERT OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR\r
+       cset 0x3C,OW_CONVERT\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_readmemorycrc2:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory2\r
+\r
+h_writememoryaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte1 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory:\r
+       lds r_bytep,addr\r
+       configZ pack,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC1\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC2\r
+       rjmp handle_end\r
+h_writememorycrc2:\r
+       lds r_temp,addr\r
+       configZ pack,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK\r
+       rjmp handle_end\r
+h_writememoryreadback:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY\r
+       rjmp handle_end\r
+\r
+h_convert:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte1 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte1: ;zweies byte glesen go crc#\r
+       sts pack+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC1\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc1:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC2\r
+       rjmp handle_end\r
+h_convertcrc2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
index 9907867..3d2bec7 100644 (file)
@@ -76,8 +76,9 @@
 \r
 #include <util/delay.h>\r
 #include <avr/pgmspace.h>\r
 \r
 #include <util/delay.h>\r
 #include <avr/pgmspace.h>\r
+#include <avr/interrupt.h>\r
 \r
 \r
-#include "USI_TWI_Master.h"\r
+#include "TWI_Master.h"\r
 #include "BME680.h"\r
 \r
 #define WC 0b11101100\r
 #include "BME680.h"\r
 \r
 #define WC 0b11101100\r
@@ -237,6 +238,14 @@ 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};\r
 \r
        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};\r
 \r
+const float lookup_k1_range1[16]  = {
+       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_range1[16]  = {
+       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};\r
+\r
+\r
 double bme680_compensate_gas_double(uint16_t gas_adc_u16, uint8_t gas_range_u8)
 {
        double gas_res_d = 0;
 double bme680_compensate_gas_double(uint16_t gas_adc_u16, uint8_t gas_range_u8)
 {
        double gas_res_d = 0;
@@ -248,11 +257,14 @@ double bme680_compensate_gas_double(uint16_t gas_adc_u16, uint8_t gas_range_u8)
        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]));
        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]));
+       //float a1=lookup_k1_range1[gas_range_u8];
+       //float a2=lookup_k2_range1[gas_range_u8];
 
        range_switching_error_val =     calib.range_switching_error;
 
 
        var1 = (1340.0 + (5.0 * range_switching_error_val))*a1;
 
        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;
 }
        gas_res_d = var1*a2/(gas_adc_u16-512.0+var1);
        return gas_res_d;
 }
@@ -345,6 +357,7 @@ void readBMP680(int16_t *T,uint16_t *H,uint32_t *P,uint16_t *G){
        I2c_StopCondition();\r
        *G=(((uint16_t)g1)<<2)|(g2>>6);\r
        *P=*G;\r
        I2c_StopCondition();\r
        *G=(((uint16_t)g1)<<2)|(g2>>6);\r
        *P=*G;\r
+       \r
        *G= bme680_compensate_gas_double(*G,g2&0xF)/10.0;\r
 \r
        int32_t temp_comp = 0;\r
        *G= bme680_compensate_gas_double(*G,g2&0xF)/10.0;\r
 \r
        int32_t temp_comp = 0;\r
@@ -431,6 +444,5 @@ void readBMP680(int16_t *T,uint16_t *H,uint32_t *P,uint16_t *G){
        *H=g2;\r
        //*P=\r
 \r
        *H=g2;\r
        //*P=\r
 \r
-\r
 }\r
 \r
 }\r
 \r
index 97ab51d..9fb4319 100644 (file)
@@ -4,7 +4,7 @@
 #include <util/delay.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <util/delay.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
-#include "USI_TWI_Master.h"\r
+#include "TWI_Master.h"\r
 \r
 uint16_t dig_T1;\r
 int16_t dig_T2;\r
 \r
 uint16_t dig_T1;\r
 int16_t dig_T2;\r
@@ -45,6 +45,12 @@ short bmp280ReadShort(unsigned char address)
 }\r
 \r
 void bmp280Init(void) {\r
 }\r
 \r
 void bmp280Init(void) {\r
+       I2c_StartCondition();\r
+       I2c_WriteByte(0xEC);\r
+       I2c_WriteByte(0xF4);\r
+       I2c_WriteByte(0b01010111); //2x Temp over 16x Press over   Normal mode\r
+       I2c_WriteByte(0b11100000);  //4s time / no IIfilter\r
+       I2c_StopCondition();\r
        dig_T1=bmp280ReadShort(0x88);\r
        dig_T2=bmp280ReadShort(0x8A);\r
        dig_T3=bmp280ReadShort(0x8C);\r
        dig_T1=bmp280ReadShort(0x88);\r
        dig_T2=bmp280ReadShort(0x8A);\r
        dig_T3=bmp280ReadShort(0x8C);\r
@@ -57,12 +63,7 @@ void bmp280Init(void) {
        dig_P7=bmp280ReadShort(0x9A);\r
        dig_P8=bmp280ReadShort(0x9C);\r
        dig_P9=bmp280ReadShort(0x9E);\r
        dig_P7=bmp280ReadShort(0x9A);\r
        dig_P8=bmp280ReadShort(0x9C);\r
        dig_P9=bmp280ReadShort(0x9E);\r
-       I2c_StartCondition();\r
-       I2c_WriteByte(0xEC);\r
-       I2c_WriteByte(0xF4);\r
-       I2c_WriteByte(0b01010111); //2x Temp over 16x Press over   Normal mode\r
-       I2c_WriteByte(0b11100000);  //4s time / no IIfilter\r
-       I2c_StopCondition();\r
+       \r
        \r
        \r
 }\r
        \r
        \r
 }\r
@@ -133,11 +134,78 @@ int32_t bmp280ReadPressure_simple() {
 \r
 \r
 }\r
 \r
 \r
 }\r
+#define BMP280_S32_t int32_t\r
+// Returns temperature in DegC, double precision. Output value of \9351.23\94 equals 51.23 DegC.\r
+// t_fine carries fine temperature as global value\r
+BMP280_S32_t t_fine;\r
+double bmp280_compensate_T_double(BMP280_S32_t adc_T)\r
+{\r
+       double var1, var2, T;\r
+       var1 = (((double)adc_T)/16384.0 - ((double)dig_T1)/1024.0) * ((double)dig_T2);\r
+       var2 = ((((double)adc_T)/131072.0 - ((double)dig_T1)/8192.0) *\r
+       (((double)adc_T)/131072.0 - ((double) dig_T1)/8192.0)) * ((double)dig_T3);\r
+       t_fine = (BMP280_S32_t)(var1 + var2);\r
+       T = (var1 + var2) / 5120.0;\r
+       return T;\r
+}\r
+// Returns pressure in Pa as double. Output value of \9396386.2\94 equals 96386.2 Pa = 963.862 hPa\r
+double bmp280_compensate_P_double(BMP280_S32_t adc_P)\r
+{\r
+       double var1, var2, p;\r
+       var1 = ((double)t_fine/2.0) - 64000.0;\r
+       var2 = var1 * var1 * ((double)dig_P6) / 32768.0;\r
+       var2 = var2 + var1 * ((double)dig_P5) * 2.0;\r
+       var2 = (var2/4.0)+(((double)dig_P4) * 65536.0);\r
+       var1 = (((double)dig_P3) * var1 * var1 / 524288.0 + ((double)dig_P2) * var1) / 524288.0;\r
+       var1 = (1.0 + var1 / 32768.0)*((double)dig_P1);\r
+       if (var1 == 0.0)\r
+       {\r
+               return 0; // avoid exception caused by division by zero\r
+       }\r
+       p = 1048576.0 - (double)adc_P;\r
+       p = (p - (var2 / 4096.0)) * 6250.0 / var1;\r
+       var1 = ((double)dig_P9) * p * p / 2147483648.0;\r
+       var2 = p * ((double)dig_P8) / 32768.0;\r
+       p = p + (var1 + var2 + ((double)dig_P7)) / 16.0;\r
+       return p;\r
+}\r
+\r
+void bmp280ConvertInt_df(int32_t * temperature,uint32_t *pressure,uint8_t oss) {\r
+               //bmp280Init();\r
+               double var1, var2, T;\r
+               int32_t adc_T=bmp280ReadTemp();\r
+               var1 = (((double)adc_T)/16384.0 - ((double)dig_T1)/1024.0) * ((double)dig_T2);\r
+               var2 = ((((double)adc_T)/131072.0 - ((double)dig_T1)/8192.0) *\r
+               (((double)adc_T)/131072.0 - ((double) dig_T1)/8192.0)) * ((double)dig_T3);\r
+               t_fine = (BMP280_S32_t)(var1 + var2);\r
+               T = (var1 + var2) / 5120.0;\r
+\r
+               int32_t adc_P= bmp280ReadPressure(oss);\r
+               double  p;\r
+               var1 = ((double)t_fine/2.0) - 64000.0;\r
+               var2 = var1 * var1 * ((double)dig_P6) / 32768.0;\r
+               var2 = var2 + var1 * ((double)dig_P5) * 2.0;\r
+               var2 = (var2/4.0)+(((double)dig_P4) * 65536.0);\r
+               var1 = (((double)dig_P3) * var1 * var1 / 524288.0 + ((double)dig_P2) * var1) / 524288.0;\r
+               var1 = (1.0 + var1 / 32768.0)*((double)dig_P1);\r
+               if (var1 == 0.0)\r
+               {\r
+                       return ; // avoid exception caused by division by zero\r
+               }\r
+               p = 1048576.0 - (double)adc_P;\r
+               p = (p - (var2 / 4096.0)) * 6250.0 / var1;\r
+               var1 = ((double)dig_P9) * p * p / 2147483648.0;\r
+               var2 = p * ((double)dig_P8) / 32768.0;\r
+               p = p + (var1 + var2 + ((double)dig_P7)) / 16.0;\r
+               *temperature=(int32_t) (T*100.0);\r
+               *pressure=(uint32_t) p;\r
+               return;\r
+}\r
+\r
+\r
 \r
 void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss) {\r
        int32_t var1,var2,T,t_fine;\r
 \r
 void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss) {\r
        int32_t var1,var2,T,t_fine;\r
-       \r
-       \r
        int32_t adc_T=bmp280ReadTemp();\r
        var1 = ((((adc_T>>3) - ((int32_t)dig_T1<<1))) * ((int32_t)dig_T2)) >> 11;\r
        var2 = ((((((adc_T>>4) - ((int32_t)dig_T1)) * ((adc_T>>4) - (int32_t)dig_T1))) >> 12) *((int32_t)dig_T3)) >> 14;\r
        int32_t adc_T=bmp280ReadTemp();\r
        var1 = ((((adc_T>>3) - ((int32_t)dig_T1<<1))) * ((int32_t)dig_T2)) >> 11;\r
        var2 = ((((((adc_T>>4) - ((int32_t)dig_T1)) * ((adc_T>>4) - (int32_t)dig_T1))) >> 12) *((int32_t)dig_T3)) >> 14;\r
@@ -145,7 +213,7 @@ void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss) {
        T = (t_fine * 5 + 128) >> 8;\r
        *temperature=T;\r
        int32_t adc_P= bmp280ReadPressure(oss);\r
        T = (t_fine * 5 + 128) >> 8;\r
        *temperature=T;\r
        int32_t adc_P= bmp280ReadPressure(oss);\r
-       uint32_t p;\r
+       int32_t p;\r
        var1 = (((int32_t)t_fine)>>1) - (int32_t)64000;\r
        var2 = (((var1>>2) * (var1>>2)) >> 11 ) * ((int32_t)dig_P6);\r
        var2 = var2 + ((var1*((int32_t)dig_P5))<<1);\r
        var1 = (((int32_t)t_fine)>>1) - (int32_t)64000;\r
        var2 = (((var1>>2) * (var1>>2)) >> 11 ) * ((int32_t)dig_P6);\r
        var2 = var2 + ((var1*((int32_t)dig_P5))<<1);\r
@@ -164,7 +232,8 @@ void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss) {
        var1 = (((int32_t)dig_P9) * ((int32_t)(((p>>3) * (p>>3))>>13)))>>12;\r
        var2 = (((int32_t)(p>>2)) * ((int32_t)dig_P8))>>13;\r
        p = (uint32_t)((int32_t)p + ((var1 + var2 + dig_P7) >> 4));\r
        var1 = (((int32_t)dig_P9) * ((int32_t)(((p>>3) * (p>>3))>>13)))>>12;\r
        var2 = (((int32_t)(p>>2)) * ((int32_t)dig_P8))>>13;\r
        p = (uint32_t)((int32_t)p + ((var1 + var2 + dig_P7) >> 4));\r
-       *pressure=p;\r
+\r
+       *pressure=(uint32_t)(p);\r
 \r
 }\r
 \r
 \r
 }\r
 \r
index 5c9f86d..330eccd 100644 (file)
@@ -9,6 +9,7 @@ int32_t bmp280ReadPressure(uint8_t oss);
 int32_t bmp280ReadPressure_simple();\r
 void bmp280Convert(double * temperature, double * pressure,uint8_t oss);\r
 void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss);\r
 int32_t bmp280ReadPressure_simple();\r
 void bmp280Convert(double * temperature, double * pressure,uint8_t oss);\r
 void bmp280ConvertInt(int32_t * temperature,uint32_t *pressure,uint8_t oss);\r
+void bmp280ConvertInt_df(int32_t * temperature,uint32_t *pressure,uint8_t oss);\r
 void bmp280ConvertIntP(int32_t temp256,uint32_t *pressure) ;\r
 void bmp280ConvertIntP1(uint32_t *pressure) ;\r
 \r
 void bmp280ConvertIntP(int32_t temp256,uint32_t *pressure) ;\r
 void bmp280ConvertIntP1(uint32_t *pressure) ;\r
 \r
index e82a138..868f344 100644 (file)
@@ -35,7 +35,7 @@
 #include <util/delay.h>\r
 \r
 \r
 #include <util/delay.h>\r
 \r
 \r
-#include "USI_TWI_Master.h"\r
+#include "TWI_Master.h"\r
 #include "CDM7160.h"\r
 \r
 \r
 #include "CDM7160.h"\r
 \r
 \r
diff --git a/common/I2C/HDC2010.c b/common/I2C/HDC2010.c
new file mode 100644 (file)
index 0000000..03036a3
--- /dev/null
@@ -0,0 +1,291 @@
+// 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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//---------- Includes ----------------------------------------------------------\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include "TWI_Master.h"\r
+#include "HDC2010.h"\r
+typedef enum{\r
+       I2C_ADR_W = 130, // sensor I2C address + write bit //ADR=VDD\r
+       I2C_ADR_R = 131 // sensor I2C address + read bit\r
+}etI2cHeader;\r
+\r
+uint8_t HDC2010_Init() {\r
+       volatile uint8_t error=0;\r
+       /*I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       error |= I2c_WriteByte (0x02); // Config\r
+       error |= I2c_WriteByte (0x0); // 14 bit\r
+       error |= I2c_WriteByte (0x0); // \r
+       I2c_StopCondition();*/\r
+       return error;\r
+\r
+}\r
+\r
+uint8_t HDC2010_Readf(double * temperature, double * hum) {    \r
+       int16_t t;\r
+       uint16_t h;\r
+       uint8_t error=0;\r
+       error=HDC2010_Readi(&t,&h);\r
+       *temperature=(double)t/65536.0*165.0-40.0;\r
+       *hum=(double)h/65536.0*100;\r
+       return error;\r
+\r
+}\r
+uint8_t HDC2010_Readi(int16_t * temperature, uint16_t * hum) {\r
+       volatile uint8_t error=0;\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       error |= I2c_WriteByte (0x0F); //\r
+       error |= I2c_WriteByte (0x01); //\r
+       I2c_StopCondition();\r
+       _delay_ms(10);\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       error |= I2c_WriteByte (0x0); //\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_R); //I2C address\r
+       *temperature=0;\r
+       *temperature |= I2c_ReadByte(ACK);\r
+       *temperature |= I2c_ReadByte(ACK)<<8; \r
+       *hum=0;\r
+       *hum|= I2c_ReadByte(ACK);\r
+       *hum|= I2c_ReadByte(NO_ACK)<<8;\r
+       I2c_StopCondition();\r
+\r
+       return error;\r
+       }\r
+\r
+/*\r
+\r
+const uint16_t POLYNOMIAL = 0x131; //P(x)=x^8+x^5+x^4+1 = 100110001\r
+\r
+\r
+//==============================================================================\r
+uint8_t SHT2x_CheckCrc(uint8_t data[], uint8_t nbrOfBytes, uint8_t checksum)\r
+//==============================================================================\r
+{\r
+       uint8_t crc = 0;\r
+       uint8_t byteCtr;\r
+       //calculates 8-Bit checksum with given polynomial\r
+       for (byteCtr = 0; byteCtr < nbrOfBytes; ++byteCtr)\r
+       { crc ^= (data[byteCtr]);\r
+               for (uint8_t bit = 8; bit > 0; --bit)\r
+               { if (crc & 0x80) crc = (crc << 1) ^ POLYNOMIAL;\r
+                       else crc = (crc << 1);\r
+               }\r
+       }\r
+       if (crc != checksum) return CHECKSUM_ERROR;\r
+       else return 0;\r
+}\r
+//===========================================================================\r
+uint8_t SHT2x_ReadUserRegister(uint8_t *pRegisterValue)\r
+//===========================================================================\r
+{\r
+       uint8_t checksum; //variable for checksum byte\r
+       uint8_t error=0; //variable for error code\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W);\r
+       error |= I2c_WriteByte (USER_REG_R);\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_R);\r
+       *pRegisterValue = I2c_ReadByte(ACK);\r
+       checksum=I2c_ReadByte(NO_ACK);\r
+       error |= SHT2x_CheckCrc (pRegisterValue,1,checksum);\r
+       I2c_StopCondition();\r
+       return error;\r
+}\r
+//===========================================================================\r
+uint8_t SHT2x_WriteUserRegister(uint8_t *pRegisterValue)\r
+//===========================================================================\r
+{\r
+       uint8_t error=0; //variable for error code\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W);\r
+       error |= I2c_WriteByte (USER_REG_W);\r
+       error |= I2c_WriteByte (*pRegisterValue);\r
+       I2c_StopCondition();\r
+       return error;\r
+}\r
+//===========================================================================\r
+uint8_t SHT2x_MeasureHM(etSHT2xMeasureType eSHT2xMeasureType, int16_t *pMeasurand)\r
+//===========================================================================\r
+{\r
+       uint8_t checksum; //checksum\r
+       uint8_t data[2]; //data array for checksum verification\r
+       uint8_t error=0; //error variable\r
+       uint16_t i; //counting variable\r
+       //-- write I2C sensor address and command --\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       switch(eSHT2xMeasureType)\r
+       { case HUMIDITY: error |= I2c_WriteByte (TRIG_RH_MEASUREMENT_HM); break;\r
+               case TEMP : error |= I2c_WriteByte (TRIG_T_MEASUREMENT_HM); break;\r
+               //default: assert(0);\r
+       }\r
+       //-- wait until hold master is released --\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_R);\r
+       //SCL=HIGH; // set SCL I/O port as input\r
+       DDR_USI&=~(1<<PIN_USI_SCL);\r
+       for(i=0; i<1000; i++) // wait until master hold is released or ;;;;; Son quatsch.... 1000 s *kopfschuettel*\r
+       { _delay_ms(1); // a timeout (~1s) is reached\r
+               //if (SCL_CONF==1) break;\r
+               if (PIN_USI&(1<<PIN_USI_SCL)) break;\r
+       }\r
+       //-- check for timeout --\r
+       //Was wenn der SHT2x die leitung auf 0 laesst? Kurzschluss???\r
+       if((PIN_USI&(1<<PIN_USI_SCL))==0) error |= TIME_OUT_ERROR; else DDR_USI|=(1<<PIN_USI_SCL);\r
+       \r
+       //-- read two data bytes and one checksum byte --\r
+       *pMeasurand=((data[0] = I2c_ReadByte(ACK))>>8) & 0xFF;\r
+       *pMeasurand|=0xFF & (data[1] = I2c_ReadByte(ACK));\r
+//     pMeasurand->s16.u8H = data[0] = I2c_ReadByte(ACK);\r
+//     pMeasurand->s16.u8L = data[1] = I2c_ReadByte(ACK);\r
+\r
+       checksum=I2c_ReadByte(NO_ACK);\r
+       //-- verify checksum --\r
+       error |= SHT2x_CheckCrc (data,2,checksum);\r
+       I2c_StopCondition();\r
+       return error;\r
+}\r
+//===========================================================================\r
+uint8_t SHT2x_MeasurePoll(etSHT2xMeasureType eSHT2xMeasureType, int16_t *pMeasurand)\r
+//===========================================================================\r
+{\r
+       uint8_t checksum; //checksum\r
+       uint8_t data[2]; //data array for checksum verification\r
+       uint8_t error=0; //error variable\r
+       uint16_t i=0; //counting variable\r
+       //-- write I2C sensor address and command --\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       switch(eSHT2xMeasureType)\r
+       { case HUMIDITY: error |= I2c_WriteByte (TRIG_RH_MEASUREMENT_POLL); break;\r
+               case TEMP : error |= I2c_WriteByte (TRIG_T_MEASUREMENT_POLL); break;\r
+               //default: assert(0);\r
+       }\r
+       //-- poll every 10ms for measurement ready. Timeout after 20 retries (200ms)--\r
+       do\r
+       { I2c_StartCondition();\r
+               _delay_ms(200); //delay 10ms\r
+               if(i++ >= 20) break;\r
+       } while(I2c_WriteByte (I2C_ADR_R) == ACK_ERROR);\r
+       if (i>=20) error |= TIME_OUT_ERROR;\r
+       //-- read two data bytes and one checksum byte --\r
+       data[0]=I2c_ReadByte(ACK);\r
+       data[1]=I2c_ReadByte(ACK);\r
+       *pMeasurand=(data[0]<<8)|data[1];\r
+       \r
+//     pMeasurand->s16.u8H = data[0] = I2c_ReadByte(ACK);\r
+//     pMeasurand->s16.u8L = data[1] = I2c_ReadByte(ACK);\r
+       checksum=I2c_ReadByte(NO_ACK);\r
+       //-- verify checksum --\r
+       error |= SHT2x_CheckCrc (data,2,checksum);\r
+       I2c_StopCondition();\r
+       return error;\r
+}\r
+//===========================================================================\r
+uint8_t SHT2x_SoftReset(void)\r
+//===========================================================================\r
+{\r
+       uint8_t error=0; //error variable\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       error |= I2c_WriteByte (SOFT_RESET); // Command\r
+       I2c_StopCondition();\r
+       _delay_ms(15); // wait till sensor has restarted\r
+       return error;\r
+}\r
+//==============================================================================\r
+float SHT2x_CalcRH(uint16_t u16sRH)\r
+//==============================================================================\r
+{\r
+       double humidityRH; // variable for result\r
+       u16sRH &= ~0x0003; // clear bits [1..0] (status bits)\r
+       //-- calculate relative humidity [%RH] --\r
+       humidityRH = -6.0 + 125.0/65536 * (double)u16sRH; // RH= -6 + 125 * SRH/2^16\r
+       return humidityRH;\r
+}\r
+//==============================================================================\r
+float SHT2x_CalcTemperatureC(uint16_t u16sT)\r
+//==============================================================================\r
+{\r
+       double temperatureC; // variable for result\r
+       u16sT &= ~0x0003; // clear bits [1..0] (status bits)\r
+       //-- calculate temperature [°C] --\r
+       temperatureC= -46.85 + 175.72/65536 *(double)u16sT; //T= -46.85 + 175.72 * ST/2^16\r
+       return temperatureC;\r
+}\r
+//==============================================================================\r
+uint8_t SHT2x_GetSerialNumber(uint8_t u8SerialNumber[])\r
+//==============================================================================\r
+{\r
+       uint8_t error=0; //error variable\r
+       //Read from memory location 1\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); //I2C address\r
+       error |= I2c_WriteByte (0xFA); //Command for readout on-chip memory\r
+       error |= I2c_WriteByte (0x0F); //on-chip memory address\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_R); //I2C address\r
+       u8SerialNumber[5] = I2c_ReadByte(ACK); //Read SNB_3\r
+       I2c_ReadByte(ACK); //Read CRC SNB_3 (CRC is not analyzed)\r
+       u8SerialNumber[4] = I2c_ReadByte(ACK); //Read SNB_2\r
+       I2c_ReadByte(ACK); //Read CRC SNB_2 (CRC is not analyzed)\r
+       u8SerialNumber[3] = I2c_ReadByte(ACK); //Read SNB_1\r
+       I2c_ReadByte(ACK); //Read CRC SNB_1 (CRC is not analyzed)\r
+       u8SerialNumber[2] = I2c_ReadByte(ACK); //Read SNB_0\r
+       I2c_ReadByte(NO_ACK); //Read CRC SNB_0 (CRC is not analyzed)\r
+       I2c_StopCondition();\r
+       //Read from memory location 2\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); //I2C address\r
+       error |= I2c_WriteByte (0xFC); //Command for readout on-chip memory\r
+       error |= I2c_WriteByte (0xC9); //on-chip memory address\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_R); //I2C address\r
+       u8SerialNumber[1] = I2c_ReadByte(ACK); //Read SNC_1\r
+       u8SerialNumber[0] = I2c_ReadByte(ACK); //Read SNC_0\r
+       I2c_ReadByte(ACK); //Read CRC SNC0/1 (CRC is not analyzed)\r
+       u8SerialNumber[7] = I2c_ReadByte(ACK); //Read SNA_1\r
+       u8SerialNumber[6] = I2c_ReadByte(ACK); //Read SNA_0\r
+       I2c_ReadByte(NO_ACK); //Read CRC SNA0/1 (CRC is not analyzed)\r
+       I2c_StopCondition();\r
+       return error;\r
+}\r
+*/
\ No newline at end of file
diff --git a/common/I2C/HDC2010.h b/common/I2C/HDC2010.h
new file mode 100644 (file)
index 0000000..84f133e
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef HDC2010_H\r
+#define HDC2010_H\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
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+\r
+uint8_t HDC2010_Init();\r
+\r
+uint8_t HDC2010_Readf(double * temperature, double * hum);\r
+uint8_t HDC2010_Readi(int16_t * temperature, uint16_t * hum);\r
+\r
+\r
+#endif\r
diff --git a/common/I2C/LPS225HB.c b/common/I2C/LPS225HB.c
new file mode 100644 (file)
index 0000000..eafb35c
--- /dev/null
@@ -0,0 +1,129 @@
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+//---------- Includes ----------------------------------------------------------\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include "USI_TWI_Master.h"\r
+#include "LPS225HB.h"\r
+typedef enum{\r
+       I2C_ADR_W = 0b10111000, // sensor I2C address + write bit //ADR=VDD\r
+       I2C_ADR_R = 0b10111001 // sensor I2C address + read bit\r
+}etI2cHeader;\r
+\r
+uint8_t LPS225HB_Init() {\r
+       volatile uint8_t error=0;\r
+       /*I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       error |= I2c_WriteByte (0x02); // Config\r
+       error |= I2c_WriteByte (0x0); // 14 bit\r
+       error |= I2c_WriteByte (0x0); // \r
+       I2c_StopCondition();*/\r
+\r
+\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       error |= I2c_WriteByte (0x11); //\r
+       //error |= I2c_WriteByte (0b01110001); //\r
+       error |= I2c_WriteByte (0b00010100); //\r
+       I2c_StopCondition();\r
+       return error;\r
+\r
+}\r
+\r
+uint8_t LPS225HB_Readf(double * temperature, double * pressure) {      \r
+       int16_t t;\r
+       uint32_t p;\r
+       uint8_t error=0;\r
+       error= LPS225HB_Readi(&t,&p);\r
+       *temperature=(double)t/100.0;\r
+       *pressure=(double)p/4096.0;\r
+       return error;\r
+\r
+}\r
+uint8_t readReg(uint8_t reg) {\r
+       volatile uint8_t error=0;\r
+       uint8_t ret;\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       error |= I2c_WriteByte (reg); //\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_R); //I2C address\r
+       ret= I2c_ReadByte(NO_ACK);\r
+       I2c_StopCondition();\r
+       return ret;\r
+}\r
+\r
+uint8_t LPS225HB_Readi(int16_t * temperature, uint32_t * pressure) {\r
+       volatile uint8_t error=0;\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       error |= I2c_WriteByte (0x11); //\r
+       //error |= I2c_WriteByte (0b00000001); //\r
+       error |= I2c_WriteByte (0b01010001); //\r
+       I2c_StopCondition();\r
+       _delay_ms(1000);\r
+//     uint16_t status=0;\r
+//     status=readReg(0x27);\r
+//     status|=readReg(0x26)<<8;\r
+//     *pressure=0;\r
+//     *pressure|= readReg(0x28);\r
+//     *pressure|= ((uint32_t)readReg(0x29))<<8;\r
+//     *pressure|= ((uint32_t)readReg(0x2A))<<16;\r
+\r
+\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_W); // I2C Adr\r
+       error |= I2c_WriteByte (0x28); //\r
+       I2c_StartCondition();\r
+       error |= I2c_WriteByte (I2C_ADR_R); //I2C address\r
+//     status= I2c_ReadByte(ACK)<<8;\r
+//     status|= I2c_ReadByte(ACK);\r
+\r
+\r
+       *pressure=0;\r
+       *pressure|= I2c_ReadByte(ACK);\r
+       *pressure|= ((uint32_t)I2c_ReadByte(ACK))<<8;\r
+       *pressure|= ((uint32_t)I2c_ReadByte(ACK))<<16;\r
+       *temperature=0;\r
+       *temperature |= I2c_ReadByte(ACK);\r
+       *temperature |= ((int16_t)I2c_ReadByte(NO_ACK)<<8); \r
+       I2c_StopCondition();\r
+       //*temperature=status;\r
+\r
+       return error;\r
+       }\r
+\r
diff --git a/common/I2C/LPS225HB.h b/common/I2C/LPS225HB.h
new file mode 100644 (file)
index 0000000..c69f90c
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef LPS225HB_H\r
+#define LPS225HB_H\r
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (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
+\r
+uint8_t LPS225HB_Init();\r
+\r
+uint8_t LPS225HB_Readf(double * temperature, double * pressure);\r
+uint8_t LPS225HB_Readi(int16_t * temperature, uint32_t * pressure);\r
+\r
+\r
+#endif\r
index 212524b..3340dbb 100644 (file)
@@ -35,7 +35,7 @@
 #include <util/delay.h>\r
 \r
 \r
 #include <util/delay.h>\r
 \r
 \r
-#include "USI_TWI_Master.h"\r
+#include "TWI_Master.h"\r
 #include "MAX44009.h"\r
 \r
 uint8_t checkMAX44009(uint8_t nr) {\r
 #include "MAX44009.h"\r
 \r
 uint8_t checkMAX44009(uint8_t nr) {\r
index 62841c4..00b24cd 100644 (file)
@@ -162,6 +162,8 @@ void save_baseline(uint16_t b1,uint16_t b2 ) {
 void read_baseline(uint16_t *b1,uint16_t *b2) {\r
        *b1=readEEPROM(0,0xFFFF);\r
        *b2=readEEPROM(2,0xFFFF);\r
 void read_baseline(uint16_t *b1,uint16_t *b2) {\r
        *b1=readEEPROM(0,0xFFFF);\r
        *b2=readEEPROM(2,0xFFFF);\r
+       *b1=0xFFFF;\r
+       *b2=0xFFFF;\r
 }\r
 \r
 void set_baseline(uint16_t b1,uint16_t b2) {\r
 }\r
 \r
 void set_baseline(uint16_t b1,uint16_t b2) {\r
index ae9f352..bc5b662 100644 (file)
@@ -15,7 +15,7 @@
 #include <util/delay.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <util/delay.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
-#include "USI_TWI_Master.h"\r
+#include "TWI_Master.h"\r
 #include "SHT2x.h"\r
 \r
 const uint16_t POLYNOMIAL = 0x131; //P(x)=x^8+x^5+x^4+1 = 100110001\r
 #include "SHT2x.h"\r
 \r
 const uint16_t POLYNOMIAL = 0x131; //P(x)=x^8+x^5+x^4+1 = 100110001\r
index 130e85b..adbaf06 100644 (file)
@@ -34,7 +34,7 @@
 #define F_CPU 8000000UL\r
 #include <avr/io.h>\r
 #include <util/delay.h>\r
 #define F_CPU 8000000UL\r
 #include <avr/io.h>\r
 #include <util/delay.h>\r
-#include "USI_TWI_Master.h"\r
+#include "TWI_Master.h"\r
 #include "SHT2xV2.h"\r
 \r
 uint8_t initSHT2x(){\r
 #include "SHT2xV2.h"\r
 \r
 uint8_t initSHT2x(){\r
@@ -97,9 +97,13 @@ uint8_t getSHT2xHumTemp(double *temp,double *hum) {
        if (calcCRCSHT2x(t1,t2)==tc)\r
                *temp=-46.85 + 175.72/65536 *(double)(((uint16_t)t1<<8)|(t2&0xF8));\r
        else ret=0;\r
        if (calcCRCSHT2x(t1,t2)==tc)\r
                *temp=-46.85 + 175.72/65536 *(double)(((uint16_t)t1<<8)|(t2&0xF8));\r
        else ret=0;\r
-       if (calcCRCSHT2x(f1,f2)==fc)\r
+       if (calcCRCSHT2x(f1,f2)==fc) {\r
                *hum=-6.0+125.0/65536*(double)(((uint16_t)f1<<8)|(f2&0xF8));\r
                *hum=-6.0+125.0/65536*(double)(((uint16_t)f1<<8)|(f2&0xF8));\r
+               *hum=(*hum)-((100.0/(*hum)*2.5)-2.5);\r
+               }\r
        else ret=0;\r
        else ret=0;\r
+       //*temp=20;\r
+       //*hum=10;\r
        return ret;\r
 }\r
 \r
        return ret;\r
 }\r
 \r
index b20de79..8246a32 100644 (file)
@@ -12,7 +12,7 @@
 #define F_CPU 8000000UL\r
 #include <avr/io.h>\r
 #include <util/delay.h>\r
 #define F_CPU 8000000UL\r
 #include <avr/io.h>\r
 #include <util/delay.h>\r
-#include "USI_TWI_Master.h"\r
+#include "TWI_Master.h"\r
 #include "SHT3x.h"\r
 \r
 uint8_t initSHT3x(uint8_t adrline){\r
 #include "SHT3x.h"\r
 \r
 uint8_t initSHT3x(uint8_t adrline){\r
index d32ab0f..979a903 100644 (file)
@@ -4,7 +4,7 @@
 #include <util/delay.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
 #include <util/delay.h>\r
 #include <avr/wdt.h>\r
 #include <avr/sleep.h>\r
-#include "USI_TWI_Master.h"\r
+#include "TWI_Master.h"\r
 \r
 void TSL256x_init() {\r
        I2c_StartCondition();\r
 \r
 void TSL256x_init() {\r
        I2c_StartCondition();\r
diff --git a/common/I2C/TWI_Master.c b/common/I2C/TWI_Master.c
new file mode 100644 (file)
index 0000000..ed125ec
--- /dev/null
@@ -0,0 +1,367 @@
+\r
+#ifdef  __4MHZ__\r
+#define F_CPU 4000000UL\r
+#else\r
+#define F_CPU 8000000UL\r
+#endif\r
+#include <avr/io.h>\r
+#include "TWI_Master.h"\r
+#include <util/delay.h>\r
+\r
+#if defined(__AVR_AT90Mega169__) | defined(__AVR_ATmega169PA__) | \\r
+defined(__AVR_AT90Mega165__) | defined(__AVR_ATmega165__) | \\r
+defined(__AVR_ATmega325__) | defined(__AVR_ATmega3250__) | \\r
+defined(__AVR_ATmega645__) | defined(__AVR_ATmega6450__) | \\r
+defined(__AVR_ATmega329__) | defined(__AVR_ATmega3290__) | \\r
+defined(__AVR_ATmega649__) | defined(__AVR_ATmega6490__) |\\r
+defined(__AVR_ATtiny25__) | defined(__AVR_ATtiny45__) | defined(__AVR_ATtiny85__) | \\r
+defined(__AVR_AT90Tiny26__) | defined(__AVR_ATtiny26__) |\\r
+defined(__AVR_AT90Tiny2313__) | defined(__AVR_ATtiny2313__) |\\r
+defined(__AVR_ATtiny84__) | defined(__AVR_ATtiny84A__)\r
+\r
+unsigned char USI_TWI_Master_Transfer( unsigned char );\r
+unsigned char USI_TWI_Master_Stop( void );\r
+\r
+union  USI_TWI_state\r
+{\r
+  unsigned char errorState;         // Can reuse the TWI_state for error states due to that it will not be need if there exists an error.\r
+  struct\r
+  {\r
+    unsigned char addressMode         : 1;\r
+    unsigned char masterWriteDataMode : 1;\r
+    unsigned char unused              : 6;\r
+  }; \r
+}   USI_TWI_state;\r
+\r
+/*---------------------------------------------------------------\r
+ USI TWI single master initialization function\r
+---------------------------------------------------------------*/\r
+void TWI_Master_Initialise( void )\r
+{\r
+  PORT_USI |= (1<<PIN_USI_SDA);           // Enable pullup on SDA, to set high as released state.\r
+  PORT_USI |= (1<<PIN_USI_SCL);           // Enable pullup on SCL, to set high as released state.\r
+  \r
+  DDR_USI  |= (1<<PIN_USI_SCL);           // Enable SCL as output.\r
+  DDR_USI  |= (1<<PIN_USI_SDA);           // Enable SDA as output.\r
+  \r
+  USIDR    =  0xFF;                       // Preload dataregister with "released level" data.\r
+  USICR    =  (0<<USISIE)|(0<<USIOIE)|                            // Disable Interrupts.\r
+              (1<<USIWM1)|(0<<USIWM0)|                            // Set USI in Two-wire mode.\r
+              (1<<USICS1)|(0<<USICS0)|(1<<USICLK)|                // Software stobe as counter clock source\r
+              (0<<USITC);\r
+  USISR   =   (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Clear flags,\r
+              (0x0<<USICNT0);                                     // and reset counter.\r
+}\r
+\r
+/*---------------------------------------------------------------\r
+Use this function to get hold of the error message from the last transmission\r
+---------------------------------------------------------------*/\r
+unsigned char USI_TWI_Get_State_Info( void )\r
+{\r
+  return ( USI_TWI_state.errorState );                            // Return error state.\r
+}\r
+\r
+/*---------------------------------------------------------------\r
+ USI Transmit and receive function. LSB of first byte in data \r
+ indicates if a read or write cycles is performed. If set a read\r
+ operation is performed.\r
+\r
+ Function generates (Repeated) Start Condition, sends address and\r
+ R/W, Reads/Writes Data, and verifies/sends ACK.\r
\r
+ Success or error code is returned. Error codes are defined in \r
+ USI_TWI_Master.h\r
+---------------------------------------------------------------*/\r
+unsigned char USI_TWI_Start_Transceiver_With_Data( unsigned char *msg, unsigned char msgSize)\r
+{\r
+  unsigned char tempUSISR_8bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and\r
+                                 (0x0<<USICNT0);                                     // set USI to shift 8 bits i.e. count 16 clock edges.\r
+  unsigned char tempUSISR_1bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and\r
+                                 (0xE<<USICNT0);                                     // set USI to shift 1 bit i.e. count 2 clock edges.\r
+\r
+  USI_TWI_state.errorState = 0;\r
+  USI_TWI_state.addressMode = TRUE;\r
+\r
+#ifdef PARAM_VERIFICATION\r
+  if(msg > (unsigned char*)RAMEND)                 // Test if address is outside SRAM space\r
+  {\r
+    USI_TWI_state.errorState = USI_TWI_DATA_OUT_OF_BOUND;\r
+    return (FALSE);\r
+  }\r
+  if(msgSize <= 1)                                 // Test if the transmission buffer is empty\r
+  {\r
+    USI_TWI_state.errorState = USI_TWI_NO_DATA;\r
+    return (FALSE);\r
+  }\r
+#endif\r
+\r
+#ifdef NOISE_TESTING                                // Test if any unexpected conditions have arrived prior to this execution.\r
+  if( USISR & (1<<USISIF) )\r
+  {\r
+    USI_TWI_state.errorState = USI_TWI_UE_START_CON;\r
+    return (FALSE);\r
+  }\r
+  if( USISR & (1<<USIPF) )\r
+  {\r
+    USI_TWI_state.errorState = USI_TWI_UE_STOP_CON;\r
+    return (FALSE);\r
+  }\r
+  if( USISR & (1<<USIDC) )\r
+  {\r
+    USI_TWI_state.errorState = USI_TWI_UE_DATA_COL;\r
+    return (FALSE);\r
+  }\r
+#endif\r
+\r
+  if ( !(*msg & (1<<TWI_READ_BIT)) )                // The LSB in the address byte determines if is a masterRead or masterWrite operation.\r
+  {\r
+    USI_TWI_state.masterWriteDataMode = TRUE;\r
+  }\r
+\r
+/* Release SCL to ensure that (repeated) Start can be performed */\r
+  PORT_USI |= (1<<PIN_USI_SCL);                     // Release SCL.\r
+  while( !(PIN_USI & (1<<PIN_USI_SCL)) );          // Verify that SCL becomes high.\r
+#ifdef TWI_FAST_MODE\r
+  _delay_us( T4_TWI/4 );                         // Delay for T4TWI if TWI_FAST_MODE\r
+#else\r
+  _delay_us( T2_TWI/4 );                         // Delay for T2TWI if TWI_STANDARD_MODE\r
+#endif\r
+\r
+/* Generate Start Condition */\r
+  PORT_USI &= ~(1<<PIN_USI_SDA);                    // Force SDA LOW.\r
+  _delay_us( T4_TWI/4 );                         \r
+  PORT_USI &= ~(1<<PIN_USI_SCL);                    // Pull SCL LOW.\r
+  PORT_USI |= (1<<PIN_USI_SDA);                     // Release SDA.\r
+\r
+#ifdef SIGNAL_VERIFY\r
+  if( !(USISR & (1<<USISIF)) )\r
+  {\r
+    USI_TWI_state.errorState = USI_TWI_MISSING_START_CON;  \r
+    return (FALSE);\r
+  }\r
+#endif\r
+\r
+/*Write address and Read/Write data */\r
+  do\r
+  {\r
+    /* If masterWrite cycle (or inital address tranmission)*/\r
+    if (USI_TWI_state.addressMode || USI_TWI_state.masterWriteDataMode)\r
+    {\r
+      /* Write a byte */\r
+      PORT_USI &= ~(1<<PIN_USI_SCL);                // Pull SCL LOW.\r
+      USIDR     = *(msg++);                        // Setup data.\r
+      USI_TWI_Master_Transfer( tempUSISR_8bit );    // Send 8 bits on bus.\r
+      \r
+      /* Clock and verify (N)ACK from slave */\r
+      DDR_USI  &= ~(1<<PIN_USI_SDA);                // Enable SDA as input.\r
+      if( USI_TWI_Master_Transfer( tempUSISR_1bit ) & (1<<TWI_NACK_BIT) ) \r
+      {\r
+        if ( USI_TWI_state.addressMode )\r
+          USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_ADDRESS;\r
+        else\r
+          USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_DATA;\r
+        return (FALSE);\r
+      }\r
+      USI_TWI_state.addressMode = FALSE;            // Only perform address transmission once.\r
+    }\r
+    /* Else masterRead cycle*/\r
+    else\r
+    {\r
+      /* Read a data byte */\r
+      DDR_USI   &= ~(1<<PIN_USI_SDA);               // Enable SDA as input.\r
+      *(msg++)  = USI_TWI_Master_Transfer( tempUSISR_8bit );\r
+\r
+      /* Prepare to generate ACK (or NACK in case of End Of Transmission) */\r
+      if( msgSize == 1)                            // If transmission of last byte was performed.\r
+      {\r
+        USIDR = 0xFF;                              // Load NACK to confirm End Of Transmission.\r
+      }\r
+      else\r
+      {\r
+        USIDR = 0x00;                              // Load ACK. Set data register bit 7 (output for SDA) low.\r
+      }\r
+      USI_TWI_Master_Transfer( tempUSISR_1bit );   // Generate ACK/NACK.\r
+    }\r
+  }while( --msgSize) ;                             // Until all data sent/received.\r
+  \r
+  USI_TWI_Master_Stop();                           // Send a STOP condition on the TWI bus.\r
+\r
+/* Transmission successfully completed*/\r
+  return (TRUE);\r
+}\r
+\r
+/*---------------------------------------------------------------\r
+ Core function for shifting data in and out from the USI.\r
+ Data to be sent has to be placed into the USIDR prior to calling\r
+ this function. Data read, will be return'ed from the function.\r
+---------------------------------------------------------------*/\r
+unsigned char USI_TWI_Master_Transfer( unsigned char temp )\r
+{\r
+  USISR = temp;                                     // Set USISR according to temp.\r
+                                                    // Prepare clocking.\r
+  temp  =  (0<<USISIE)|(0<<USIOIE)|                 // Interrupts disabled\r
+           (1<<USIWM1)|(0<<USIWM0)|                 // Set USI in Two-wire mode.\r
+           (1<<USICS1)|(0<<USICS0)|(1<<USICLK)|     // Software clock strobe as source.\r
+           (1<<USITC);                              // Toggle Clock Port.\r
+  do\r
+  {\r
+    _delay_us( T2_TWI/4 );              \r
+    USICR = temp;                          // Generate positve SCL edge.\r
+    while( !(PIN_USI & (1<<PIN_USI_SCL)) );// Wait for SCL to go high.\r
+    _delay_us( T4_TWI/4 );              \r
+    USICR = temp;                          // Generate negative SCL edge.\r
+  }while( !(USISR & (1<<USIOIF)) );        // Check for transfer complete.\r
+  \r
+  _delay_us( T2_TWI/4 );                \r
+  temp  = USIDR;                           // Read out data.\r
+  USIDR = 0xFF;                            // Release SDA.\r
+  DDR_USI |= (1<<PIN_USI_SDA);             // Enable SDA as output.\r
+\r
+  return temp;                             // Return the data from the USIDR\r
+}\r
+\r
+/*---------------------------------------------------------------\r
+ Function for generating a TWI Stop Condition. Used to release \r
+ the TWI bus.\r
+---------------------------------------------------------------*/\r
+unsigned char USI_TWI_Master_Stop( void )\r
+{\r
+  PORT_USI &= ~(1<<PIN_USI_SDA);           // Pull SDA low.\r
+  PORT_USI |= (1<<PIN_USI_SCL);            // Release SCL.\r
+  while( !(PIN_USI & (1<<PIN_USI_SCL)) );  // Wait for SCL to go high.\r
+  _delay_us( T4_TWI/4 );               \r
+  PORT_USI |= (1<<PIN_USI_SDA);            // Release SDA.\r
+  _delay_us( T2_TWI/4 );                \r
+  \r
+#ifdef SIGNAL_VERIFY\r
+  if( !(USISR & (1<<USIPF)) )\r
+  {\r
+    USI_TWI_state.errorState = USI_TWI_MISSING_STOP_CON;    \r
+    return (FALSE);\r
+  }\r
+#endif\r
+\r
+  return (TRUE);\r
+}\r
+\r
+\r
+\r
+unsigned char I2c_WriteByte(unsigned char msg) {\r
+  unsigned char tempUSISR_8bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and\r
+  (0x0<<USICNT0);                                     // set USI to shift 8 bits i.e. count 16 clock edges.\r
+  unsigned char tempUSISR_1bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and\r
+  (0xE<<USICNT0);                                     // set USI to shift 1 bit i.e. count 2 clock edges.\r
+\r
+       /* Write a byte */\r
+       PORT_USI &= ~(1<<PIN_USI_SCL);                // Pull SCL LOW.\r
+       USIDR     = msg;                        // Setup data.\r
+       USI_TWI_Master_Transfer( tempUSISR_8bit );    // Send 8 bits on bus.\r
+       /* Clock and verify (N)ACK from slave */\r
+       DDR_USI  &= ~(1<<PIN_USI_SDA);                // Enable SDA as input.\r
+       if( USI_TWI_Master_Transfer( tempUSISR_1bit ) & (1<<TWI_NACK_BIT) ){\r
+               if ( USI_TWI_state.addressMode )\r
+                       USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_ADDRESS;\r
+               else\r
+                       USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_DATA;\r
+               return 2;\r
+       }\r
+       return 0;\r
+}\r
+unsigned char I2c_ReadByte(unsigned char ack_mode) {\r
+  unsigned char tempUSISR_8bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and\r
+  (0x0<<USICNT0);                                     // set USI to shift 8 bits i.e. count 16 clock edges.\r
+  unsigned char tempUSISR_1bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)|      // Prepare register value to: Clear flags, and\r
+  (0xE<<USICNT0);                                     // set USI to shift 1 bit i.e. count 2 clock edges.\r
+       \r
+       /* Read a data byte */\r
+       DDR_USI   &= ~(1<<PIN_USI_SDA);               // Enable SDA as input.\r
+    unsigned char msg = USI_TWI_Master_Transfer( tempUSISR_8bit );\r
+\r
+    /* Prepare to generate ACK (or NACK in case of End Of Transmission) */\r
+    if( ack_mode == NO_ACK) {                           // If transmission of last byte was performed.\r
+               USIDR = 0xFF;                              // Load NACK to confirm End Of Transmission.\r
+    } else   {\r
+               USIDR = 0x00;                              // Load ACK. Set data register bit 7 (output for SDA) low.\r
+    }\r
+    USI_TWI_Master_Transfer( tempUSISR_1bit );   // Generate ACK/NACK.\r
+       return msg;\r
+}\r
+\r
+void I2c_StartCondition(void) {\r
+/* Release SCL to ensure that (repeated) Start can be performed */\r
+PORT_USI |= (1<<PIN_USI_SCL);                     // Release SCL.\r
+while( !(PIN_USI & (1<<PIN_USI_SCL)) );          // Verify that SCL becomes high.\r
+#ifdef TWI_FAST_MODE\r
+_delay_us( T4_TWI/4 );                         // Delay for T4TWI if TWI_FAST_MODE\r
+#else\r
+_delay_us( T2_TWI/4 );                         // Delay for T2TWI if TWI_STANDARD_MODE\r
+#endif\r
+\r
+/* Generate Start Condition */\r
+PORT_USI &= ~(1<<PIN_USI_SDA);                    // Force SDA LOW.\r
+_delay_us( T4_TWI/4 );\r
+PORT_USI &= ~(1<<PIN_USI_SCL);                    // Pull SCL LOW.\r
+PORT_USI |= (1<<PIN_USI_SDA);                     // Release SDA.\r
+       \r
+       \r
+}\r
+void I2c_StopCondition(void) {\r
+       USI_TWI_Master_Stop();\r
+}\r
+\r
+#endif\r
+\r
+\r
+\r
+\r
+#if defined(__AVR_ATmega328PB__)| defined(__AVR_ATmega328P__)\r
+\r
+\r
+#include <util/twi.h>\r
+\r
+void TWI_Wait_Busy() {\r
+       _delay_us(100);\r
+       while (!( TWCR & (1<<TWINT) )); \r
+}\r
+\r
+\r
+void TWI_Master_Initialise( void ) {\r
+       TWBR = TWI_TWBR;                                  // Set bit rate register (Baud rate). Defined in header file.Driver presumes prescaler to be 00.\r     TWSR=0;\r        TWDR = 0xFF;                                      // Default content = SDA released.\r   TWCR = (1<<TWEN)|                                 // Enable TWI-interface and release TWI pins.\r                (0<<TWIE)|(0<<TWINT)|                      // Disable Interrupt.\r               (0<<TWEA)|(0<<TWSTA)|(0<<TWSTO)|           // No Signal requests.\r              (0<<TWWC);\r
+               \r
+}\r
+\r
+unsigned char I2c_WriteByte(unsigned char msg) {\r
+       uint8_t   twst;\r        TWDR = msg;\r    TWCR = (1<<TWINT) | (1<<TWEN);\r TWI_Wait_Busy();\r        // check value of TWI Status Register. Mask prescaler bits\r     twst = TW_STATUS & 0xF8;\r       if( twst != TW_MT_DATA_ACK) return 1;\r return 0;\r
+}\r
+unsigned char I2c_ReadByte(unsigned char ack_mode) {\r
+       TWCR = (1<<TWINT) | (1<<TWEN) |ack_mode;\r       TWI_Wait_Busy();\r    return TWDR;\r
+\r
+}\r
+void I2c_StartCondition(void) {\r
+       TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);\r
+       TWI_Wait_Busy();\r
+       uint8_t twst = TW_STATUS & 0xF8;\r       if ( (twst != TW_START) && (twst != TW_REP_START)) return ;// return 1;\r}\r
+/*\r\r
+// send device address\r\r
+TWDR = address;\r\r
+TWCR = (1<<TWINT) | (1<<TWEN);\r\r
+\r\r
+// wail until transmission completed and ACK/NACK has been received\r\r
+while(!(TWCR & (1<<TWINT)));\r\r
+\r\r
+// check value of TWI Status Register. Mask prescaler bits.\r\r
+twst = TW_STATUS & 0xF8;\r\r
+if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return 1;\r\r
+\r\r
+return 0;\r\r
+\r
+}\r
+*/\r
+void I2c_StopCondition(void) {\r
+\r
+   TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);\r\r
+   while(TWCR & (1<<TWSTO));\r
+\r
+}\r
+\r
+#endif
\ No newline at end of file
diff --git a/common/I2C/TWI_Master.h b/common/I2C/TWI_Master.h
new file mode 100644 (file)
index 0000000..327b2a5
--- /dev/null
@@ -0,0 +1,147 @@
+#ifndef TWI_MASTER_H\r
+#define TWI_MASTER_H\r
+#include<avr/io.h> \r
+//********** Defines **********//\r
+\r
+// Defines controlling timing limits\r
+#define TWI_FAST_MODE\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
+  #define T4_TWI    ((SYS_CLK * 600) /1000000) +1 // >0,6us\r
+  \r
+#else                              // TWI STANDARD mode timing limits. SCL <= 100kHz\r
+  #define T2_TWI    ((SYS_CLK *4700) /1000000) +1 // >4,7us\r
+  #define T4_TWI    ((SYS_CLK *4000) /1000000) +1 // >4,0us\r
+#endif\r
+\r
+// Defines controling code generating\r
+//#define PARAM_VERIFICATION\r
+//#define NOISE_TESTING\r
+//#define SIGNAL_VERIFY\r
+\r
+//USI_TWI messages and flags and bit masks\r
+//#define SUCCESS   7\r
+//#define MSG       0\r
+/****************************************************************************\r
+  Bit and byte definitions\r
+****************************************************************************/\r
+#define TWI_READ_BIT  0       // Bit position for R/W bit in "address byte".\r
+#define TWI_ADR_BITS  1       // Bit position for LSB of the slave address bits in the init byte.\r
+#define TWI_NACK_BIT  0       // Bit position for (N)ACK bit.\r
+\r
+#define USI_TWI_NO_DATA             0x00  // Transmission buffer is empty\r
+#define USI_TWI_DATA_OUT_OF_BOUND   0x01  // Transmission buffer is outside SRAM space\r
+#define USI_TWI_UE_START_CON        0x02  // Unexpected Start Condition\r
+#define USI_TWI_UE_STOP_CON         0x03  // Unexpected Stop Condition\r
+#define USI_TWI_UE_DATA_COL         0x04  // Unexpected Data Collision (arbitration)\r
+#define USI_TWI_NO_ACK_ON_DATA      0x05  // The slave did not acknowledge  all data\r
+#define USI_TWI_NO_ACK_ON_ADDRESS   0x06  // The slave did not acknowledge  the address\r
+#define USI_TWI_MISSING_START_CON   0x07  // Generated Start Condition not detected on bus\r
+#define USI_TWI_MISSING_STOP_CON    0x08  // Generated Stop Condition not detected on bus\r
+\r
+// Device dependant defines\r
+\r
+#if defined(__AVR_AT90Mega169__) | defined(__AVR_ATmega169PA__) | \\r
+    defined(__AVR_AT90Mega165__) | defined(__AVR_ATmega165__) | \\r
+    defined(__AVR_ATmega325__) | defined(__AVR_ATmega3250__) | \\r
+    defined(__AVR_ATmega645__) | defined(__AVR_ATmega6450__) | \\r
+    defined(__AVR_ATmega329__) | defined(__AVR_ATmega3290__) | \\r
+    defined(__AVR_ATmega649__) | defined(__AVR_ATmega6490__)\r
+    #define DDR_USI             DDRE\r
+    #define PORT_USI            PORTE\r
+    #define PIN_USI             PINE\r
+    #define PORT_USI_SDA        PORTE5\r
+    #define PORT_USI_SCL        PORTE4\r
+    #define PIN_USI_SDA         PINE5\r
+    #define PIN_USI_SCL         PINE4\r
+#endif\r
+\r
+#if defined(__AVR_ATtiny25__) | defined(__AVR_ATtiny45__) | defined(__AVR_ATtiny85__) | \\r
+    defined(__AVR_AT90Tiny26__) | defined(__AVR_ATtiny26__)\r
+    #define DDR_USI             DDRB\r
+    #define PORT_USI            PORTB\r
+    #define PIN_USI             PINB\r
+    #define PORT_USI_SDA        PORTB0\r
+    #define PORT_USI_SCL        PORTB2\r
+    #define PIN_USI_SDA         PINB0\r
+    #define PIN_USI_SCL         PINB2\r
+#endif\r
+\r
+#if defined(__AVR_AT90Tiny2313__) | defined(__AVR_ATtiny2313__)\r
+    #define DDR_USI             DDRB\r
+    #define PORT_USI            PORTB\r
+    #define PIN_USI             PINB\r
+    #define PORT_USI_SDA        PORTB5\r
+    #define PORT_USI_SCL        PORTB7\r
+    #define PIN_USI_SDA         PINB5\r
+    #define PIN_USI_SCL         PINB7\r
+#endif\r
+\r
+#if defined(__AVR_ATtiny84__) | defined(__AVR_ATtiny84A__)\r
+#define DDR_USI             DDRA\r
+#define PORT_USI            PORTA\r
+#define PIN_USI             PINA\r
+#define PORT_USI_SDA        PORTA6\r
+#define PORT_USI_SCL        PORTA4\r
+#define PIN_USI_SDA         PINA6\r
+#define PIN_USI_SCL         PINA4\r
+#endif\r
+\r
+\r
+//****************** ATMEGA TWI without USI\r
+#define TWI_BUFFER_SIZE 4   // Set this to the largest message size that will be sent including address byte.\r
+#define TWI_TWBR         0x4C; //  0x0C         // TWI Bit rate Register setting.\r// Se Application note for detailed\r// information on setting this value.\r\r
+\r
+\r
+\r
+#define ACK (1<<TWI_NACK_BIT )\r
+#define NO_ACK 0\r
+\r
+\r
+\r
+#if  defined(__AVR_ATmega328PB__)\r
+#undef ACK\r
+#define ACK  (1<<TWEA)\r
+\r
+#define TWBR TWBR0\r
+#define TWSR TWSR0\r
+#define TWCR TWCR0\r
+#define TWDR TWDR0\r
+#define TW_STATUS_MASK         (_BV(TWS7)|_BV(TWS6)|_BV(TWS5)|_BV(TWS4)|_BV(TWS3))\r
+#define TW_STATUS              (TWSR_R & TW_STATUS_MASK)\r
+\r
+#endif\r
+\r
+#if defined(__AVR_ATmega328P__)\r
+#undef ACK\r
+#define ACK  (1<<TWEA)\r
+\r
+#define TW_STATUS_MASK         (_BV(TWS7)|_BV(TWS6)|_BV(TWS5)|_BV(TWS4)|_BV(TWS3))\r
+#define TW_STATUS              (TWSR_R & TW_STATUS_MASK)\r
+\r
+\r
+#endif\r
+\r
+// General defines\r
+#define TRUE  1\r
+#define FALSE 0\r
+\r
+\r
+//********** Prototypes **********//\r
+\r
+void TWI_Master_Initialise( void );\r
+\r
+unsigned char I2c_WriteByte(unsigned char msg);\r
+unsigned char I2c_ReadByte(unsigned char ack_mode);\r
+void I2c_StartCondition(void);\r
+void I2c_StopCondition(void);\r
+\r
+#endif
\ No newline at end of file
index d5f2596..9aaf21d 100644 (file)
 *                     success of the transmission.\r
 *\r
 ****************************************************************************/\r
 *                     success of the transmission.\r
 *\r
 ****************************************************************************/\r
+\r
+#ifdef  __4MHZ__\r
+#define F_CPU 4000000UL\r
+#else\r
 #define F_CPU 8000000UL\r
 #define F_CPU 8000000UL\r
+#endif\r
 #include <avr/io.h>\r
 #include <avr/io.h>\r
-#include "USI_TWI_Master.h"\r
+#include "TWI_Master.h"\r
 #include <util/delay.h>\r
 \r
 unsigned char USI_TWI_Master_Transfer( unsigned char );\r
 #include <util/delay.h>\r
 \r
 unsigned char USI_TWI_Master_Transfer( unsigned char );\r
index d6b1f85..19f3e88 100644 (file)
 #define PIN_USI_SCL         PINA4\r
 #endif\r
 \r
 #define PIN_USI_SCL         PINA4\r
 #endif\r
 \r
+\r
+#if defined(__AVR_ATmega328__) | defined(__AVR_ATmega328P__) | defined(__AVR_ATmega328PB__)\r
+#define DDR_USI             DDRC\r
+#define PORT_USI            PORTC\r
+#define PIN_USI             PINC\r
+#define PORT_USI_SDA        PORTC4\r
+#define PORT_USI_SCL        PORTC5\r
+#define PIN_USI_SDA         PINC4\r
+#define PIN_USI_SCL         PINC5\r
+#endif\r
+\r
 // General defines\r
 #define TRUE  1\r
 #define FALSE 0\r
 \r
 // General defines\r
 #define TRUE  1\r
 #define FALSE 0\r
 \r
-#define ACK (1<<TWI_NACK_BIT )\r
-#define NO_ACK 0\r
+//#define ACK (1<<TWI_NACK_BIT )\r
+//#define NO_ACK 0\r
 \r
 \r
 //********** Prototypes **********//\r
 \r
 \r
 //********** Prototypes **********//\r
diff --git a/common/OWCRC8_16.s b/common/OWCRC8_16.s
new file mode 100644 (file)
index 0000000..0518dfe
--- /dev/null
@@ -0,0 +1,105 @@
+// 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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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
+\r
+.comm crc16,2\r
+.comm crc8,2\r
+#define _CRC8_16_\r
+\r
+CRC16_alg:\r
+       ;crc\r
+       \r
+       lds r_crc,crc16;lade low byte fuer vergleich mit bit\r
+       mov r_temp,r_crc\r
+       andi r_temp,0x01 ;nur bit 0\r
+       cp r_temp2,r_temp  ;r_temp2 wird in interruptroutine gesetzt\r
+       brne crc2_16 ;nur schieben\r
+       ;schieben und XOR\r
+       lds r_temp2,crc16+1\r
+       lsr     r_temp2\r
+       ror     r_crc\r
+       ldi     r_temp, 0x01    \r
+       eor     r_crc, r_temp\r
+       ldi     r_temp, 0xA0    ;\r
+       eor     r_temp2, r_temp\r
+       rjmp crce_16\r
+crc2_16:\r
+       lds r_temp2,crc16+1\r
+       lsr     r_temp2\r
+       ror     r_crc\r
+crce_16:\r
+       sts crc16,r_crc\r
+       sts crc16+1,r_temp2\r
+       \r
+       ret\r
+\r
+.macro CRCS ; CRC beim Senden\r
+       push r_crc\r
+       push r_temp2\r
+       rcall CRC16_alg\r
+       pop r_temp2\r
+               ;crc\r
+       lds r_crc,crc8\r
+       mov r_temp,r_crc\r
+       andi r_temp,0x01\r
+       cp r_temp2,r_temp\r
+       brne crc2_8\r
+       lsr r_crc\r
+       ldi r_temp,0x8c\r
+       eor r_crc,r_temp\r
+       rjmp crce_8\r
+crc2_8:\r
+       lsr r_crc\r
+crce_8:\r
+       sts crc8,r_crc\r
+       pop r_crc\r
+.endm\r
+\r
+.macro CRCR; CRC beim Empfangen\r
+       ;clr r_temp2\r
+       ;sbrc r_rwbyte,7\r
+       ;ldi r_temp2,1\r
+       push r_crc\r
+       rcall CRC16_alg\r
+       pop r_crc\r
+.endm\r
+\r
+.macro CRCInit1; CRC initialisierung bei READ_COMMAND\r
+       ldi r_temp,0\r
+       sts crc16,r_temp\r
+       sts crc16+1,r_temp\r
+.endm\r
+\r
+.macro CRCInit2; CRC initialisierung bei READ_DATA\r
+       ldi r_temp,0\r
+       sts crc8,r_temp\r
+.endm\r
index 8b8928f..41ba41b 100644 (file)
 #if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__)||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
 #include "../common/OWSet_ATTINYX4.s"\r
 #endif\r
 #if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__)||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
 #include "../common/OWSet_ATTINYX4.s"\r
 #endif\r
\r
+\r
+#if  defined(__AVR_ATmega168__)||defined(__AVR_ATmega168A__) ||defined(__AVR_ATmega328__) ||defined(__AVR_ATmega328P__) ||defined(__AVR_ATmega328PB__) \r
+#include "../common/OWSet_ATMEGA168.s"\r
+#endif \r
+\r
 #if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
 #include "../common/OWSet_ATTINYX5.s"\r
 #endif\r
 #if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
 #include "../common/OWSet_ATTINYX5.s"\r
 #endif\r
diff --git a/common/OWDS18B20_DS18B20.S b/common/OWDS18B20_DS18B20.S
new file mode 100644 (file)
index 0000000..e3c7eda
--- /dev/null
@@ -0,0 +1,392 @@
+\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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+#define _HANDLE_CC_COMMAND_\r
+//#define  __4MHZ__\r
+//#define _DB_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC8.s"\r
+\r
+.extern pack1,8\r
+\r
+.extern pack2,8\r
+\r
+\r
+\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
+       sbic _SFR_IO_ADDR(EECR), EEPE\r
+       rjmp Init_EEPROM_read\r
+       ldi r_temp,0\r
+       out _SFR_IO_ADDR(EEARH), r_temp\r
+       ldi r_temp,2\r
+       out _SFR_IO_ADDR(EEARL), r_temp\r
+       sbi _SFR_IO_ADDR(EECR), EERE\r
+       in r_temp,_SFR_IO_ADDR(EEDR)\r
+       sbrs r_temp,7\r
+       rcall hrc_recall_eeprom_func1\r
+       pop r_rwbyte\r
+       pop r_bytep\r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readscratchpad1\r
+               rjmp h_writescratchpad1\r
+               rjmp h_convert_run1\r
+               rjmp h_readscratchpad2\r
+               rjmp h_writescratchpad2\r
+               rjmp h_convert_run2\r
+.endm\r
+\r
+#include "../common/OWRomFunctionsDual.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+0\r
+#define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+1\r
+#define OW_CONVERT_RUN1  OW_FIRST_COMMAND+2\r
+#define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+4\r
+#define OW_CONVERT_RUN2  OW_FIRST_COMMAND+5\r
+\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+#ifdef _HANDLE_CC_COMMAND_\r
+h_readcommand12:\r
+       clr r_bytep\r
+       cjmp 0x44,hrc_set_convertT12\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+#endif\r
+\r
+\r
+h_readcommand1:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cjmp 0xBE,hrc_set_readscratchpad1\r
+       cjmp 0x4E,hrc_set_writescratchpad1\r
+       cjmp 0x44,hrc_set_convertT1\r
+       cjmp 0x48,hrc_copy_scratchpad1\r
+       cjmp 0xB8,hrc_recall_eeprom1\r
+       FW_CONFIG_INFO1\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+hrc_set_readscratchpad1:\r
+       ldi r_mode,OW_READ_SCRATCHPAD1\r
+       ldi r_sendflag,1\r
+       CRCInit2\r
+       rjmp h_readscratchpad1\r
+\r
+hrc_set_writescratchpad1:\r
+       ldi r_mode,OW_WRITE_SCRATCHPAD1\r
+       ldi r_bytep,2 ;start to write in 2\r
+       rjmp handle_end\r
+\r
+hrc_recall_eeprom1:\r
+       rcall hrc_recall_eeprom_func1\r
+       rjmp handle_end\r
+\r
+#ifdef _HANDLE_CC_COMMAND_\r
+hrc_set_convertT12:\r
+       ldi r_temp,3\r
+       sts gcontrol,r_temp\r
+       rjmp hrc_set_convertT12b  //egal ob hrc_set_convertT12b oder hrc_set_convertT22b\r
+#endif\r
+\r
+hrc_set_convertT1:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+hrc_set_convertT12b:\r
+       ldi r_mode,OW_CONVERT_RUN1\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_run1:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+hrc_copy_scratchpad1:\r
+       ldi r_bytep,2\r
+       configZ pack1,r_bytep\r
+       clr r_bytep\r
+hrc_copy_scratchpad_EEPROM_write1:\r
+       sbic _SFR_IO_ADDR(EECR), EEPE   \r
+       rjmp hrc_copy_scratchpad_EEPROM_write1\r
+       ldi r_temp, (0<<EEPM1)|(0<<EEPM0)\r
+       out _SFR_IO_ADDR(EECR), r_temp\r
+       ldi r_temp,0\r
+       out _SFR_IO_ADDR(EEARH),r_temp\r
+       out _SFR_IO_ADDR(EEARL), r_bytep\r
+       ld  r_rwbyte,Z+\r
+       out _SFR_IO_ADDR(EEDR), r_rwbyte\r
+       sbi _SFR_IO_ADDR(EECR), EEMPE\r
+       sbi _SFR_IO_ADDR(EECR), EEPE\r
+       inc r_bytep\r
+       cpi r_bytep,3\r
+       brne hrc_copy_scratchpad_EEPROM_write1\r
+       rjmp handle_end\r
+\r
+\r
+hrc_recall_eeprom_func1:\r
+       ldi r_bytep,2\r
+       configZ pack1,r_bytep\r
+       clr r_bytep\r
+       clr r_temp\r
+hrc_recall_eeprom_EEPROM_read1:\r
+       sbic _SFR_IO_ADDR(EECR), EEPE\r
+       rjmp hrc_recall_eeprom_EEPROM_read1\r
+       out _SFR_IO_ADDR(EEARH), r_temp\r
+       out _SFR_IO_ADDR(EEARL), r_bytep\r
+       sbi _SFR_IO_ADDR(EECR), EERE\r
+       in r_rwbyte,_SFR_IO_ADDR(EEDR)\r
+       st Z+,r_rwbyte\r
+       inc r_bytep\r
+       cpi r_bytep,3\r
+       brne hrc_recall_eeprom_EEPROM_read1\r
+       ret\r
+\r
+\r
+\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   READ SCRATCHPAD\r
+;---------------------------------------------------\r
+\r
+h_readscratchpad1:\r
+       cpi  r_bytep,8\r
+       breq h_readscratchpad_crc1\r
+       cpi  r_bytep,9\r
+       breq h_readscratchpad_all1\r
+       configZ pack1,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp h_readscratchpad_endc1\r
+h_readscratchpad_crc1:\r
+       lds  r_rwbyte,crc\r
+h_readscratchpad_endc1:\r
+       inc  r_bytep\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end\r
+h_readscratchpad_all1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   WRITE SCRATCHPAD\r
+;---------------------------------------------------\r
+\r
+h_writescratchpad1:\r
+       configZ pack1,r_bytep\r
+       inc  r_bytep\r
+       cpi  r_bytep,5\r
+       breq h_writescratchpad_all1\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end\r
+h_writescratchpad_all1:\r
+       ;ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1 -->VOC use different\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end_sleep\r
+\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+\r
+\r
+\r
+h_readcommand2:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cjmp 0xBE,hrc_set_readscratchpad2\r
+       cjmp 0x4E,hrc_set_writescratchpad2\r
+       cjmp 0x44,hrc_set_convertT2\r
+       cjmp 0x48,hrc_copy_scratchpad2\r
+       cjmp 0xB8,hrc_recall_eeprom2\r
+       FW_CONFIG_INFO2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+hrc_set_readscratchpad2:\r
+       ldi r_mode,OW_READ_SCRATCHPAD2\r
+       ldi r_sendflag,1\r
+       CRCInit2\r
+       rjmp h_readscratchpad2\r
+\r
+hrc_set_writescratchpad2:\r
+       ldi r_mode,OW_WRITE_SCRATCHPAD2\r
+       ldi r_bytep,2 ;start to write in 2\r
+       rjmp handle_end\r
+\r
+hrc_recall_eeprom2:\r
+       rcall hrc_recall_eeprom_func2\r
+       rjmp handle_end\r
+\r
+hrc_set_convertT2:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+hrc_set_convertT22b:\r
+       ldi r_mode,OW_CONVERT_RUN2\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_run2:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+hrc_copy_scratchpad2:\r
+       ldi r_bytep,2\r
+       configZ pack2,r_bytep\r
+       clr r_bytep\r
+hrc_copy_scratchpad_EEPROM_write2:\r
+       sbic _SFR_IO_ADDR(EECR), EEPE   \r
+       rjmp hrc_copy_scratchpad_EEPROM_write2\r
+       ldi r_temp, (0<<EEPM1)|(0<<EEPM0)\r
+       out _SFR_IO_ADDR(EECR), r_temp\r
+       ldi r_temp,0\r
+       out _SFR_IO_ADDR(EEARH),r_temp\r
+       out _SFR_IO_ADDR(EEARL), r_bytep\r
+       ld  r_rwbyte,Z+\r
+       out _SFR_IO_ADDR(EEDR), r_rwbyte\r
+       sbi _SFR_IO_ADDR(EECR), EEMPE\r
+       sbi _SFR_IO_ADDR(EECR), EEPE\r
+       inc r_bytep\r
+       cpi r_bytep,3\r
+       brne hrc_copy_scratchpad_EEPROM_write2\r
+       rjmp handle_end\r
+\r
+\r
+hrc_recall_eeprom_func2:\r
+       ldi r_bytep,2\r
+       configZ pack2,r_bytep\r
+       //clr r_bytep\r
+       ldi r_bytep,8\r
+       clr r_temp\r
+hrc_recall_eeprom_EEPROM_read2:\r
+       sbic _SFR_IO_ADDR(EECR), EEPE\r
+       rjmp hrc_recall_eeprom_EEPROM_read2\r
+       out _SFR_IO_ADDR(EEARH), r_temp\r
+       out _SFR_IO_ADDR(EEARL), r_bytep\r
+       sbi _SFR_IO_ADDR(EECR), EERE\r
+       in r_rwbyte,_SFR_IO_ADDR(EEDR)\r
+       st Z+,r_rwbyte\r
+       inc r_bytep\r
+       cpi r_bytep,3\r
+       brne hrc_recall_eeprom_EEPROM_read2\r
+       ret\r
+\r
+\r
+\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   READ SCRATCHPAD\r
+;---------------------------------------------------\r
+\r
+h_readscratchpad2:\r
+       cpi  r_bytep,8\r
+       breq h_readscratchpad_crc2\r
+       cpi  r_bytep,9\r
+       breq h_readscratchpad_all2\r
+       configZ pack2,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp h_readscratchpad_endc2\r
+h_readscratchpad_crc2:\r
+       lds  r_rwbyte,crc\r
+h_readscratchpad_endc2:\r
+       inc  r_bytep\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end\r
+h_readscratchpad_all2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   WRITE SCRATCHPAD\r
+;---------------------------------------------------\r
+\r
+h_writescratchpad2:\r
+       configZ pack2,r_bytep\r
+       inc  r_bytep\r
+       cpi  r_bytep,5\r
+       breq h_writescratchpad_all2\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end\r
+h_writescratchpad_all2:\r
+       ;ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1 -->VOC use different\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end\r
diff --git a/common/OWDS18B20_DS2408.S b/common/OWDS18B20_DS2408.S
new file mode 100644 (file)
index 0000000..3b7802a
--- /dev/null
@@ -0,0 +1,456 @@
+\r
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+#define _HANDLE_CC_COMMAND_\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC8_16.s"\r
+\r
+.extern pack1,8\r
+\r
+.extern pack2,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+.comm stat_to_sample,1\r
+\r
+.comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)\r
+.comm cpsp,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 cpsp,r_temp\r
+Init_EEPROM_read:\r
+       push r_bytep\r
+       push r_rwbyte\r
+       sbic _SFR_IO_ADDR(EECR), EEPE\r
+       rjmp Init_EEPROM_read\r
+       ldi r_temp,0\r
+       out _SFR_IO_ADDR(EEARH), r_temp\r
+       ldi r_temp,2\r
+       out _SFR_IO_ADDR(EEARL), r_temp\r
+       sbi _SFR_IO_ADDR(EECR), EERE\r
+       in r_temp,_SFR_IO_ADDR(EEDR)\r
+       sbrs r_temp,7\r
+       rcall hrc_recall_eeprom_func1\r
+       pop r_rwbyte\r
+       pop r_bytep\r
+.endm\r
+\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readscratchpad1\r
+               rjmp h_writescratchpad1\r
+               rjmp h_convert_run1\r
+               rjmp h_readpioregaddr2\r
+               rjmp h_readpioreg2\r
+               rjmp h_readpioregcrc12\r
+               rjmp h_readpioregcrc22\r
+               rjmp h_readchanel2\r
+               rjmp h_readchanel_crc2\r
+               rjmp h_writechanel2\r
+               rjmp h_writecomchanel2\r
+               rjmp h_writesendaa2\r
+               rjmp h_writesendchanel2\r
+               rjmp h_resetactivity2\r
+               rjmp h_writeregaddr2\r
+               rjmp h_writereg2\r
+.endm\r
+\r
+#include "../common/OWRomFunctionsDual.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+\r
+#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+0\r
+#define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+1\r
+#define OW_CONVERT_RUN1  OW_FIRST_COMMAND+2\r
+\r
+#define OW_READ_PIO_REG_ADDR2 OW_FIRST_COMMAND+3\r
+#define OW_READ_PIO_REG2 OW_FIRST_COMMAND+4\r
+#define OW_READ_PIO_REG_CRC12 OW_FIRST_COMMAND+5\r
+#define OW_READ_PIO_REG_CRC22 OW_FIRST_COMMAND+6\r
+#define OW_READ_CHANEL2 OW_FIRST_COMMAND+7\r
+#define OW_READ_CHANEL_CRC2 OW_FIRST_COMMAND+8\r
+#define OW_WRITE_CHANEL2 OW_FIRST_COMMAND+9\r
+#define OW_WRITE_COMCHANEL2 OW_FIRST_COMMAND+10\r
+#define OW_WRITE_SENDAA2 OW_FIRST_COMMAND+11\r
+#define OW_WRITE_SEND_CHANEL2 OW_FIRST_COMMAND+12\r
+#define OW_RESET_ACTIVITY2 OW_FIRST_COMMAND+13\r
+#define OW_WRITE_REG_ADDR2 OW_FIRST_COMMAND+14\r
+#define OW_WRITE_REG2 OW_FIRST_COMMAND+15\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+#ifdef _HANDLE_CC_COMMAND_\r
+h_readcommand12:\r
+       clr r_bytep\r
+       cjmp 0x44,hrc_set_convertT12\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+#endif\r
+\r
+\r
+h_readcommand1:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cjmp 0xBE,hrc_set_readscratchpad1\r
+       cjmp 0x4E,hrc_set_writescratchpad1\r
+       cjmp 0x44,hrc_set_convertT1\r
+       cjmp 0x48,hrc_copy_scratchpad1\r
+       cjmp 0xB8,hrc_recall_eeprom1\r
+       FW_CONFIG_INFO1\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+hrc_set_readscratchpad1:\r
+       ldi r_mode,OW_READ_SCRATCHPAD1\r
+       ldi r_sendflag,1\r
+       CRCInit2\r
+       rjmp h_readscratchpad1\r
+\r
+hrc_set_writescratchpad1:\r
+       ldi r_mode,OW_WRITE_SCRATCHPAD1\r
+       ldi r_bytep,2 ;start to write in 2\r
+       rjmp handle_end\r
+\r
+hrc_recall_eeprom1:\r
+       rcall hrc_recall_eeprom_func1\r
+       rjmp handle_end\r
+\r
+#ifdef _HANDLE_CC_COMMAND_\r
+hrc_set_convertT12:\r
+       rjmp hrc_set_convertT1\r
+#endif\r
+\r
+hrc_set_convertT1:\r
+       ldi r_temp,16\r
+       sts gcontrol,r_temp\r
+hrc_set_convertT12b:\r
+       ldi r_mode,OW_CONVERT_RUN1\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_run1:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount       \r
+\r
+\r
+\r
+hrc_copy_scratchpad1:\r
+       ldi r_bytep,2\r
+       configZ pack1,r_bytep\r
+       clr r_bytep\r
+hrc_copy_scratchpad_EEPROM_write1:\r
+       sbic _SFR_IO_ADDR(EECR), EEPE   \r
+       rjmp hrc_copy_scratchpad_EEPROM_write1\r
+       ldi r_temp, (0<<EEPM1)|(0<<EEPM0)\r
+       out _SFR_IO_ADDR(EECR), r_temp\r
+       ldi r_temp,0\r
+       out _SFR_IO_ADDR(EEARH),r_temp\r
+       out _SFR_IO_ADDR(EEARL), r_bytep\r
+       ld  r_rwbyte,Z+\r
+       out _SFR_IO_ADDR(EEDR), r_rwbyte\r
+       sbi _SFR_IO_ADDR(EECR), EEMPE\r
+       sbi _SFR_IO_ADDR(EECR), EEPE\r
+       inc r_bytep\r
+       cpi r_bytep,3\r
+       brne hrc_copy_scratchpad_EEPROM_write1\r
+       rjmp handle_end\r
+\r
+\r
+hrc_recall_eeprom_func1:\r
+       ldi r_bytep,2\r
+       configZ pack1,r_bytep\r
+       clr r_bytep\r
+       clr r_temp\r
+hrc_recall_eeprom_EEPROM_read1:\r
+       sbic _SFR_IO_ADDR(EECR), EEPE\r
+       rjmp hrc_recall_eeprom_EEPROM_read1\r
+       out _SFR_IO_ADDR(EEARH), r_temp\r
+       out _SFR_IO_ADDR(EEARL), r_bytep\r
+       sbi _SFR_IO_ADDR(EECR), EERE\r
+       in r_rwbyte,_SFR_IO_ADDR(EEDR)\r
+       st Z+,r_rwbyte\r
+       inc r_bytep\r
+       cpi r_bytep,3\r
+       brne hrc_recall_eeprom_EEPROM_read1\r
+       ret\r
+\r
+\r
+\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   READ SCRATCHPAD\r
+;---------------------------------------------------\r
+\r
+h_readscratchpad1:\r
+       cpi  r_bytep,8\r
+       breq h_readscratchpad_crc1\r
+       cpi  r_bytep,9\r
+       breq h_readscratchpad_all1\r
+       configZ pack1,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp h_readscratchpad_endc1\r
+h_readscratchpad_crc1:\r
+       lds  r_rwbyte,crc8\r
+h_readscratchpad_endc1:\r
+       inc  r_bytep\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end\r
+h_readscratchpad_all1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   WRITE SCRATCHPAD\r
+;---------------------------------------------------\r
+\r
+h_writescratchpad1:\r
+       configZ pack1,r_bytep\r
+       inc  r_bytep\r
+       cpi  r_bytep,5\r
+       breq h_writescratchpad_all1\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end\r
+h_writescratchpad_all1:\r
+       ;ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1 -->VOC use different\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end_sleep\r
+\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+h_readcommand2:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xF0,OW_READ_PIO_REG_ADDR2\r
+       cljmp 0xF5,hrc_readchanel2\r
+       cset 0x5A,OW_WRITE_CHANEL2\r
+       cljmp 0xC3,hrc_reset_activity2\r
+       cset 0xCC,OW_WRITE_REG_ADDR2\r
+       FW_CONFIG_INFO2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readpioregaddr2:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readpioreg_addr_byte12 ;nein dann weiter\r
+       //andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       subi r_rwbyte,0x89  ;beim lesen von 0x88 --> 0xFF inc addr -> 0x00\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readpioreg_addr_byte12:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_PIO_REG2 ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+h_readpioreg2:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       cpi r_bytep,0x08\r
+       breq h_readpioreg_init_crc2\r
+       brge h_readpioreg_end2 ; groeser dann nix senden\r
+       configZ pack2,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readpioreg_init_crc2:; init erstes CRC byte\r
+       lds r_rwbyte,crc16\r
+       com r_rwbyte\r
+       lds r_temp,crc16+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_PIO_REG_CRC12\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readpioreg_end2:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readpioregcrc12:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_PIO_REG_CRC22\r
+       rjmp handle_end\r
+h_readpioregcrc22: ; 2. CRC Byte gesendet\r
+       rjmp h_readpioreg_end2\r
+\r
+\r
+hrc_readchanel2:\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       ldi r_mode,OW_READ_CHANEL2\r
+       ldi r_temp,8\r
+       sts gcontrol,r_temp\r
+       rjmp h_readchanel12\r
+h_readchanel2:\r
+       ldi r_temp,4\r
+       sts gcontrol,r_temp\r
+h_readchanel12:\r
+       cpi r_bytep,31\r
+       brge h_readchanelcrc12\r
+       lds r_rwbyte,stat_to_sample\r
+       sts pack2,r_rwbyte //sample \r
+       rjmp handle_end_inc\r
+h_readchanelcrc12:\r
+       lds r_rwbyte,crc16\r
+       com r_rwbyte\r
+       lds r_temp,crc16+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_CHANEL_CRC2\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readchanel_crc2:\r
+       clr r_bytep\r
+       ldi r_mode,OW_READ_CHANEL2\r
+       lds r_rwbyte,crcsave\r
+       rjmp handle_end\r
+       \r
+h_writechanel2:\r
+       sts crcsave,r_rwbyte\r
+       ldi r_mode,OW_WRITE_COMCHANEL2\r
+       rjmp handle_end\r
+h_writecomchanel2:\r
+       com r_rwbyte\r
+       lds r_temp,crcsave\r
+       cp r_rwbyte,r_temp\r
+       breq h_writeok2\r
+       rjmp handle_end_sleep\r
+h_writeok2:\r
+       sts pack2+1,r_rwbyte\r
+       ldi r_temp2,1\r
+       sts gcontrol,r_temp2\r
+       clr r_sendflag\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_mode,OW_WRITE_SENDAA2\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       rjmp handle_end\r
+h_writesendaa2:\r
+       lds r_rwbyte,pack2\r
+       ldi r_mode,OW_WRITE_SEND_CHANEL2\r
+       rjmp handle_end\r
+h_writesendchanel2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+hrc_reset_activity2:\r
+       ldi r_temp,2\r
+       sts gcontrol,r_temp\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_mode,OW_RESET_ACTIVITY2\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       rjmp handle_end\r
+h_resetactivity2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+h_writeregaddr2:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writeregddr_byte12 ;nein dann weiter\r
+       //andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       subi r_rwbyte,0x8B  \r
+       brmi h_writereg_end2\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_writeregddr_byte12:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_REG2 ;weiter zu write Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       clr r_bytep\r
+       rjmp handle_end\r
+h_writereg2:\r
+       lds r_temp,addr\r
+       configZ pack2+3,r_temp\r
+       st Z,r_rwbyte\r
+       cpi r_temp,5\r
+       brge h_writereg_end2\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       rjmp handle_end_sleep\r
+               \r
+h_writereg_end2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
index 73fd42e..a95559e 100644 (file)
@@ -34,7 +34,8 @@
 #define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
 #define _HANDLE_CC_COMMAND_\r
 #define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
 #define _HANDLE_CC_COMMAND_\r
-               \r
+#define _NO_BOOTLOADER_PIN_    \r
+//#define  __4MHZ__\r
 //#define _DB_\r
 \r
 #include "../common/OWConfig.s"\r
 //#define _DB_\r
 \r
 #include "../common/OWConfig.s"\r
 \r
 .extern pack1,8\r
 \r
 \r
 .extern pack1,8\r
 \r
-//.extern  am2302_temp,2\r
-\r
 #if  defined(__AVR_ATtiny25__)\r
 .extern pack2,16\r
 #else\r
 .extern pack2,64\r
 #endif\r
 #if  defined(__AVR_ATtiny25__)\r
 .extern pack2,16\r
 #else\r
 .extern pack2,64\r
 #endif\r
-//.extern  am2302_temp,2\r
-//.extern  am2302_hum,2\r
+\r
+\r
+\r
 .comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)\r
 .comm cpsp,1 ; Copy Scratchpad marker\r
 \r
 .comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)\r
 .comm cpsp,1 ; Copy Scratchpad marker\r
 \r
@@ -110,8 +110,9 @@ Init_EEPROM_read:
 h_readcommand12:\r
        clr r_bytep\r
        cjmp 0x44,hrc_set_convertT12\r
 h_readcommand12:\r
        clr r_bytep\r
        cjmp 0x44,hrc_set_convertT12\r
-       ldi r_mode,OW_SLEEP\r
-       rjmp handle_end\r
+       rjmp h_readcccommand  ;fuehre DS2438 commands aus...\r
+       //ldi r_mode,OW_SLEEP\r
+       //rjmp handle_end\r
 #endif\r
 \r
 \r
 #endif\r
 \r
 \r
@@ -120,9 +121,10 @@ h_readcommand1:
 #ifndef _DIS_FLASH_\r
        FLASH_COMMANDS ; muss zu erst sein....\r
 #endif\r
 #ifndef _DIS_FLASH_\r
        FLASH_COMMANDS ; muss zu erst sein....\r
 #endif\r
+       cjmp 0x44,hrc_set_convertT1\r
+h_readcccommand:\r
        cjmp 0xBE,hrc_set_readscratchpad1\r
        cjmp 0x4E,hrc_set_writescratchpad1\r
        cjmp 0xBE,hrc_set_readscratchpad1\r
        cjmp 0x4E,hrc_set_writescratchpad1\r
-       cjmp 0x44,hrc_set_convertT1\r
        cjmp 0x48,hrc_copy_scratchpad1\r
        cjmp 0xB8,hrc_recall_eeprom1\r
        FW_CONFIG_INFO1\r
        cjmp 0x48,hrc_copy_scratchpad1\r
        cjmp 0xB8,hrc_recall_eeprom1\r
        FW_CONFIG_INFO1\r
@@ -151,9 +153,9 @@ hrc_recall_eeprom1:
 hrc_set_convertT12:\r
        ldi r_temp,3\r
        sts gcontrol,r_temp\r
 hrc_set_convertT12:\r
        ldi r_temp,3\r
        sts gcontrol,r_temp\r
-       lds r_temp,am2302_temp\r
+       lds r_temp,DS2438_2_TEMP\r
        sts pack2+1,r_temp\r
        sts pack2+1,r_temp\r
-       lds r_temp,am2302_temp+1\r
+       lds r_temp,DS2438_2_TEMP+1\r
        sts pack2+2,r_temp\r
        rjmp hrc_set_convertT12b\r
 #endif\r
        sts pack2+2,r_temp\r
        rjmp hrc_set_convertT12b\r
 #endif\r
@@ -288,26 +290,28 @@ h_readcommand2:
 hrc_set_convertT2:\r
        ldi r_temp,2\r
        sts gcontrol,r_temp\r
 hrc_set_convertT2:\r
        ldi r_temp,2\r
        sts gcontrol,r_temp\r
-       lds r_temp,am2302_temp\r
+       lds r_temp,DS2438_2_TEMP\r
        sts pack2+1,r_temp\r
        sts pack2+1,r_temp\r
-       lds r_temp,am2302_temp+1\r
+       lds r_temp,DS2438_2_TEMP+1\r
        sts pack2+2,r_temp\r
        rjmp handle_end_sleep\r
 hrc_set_convertV2:\r
        sts pack2+2,r_temp\r
        rjmp handle_end_sleep\r
 hrc_set_convertV2:\r
+       ldi r_temp,4\r
+       sts gcontrol,r_temp\r
        lds r_temp,pack2\r
        sbrs r_temp,3\r
        rjmp hrc_set_convertVV2\r
        lds r_temp,pack2\r
        sbrs r_temp,3\r
        rjmp hrc_set_convertVV2\r
-       ldi r_temp,0xF4\r
+       lds r_temp,DS2438_2_VDD\r
        sts pack2+3,r_temp\r
        sts pack2+3,r_temp\r
-       ldi r_temp,0x01\r
+       lds r_temp,DS2438_2_VDD+1\r
        sts pack2+4,r_temp\r
        rjmp hrc_set_convertend2\r
 hrc_set_convertVV2:\r
        sts pack2+4,r_temp\r
        rjmp hrc_set_convertend2\r
 hrc_set_convertVV2:\r
-       ldi r_temp,3\r
+       ldi r_temp,8\r
        sts gcontrol,r_temp\r
        sts gcontrol,r_temp\r
-       lds r_temp,am2302_hum\r
+       lds r_temp,DS2438_2_VAD\r
        sts pack2+3,r_temp\r
        sts pack2+3,r_temp\r
-       lds r_temp,am2302_hum+1\r
+       lds r_temp,DS2438_2_VAD+1\r
        sts pack2+4,r_temp\r
 hrc_set_convertend2:\r
        rjmp handle_end_sleep\r
        sts pack2+4,r_temp\r
 hrc_set_convertend2:\r
        rjmp handle_end_sleep\r
diff --git a/common/OWDS2408.S b/common/OWDS2408.S
new file mode 100644 (file)
index 0000000..1bad722
--- /dev/null
@@ -0,0 +1,255 @@
+\r
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,8\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+.comm stat_to_sample,1\r
+\r
+\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readpioregaddr\r
+               rjmp h_readpioreg\r
+               rjmp h_readpioregcrc1\r
+               rjmp h_readpioregcrc2\r
+               rjmp h_readchanel\r
+               rjmp h_readchanel_crc\r
+               rjmp h_writechanel\r
+               rjmp h_writecomchanel\r
+               rjmp h_writesendaa\r
+               rjmp h_writesendchanel\r
+               rjmp h_resetactivity\r
+               rjmp h_writeregaddr\r
+               rjmp h_writereg\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_PIO_REG_ADDR OW_FIRST_COMMAND+0\r
+#define OW_READ_PIO_REG OW_FIRST_COMMAND+1\r
+#define OW_READ_PIO_REG_CRC1 OW_FIRST_COMMAND+2\r
+#define OW_READ_PIO_REG_CRC2 OW_FIRST_COMMAND+3\r
+#define OW_READ_CHANEL OW_FIRST_COMMAND+4\r
+#define OW_READ_CHANEL_CRC OW_FIRST_COMMAND+5\r
+#define OW_WRITE_CHANEL OW_FIRST_COMMAND+6\r
+#define OW_WRITE_COMCHANEL OW_FIRST_COMMAND+7\r
+#define OW_WRITE_SENDAA OW_FIRST_COMMAND+8\r
+#define OW_WRITE_SEND_CHANEL OW_FIRST_COMMAND+9\r
+#define OW_RESET_ACTIVITY OW_FIRST_COMMAND+10\r
+#define OW_WRITE_REG_ADDR OW_FIRST_COMMAND+11\r
+#define OW_WRITE_REG OW_FIRST_COMMAND+12\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xF0,OW_READ_PIO_REG_ADDR\r
+       cljmp 0xF5,hrc_readchanel\r
+       cset 0x5A,OW_WRITE_CHANEL\r
+       cljmp 0xC3,hrc_reset_activity\r
+       cset 0xCC,OW_WRITE_REG_ADDR\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readpioregaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readpioreg_addr_byte1 ;nein dann weiter\r
+       //andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       subi r_rwbyte,0x89  ;beim lesen von 0x88 --> 0xFF inc addr -> 0x00\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readpioreg_addr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_PIO_REG ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+h_readpioreg:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       cpi r_bytep,0x08\r
+       breq h_readpioreg_init_crc\r
+       brge h_readpioreg_end ; groeser dann nix senden\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readpioreg_init_crc:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_PIO_REG_CRC1\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readpioreg_end:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readpioregcrc1:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_PIO_REG_CRC2\r
+       rjmp handle_end\r
+h_readpioregcrc2: ; 2. CRC Byte gesendet\r
+       rjmp h_readpioreg_end\r
+\r
+\r
+hrc_readchanel:\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       ldi r_mode,OW_READ_CHANEL\r
+       ldi r_temp,8\r
+       sts gcontrol,r_temp\r
+       rjmp h_readchanel1\r
+h_readchanel:\r
+       ldi r_temp,4\r
+       sts gcontrol,r_temp\r
+h_readchanel1:\r
+       cpi r_bytep,31\r
+       brge h_readchanelcrc1\r
+       lds r_rwbyte,stat_to_sample\r
+       sts pack,r_rwbyte //sample \r
+       rjmp handle_end_inc\r
+h_readchanelcrc1:\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_CHANEL_CRC\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readchanel_crc:\r
+       clr r_bytep\r
+       ldi r_mode,OW_READ_CHANEL\r
+       lds r_rwbyte,crcsave\r
+       rjmp handle_end\r
+       \r
+h_writechanel:\r
+       sts crcsave,r_rwbyte\r
+       ldi r_mode,OW_WRITE_COMCHANEL\r
+       rjmp handle_end\r
+h_writecomchanel:\r
+       com r_rwbyte\r
+       lds r_temp,crcsave\r
+       cp r_rwbyte,r_temp\r
+       breq h_writeok\r
+       rjmp handle_end_sleep\r
+h_writeok:\r
+       sts pack+1,r_rwbyte\r
+       ldi r_temp2,1\r
+       sts gcontrol,r_temp2\r
+       clr r_sendflag\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_mode,OW_WRITE_SENDAA\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       rjmp handle_end\r
+h_writesendaa:\r
+       lds r_rwbyte,pack\r
+       ldi r_mode,OW_WRITE_SEND_CHANEL\r
+       rjmp handle_end\r
+h_writesendchanel:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+hrc_reset_activity:\r
+       ldi r_temp,2\r
+       sts gcontrol,r_temp\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_mode,OW_RESET_ACTIVITY\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       rjmp handle_end\r
+h_resetactivity:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+h_writeregaddr:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writeregddr_byte1 ;nein dann weiter\r
+       //andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       subi r_rwbyte,0x8B  \r
+       brmi h_writereg_end\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_writeregddr_byte1:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_REG ;weiter zu write Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       clr r_bytep\r
+       rjmp handle_end\r
+h_writereg:\r
+       lds r_temp,addr\r
+       configZ pack+3,r_temp\r
+       st Z,r_rwbyte\r
+       cpi r_temp,5\r
+       brge h_writereg_end     \r
+       inc r_temp\r
+       sts addr,r_temp\r
+       rjmp handle_end_sleep\r
+               \r
+h_writereg_end:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/common/OWDS2413_DS2413.S b/common/OWDS2413_DS2413.S
new file mode 100644 (file)
index 0000000..df6d04b
--- /dev/null
@@ -0,0 +1,248 @@
+\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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+//#define _HANDLE_CC_COMMAND_\r
+//#define _DB_\r
+//#define __4MHZ__\r
+        \r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pin_state1,1\r
+.extern pin_state1,1\r
+.extern pin_state2,1\r
+.extern pin_set2,1\r
+.comm resv1,1\r
+.comm resv2,1\r
+.macro CHIP_INIT       ;r_temp is pushed other Registers should be saved\r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+\r
+               rjmp h_accessread1\r
+               rjmp h_accesswrite1\r
+               rjmp h_accesswrite_read1\r
+\r
+               rjmp h_accessread2\r
+               rjmp h_accesswrite2\r
+               rjmp h_accesswrite_read2\r
+.endm\r
+\r
+#include "../common/OWRomFunctionsDual.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_ACCESSREAD1 OW_FIRST_COMMAND+0\r
+#define OW_ACCESSWRITE1 OW_FIRST_COMMAND+1\r
+#define OW_ACCESSWRITE_READ1 OW_FIRST_COMMAND+2\r
+\r
+\r
+#define OW_ACCESSREAD2 OW_FIRST_COMMAND+3\r
+#define OW_ACCESSWRITE2 OW_FIRST_COMMAND+4\r
+#define OW_ACCESSWRITE_READ2 OW_FIRST_COMMAND+5\r
+\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+h_readcommand1:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cjmp 0xF5,hrc_accessread1\r
+       cset 0x5A,OW_ACCESSWRITE1\r
+/*     cset 0xBE,OW_READ_SCRATCHPAD_ADR2\r
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2\r
+       cjmp 0x44,hrc_set_convertT2\r
+       cjmp 0xB4,hrc_set_convertV2*/\r
+       FW_CONFIG_INFO1\r
+       //cljmp 0x85,hrc_fw_configinfo2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       rjmp handle_end_sleep\r
+\r
+\r
+hrc_accessread1:\r
+       ldi r_sendflag,1\r
+       ldi r_mode,OW_ACCESSREAD1\r
+h_accessread1:\r
+       lds r_temp,pin_state1\r
+       andi r_temp,0x0F\r
+       mov r_rwbyte,r_temp\r
+       com r_rwbyte\r
+       swap r_rwbyte\r
+       andi r_rwbyte,0xF0\r
+       or r_rwbyte,r_temp\r
+       rjmp handle_end\r
+\r
+\r
+\r
+\r
+h_accesswrite_read1:\r
+       //lds r_rwbyte,pin_state1\r
+       rjmp handle_end_sleep\r
+       \r
+\r
+\r
+h_accesswrite1:\r
+       cpi  r_bytep,1\r
+       breq h_accesswrite_compl1\r
+       sts resv1,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_accesswrite_compl1:\r
+       com r_rwbyte\r
+       lds r_temp,resv1\r
+       cp r_temp,r_rwbyte\r
+       brne h_accesswrite_error1\r
+       sts  pin_set1,r_rwbyte\r
+       ldi r_mode,OW_ACCESSWRITE_READ1\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_sendflag,1\r
+       rjmp handle_end_inc\r
+h_accesswrite_error1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+\r
+\r
+h_readcommand2:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cjmp 0xF5,hrc_accessread2\r
+       cset 0x5A,OW_ACCESSWRITE2\r
+/*     cset 0xBE,OW_READ_SCRATCHPAD_ADR2\r
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2\r
+       cjmp 0x44,hrc_set_convertT2\r
+       cjmp 0xB4,hrc_set_convertV2*/\r
+       FW_CONFIG_INFO2\r
+       //cljmp 0x85,hrc_fw_configinfo2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       rjmp handle_end_sleep\r
+\r
+\r
+hrc_accessread2:\r
+       ldi r_sendflag,1\r
+       ldi r_mode,OW_ACCESSREAD2\r
+h_accessread2:\r
+       lds r_temp,pin_state2\r
+       andi r_temp,0x0F\r
+       mov r_rwbyte,r_temp\r
+       com r_rwbyte\r
+       swap r_rwbyte\r
+       andi r_rwbyte,0xF0\r
+       or r_rwbyte,r_temp\r
+       rjmp handle_end\r
+\r
+\r
+\r
+\r
+h_accesswrite_read2:\r
+       //lds r_rwbyte,pin_state2\r
+       rjmp handle_end_sleep\r
+       \r
+\r
+\r
+h_accesswrite2:\r
+       cpi  r_bytep,1\r
+       breq h_accesswrite_compl2\r
+       sts resv2,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_accesswrite_compl2:\r
+       com r_rwbyte\r
+       lds r_temp,resv2\r
+       cp r_temp,r_rwbyte\r
+       brne h_accesswrite_error2\r
+       sts  pin_set2,r_rwbyte\r
+       ldi r_mode,OW_ACCESSWRITE_READ2\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_sendflag,1\r
+       rjmp handle_end_inc\r
+h_accesswrite_error2:\r
+       rjmp handle_end_sleep\r
+/*\r
+;---------------------------------------------------\r
+;   WRITE SCRATCHPAD\r
+;---------------------------------------------------\r
+h_writescratchpad_adr2:\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+#if  defined(__AVR_ATtiny25__)\r
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen\r
+#endif\r
+       sts block,r_rwbyte\r
+       ldi r_mode,OW_WRITE_SCRATCHPAD2\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end \r
+h_writescratchpad2:\r
+       cpi  r_bytep,8\r
+       breq h_writescratchpad_all2\r
+       lds  r_temp,block\r
+       add  r_temp,r_bytep\r
+       configZ pack2,r_temp\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_writescratchpad_all2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+       */\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end\r
index 2d2c891..78b51c1 100644 (file)
 // (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
 // (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
+#ifndef _NOCHANGEABLE_ID_\r
 #define _CHANGEABLE_ID_\r
 #define _CHANGEABLE_ID_\r
+#endif\r
 #define _ZERO_POLLING_\r
 #define _HANDLE_CC_COMMAND_\r
 #define _ZERO_POLLING_\r
 #define _HANDLE_CC_COMMAND_\r
+#define _NO_BOOTLOADER_PIN_    \r
+//#define __4MHZ__\r
+\r
 //#define _DB_\r
 \r
 #include "../common/OWConfig.s"\r
 //#define _DB_\r
 \r
 #include "../common/OWConfig.s"\r
@@ -139,9 +144,9 @@ chrc_set_convertV1:
        lds r_temp,pack1\r
        sbrs r_temp,3\r
        rjmp hrc_set_convertVV1\r
        lds r_temp,pack1\r
        sbrs r_temp,3\r
        rjmp hrc_set_convertVV1\r
-       ldi r_temp,0xF4  //5V\r
+       lds r_temp,DS2438_1_VDD  \r
        sts pack1+3,r_temp\r
        sts pack1+3,r_temp\r
-       ldi r_temp,0x01\r
+       lds r_temp,DS2438_1_VDD+1\r
        sts pack1+4,r_temp\r
        rjmp hrc_set_convertend1\r
 hrc_set_convertVV1:\r
        sts pack1+4,r_temp\r
        rjmp hrc_set_convertend1\r
 hrc_set_convertVV1:\r
@@ -284,9 +289,9 @@ chrc_set_convertV2:
        lds r_temp,pack2\r
        sbrs r_temp,3\r
        rjmp hrc_set_convertVV2\r
        lds r_temp,pack2\r
        sbrs r_temp,3\r
        rjmp hrc_set_convertVV2\r
-       ldi r_temp,0xF4\r
+       lds r_temp,DS2438_2_VDD  \r
        sts pack2+3,r_temp\r
        sts pack2+3,r_temp\r
-       ldi r_temp,0x01\r
+       lds r_temp,DS2438_2_VDD+1\r
        sts pack2+4,r_temp\r
        rjmp hrc_set_convertend2\r
 hrc_set_convertVV2:\r
        sts pack2+4,r_temp\r
        rjmp hrc_set_convertend2\r
 hrc_set_convertVV2:\r
diff --git a/common/OWDS2450_DS2423.S b/common/OWDS2450_DS2423.S
new file mode 100644 (file)
index 0000000..f4ca4f5
--- /dev/null
@@ -0,0 +1,548 @@
+\r
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack1,20\r
+.extern pack2,45\r
+.extern counters2,16\r
+//Bleiben gleich denn es werden nicht beide gleichzeitig abgefragt\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+.comm gcontrol1,1\r
+.comm gcontrol2,1\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr1\r
+               rjmp h_readmemory1\r
+               rjmp h_readmemorycrc11\r
+               rjmp h_readmemorycrc21\r
+               rjmp h_writememoryaddr1\r
+               rjmp h_writememory1\r
+               rjmp h_writememorycrc11\r
+               rjmp h_writememorycrc21\r
+               rjmp h_writememoryreadback1\r
+               rjmp h_convert1\r
+               rjmp h_convertcrc11\r
+               rjmp h_convertcrc21\r
+               rjmp h_convert_conv1\r
+\r
+               rjmp h_writescratchpad2\r
+               rjmp h_writescratchpad_crc2\r
+               rjmp h_readscratchpad2\r
+               rjmp h_copyscratchpad2\r
+               rjmp h_readmemory_addr2\r
+               rjmp h_readmemory2\r
+               rjmp h_readmemorycounter_addr2\r
+               rjmp h_readmemorycounter2\r
+               rjmp h_readmemorycounter_ex2\r
+.endm\r
+\r
+#include "../common/OWRomFunctionsDual.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR1 OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY1 OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC11 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC21 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR1 OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY1 OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC11 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC21 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK1 OW_FIRST_COMMAND+8\r
+#define OW_CONVERT1 OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC11 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC21 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV1 OW_FIRST_COMMAND+12\r
+\r
+#define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+13\r
+#define OW_WRITE_SCRATCHPAD_CRC2 OW_FIRST_COMMAND+14\r
+#define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+15\r
+#define OW_COPY_SCRATCHPAD2 OW_FIRST_COMMAND+16\r
+#define OW_READ_MEMORY_ADDR2 OW_FIRST_COMMAND+17\r
+#define OW_READ_MEMORY2 OW_FIRST_COMMAND+18\r
+#define OW_READ_MEMORYCOUNTER_ADDR2 OW_FIRST_COMMAND+19\r
+#define OW_READ_MEMORYCOUNTER2 OW_FIRST_COMMAND+20\r
+#define OW_READ_MEMORYCOUNTER_EX2 OW_FIRST_COMMAND+21\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand1:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR1\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR1\r
+       cset 0x3C,OW_CONVERT1\r
+       FW_CONFIG_INFO1\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr1:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte11 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte11:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY1 ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory21\r
+h_readmemory1:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc1\r
+h_readmemory21:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack1,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc1:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC11\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end1:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc11:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC21\r
+       rjmp handle_end\r
+h_readmemorycrc21:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end1; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY1\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory21\r
+\r
+h_writememoryaddr1:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte11 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte11:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY1 ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory1:\r
+       lds r_bytep,addr\r
+       configZ pack1,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC11\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc11:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC21\r
+       rjmp handle_end\r
+h_writememorycrc21:\r
+       lds r_temp,addr\r
+       configZ pack1,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK1\r
+       rjmp handle_end\r
+h_writememoryreadback1:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY1\r
+       rjmp handle_end\r
+\r
+h_convert1:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte11 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack1+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte11: ;zweies byte glesen go crc#\r
+       sts pack1+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC11\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc11:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC21\r
+       rjmp handle_end\r
+h_convertcrc21:\r
+       ldi r_temp,1\r
+       sts gcontrol1,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV1\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv1:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount\r
+\r
+/////////////////////////////////////////////////////////////////////\r
+\r
+\r
+\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+\r
+\r
+\r
+\r
+h_readcommand2:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0x0F,OW_WRITE_SCRATCHPAD2\r
+       cjmp 0xAA,hrc_set_readscratchpad2\r
+       cset 0x5A,OW_COPY_SCRATCHPAD2\r
+       cset 0xF0,OW_READ_MEMORY_ADDR2\r
+       cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR2\r
+       FW_CONFIG_INFO2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+hrc_set_readscratchpad2:\r
+       ldi r_mode,OW_READ_SCRATCHPAD2\r
+       ldi r_sendflag,1\r
+       rjmp h_readscratchpad2\r
+\r
+h_writescratchpad2:\r
+       configZ pack2,r_bytep\r
+       inc  r_bytep\r
+       st   Z,r_rwbyte\r
+       cpi  r_bytep,2\r
+       breq h_writescratchpad_block2\r
+       brsh h_writescratchpad_set_eoffset2 ;;33\r
+       rjmp handle_end  ;handle_end zu weit entfernt fuer br...\r
+h_writescratchpad_set_eoffset2:\r
+       cpi  r_bytep,35\r
+       breq h_writescratchpad_setcrc2\r
+       mov r_temp,r_bytep\r
+       subi r_temp,4\r
+       sts pack2+2,r_temp ;AA und PF cleared\r
+       rjmp handle_end\r
+;Start writeing to 32 Byte Block ; skip status byte    \r
+h_writescratchpad_block2:\r
+       lds r_temp,pack2 ; Adresse low byte\r
+       andi r_temp,0x1F ;32 byte\r
+       add r_bytep,r_temp ;Zur angegebenen Startadresse springen\r
+       ;ori r_temp,0x20 ; Set PF flag\r
+       sts pack2+2,r_temp  ;E4:E0 vorher setzen\r
+       ; Byte 3 ueberspringen\r
+       rjmp handle_end_inc\r
+\r
+h_writescratchpad_setcrc2:\r
+       ;copy crc to pack2\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack2+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp ; invertieren , komischer name.....\r
+       sts pack2+44,r_temp\r
+       ldi  r_mode,OW_WRITE_SCRATCHPAD_CRC2\r
+       ldi r_sendflag,1\r
+       ldi r_bytep,43\r
+h_writescratchpad_crc2:\r
+       cpi r_bytep,45\r
+       breq h_writescratchpad_crc_end2\r
+       configZ pack2,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_writescratchpad_crc_end2:\r
+       rjmp handle_end_sleep\r
+       \r
+       \r
+h_readscratchpad2:\r
+       cpi r_bytep,35\r
+       breq h_readscratchpad_end2\r
+       cpi r_bytep,3\r
+       brne h_readscratchpad_read_byte2\r
+h_readscratchpad_set_offset2:\r
+       lds r_temp,pack2\r
+       andi r_temp,0x1F\r
+       ldi r_temp2,3\r
+       add r_temp,r_temp2\r
+       mov r_bytep,r_temp\r
+h_readscratchpad_read_byte2:\r
+       configZ pack2,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_readscratchpad_end2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+h_copyscratchpad2:\r
+       cpi  r_bytep,3\r
+       brsh h_copyscratchpad_ok2\r
+       configZ pack2,r_bytep\r
+       inc  r_bytep\r
+       ld   r_temp,Z\r
+       cp r_temp,r_rwbyte\r
+       brne h_copyscratchpad_nok2\r
+       cpi  r_bytep,3\r
+       breq h_copyscratchpad_ok2\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end\r
+h_copyscratchpad_ok2:\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_sendflag,1\r
+       ldi r_temp,1\r
+       sts gcontrol2,r_temp\r
+       rjmp handle_end\r
+h_copyscratchpad_nok2:\r
+       lds r_temp,pack2+3\r
+       andi r_temp,~0x80\r
+       sts pack2+3,r_temp\r
+       rjmp handle_end_sleep\r
+\r
+\r
+h_readmemory_addr2:\r
+       cpi r_bytep,0\r
+       brne h_readmrmory_addr_byte12\r
+       sts pack2,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_readmrmory_addr_byte12:\r
+       sts pack2+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORY2\r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemory22\r
+h_readmemory2:\r
+       lds r_bytep,pack2\r
+       lds r_temp2,pack2+1\r
+       inc r_bytep\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1\r
+       rjmp h_readmemory_end2\r
+       sts pack2+1,r_temp2\r
+       sts pack2,r_bytep\r
+h_readmemory22:\r
+       ldi  zl,lo8(pack2+45)       \r
+    ldi  zh,hi8(pack2+45)\r
+       lds r_bytep,pack2\r
+       add  zl,r_bytep\r
+       lds r_bytep,pack2+1\r
+       adc zh,r_bytep\r
+       //configZ pack2+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemory_end2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+h_readmemorycounter_addr2:\r
+       cpi r_bytep,0\r
+       brne h_readmrmorycounter_addr_byte12\r
+       sts pack2,r_rwbyte\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmrmorycounter_addr_byte12:\r
+       sts pack2+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORYCOUNTER2\r
+       ;ldi r_bcount,1 \r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemorycounter22\r
+h_readmemorycounter2:\r
+       lds r_bytep,pack2\r
+       lds r_temp2,pack2+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       mov r_temp,r_bytep\r
+       andi r_temp,0x1F\r
+       breq h_readmemorycounter_next2\r
+       sts pack2+1,r_temp2\r
+       sts pack2,r_bytep\r
+h_readmemorycounter22:  ;Lesen von dem worauf die erstenzwei bytes zeigen\r
+       lds r_bytep,pack2\r
+       andi r_bytep,0x1F\r
+       configZ pack2+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+//h_readmemorycounter_end:\r
+//     ldi  r_mode,OW_SLEEP\r
+//     clr r_sendflag\r
+//     rjmp handle_end\r
+h_readmemorycounter_next2:  ; rest lesen\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER_EX2\r
+       ldi r_bytep,34\r
+       lds r_temp2,pack2\r
+       lds r_temp,pack2+1\r
+       //lsr r_temp\r
+       //ror r_temp2\r
+\r
+       lsl r_temp2\r
+       rol r_temp\r
+       cpi r_temp,3\r
+       brne h_readmemorycounter_cFF2\r
+       andi r_temp2,0xC0\r
+       swap r_temp2\r
+\r
+       ;cpi r_temp,0xE0\r
+\r
+       configZ counters2,r_temp2\r
+       ld r_temp,Z+\r
+       sts pack2+35,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack2+36,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack2+37,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack2+38,r_temp     \r
+       rjmp h_readmemorycounter_ex2\r
+h_readmemorycounter_cFF2:\r
+       ldi r_temp,0xFF\r
+       sts pack2+35,r_temp     \r
+       sts pack2+36,r_temp     \r
+       sts pack2+37,r_temp     \r
+       sts pack2+38,r_temp     \r
+\r
+h_readmemorycounter_ex2:\r
+       inc r_bytep\r
+       cpi r_bytep,45\r
+       breq h_readmemorycounter_ex_end2\r
+       cpi r_bytep,43\r
+       brne h_readmemorycounter_ex22\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack2+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts pack2+44,r_temp\r
+h_readmemorycounter_ex22:\r
+       ;ldi r_bcount,1\r
+       configZ pack2,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemorycounter_ex_end2:\r
+       lds r_bytep,pack2\r
+       lds r_temp2,pack2+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1 ;am ene von allem \r
+       rjmp h_readmemorycounter_ex_sleep2\r
+       CRCInit1\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER2\r
+       sts pack2+1,r_temp2\r
+       sts pack2,r_bytep\r
+       rjmp h_readmemorycounter22\r
+h_readmemorycounter_ex_sleep2:\r
+       ldi r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+\r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
diff --git a/common/OWDS2450_DS2450.S b/common/OWDS2450_DS2450.S
new file mode 100644 (file)
index 0000000..bdf354f
--- /dev/null
@@ -0,0 +1,440 @@
+\r
+// Copyright (c) 2018, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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 _ZERO_POLLING_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack1,20\r
+.extern pack2,20\r
+\r
+//Bleiben gleich denn es werden nicht beide gleichzeitig abgefragt\r
+.comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)\r
+.comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....\r
+//.extern  am2302_temp,2\r
+\r
+.comm gcontrol1,1\r
+.comm gcontrol2,1\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readmemoryaddr1\r
+               rjmp h_readmemory1\r
+               rjmp h_readmemorycrc11\r
+               rjmp h_readmemorycrc21\r
+               rjmp h_writememoryaddr1\r
+               rjmp h_writememory1\r
+               rjmp h_writememorycrc11\r
+               rjmp h_writememorycrc21\r
+               rjmp h_writememoryreadback1\r
+               rjmp h_convert1\r
+               rjmp h_convertcrc11\r
+               rjmp h_convertcrc21\r
+               rjmp h_convert_conv1\r
+\r
+               rjmp h_readmemoryaddr2\r
+               rjmp h_readmemory2\r
+               rjmp h_readmemorycrc12\r
+               rjmp h_readmemorycrc22\r
+               rjmp h_writememoryaddr2\r
+               rjmp h_writememory2\r
+               rjmp h_writememorycrc12\r
+               rjmp h_writememorycrc22\r
+               rjmp h_writememoryreadback2\r
+               rjmp h_convert2\r
+               rjmp h_convertcrc12\r
+               rjmp h_convertcrc22\r
+               rjmp h_convert_conv2\r
+.endm\r
+\r
+#include "../common/OWRomFunctionsDual.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_MEMORY_ADDR1 OW_FIRST_COMMAND+0\r
+#define OW_READ_MEMORY1 OW_FIRST_COMMAND+1\r
+#define OW_READ_MEMORY_CRC11 OW_FIRST_COMMAND+2\r
+#define OW_READ_MEMORY_CRC21 OW_FIRST_COMMAND+3\r
+#define OW_WRITE_MEMORY_ADDR1 OW_FIRST_COMMAND+4\r
+#define OW_WRITE_MEMORY1 OW_FIRST_COMMAND+5\r
+#define OW_WRITE_MEMORY_CRC11 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_MEMORY_CRC21 OW_FIRST_COMMAND+7\r
+#define OW_WRITE_MEMORY_READBACK1 OW_FIRST_COMMAND+8\r
+#define OW_CONVERT1 OW_FIRST_COMMAND+9\r
+#define OW_CONVERT_CRC11 OW_FIRST_COMMAND+10\r
+#define OW_CONVERT_CRC21 OW_FIRST_COMMAND+11\r
+#define OW_CONVERT_CONV1 OW_FIRST_COMMAND+12\r
+\r
+#define OW_READ_MEMORY_ADDR2 OW_FIRST_COMMAND+13\r
+#define OW_READ_MEMORY2 OW_FIRST_COMMAND+14\r
+#define OW_READ_MEMORY_CRC12 OW_FIRST_COMMAND+15\r
+#define OW_READ_MEMORY_CRC22 OW_FIRST_COMMAND+16\r
+#define OW_WRITE_MEMORY_ADDR2 OW_FIRST_COMMAND+17\r
+#define OW_WRITE_MEMORY2 OW_FIRST_COMMAND+18\r
+#define OW_WRITE_MEMORY_CRC12 OW_FIRST_COMMAND+19\r
+#define OW_WRITE_MEMORY_CRC22 OW_FIRST_COMMAND+20\r
+#define OW_WRITE_MEMORY_READBACK2 OW_FIRST_COMMAND+21\r
+#define OW_CONVERT2 OW_FIRST_COMMAND+22\r
+#define OW_CONVERT_CRC12 OW_FIRST_COMMAND+23\r
+#define OW_CONVERT_CRC22 OW_FIRST_COMMAND+24\r
+#define OW_CONVERT_CONV2 OW_FIRST_COMMAND+25\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand1:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR1\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR1\r
+       cset 0x3C,OW_CONVERT1\r
+       FW_CONFIG_INFO1\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr1:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte11 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte11:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY1 ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory21\r
+h_readmemory1:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc1\r
+h_readmemory21:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack1,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc1:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC11\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end1:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc11:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC21\r
+       rjmp handle_end\r
+h_readmemorycrc21:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end1; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY1\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory21\r
+\r
+h_writememoryaddr1:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte11 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte11:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY1 ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory1:\r
+       lds r_bytep,addr\r
+       configZ pack1,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC11\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc11:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC21\r
+       rjmp handle_end\r
+h_writememorycrc21:\r
+       lds r_temp,addr\r
+       configZ pack1,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK1\r
+       rjmp handle_end\r
+h_writememoryreadback1:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY1\r
+       rjmp handle_end\r
+\r
+h_convert1:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte11 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack1+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte11: ;zweies byte glesen go crc#\r
+       sts pack1+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC11\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc11:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC21\r
+       rjmp handle_end\r
+h_convertcrc21:\r
+       ldi r_temp,1\r
+       sts gcontrol1,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV1\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv1:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount\r
+\r
+/////////////////////////////////////////////////////////////////////\r
+\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand2:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xAA,OW_READ_MEMORY_ADDR2\r
+       cset 0x55,OW_WRITE_MEMORY_ADDR2\r
+       cset 0x3C,OW_CONVERT2\r
+       FW_CONFIG_INFO2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+\r
+h_readmemoryaddr2:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_readmemory_addr_byte12 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       rjmp handle_end_inc\r
+h_readmemory_addr_byte12:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_READ_MEMORY2 ;weiter zu read Memory\r
+       ;;ldi r_bcount,1 ;ist unten\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       clr r_bytep\r
+       rjmp h_readmemory22\r
+h_readmemory2:\r
+       lds r_bytep,addr\r
+       inc r_bytep\r
+       sts addr,r_bytep\r
+       andi r_bytep,0x07\r
+       breq h_readmemory_init_crc2\r
+h_readmemory22:\r
+       lds r_bytep,addr\r
+       ;andi r_bytep,0x1F ist oben\r
+       configZ pack2,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end ;sendet das Byte und geht zu h_readmemory\r
+h_readmemory_init_crc2:; init erstes CRC byte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_READ_MEMORY_CRC12\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmemory_end2:\r
+       ldi  r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+h_readmemorycrc12:;init zweites CRC Byte\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_READ_MEMORY_CRC22\r
+       rjmp handle_end\r
+h_readmemorycrc22:;weiteres senden..... nach zweitem Byte\r
+       lds r_temp,addr\r
+       andi r_temp,0xE0\r
+       brne h_readmemory_end2; ende des speichers\r
+       ldi r_mode,OW_READ_MEMORY2\r
+       CRCInit1 ;Start with new CRC\r
+       rjmp h_readmemory22\r
+\r
+h_writememoryaddr2:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_writememory_addr_byte12 ;nein dann weiter\r
+       andi r_rwbyte,0x1F  ; nur Adressen zwischen 0 und 0x1F zulassen\r
+       sts addr,r_rwbyte  ;speichern des ersten bytes\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_writememory_addr_byte12:  ;zweiters Addressbyte wird nicht gespeichert!\r
+       ldi r_mode,OW_WRITE_MEMORY2 ;weiter zu read Memory\r
+       ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....\r
+       lds r_bytep,addr\r
+       rjmp handle_end ;read Memory Byte\r
+h_writememory2:\r
+       lds r_bytep,addr\r
+       configZ pack2,r_bytep\r
+       st Z,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC12\r
+       ldi r_sendflag,1 ;jetzt sendet der Slave zum Master\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       rjmp handle_end\r
+h_writememorycrc12:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_CRC22\r
+       rjmp handle_end\r
+h_writememorycrc22:\r
+       lds r_temp,addr\r
+       configZ pack2,r_temp\r
+       ld r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY_READBACK2\r
+       rjmp handle_end\r
+h_writememoryreadback2:\r
+       ldi r_temp,0x00\r
+       sts crc+1,r_temp\r
+       lds r_temp,addr\r
+       inc r_temp\r
+       sts addr,r_temp\r
+       sts crc,r_temp\r
+       ldi r_sendflag,0\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_WRITE_MEMORY2\r
+       rjmp handle_end\r
+\r
+h_convert2:\r
+       cpi r_bytep,0  ;erstes Adressbyte ?\r
+       brne h_convert_byte12 ;nein dann weiter\r
+       inc r_bytep\r
+       sts pack2+0x20,r_rwbyte\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_convert_byte12: ;zweies byte glesen go crc#\r
+       sts pack2+0x21,r_rwbyte\r
+       lds r_rwbyte,crc\r
+       com r_rwbyte\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts crcsave,r_temp\r
+       ldi r_mode,OW_CONVERT_CRC12\r
+       ;ldi r_bcount,1\r
+       ldi r_sendflag,1\r
+       rjmp handle_end \r
+h_convertcrc12:\r
+       lds r_rwbyte,crcsave\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CRC22\r
+       rjmp handle_end\r
+h_convertcrc22:\r
+       ldi r_temp,1\r
+       sts gcontrol2,r_temp\r
+       ;ldi r_bcount,1\r
+       ldi r_mode,OW_CONVERT_CONV2\r
+       ;clr r_sendflag\r
+       ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling\r
+h_convert_conv2:\r
+       ldi r_bcount,0\r
+       ldi r_rwbyte,0\r
+       rjmp handle_end_no_bcount\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end
\ No newline at end of file
index 69f84f3..7d8a711 100644 (file)
@@ -31,8 +31,8 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
 \r
        \r
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
 \r
        \r
-.global PIN_INTERRIPT  \r
-PIN_INTERRIPT:\r
+.global PIN_INTERRUPT  \r
+PIN_INTERRUPT:\r
        ;leitung auf Low ziehen\r
        TESTZEROMARKER ; ueberspringe wenn zeromarker=0   ;sbic und cbi/sbi andern SREG nicht\r
        sbi OW_DDR,OW_PINN  \r
        ;leitung auf Low ziehen\r
        TESTZEROMARKER ; ueberspringe wenn zeromarker=0   ;sbic und cbi/sbi andern SREG nicht\r
        sbi OW_DDR,OW_PINN  \r
index fb1d85b..6abeffc 100644 (file)
@@ -169,11 +169,7 @@ hrc_jmp_flasher:
        lds r_temp,flashmarker\r
        cpi r_temp,2\r
        brne hrc_jmp_flasher_inc\r
        lds r_temp,flashmarker\r
        cpi r_temp,2\r
        brne hrc_jmp_flasher_inc\r
-       ldi r_temp,0xC0\r
-       push r_temp\r
-       ldi r_temp,0x0E\r
-       push r_temp\r
-       ret ; Direkter Sprung zum Bootloader\r
+       JMP_FLASHER\r
 hrc_jmp_flasher_inc:\r
        inc r_temp\r
        sts flashmarker,r_temp\r
 hrc_jmp_flasher_inc:\r
        inc r_temp\r
        sts flashmarker,r_temp\r
@@ -276,7 +272,7 @@ h_searchroms_next: ; Setup next bit
 \r
        configZ owid,r_bcount\r
        ld r_rwbyte,Z\r
 \r
        configZ owid,r_bcount\r
        ld r_rwbyte,Z\r
-       sts srbyte,r_rwbyte\r
+       sts srbyte,r_rwbyte ;#################### Doppelung ist schon in h_searchrom_next_bit\r
        rjmp h_searchrom_next_bit\r
                \r
 h_searchroms_next_bit: ;next Bit lesen\r
        rjmp h_searchrom_next_bit\r
                \r
 h_searchroms_next_bit: ;next Bit lesen\r
@@ -316,7 +312,7 @@ h_readrom_all:
 h_fwconfiginfo:\r
        cpi  r_bytep,24\r
        breq h_fwconfiginfo_crc\r
 h_fwconfiginfo:\r
        cpi  r_bytep,24\r
        breq h_fwconfiginfo_crc\r
-#ifdef _CRC8_\r
+#if defined(_CRC8_)  || defined( _CRC8_16_) \r
        cpi  r_bytep,25\r
        breq h_fwconfiginfo_all\r
 #elif defined _CRC16_\r
        cpi  r_bytep,25\r
        breq h_fwconfiginfo_all\r
 #elif defined _CRC16_\r
@@ -446,31 +442,9 @@ spause:
 \r
 .global OWINIT\r
 OWINIT:\r
 \r
 .global OWINIT\r
 OWINIT:\r
-#ifndef _DIS_FLASH_\r
-; check for bootloader jumper\r
-       ;vor allen anderen Registerconfigs\r
        push r_temp\r
        push r_temp\r
-       ldi r_temp,(1<<PUD) ;enable pullup \r
-       out _SFR_IO_ADDR(MCUCR) ,r_temp\r
-       sbi _SFR_IO_ADDR(PORTA),PINA5 ;internal pullup on PINA5\r
-       sbi _SFR_IO_ADDR(PORTA),PINA4 ;internal pullup on PINA4\r
-       rcall spause\r
-       sbis _SFR_IO_ADDR(PINA),PINA5\r
-       rjmp owinit_botest_end  ;PinA5 nicht auf 1\r
-       sbis _SFR_IO_ADDR(PINA),PINA4\r
-       rjmp owinit_botest_end ;PinA4 nicht auf 1\r
-       cbi _SFR_IO_ADDR(PORTA),PINA4 \r
-       sbi _SFR_IO_ADDR(DDRA),PINA4  ;PINA4 AUSGANG und 0\r
-       rcall spause\r
-       sbic _SFR_IO_ADDR(PINA),PINA5 \r
-       rjmp owinit_botest_end ;PINA5 nicht 0.... nicht verbunden\r
-       cbi _SFR_IO_ADDR(DDRA),PINA4\r
-       ldi r_temp,0xC0\r
-       push r_temp\r
-       ldi r_temp,0x0E\r
-       push r_temp\r
-       ret ; Direkter Sprung zum Bootloader*/\r
-owinit_botest_end:\r
+#ifndef _DIS_FLASH_\r
+       CHECK_BOOTLOADER_PIN \r
 #endif\r
        HW_INIT  //Microcontroller specific\r
        CHIP_INIT //1-Wire device specific\r
 #endif\r
        HW_INIT  //Microcontroller specific\r
        CHIP_INIT //1-Wire device specific\r
index 6f1e709..d4d13d5 100644 (file)
        cljmp 0x85,hrc_fw_configinfo2\r
 .endm\r
 \r
        cljmp 0x85,hrc_fw_configinfo2\r
 .endm\r
 \r
-#ifdef _CHANGEABLE_ID_\r
+//#ifdef _CHANGEABLE_ID_ //--> ID vom EEPROM lesen auch wenn sie sich nicht ändern laesst\r
 ; lesen der ID aus dem EEPROM beim Start\r
 read_EEPROM_ID1:  \r
        ldi r_temp2,lo8(E2END)\r
 ; lesen der ID aus dem EEPROM beim Start\r
 read_EEPROM_ID1:  \r
        ldi r_temp2,lo8(E2END)\r
@@ -139,7 +139,7 @@ read_EEPROM_ID_loop:
        brne read_EEPROM_ID_loop\r
 read_EEPROM_ID_end:\r
        ret\r
        brne read_EEPROM_ID_loop\r
 read_EEPROM_ID_end:\r
        ret\r
-#endif\r
+//#endif\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -187,11 +187,7 @@ hrc_jmp_flasher:
        lds r_temp,flashmarker\r
        cpi r_temp,2\r
        brne hrc_jmp_flasher_inc\r
        lds r_temp,flashmarker\r
        cpi r_temp,2\r
        brne hrc_jmp_flasher_inc\r
-       ldi r_temp,0xC0\r
-       push r_temp\r
-       ldi r_temp,0x0E\r
-       push r_temp\r
-       ret ; Direkter Sprung zum Bootloader\r
+       JMP_FLASHER\r
 hrc_jmp_flasher_inc:\r
        inc r_temp\r
        sts flashmarker,r_temp\r
 hrc_jmp_flasher_inc:\r
        inc r_temp\r
        sts flashmarker,r_temp\r
@@ -426,7 +422,7 @@ h_fwconfiginfo2:
 h_fwconfiginfo_go:\r
        cpi  r_bytep,24\r
        breq h_fwconfiginfo_crc\r
 h_fwconfiginfo_go:\r
        cpi  r_bytep,24\r
        breq h_fwconfiginfo_crc\r
-#ifdef _CRC8_\r
+#if defined(_CRC8_)  || defined( _CRC8_16_) \r
        cpi  r_bytep,25\r
        breq h_fwconfiginfo_all\r
 #elif defined _CRC16_\r
        cpi  r_bytep,25\r
        breq h_fwconfiginfo_all\r
 #elif defined _CRC16_\r
@@ -587,27 +583,7 @@ OWINIT:
        ;vor allen anderen Registerconfigs\r
        push r_temp\r
 #ifndef _DIS_FLASH_\r
        ;vor allen anderen Registerconfigs\r
        push r_temp\r
 #ifndef _DIS_FLASH_\r
-       ldi r_temp,(1<<PUD) ;enable pullup \r
-       out _SFR_IO_ADDR(MCUCR) ,r_temp\r
-       sbi _SFR_IO_ADDR(PORTA),PINA5 ;internal pullup on PINA5\r
-       sbi _SFR_IO_ADDR(PORTA),PINA4 ;internal pullup on PINA4\r
-       rcall spause\r
-       sbis _SFR_IO_ADDR(PINA),PINA5\r
-       rjmp owinit_botest_end  ;PinA5 nicht auf 1\r
-       sbis _SFR_IO_ADDR(PINA),PINA4\r
-       rjmp owinit_botest_end ;PinA4 nicht auf 1\r
-       cbi _SFR_IO_ADDR(PORTA),PINA4 \r
-       sbi _SFR_IO_ADDR(DDRA),PINA4  ;PINA4 AUSGANG und 0\r
-       rcall spause\r
-       sbic _SFR_IO_ADDR(PINA),PINA5 \r
-       rjmp owinit_botest_end ;PINA5 nicht 0.... nicht verbunden\r
-       cbi _SFR_IO_ADDR(DDRA),PINA4\r
-       ldi r_temp,0xC0\r
-       push r_temp\r
-       ldi r_temp,0x0E\r
-       push r_temp\r
-       ret ; Direkter Sprung zum Bootloader*/\r
-owinit_botest_end:\r
+       CHECK_BOOTLOADER_PIN \r
 #endif\r
        HW_INIT  //Microcontroller specific\r
        CHIP_INIT //1-Wire device specific\r
 #endif\r
        HW_INIT  //Microcontroller specific\r
        CHIP_INIT //1-Wire device specific\r
@@ -619,10 +595,10 @@ init_idtable:
        push r_rwbyte\r
        push r_idn1\r
        push r_idn2\r
        push r_rwbyte\r
        push r_idn1\r
        push r_idn2\r
-#ifdef _CHANGEABLE_ID_\r
+//#ifdef _CHANGEABLE_ID_\r
        rcall read_EEPROM_ID1\r
        rcall read_EEPROM_ID2\r
        rcall read_EEPROM_ID1\r
        rcall read_EEPROM_ID2\r
-#endif\r
+//#endif\r
        ldi r_bytep,8\r
        ldi r_temp,0\r
        ldi  zl,lo8(idtable)\r
        ldi r_bytep,8\r
        ldi r_temp,0\r
        ldi  zl,lo8(idtable)\r
diff --git a/common/OWSet_ATMEGA168.s b/common/OWSet_ATMEGA168.s
new file mode 100644 (file)
index 0000000..cae70b5
--- /dev/null
@@ -0,0 +1,167 @@
+// 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
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (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
+\r
+#define OW_PORT _SFR_IO_ADDR(PORTD) //1 Wire Port\r
+#define OW_PIN _SFR_IO_ADDR(PIND) //1 Wire Pin as number\r
+#define OW_PINN PORTD2\r
+#define OW_DDR _SFR_IO_ADDR(DDRD)  //pin direction register\r
+\r
+#define TCNT_REG _SFR_IO_ADDR(TCNT0)\r
+\r
+\r
+#define DB_PORT _SFR_IO_ADDR(PORTB) //DEBUG\r
+#define DB_PIN _SFR_IO_ADDR(PINB) //DEBUG\r
+#define DB_DDR _SFR_IO_ADDR(DDRB) //DEBUG\r
+#define DB_PINN PORTB1\r
+\r
+#define SETZEROMARKER sbi _SFR_IO_ADDR(DDRC),6\r
+#define RESETZEROMARKER cbi _SFR_IO_ADDR(DDRC),6\r
+#define TESTZEROMARKER sbic _SFR_IO_ADDR(DDRC),6\r
+\r
+#ifdef _DB_\r
+#define sdb sbi _SFR_IO_ADDR(PORTB),DB_PINN\r
+#define cdb cbi _SFR_IO_ADDR(PORTB),DB_PINN\r
+#else\r
+#define sdb\r
+#define cdb\r
+#endif\r
+\r
+#define TIMER_INTERRUPT TIMER0_OVF_vect\r
+#define PIN_INTERRUPT INT0_vect\r
+\r
+\r
+//#define OWT_MIN_RESET 160 \r
+//#define OWT_RESET2 40\r
+//#define OWT_RESET_PRESENT 15\r
+//#define OWT_PRESENT 50\r
+//#define OWT_WRITE 18\r
+//#define OWT_READ 4\r
+#ifdef __4MHZ__\r
+#define OWT_MIN_RESET 80\r
+#define OWT_RESET2 30\r
+#define OWT_RESET_PRESENT 15\r
+#define OWT_PRESENT 60\r
+#define OWT_WRITE 16\r
+#define OWT_READ 5\r
+#define OWT_ZP_WAIT_LOW_TO 36  ; Zeit fuer die Maximale Lowzeit bei der Zerro Polling pruefung. Ist die Leitung laenger low, ist es vieleicht ein Reset \r
+#define OWT_ZP_WAIT_HIGH_TO 54 ; Zeit fuer die Maximale Hight zeit bis zu einem Low Impuls vom Master. Nach laengeren Pausen wird nicht mehr gepollt sondern der Interrup vererndet.\r
+#else\r
+#define OWT_MIN_RESET 180\r
+#define OWT_RESET2 80\r
+#define OWT_RESET_PRESENT 30\r
+#define OWT_PRESENT 130\r
+#define OWT_WRITE 35\r
+#define OWT_READ 12\r
+#define OWT_ZP_WAIT_LOW_TO 60  ; Zeit fuer die Maximale Lowzeit bei der Zerro Polling pruefung. Ist die Leitung laenger low, ist es vieleicht ein Reset \r
+#define OWT_ZP_WAIT_HIGH_TO 90 ; Zeit fuer die Maximale Hight zeit bis zu einem Low Impuls vom Master. Nach laengeren Pausen wird nicht mehr gepollt sondern der Interrup vererndet.\r
+#endif\r
+\r
+.macro CLEAR_TOV_FLAG\r
+       ldi r_temp,1\r
+       out _SFR_IO_ADDR(TIFR0),r_temp\r
+.endm\r
+\r
+.macro JMP_NO_TOV\r
+       in r_temp, _SFR_IO_ADDR(TIFR0)\r
+       sbrc r_temp,TOV0 ; wenn ueberlauf gleich weiter\r
+.endm\r
+\r
+.macro CLEAR_INTERRUPT_FLAG \r
+       ldi r_temp,(1<<INTF0);inerrupt flags durch 1 loeschen..... 0 macht nix\r
+       out _SFR_IO_ADDR(EIFR),r_temp\r
+.endm\r
+\r
+.macro EN_TIM_INT\r
+       ldi r_temp,(1<<TOIE0)\r
+       sts TIMSK0,r_temp\r
+       ldi r_temp,(1<<TOV0) ;inerrupt flags durch 1 loeschen..... 0 macht nix\r
+       out _SFR_IO_ADDR(TIFR0),r_temp\r
+.endm\r
+\r
+.macro DIS_TIM_INT\r
+       ldi r_temp,0\r
+       sts TIMSK0,r_temp\r
+.endm\r
+\r
+//Wiederherstellen von Idle mode und umschalten von Low-Level interrupt zu Falling edge\r
+.macro SET_FALLING_RESET_SLEEP\r
+       lds r_temp,EICRA\r
+       ori r_temp,(1<<ISC01)\r
+       sts     EICRA,r_temp\r
+       lds r_temp,SMCR\r
+       andi r_temp,~(1<<SM1)\r
+       sts     SMCR,r_temp\r
+.endm\r
+\r
+.macro HW_INIT  ;r_temp is pushed other Registers should be saved\r
+       ;set clock to 8 MHz\r
+       ldi r_temp,0x80;\r
+       sts CLKPR,r_temp\r
+       //ldi r_temp,(1<<CLKPS0)\r
+#ifdef __4MHZ__\r
+       ldi r_temp,0x01;\r
+#else\r
+       ldi r_temp,0\r
+#endif\r
+       sts CLKPR,r_temp\r
+       ;Disable Timer int\r
+       ldi r_temp,0\r
+       sts TIMSK0,r_temp ;; is default\r
+       ;Enable Pin int\r
+       ldi r_temp,(1<<INT0)\r
+       out _SFR_IO_ADDR(EIMSK),r_temp\r
+       ;Set Timerclock to Clock / 8 (2us bei 4MHz) bzw 1us bei 8 MHz\r
+       ldi r_temp,(1<<CS01)\r
+       out _SFR_IO_ADDR(TCCR0B),r_temp\r
+       ;OWPin as input\r
+       cbi OW_DDR,OW_PINN ;; is default.... \r
+       cbi OW_PORT,OW_PINN ;; vereinfachung im Hauptprogram (PORTB=0xFF) wegen pullup\r
+       ;set falling edge\r
+       ldi r_temp,(1<<ISC01)\r
+       sts EICRA,r_temp\r
+#ifdef _DB_\r
+       sbi DB_DDR,DB_PINN\r
+#endif\r
+.endm\r
+\r
+.macro JMP_FLASHER\r
+       ldi r_temp,0x00\r
+       push r_temp\r
+       ldi r_temp,0x3E\r
+       push r_temp\r
+       ret ; Direkter Sprung zum Bootloader\r
+.endm\r
+\r
+.macro CHECK_BOOTLOADER_PIN\r
+.endm\r
+\r
index b50fde5..c019baf 100644 (file)
@@ -56,7 +56,7 @@
 #endif\r
 \r
 #define TIMER_INTERRUPT TIM0_OVF_vect\r
 #endif\r
 \r
 #define TIMER_INTERRUPT TIM0_OVF_vect\r
-#define PIN_INTERRIPT EXT_INT0_vect\r
+#define PIN_INTERRUPT EXT_INT0_vect\r
 \r
 \r
 //#define OWT_MIN_RESET 160 \r
 \r
 \r
 //#define OWT_MIN_RESET 160 \r
@@ -70,7 +70,7 @@
 #define OWT_RESET2 30\r
 #define OWT_RESET_PRESENT 15\r
 #define OWT_PRESENT 60\r
 #define OWT_RESET2 30\r
 #define OWT_RESET_PRESENT 15\r
 #define OWT_PRESENT 60\r
-#define OWT_WRITE 16\r
+#define OWT_WRITE 15\r
 #define OWT_READ 5\r
 #define OWT_ZP_WAIT_LOW_TO 36  ; Zeit fuer die Maximale Lowzeit bei der Zerro Polling pruefung. Ist die Leitung laenger low, ist es vieleicht ein Reset \r
 #define OWT_ZP_WAIT_HIGH_TO 54 ; Zeit fuer die Maximale Hight zeit bis zu einem Low Impuls vom Master. Nach laengeren Pausen wird nicht mehr gepollt sondern der Interrup vererndet.\r
 #define OWT_READ 5\r
 #define OWT_ZP_WAIT_LOW_TO 36  ; Zeit fuer die Maximale Lowzeit bei der Zerro Polling pruefung. Ist die Leitung laenger low, ist es vieleicht ein Reset \r
 #define OWT_ZP_WAIT_HIGH_TO 54 ; Zeit fuer die Maximale Hight zeit bis zu einem Low Impuls vom Master. Nach laengeren Pausen wird nicht mehr gepollt sondern der Interrup vererndet.\r
@@ -79,7 +79,7 @@
 #define OWT_RESET2 80\r
 #define OWT_RESET_PRESENT 30\r
 #define OWT_PRESENT 130\r
 #define OWT_RESET2 80\r
 #define OWT_RESET_PRESENT 30\r
 #define OWT_PRESENT 130\r
-#define OWT_WRITE 35\r
+#define OWT_WRITE 33\r
 #define OWT_READ 12\r
 #define OWT_ZP_WAIT_LOW_TO 60  ; Zeit fuer die Maximale Lowzeit bei der Zerro Polling pruefung. Ist die Leitung laenger low, ist es vieleicht ein Reset \r
 #define OWT_ZP_WAIT_HIGH_TO 90 ; Zeit fuer die Maximale Hight zeit bis zu einem Low Impuls vom Master. Nach laengeren Pausen wird nicht mehr gepollt sondern der Interrup vererndet.\r
 #define OWT_READ 12\r
 #define OWT_ZP_WAIT_LOW_TO 60  ; Zeit fuer die Maximale Lowzeit bei der Zerro Polling pruefung. Ist die Leitung laenger low, ist es vieleicht ein Reset \r
 #define OWT_ZP_WAIT_HIGH_TO 90 ; Zeit fuer die Maximale Hight zeit bis zu einem Low Impuls vom Master. Nach laengeren Pausen wird nicht mehr gepollt sondern der Interrup vererndet.\r
        sbi DB_DDR,DB_PINN\r
 #endif\r
 .endm\r
        sbi DB_DDR,DB_PINN\r
 #endif\r
 .endm\r
+.macro JMP_FLASHER\r
+       ldi r_temp,0xC0\r
+       push r_temp\r
+       ldi r_temp,0x0E\r
+       push r_temp\r
+       ret ; Direkter Sprung zum Bootloader\r
+.endm\r
 \r
 \r
 \r
 \r
+.macro CHECK_BOOTLOADER_PIN  ;r_temp is pushed other Registers should be saved\r
+; check for bootloader jumper\r
+       ;vor allen anderen Registerconfigs\r
+#ifndef _NO_BOOTLOADER_PIN_    \r
+       ldi r_temp,(1<<PUD) ;enable pullup \r
+       out _SFR_IO_ADDR(MCUCR) ,r_temp\r
+       sbi _SFR_IO_ADDR(PORTA),PINA5 ;internal pullup on PINA5\r
+       sbi _SFR_IO_ADDR(PORTA),PINA4 ;internal pullup on PINA4\r
+       rcall spause\r
+       sbis _SFR_IO_ADDR(PINA),PINA5\r
+       rjmp owinit_botest_end  ;PinA5 nicht auf 1\r
+       sbis _SFR_IO_ADDR(PINA),PINA4\r
+       rjmp owinit_botest_end ;PinA4 nicht auf 1\r
+       cbi _SFR_IO_ADDR(PORTA),PINA4 \r
+       sbi _SFR_IO_ADDR(DDRA),PINA4  ;PINA4 AUSGANG und 0\r
+       rcall spause\r
+       sbic _SFR_IO_ADDR(PINA),PINA5 \r
+       rjmp owinit_botest_end ;PINA5 nicht 0.... nicht verbunden\r
+       cbi _SFR_IO_ADDR(DDRA),PINA4\r
+       JMP_FLASHER\r
+owinit_botest_end:\r
+#endif\r
+.endm\r
 \r
 \r
index e08d373..c9e5f40 100644 (file)
@@ -20,4 +20,9 @@ double calibr_hum(double temp,double tempdiv,double hum) {
         double r=hum*(SDDD(temp,tempdiv)*(tempdiv/(temp+273.15)+1));\r
         if (r>100) return 100.0;\r
        return r;\r
         double r=hum*(SDDD(temp,tempdiv)*(tempdiv/(temp+273.15)+1));\r
         if (r>100) return 100.0;\r
        return r;\r
+}\r
+\r
+inline double calibr_hum05(double t,double hum) {\r
+       double y=-0.0006*t*t-0.2455*t-28.5902;\r
+       return -(hum/y)+hum;\r
 }
\ No newline at end of file
 }
\ No newline at end of file
index 2ba627c..bef35d8 100644 (file)
@@ -5,5 +5,4 @@
 \r
 double calibr_hum(double temp,double tempdiv,double hum);\r
 \r
 \r
 double calibr_hum(double temp,double tempdiv,double hum);\r
 \r
-\r
 #endif
\ No newline at end of file
 #endif
\ No newline at end of file
diff --git a/common/owSlave_tools.h b/common/owSlave_tools.h
new file mode 100644 (file)
index 0000000..3dbba63
--- /dev/null
@@ -0,0 +1,187 @@
+#ifndef OWSLAVE_TOOLS_H\r
+#define OWSLAVE_TOOLS_H\r
+\r
+#if  defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+#define OWST_INIT_ALL_OFF \\r
+       PRR|=(1<<PRUSI)|(1<<PRADC);  /*Switch off usi and adc for save Power*/\\r
+       ACSR|=(1<<ACD);  /*Disable Comparator*/\\r
+       ADCSRB|=(1<<ACME); /*Disable Analog multiplexer*/\\r
+       PORTB|=~(1<<PINB2)|(1<<PORTB0); /*Make PullUp an all Pins but not OW_PIN*/\\r
+       /*Schalter kann gegen Masse sein und zieht dann immer Strom*/ \\r
+       DDRB|=(1<<PORTB0); /*Als Ausgang und 0*/\\r
+       PORTA|=0xFF;\r
+\r
+#define OWST_INIT_ADC_ON \\r
+PRR|=(1<<PRUSI);  /*Switch off usi and adc for save Power*/\\r
+ACSR|=(1<<ACD);  /*Disable Comparator*/\\r
+PORTB=~((1<<PINB2)|(1<<PORTB0)); /*Make PullUp an all Pins but not OW_PIN*/\\r
+/*Schalter kann gegen Masse sein und zieht dann immer Strom*/ \\r
+DDRB|=(1<<PORTB0); /*Als Ausgang und 0*/\\r
+PORTA|=0xFF;   \r
+\r
+#define OWST_INIT_USI_ON \\r
+PRR|=(1<<PRADC);  /*Switch off usi and adc for save Power*/\\r
+ACSR|=(1<<ACD);  /*Disable Comparator*/\\r
+ADCSRB|=(1<<ACME); /*Disable Analog multiplexer*/\\r
+PORTB|=~(1<<PINB2)|(1<<PORTB0); /*Make PullUp an all Pins but not OW_PIN*/\\r
+/*Schalter kann gegen Masse sein und zieht dann immer Strom*/ \\r
+DDRB|=(1<<PORTB0); /*Als Ausgang und 0*/\\r
+PORTA|=0xFF;\r
+\r
+#define OWST_INIT_ALL_ON \\r
+PORTB|=~(1<<PINB2)|(1<<PORTB0); /*Make PullUp an all Pins but not OW_PIN*/\\r
+/*Schalter kann gegen Masse sein und zieht dann immer Strom*/ \\r
+DDRB|=(1<<PORTB0); /*Als Ausgang und 0*/\\r
+PORTA|=0xFF;\r
+\r
+       \r
+#define OWST_EN_PULLUP MCUCR &=~(1<<PUD); /*All Pins Pullup...*/\r
+\r
+#define OWST_WDT_ISR \\r
+uint8_t wdcounter=0;\\r
+ISR(WATCHDOG_vect) {/* #else ISR(WDT_vect) {           #endif*/\\r
+               wdcounter++;\\r
+               if (reset_indicator==1) reset_indicator++;\\r
+               else if (reset_indicator==2) mode=0;\\r
+}\r
+\r
+#define OWST_WDR_CONFIG8\\r
+       WDTCSR |= ((1<<WDCE) );   /* Enable the WD Change Bit//| (1<<WDE)*/\\r
+       WDTCSR |=   (1<<WDIE) |              /* Enable WDT Interrupt*/\\r
+       (1<<WDP3) | (1<<WDP0);   /*Set Timeout to ~8 seconds*/\r
+\r
+#define OWST_WDR_CONFIG4\\r
+       WDTCSR |= ((1<<WDCE) );   /* Enable the WD Change Bit//| (1<<WDE)*/\\r
+       WDTCSR |=   (1<<WDIE) |              /* Enable WDT Interrupt*/\\r
+       (1<<WDP3) ;   /*Set Timeout to ~2 seconds*/\r
+\r
+#define OWST_WDR_CONFIG2\\r
+       WDTCSR |= ((1<<WDCE) );   /* Enable the WD Change Bit//| (1<<WDE)*/\\r
+       WDTCSR |=   (1<<WDIE) |              /* Enable WDT Interrupt*/\\r
+       (1<<WDP2) | (1<<WDP1)| (1<<WDP0);   /*Set Timeout to ~1 seconds*/\r
+\r
+#define OWST_WDR_CONFIG1\\r
+       WDTCSR |= ((1<<WDCE) );   /* Enable the WD Change Bit//| (1<<WDE)*/\\r
+       WDTCSR |=   (1<<WDIE) |              /* Enable WDT Interrupt*/\\r
+       (1<<WDP2) | (1<<WDP1);   /*Set Timeout to ~1 seconds*/\r
+\r
+\r
+#define OWST_TESTSW \\r
+       int testSW(void) {\\r
+               uint8_t r;\\r
+               DDRB&=~(1<<PORTB0);  /*Eingang*/\\r
+               __asm__ __volatile__ ("nop");\\r
+               PORTB|=(1<<PORTB0); /*Pullup*/\\r
+               __asm__ __volatile__ ("nop");\\r
+               __asm__ __volatile__ ("nop");\\r
+               __asm__ __volatile__ ("nop");\\r
+               __asm__ __volatile__ ("nop");\\r
+               __asm__ __volatile__ ("nop");\\r
+               r=PINB&(1<<PORTB0);\\r
+               __asm__ __volatile__ ("nop");\\r
+               PORTB&=~(1<<PORTB0);\\r
+               __asm__ __volatile__ ("nop");\\r
+               DDRB|=(1<<PORTB0);  /*Eingang*/\\r
+               return (r==0);\\r
+       }\\r
+\r
+#define OWST_EXTERN_VARS\r
+extern uint8_t mode;\\r
+extern uint8_t gcontrol;\\r
+extern uint8_t reset_indicator;\\r
+extern uint8_t alarmflag; \\r
+extern void OWINIT(void);\\r
+extern void EXTERN_SLEEP(void);\\r
+\r
+\r
+\r
+#define OWST_MAIN_END \\r
+       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))       {\\r
+               MCUCR|=(1<<SE)|(1<<SM1);\\r
+               MCUCR&=~(1<<ISC01);\\r
+       } else {\\r
+               MCUCR|=(1<<SE);\\r
+               MCUCR&=~(1<<SM1);\\r
+       }\\r
+       asm("SLEEP");\r
+\r
+#endif\r
+\r
+//********************** AD_WANDLER ********************************\r
+//******************************************************************\r
+//clock fuer ADC 50kHz - 200kHz     8M / 128 = 62500   = 4M/64   erste Messng 25 = 0,4ms / zweite Messung 13 rund 0,21ms\r
+#ifdef __4MHZ__\r
+#define OWST_INIT_ADC \\r
+ADCSRA = (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1);\r
+#else\r
+#define OWST_INIT_ADC \\r
+ADCSRA = (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);\r
+#endif\r
+\r
+#define OWST_ADC_CONF ADCSRA|=(1<<ADSC); while ((ADCSRA&(1<<ADSC)));\r
+\r
+#define OWST_ADCREF_VCC 0\r
+#define OWST_ADCREF_AREF (1<<REFS0)\r
+#define OWST_ADCREF_INT ((1<<REFS0)|(1<<REFS1))\r
+\r
+#define OWST_ADCIN_PA0 0\r
+#define OWST_ADCIN_PA1 1\r
+#define OWST_ADCIN_PA2 2\r
+#define OWST_ADCIN_PA3 3\r
+#define OWST_ADCIN_PA4 4\r
+#define OWST_ADCIN_PA5 5\r
+#define OWST_ADCIN_PA6 6\r
+#define OWST_ADCIN_PA7 7\r
+\r
+\r
+#if  defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+#define OWST_ADCIN_REFINT 0b0100001\r
+#endif\r
+#if  defined(__AVR_ATmega168__)||defined(__AVR_ATmega168A__) ||defined(__AVR_ATmega328__) ||defined(__AVR_ATmega328P__) ||defined(__AVR_ATmega328PB__)\r
+#define OWST_ADCIN_REFINT 0b00001110\r
+#endif\r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__)||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+#define AD_PORT PORTA\r
+#define AD_DDR DDRA\r
+#endif\r
+\r
+#if  defined(__AVR_ATmega168__)||defined(__AVR_ATmega168A__) ||defined(__AVR_ATmega328__) ||defined(__AVR_ATmega328P__) ||defined(__AVR_ATmega328PB__)\r
+#define AD_PORT PORTC\r
+#define AD_DDR DDRC\r
+#endif\r
+\r
+#define OWST_ADC_CONF16_FUNC \\r
+uint16_t owst_ADC_run() {/*14,5ms*/\\r
+       uint16_t r=0;\\r
+       for(uint8_t i=0;i<64;i++) {     OWST_ADC_CONF   r+=ADC; }\\r
+       return r;\\r
+} \\r
+double owst_ADC_runf() {/*16,5ms*/\\r
+       double r=0;\\r
+       for(uint8_t i=0;i<64;i++) {     OWST_ADC_CONF   r+=ADC; }\\r
+       r*=0.9993;\\r
+       return r;\\r
+}\r
+\r
+#define OWST_ADC_CONF16_OSS_FUNC \\r
+uint16_t owst_ADC_OSS_run() {/*896ms*/\\r
+       uint32_t r=0;\\r
+       for(uint16_t i=0;i<4096;i++) {\\r
+               OWST_ADC_CONF \\r
+               r+=ADC;\\r
+       }\\r
+       return r>>6;\\r
+} \\r
+double owst_ADC_OSS_runf() {/*964ms*/\\r
+       double r=0;\\r
+       for(uint16_t i=0;i<4096;i++) {\\r
+               OWST_ADC_CONF \\r
+               r+=ADC;\\r
+       }\\r
+       r+=5150;\\r
+       r*=0.9993;\\r
+       return r/64.0;\\r
+} \r
+\r
+\r
+#endif
\ No newline at end of file
index 2f55cc1..5a5c1e2 100644 (file)
@@ -25,7 +25,7 @@
     <preserveEEPROM>true</preserveEEPROM>\r
     <OverrideVtorValue>exception_table</OverrideVtorValue>\r
     <BootSegment>2</BootSegment>\r
     <preserveEEPROM>true</preserveEEPROM>\r
     <OverrideVtorValue>exception_table</OverrideVtorValue>\r
     <BootSegment>2</BootSegment>\r
-    <eraseonlaunchrule>0</eraseonlaunchrule>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
         <options />\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
         <options />\r
         </dependencies>\r
       </framework-data>\r
     </AsfFrameworkConfig>\r
         </dependencies>\r
       </framework-data>\r
     </AsfFrameworkConfig>\r
-    <avrtool>com.atmel.avrdbg.tool.avrdragon</avrtool>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
       <ToolOptions>\r
         <InterfaceProperties>\r
     <com_atmel_avrdbg_tool_atmelice>\r
       <ToolOptions>\r
         <InterfaceProperties>\r
-          <IspClock>100000</IspClock>\r
+          <IspClock>125000</IspClock>\r
           <DebugWireClockDiv>0</DebugWireClockDiv>\r
         </InterfaceProperties>\r
         <InterfaceName>debugWIRE</InterfaceName>\r
           <DebugWireClockDiv>0</DebugWireClockDiv>\r
         </InterfaceProperties>\r
         <InterfaceName>debugWIRE</InterfaceName>\r
       <ToolNumber>J41800000789</ToolNumber>\r
       <ToolName>Atmel-ICE</ToolName>\r
     </com_atmel_avrdbg_tool_atmelice>\r
       <ToolNumber>J41800000789</ToolNumber>\r
       <ToolName>Atmel-ICE</ToolName>\r
     </com_atmel_avrdbg_tool_atmelice>\r
-    <avrtoolinterface>ISP</avrtoolinterface>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\r
     <ExternalProgrammingToolCommand />\r
     <ExternalProgrammingToolCommand />\r
-    <avrtoolserialnumber>00A200054127</avrtoolserialnumber>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
     <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
     <com_atmel_avrdbg_tool_avrdragon>\r
       <ToolOptions>\r
         <InterfaceProperties>\r
     <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
     <com_atmel_avrdbg_tool_avrdragon>\r
       <ToolOptions>\r
         <InterfaceProperties>\r
-          <IspClock>125000</IspClock>\r
+          <IspClock>0</IspClock>\r
         </InterfaceProperties>\r
         <InterfaceName>ISP</InterfaceName>\r
       </ToolOptions>\r
         </InterfaceProperties>\r
         <InterfaceName>ISP</InterfaceName>\r
       </ToolOptions>\r
diff --git a/programmer/programmer/programmer_8MHz_2017.asm b/programmer/programmer/programmer_8MHz_2017.asm
new file mode 100644 (file)
index 0000000..5a51e4e
--- /dev/null
@@ -0,0 +1,489 @@
+.def srbyte = r12  ;byty for search rom algorithm\r
+.def writelow = r13;  marker for send low\r
+.def zero =r14;  always zero \r
+.def smode=r15; if 1 then send \r
+.def temp = r16 ; \r
+.def temp2 = r17; \r
+.def mode = r18 ; \r
+.def bitp = r19 ; bit counter ... shift...\r
+.def rwbyte = r21;\r
+.def param = r22;\r
+.def bytep = r23  ;byte counter\r
+#define spmcrval  param\r
+\r
+\r
+.equ OWM_READ_ROM_COMMAND=0 ; 0 wegen schnellen test ist dieser wert 0! Daturch wird die Sprungdabelle nicht verwendet\r
+.equ OWM_SLEEP=1 ; Warten auf Reset\r
+.equ OWM_MATCH_ROM=2\r
+.equ OWM_SEARCH_ROM_S=3  ;send bit\r
+.equ OWM_SEARCH_ROM_R=4  ;resive master\r
+.equ OWM_READ_COMMAND=5\r
+.equ OWM_WRITE_SCRATCHPAD=6\r
+.equ OWM_READ_SCRATCHPAD=7\r
+.equ OWM_PROGRAMM_PAGE=8\r
+.equ OWM_RECALL_FLASH=9\r
+\r
+\r
+.equ OW_DDR = DDRB \r
+.equ OW_PIN = PORTB2\r
+.equ OW_PORT = PORTB \r
+.equ OW_PINN = PINB \r
+\r
+;.equ SRAM_START = 0x60\r
+\r
+.macro set_clock\r
+               ldi temp,0x80;\r
+               out CLKPR,temp\r
+               ldi temp,@0\r
+               out CLKPR,temp\r
+.endmacro \r
+\r
+.macro owwl\r
+               sbic OW_PINN,OW_PIN\r
+               rjmp pc-1\r
+.endmacro \r
+\r
+.macro owwh\r
+               sbis OW_PINN,OW_PIN\r
+               rjmp pc-1\r
+.endmacro \r
+\r
+\r
+\r
+\r
+ ;---------------------------------------------------\r
+; START of PROG \r
+;---------------------------------------------------\r
+\r
+\r
+.CSEG \r
+.ORG 0x000\r
+jreset:\r
+               rjmp start ; Reset-Vector \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+\r
+\r
+.ORG 0x0EC0\r
+//7552 Byte \r
+start: \r
+               cli\r
+               ldi temp,0\r
+               mov zero,temp\r
+               set_clock 0x00 ;8mhz\r
+               ldi mode,OWM_SLEEP\r
+               ldi temp,(1<<CS01) //1us\r
+               out TCCR0B,temp\r
+               ldi temp, HIGH(RAMEND) ; HIGH-Byte der obersten RAM-Adresse \r
+               out SPH, temp \r
+               ldi temp, LOW(RAMEND) ; LOW-Byte der obersten RAM-Adresse \r
+               out SPL, temp \r
+               ;ldi temp,1\r
+               ;out DDRB,temp\r
+               clr writelow\r
+               clr bitp\r
+       \r
+               ;sbi PORTB,0\r
+               ldi ZL,low(pro_owid*2) \r
+               ldi ZH,high(pro_owid*2) \r
+               ldi XL,low(sowid)\r
+               ldi XH,high(sowid)\r
+               ;ldi temp2,8\r
+pro_copy_loop: ;copy ID on SRAM for better handling\r
+               lpm temp,Z+\r
+               st X+,temp\r
+               cpi XL,SRAM_START+8\r
+               brlo pro_copy_loop\r
+pro_loop:\r
+               ;sbi PORTB,0\r
+               owwl                            ;wait for line goes low (polling)\r
+               sbrs writelow,0         ;test of zero send\r
+               rjmp pro_loop1          ;no ? goes next\r
+               sbi OW_DDR,OW_PIN       ;yes pull line to low\r
+               ldi param,45            ;wait for 50 us\r
+               rcall wait_time\r
+               clr writelow            ;reset write low indecator\r
+               cbi OW_DDR,OW_PIN   ;release line\r
+               owwh                            ;wait for line is high (it can takes some time cause of the capacity of line)\r
+pro_loop1:\r
+               tst smode                       ;smode=1 for slave sends to master\r
+               breq pro_loop_resv\r
+pro_loop_send:\r
+               tst bitp\r
+               brne pro_loop_send1\r
+               rcall pro_hb\r
+               tst smode\r
+               breq pro_loop_end ; now reading ... do nothing \r
+pro_loop_send1:  ;prebare next bit\r
+               sbrs rwbyte ,0; if bit 0 set in rwbyte then skip next command\r
+               inc writelow\r
+               lsl bitp\r
+               ror rwbyte\r
+               rjmp pro_loop_end\r
+\r
+pro_loop_resv:\r
+               ldi param,15  ;wait 15us\r
+               rcall wait_time\r
+               lsr rwbyte\r
+               ;cbi PORTB,0\r
+               sbic OW_PINN,OW_PIN  ;test line\r
+               ori rwbyte,0x80\r
+               lsl bitp\r
+               brne pro_loop_end ;no handle need\r
+               rcall pro_hb\r
+               tst smode\r
+               brne pro_loop_send ; Nach dem Gelesen byte koennte gesendet werden muessen....\r
+pro_loop_end:\r
+               //owwh\r
+               out TCNT0,zero\r
+pro_loop_end_test_reset:\r
+               sbic OW_PINN,OW_PIN  //leitung wieder high\r
+               rjmp pro_loop\r
+               in temp,TCNT0\r
+               cpi temp,130\r
+               brlo pro_loop_end_test_reset\r
+               rcall pro_sleep_s2\r
+               rjmp pro_loop\r
+\r
+\r
+\r
+\r
+pro_sleep:\r
+               out TCNT0,zero\r
+pro_sleep_s1:\r
+               sbic OW_PINN,OW_PIN  //leitung wieder high\r
+               ret\r
+               in temp,TCNT0\r
+               cpi temp,200\r
+               brlo pro_sleep_s1\r
+               //leitung wieder high\r
+pro_sleep_s2:\r
+               owwh \r
+               ldi param,40\r
+               rcall wait_time\r
+               //Presents Impuls\r
+               sbi OW_DDR,OW_PIN\r
+               ldi param,130\r
+               rcall wait_time\r
+               cbi OW_DDR,OW_PIN\r
+               //init read byte\r
+               ldi bitp,0x01\r
+               ldi rwbyte,0\r
+               clr smode\r
+               ldi mode,OWM_READ_ROM_COMMAND\r
+               //Wait for all other devices presents impuls finished\r
+               ldi param,40\r
+               rcall wait_time\r
+               ret\r
+\r
+\r
+\r
+pro_hb:\r
+               ldi ZL,low(pro_stable) \r
+               ldi ZH,high(pro_stable) \r
+               add ZL,mode \r
+               adc ZH,zero\r
+               icall\r
+               ret\r
+\r
+pro_stable: \r
+               rjmp pro_read_rom_command\r
+               rjmp pro_sleep \r
+               rjmp pro_match_rom\r
+               rjmp pro_search_rom_s\r
+               rjmp pro_search_rom_r\r
+               rjmp pro_read_command\r
+               rjmp pro_write_scratchpad\r
+               rjmp pro_read_scratchpad\r
+               rjmp pro_programm_page\r
+               rjmp pro_recall_flash\r
+\r
+pro_read_rom_command:\r
+               ldi mode,OWM_SLEEP\r
+               cpi rwbyte,0xCC\r
+               brne pro_rcc_1\r
+               ldi mode,OWM_READ_COMMAND\r
+               rjmp pro_out_bitp1\r
+pro_rcc_1:\r
+               cpi rwbyte,0xF0 ;Searchrom\r
+               brne pro_rcc_2\r
+               ldi XL,low(sowid)  ;init sram pointer\r
+               ldi XH,high(sowid)\r
+               ld srbyte,X+\r
+               ldi bytep,0\r
+               rjmp pro_serchrom_next_bit\r
+pro_rcc_2:\r
+               cpi rwbyte,0x55 ;Matchrom\r
+               brne pro_rcc_3\r
+//             rcall pro_owidinit\r
+               ldi XL,low(sowid)  ;init sram pointer\r
+               ldi XH,high(sowid)\r
+               ldi mode,OWM_MATCH_ROM\r
+               rjmp pro_out_bytep0\r
+\r
+pro_rcc_3:\r
+               ret\r
+\r
+pro_match_rom:         \r
+               ld temp,X+\r
+               cp temp,rwbyte\r
+               breq pro_match_rom_next\r
+               ldi mode,OWM_SLEEP\r
+               ret\r
+pro_match_rom_next:                                    \r
+               cpi XL,SRAM_START+8\r
+               breq pro_match_rom_found\r
+               rjmp pro_out_bitp1\r
+pro_match_rom_found:\r
+           ldi mode,OWM_READ_COMMAND\r
+               rjmp pro_out_bitp1\r
+\r
+pro_read_command:\r
+               ldi mode,OWM_SLEEP\r
+               cpi rwbyte,0x0F ;; Write to Scratchpad\r
+               brne pro_rc_1\r
+               ldi mode,OWM_WRITE_SCRATCHPAD\r
+               ldi XL,low(scratchpad)  ;init sram pointer\r
+               ldi XH,high(scratchpad)\r
+               rjmp pro_out_bytep0\r
+pro_rc_1:\r
+               cpi rwbyte,0xAA\r
+               brne pro_rc_2\r
+               ldi mode,OWM_READ_SCRATCHPAD  ;;Read from Scratchpad\r
+               ldi XL,low(scratchpad)  ;init sram pointer\r
+               ldi XH,high(scratchpad)\r
+               inc smode\r
+               ld rwbyte,X+\r
+               rjmp pro_out_bytep0\r
+\r
+pro_rc_2:\r
+               cpi rwbyte,0xB8\r
+               brne pro_rc_3\r
+               ldi mode,OWM_RECALL_FLASH  ;; copy Flash page in Scratchpad\r
+               ldi XL,low(scratchpad)  ;init sram pointer\r
+               ldi XH,high(scratchpad)\r
+               rjmp pro_out_bytep0\r
+pro_rc_3:\r
+               cpi rwbyte,0x55 ; copy Scratchpad to Flash\r
+               brne pro_rc_4\r
+               ldi mode,OWM_SLEEP\r
+               rjmp pro_programm_page\r
+               \r
+pro_rc_4:\r
+               cpi rwbyte,0x89 ; Reset Device /Boot (new) Firmware\r
+               brne pro_rc_5\r
+               rjmp jreset             \r
+pro_rc_5:\r
+               cpi rwbyte,0x8B ; Clear the OWID saved in EEPROM / one ID1\r
+               brne pro_rc_6   \r
+               ldi temp,7\r
+pro_rc_5a:\r
+               ldi XL,low(E2END)\r
+               ldi XH,high(E2END)\r
+               sub XL,temp\r
+               out EEARH,XH\r
+               out EEARL,XL\r
+               ldi temp, (0<<EEPM1)|(0<<EEPM0)\r
+               out EECR, temp\r
+               ldi temp,0xFF\r
+               out EEDR, temp\r
+               sbi EECR, EEMPE\r
+               sbi EECR, EEPE\r
+               ret\r
+\r
+\r
+pro_rc_6:\r
+               cpi rwbyte,0x8C ; Clear the OWID saved in EEPROM / one ID2\r
+               brne pro_rc_7\r
+               ldi temp,7+8\r
+               rjmp pro_rc_5a\r
+\r
+pro_rc_7:\r
+               ret\r
+\r
+pro_write_scratchpad:\r
+               st X+,rwbyte\r
+               cpi XL,SRAM_START+8+66\r
+               brlo pro_write_scratchpad_next\r
+               ldi mode,OWM_SLEEP\r
+               ret             \r
+pro_write_scratchpad_next:\r
+               ldi bitp,1\r
+               ret\r
+\r
+pro_read_scratchpad:\r
+               cpi XL,SRAM_START+8+66\r
+               brlo pro_read_scratchpad_next\r
+               ldi mode,OWM_SLEEP\r
+               clr smode\r
+               ret\r
+pro_read_scratchpad_next:\r
+               ld rwbyte,X+\r
+               rjmp pro_out_bitp1\r
+\r
+\r
+pro_programm_page:\r
+.equ PAGESIZEB = PAGESIZE*2;PAGESIZEB is page size in BYTES, not words\r
+// .org SMALLBOOTSTART\r
+write_page:\r
+               ;transfer data from RAM to Flash page buffer\r
+               ldi bytep, PAGESIZEB ;init loop variable\r
+               ldi YL,low(scratchpad)  ;init sram pointer\r
+               ldi YH,high(scratchpad)\r
+               ld ZL,Y+\r
+               ld ZH,Y+\r
+               ;page erase\r
+               ldi spmcrval, (1<<PGERS) + (1<<SPMEN)\r
+               rcall do_spm\r
+wrloop:\r
+               ld r0, Y+\r
+               ld r1, Y+\r
+               ldi spmcrval, (1<<SPMEN)\r
+               rcall do_spm\r
+               adiw ZH:ZL, 2\r
+               subi bytep, 2;use subi for PAGESIZEB<=256\r
+               brne wrloop\r
+               ;execute page write\r
+               subi ZL, low(PAGESIZEB) ;restore pointer\r
+               sbci ZH, high(PAGESIZEB) ;not required for PAGESIZEB<=256\r
+               ldi spmcrval, (1<<PGWRT) + (1<<SPMEN)\r
+               rcall do_spm\r
+               ;read back and check, optional\r
+               ldi bytep, PAGESIZEB\r
+               subi YL, low(PAGESIZEB) ;restore pointer\r
+               sbci YH, high(PAGESIZEB)\r
+rdloop:\r
+               lpm r0, Z+\r
+               ld r1, Y+\r
+               cpse r0, r1\r
+               rjmp error\r
+               subi bytep, 2;use subi for PAGESIZEB<=256\r
+               brne rdloop\r
+               ;return\r
+               ret\r
+do_spm:\r
+                ;input: spmcrval determines SPM action\r
+               ;disable interrupts if enabled, store status\r
+               in temp2, SREG\r
+               cli\r
+               ;check for previous SPM complete\r
+wait:\r
+               in temp, SPMCSR\r
+               sbrc temp, SPMEN\r
+               rjmp wait\r
+               ;SPM timed sequence\r
+               out SPMCSR, spmcrval\r
+               spm\r
+               ;restore SREG (to enable interrupts if originally enabled)\r
+               out SREG, temp2\r
+               ret\r
+\r
+error:\r
+\r
+\r
+               ret\r
+\r
+pro_recall_flash:\r
+               st X+,rwbyte\r
+               ;inc bytep\r
+               cpi XL,SRAM_START+8+2\r
+               brlo pro_out_bitp1;pro_recall_flash_next\r
+               lds ZL,scratchpad\r
+               lds ZH,scratchpad+1\r
+pro_recall_flash_cl:\r
+               lpm temp,Z+\r
+               st X+,temp\r
+               cpi XL,SRAM_START+8+66\r
+               brne pro_recall_flash_cl\r
+               ldi mode,OWM_SLEEP\r
+               ret\r
+\r
+pro_out_read_command:\r
+               ldi mode,OWM_READ_COMMAND\r
+pro_out_bytep0:\r
+               ldi bytep,0\r
+pro_out_bitp1:\r
+               ldi bitp,1\r
+               ret             \r
+\r
+\r
+\r
+pro_serchrom_next_bit:\r
+               mov rwbyte,srbyte\r
+               mov temp2,rwbyte\r
+               com rwbyte\r
+               ror temp2  ;first bit in C\r
+               rol rwbyte ;C in first bit \r
+               inc smode\r
+               ldi bitp,0x40\r
+               ldi mode,OWM_SEARCH_ROM_R  ;next mod Resive\r
+               ret\r
+\r
+\r
+pro_search_rom_s:\r
+               clr temp2\r
+               lsr srbyte ;shift in C lowest bit\r
+               ror temp2  ; shift in temp2 as highest bit\r
+               andi rwbyte,0x80  ;  clear other bits\r
+               eor temp2,rwbyte\r
+               breq pro_search_rom_s_goon\r
+               ldi mode,OWM_SLEEP\r
+               ret\r
+pro_search_rom_s_goon:\r
+               inc bytep\r
+               mov temp2,bytep\r
+               andi temp2,0x07\r
+               brne pro_serchrom_next_bit ;prepare next bit\r
+               mov temp2,bytep\r
+               andi temp2,0x40 ;;end\r
+               brne pro_search_rom_found\r
+               ;read next byte\r
+               ld srbyte,X+\r
+               rjmp pro_serchrom_next_bit\r
+\r
+pro_search_rom_found:\r
+               ldi mode,OWM_READ_COMMAND\r
+               rjmp pro_out_bytep0\r
+\r
+pro_search_rom_r:\r
+               clr smode\r
+               ldi mode,OWM_SEARCH_ROM_S\r
+               ldi bitp,0  ;go to searchrom_s after bit get\r
+               ret\r
+\r
+pro_owid: .DB  0xA3, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xFA\r
+\r
+\r
+\r
+\r
+\r
+wait_time:\r
+               out TCNT0,zero\r
+wait_time1:\r
+               in temp,TCNT0\r
+               cp temp,param\r
+               brlo wait_time1\r
+               ret\r
+\r
+\r
+.DSEG\r
+sowid: .BYTE 8\r
+scratchpad: .BYTE 66
\ No newline at end of file
diff --git a/programmer_atmega328/programmer_atmega328/programmer_atmega328.asm b/programmer_atmega328/programmer_atmega328/programmer_atmega328.asm
new file mode 100644 (file)
index 0000000..816731c
--- /dev/null
@@ -0,0 +1,497 @@
+\r
+.def srbyte = r12  ;byty for search rom algorithm\r
+.def writelow = r13;  marker for send low\r
+.def zero =r14;  always zero \r
+.def smode=r15; if 1 then send \r
+.def temp = r16 ; \r
+.def temp2 = r17; \r
+.def mode = r18 ; \r
+.def bitp = r19 ; bit counter ... shift...\r
+.def rwbyte = r21;\r
+.def param = r22;\r
+.def bytep = r23  ;byte counter\r
+#define spmcrval  param\r
+\r
+\r
+.equ OWM_READ_ROM_COMMAND=0 ; 0 wegen schnellen test ist dieser wert 0! Daturch wird die Sprungdabelle nicht verwendet\r
+.equ OWM_SLEEP=1 ; Warten auf Reset\r
+.equ OWM_MATCH_ROM=2\r
+.equ OWM_SEARCH_ROM_S=3  ;send bit\r
+.equ OWM_SEARCH_ROM_R=4  ;resive master\r
+.equ OWM_READ_COMMAND=5\r
+.equ OWM_WRITE_SCRATCHPAD=6\r
+.equ OWM_READ_SCRATCHPAD=7\r
+.equ OWM_PROGRAMM_PAGE=8\r
+.equ OWM_RECALL_FLASH=9\r
+\r
+\r
+\r
+.equ OW_DDR = DDRD \r
+.equ OW_PIN = PORTD2\r
+.equ OW_PORT = PORTD \r
+.equ OW_PINN = PIND\r
+\r
+//.equ SPMEN = 0\r
+\r
+;.equ SRAM_START = 0x60\r
+\r
+.macro set_clock\r
+               ldi temp,0x80;\r
+               sts CLKPR,temp\r
+               ldi temp,@0\r
+               sts CLKPR,temp\r
+.endmacro \r
+\r
+.macro owwl\r
+               sbic OW_PINN,OW_PIN\r
+               rjmp pc-1\r
+.endmacro \r
+\r
+.macro owwh\r
+               sbis OW_PINN,OW_PIN\r
+               rjmp pc-1\r
+.endmacro \r
+\r
+\r
+\r
+\r
+ ;---------------------------------------------------\r
+; START of PROG \r
+;---------------------------------------------------\r
+\r
+\r
+.CSEG \r
+.ORG 0x000\r
+jreset:\r
+               jmp start ; Reset-Vector \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+               reti ; \r
+\r
+\r
+.ORG 0x3E00\r
+start: \r
+               cli\r
+               ldi temp,0\r
+               mov zero,temp\r
+               set_clock 0x01 ;4mhz\r
+               ldi mode,OWM_SLEEP\r
+               ldi temp,(1<<CS01) //2us\r
+               out TCCR0B,temp\r
+               ldi temp, HIGH(RAMEND) ; HIGH-Byte der obersten RAM-Adresse \r
+               out SPH, temp \r
+               ldi temp, LOW(RAMEND) ; LOW-Byte der obersten RAM-Adresse \r
+               out SPL, temp \r
+               ;ldi temp,1\r
+               ;out DDRB,temp\r
+               clr writelow\r
+               clr bitp\r
+       \r
+               ;sbi PORTB,0\r
+               ldi ZL,low(pro_owid*2) \r
+               ldi ZH,high(pro_owid*2) \r
+               ldi XL,low(sowid)\r
+               ldi XH,high(sowid)\r
+               ;ldi temp2,8\r
+pro_copy_loop: ;copy ID on SRAM for better handling\r
+               lpm temp,Z+\r
+               st X+,temp\r
+               cpi XL,low(SRAM_START+8) ;#################################\r
+               brlo pro_copy_loop\r
+pro_loop:\r
+               ;sbi PORTB,0\r
+               owwl                            ;wait for line goes low (polling)\r
+               sbrc writelow,0         ;test of zero send\r
+               sbi OW_DDR,OW_PIN       ;yes pull line to low 2us faster\r
+               sbrs writelow,0     ;test egain 2us faster.....\r
+               rjmp pro_loop1          ;no ? goes next\r
+               ldi param,20            ;wait for 50 us\r
+               rcall wait_time\r
+               clr writelow            ;reset write low indecator\r
+               cbi OW_DDR,OW_PIN   ;release line\r
+               owwh                            ;wait for line is high (it can takes some time cause of the capacity of line)\r
+pro_loop1:\r
+               tst smode                       ;smode=1 for slave sends to master\r
+               breq pro_loop_resv\r
+pro_loop_send:\r
+               tst bitp\r
+               brne pro_loop_send1\r
+               rcall pro_hb\r
+               tst smode\r
+               breq pro_loop_end ; now reading ... do nothing \r
+pro_loop_send1:  ;prebare next bit\r
+               sbrs rwbyte ,0; if bit 0 set in rwbyte then skip next command\r
+               inc writelow\r
+               lsl bitp\r
+               ror rwbyte\r
+               rjmp pro_loop_end\r
+\r
+pro_loop_resv:\r
+               ldi param,7  ;wait 15us\r
+               rcall wait_time\r
+               lsr rwbyte\r
+               ;cbi PORTB,0\r
+               sbic OW_PINN,OW_PIN  ;test line\r
+               ori rwbyte,0x80\r
+               lsl bitp\r
+               brne pro_loop_end ;no handle need\r
+               rcall pro_hb\r
+               tst smode\r
+               brne pro_loop_send ; Nach dem Gelesen byte koennte gesendet werden muessen....\r
+pro_loop_end:\r
+               //owwh\r
+               out TCNT0,zero\r
+pro_loop_end_test_reset:\r
+               sbic OW_PINN,OW_PIN  //leitung wieder high\r
+               rjmp pro_loop\r
+               in temp,TCNT0\r
+               cpi temp,63\r
+               brlo pro_loop_end_test_reset\r
+               rcall pro_sleep_s2\r
+               rjmp pro_loop\r
+\r
+\r
+\r
+\r
+pro_sleep:\r
+               out TCNT0,zero\r
+pro_sleep_s1:\r
+               sbic OW_PINN,OW_PIN  //leitung wieder high\r
+               ret\r
+               in temp,TCNT0\r
+               cpi temp,100\r
+               brlo pro_sleep_s1\r
+               //leitung wieder high\r
+pro_sleep_s2:\r
+               owwh \r
+               ldi param,20\r
+               rcall wait_time\r
+               //Presents Impuls\r
+               sbi OW_DDR,OW_PIN\r
+               ldi param,75\r
+               rcall wait_time\r
+               cbi OW_DDR,OW_PIN\r
+               //init read byte\r
+               ldi bitp,0x01\r
+               ldi rwbyte,0\r
+               clr smode\r
+               ldi mode,OWM_READ_ROM_COMMAND\r
+               //Wait for all other devices presents impuls finished\r
+               ldi param,20\r
+               rcall wait_time\r
+               ret\r
+\r
+\r
+\r
+pro_hb:\r
+               ldi ZL,low(pro_stable) \r
+               ldi ZH,high(pro_stable) \r
+               add ZL,mode \r
+               adc ZH,zero\r
+               icall\r
+               ret\r
+\r
+pro_stable: \r
+               rjmp pro_read_rom_command\r
+               rjmp pro_sleep \r
+               rjmp pro_match_rom\r
+               rjmp pro_search_rom_s\r
+               rjmp pro_search_rom_r\r
+               rjmp pro_read_command\r
+               rjmp pro_write_scratchpad\r
+               rjmp pro_read_scratchpad\r
+               rjmp pro_programm_page\r
+               rjmp pro_recall_flash\r
+\r
+pro_read_rom_command:\r
+               ldi mode,OWM_SLEEP\r
+               cpi rwbyte,0xCC\r
+               brne pro_rcc_1\r
+               ldi mode,OWM_READ_COMMAND\r
+               rjmp pro_out_bitp1\r
+pro_rcc_1:\r
+               cpi rwbyte,0xF0 ;Searchrom\r
+               brne pro_rcc_2\r
+               ldi XL,low(sowid)  ;init sram pointer\r
+               ldi XH,high(sowid)\r
+               ld srbyte,X+\r
+               ldi bytep,0\r
+               rjmp pro_serchrom_next_bit\r
+pro_rcc_2:\r
+               cpi rwbyte,0x55 ;Matchrom\r
+               brne pro_rcc_3\r
+//             rcall pro_owidinit\r
+               ldi XL,low(sowid)  ;init sram pointer\r
+               ldi XH,high(sowid)\r
+               ldi mode,OWM_MATCH_ROM\r
+               rjmp pro_out_bytep0\r
+\r
+pro_rcc_3:\r
+               ret\r
+\r
+pro_match_rom:         \r
+               ld temp,X+\r
+               cp temp,rwbyte\r
+               breq pro_match_rom_next\r
+               ldi mode,OWM_SLEEP\r
+               ret\r
+pro_match_rom_next:                                    \r
+               cpi XL,LOW(SRAM_START+8);####################\r
+               breq pro_match_rom_found\r
+               rjmp pro_out_bitp1\r
+pro_match_rom_found:\r
+           ldi mode,OWM_READ_COMMAND\r
+               rjmp pro_out_bitp1\r
+\r
+pro_read_command:\r
+               ldi mode,OWM_SLEEP\r
+               cpi rwbyte,0x0F ;; Write to Scratchpad\r
+               brne pro_rc_1\r
+               ldi mode,OWM_WRITE_SCRATCHPAD\r
+               ldi XL,low(scratchpad)  ;init sram pointer\r
+               ldi XH,high(scratchpad)\r
+               rjmp pro_out_bytep0\r
+pro_rc_1:\r
+               cpi rwbyte,0xAA\r
+               brne pro_rc_2\r
+               ldi mode,OWM_READ_SCRATCHPAD  ;;Read from Scratchpad\r
+               ldi XL,low(scratchpad)  ;init sram pointer\r
+               ldi XH,high(scratchpad)\r
+               inc smode\r
+               ld rwbyte,X+\r
+               rjmp pro_out_bytep0\r
+\r
+pro_rc_2:\r
+               cpi rwbyte,0xB8\r
+               brne pro_rc_3\r
+               ldi mode,OWM_RECALL_FLASH  ;; copy Flash page in Scratchpad\r
+               ldi XL,low(scratchpad)  ;init sram pointer\r
+               ldi XH,high(scratchpad)\r
+               rjmp pro_out_bytep0\r
+pro_rc_3:\r
+               cpi rwbyte,0x55 ; copy Scratchpad to Flash\r
+               brne pro_rc_4\r
+               ldi mode,OWM_SLEEP\r
+               rjmp pro_programm_page\r
+               \r
+pro_rc_4:\r
+               cpi rwbyte,0x89 ; Reset Device /Boot (new) Firmware\r
+               brne pro_rc_5\r
+               jmp jreset              \r
+pro_rc_5:\r
+               cpi rwbyte,0x8B ; Clear the OWID saved in EEPROM / one ID1\r
+               brne pro_rc_6   \r
+               ldi temp,7\r
+pro_rc_5a:\r
+               ldi XL,low(E2END)\r
+               ldi XH,high(E2END)\r
+               sub XL,temp\r
+               out EEARH,XH\r
+               out EEARL,XL\r
+               ldi temp, (0<<EEPM1)|(0<<EEPM0)\r
+               out EECR, temp\r
+               ldi temp,0xFF\r
+               out EEDR, temp\r
+               sbi EECR, EEMPE\r
+               sbi EECR, EEPE\r
+               ret\r
+\r
+\r
+pro_rc_6:\r
+               cpi rwbyte,0x8C ; Clear the OWID saved in EEPROM / one ID2\r
+               brne pro_rc_7\r
+               ldi temp,7+8\r
+               rjmp pro_rc_5a\r
+\r
+pro_rc_7:\r
+               ret\r
+\r
+pro_write_scratchpad:\r
+               st X+,rwbyte\r
+               cpi XL,138 ;#####################################\r
+               brlo pro_write_scratchpad_next\r
+               ldi mode,OWM_SLEEP\r
+               ret             \r
+pro_write_scratchpad_next:\r
+               ldi bitp,1\r
+               ret\r
+\r
+pro_read_scratchpad:\r
+               cpi XL,8+130 ;###################################\r
+               brlo pro_read_scratchpad_next\r
+               ldi mode,OWM_SLEEP\r
+               clr smode\r
+               ret\r
+pro_read_scratchpad_next:\r
+               ld rwbyte,X+\r
+               rjmp pro_out_bitp1\r
+\r
+\r
+pro_programm_page:\r
+.equ PAGESIZEB = 128 ; Not correct deglaration in inc file of ATMEGA328PB  PAGESIZE*2;PAGESIZEB is page size in BYTES, not words\r
+// .org SMALLBOOTSTART\r
+write_page:\r
+               ;transfer data from RAM to Flash page buffer\r
+               ldi bytep, PAGESIZEB ;init loop variable\r
+               ldi YL,low(scratchpad)  ;init sram pointer\r
+               ldi YH,high(scratchpad)\r
+               ld ZL,Y+\r
+               ld ZH,Y+\r
+               ;page erase\r
+               ldi spmcrval,(1<<PGERS) | (1<<SPMEN)\r
+               rcall do_spm\r
+               ldi spmcrval, (1<<RWWSRE) | (1<<SPMEN)\r
+               rcall do_spm\r
+wrloop:\r
+               ld r0, Y+\r
+               ld r1, Y+\r
+               ldi spmcrval, (1<<SPMEN)\r
+               rcall do_spm\r
+               adiw ZH:ZL, 2\r
+               subi bytep, 2;use subi for PAGESIZEB<=256\r
+               brne wrloop\r
+               ;execute page write\r
+               subi ZL, low(PAGESIZEB) ;restore pointer\r
+               sbci ZH, high(PAGESIZEB) ;not required for PAGESIZEB<=256\r
+               ldi spmcrval, (1<<PGWRT) + (1<<SPMEN)\r
+               rcall do_spm\r
+               ldi spmcrval, (1<<RWWSRE) | (1<<SPMEN)\r
+               rcall do_spm\r
+               ;read back and check, optional\r
+               ldi bytep, PAGESIZEB\r
+               subi YL, low(PAGESIZEB) ;restore pointer\r
+               sbci YH, high(PAGESIZEB)\r
+rdloop:\r
+               lpm r0, Z+\r
+               ld r1, Y+\r
+               cpse r0, r1\r
+               rjmp error\r
+               subi bytep, 2;use subi for PAGESIZEB<=256\r
+               brne rdloop\r
+               ;return\r
+               ret\r
+do_spm:\r
+                ;input: spmcrval determines SPM action\r
+               ;disable interrupts if enabled, store status\r
+               in temp2, SREG\r
+               cli\r
+               ;check for previous SPM complete\r
+wait:\r
+               in temp, SPMCSR\r
+               sbrc temp, SPMEN\r
+               rjmp wait\r
+               ;SPM timed sequence\r
+               out SPMCSR, spmcrval\r
+               spm\r
+               ;restore SREG (to enable interrupts if originally enabled)\r
+               out SREG, temp2\r
+               ret\r
+\r
+error:\r
+\r
+\r
+               ret\r
+\r
+pro_recall_flash:\r
+               st X+,rwbyte\r
+               ;inc bytep\r
+               cpi XL,low(SRAM_START+8+2) ;##############################################\r
+               brlo pro_out_bitp1;pro_recall_flash_next\r
+               lds ZL,scratchpad\r
+               lds ZH,scratchpad+1\r
+pro_recall_flash_cl:\r
+               lpm temp,Z+\r
+               st X+,temp\r
+               cpi XL,low(SRAM_START+8+66) ;############################################\r
+               brne pro_recall_flash_cl\r
+               ldi mode,OWM_SLEEP\r
+               ret\r
+\r
+pro_out_read_command:\r
+               ldi mode,OWM_READ_COMMAND\r
+pro_out_bytep0:\r
+               ldi bytep,0\r
+pro_out_bitp1:\r
+               ldi bitp,1\r
+               ret             \r
+\r
+\r
+\r
+pro_serchrom_next_bit:\r
+               mov rwbyte,srbyte\r
+               mov temp2,rwbyte\r
+               com rwbyte\r
+               ror temp2  ;first bit in C\r
+               rol rwbyte ;C in first bit \r
+               inc smode\r
+               ldi bitp,0x40\r
+               ldi mode,OWM_SEARCH_ROM_R  ;next mod Resive\r
+               ret\r
+\r
+\r
+pro_search_rom_s:\r
+               clr temp2\r
+               lsr srbyte ;shift in C lowest bit\r
+               ror temp2  ; shift in temp2 as highest bit\r
+               andi rwbyte,0x80  ;  clear other bits\r
+               eor temp2,rwbyte\r
+               breq pro_search_rom_s_goon\r
+               ldi mode,OWM_SLEEP\r
+               ret\r
+pro_search_rom_s_goon:\r
+               inc bytep\r
+               mov temp2,bytep\r
+               andi temp2,0x07\r
+               brne pro_serchrom_next_bit ;prepare next bit\r
+               mov temp2,bytep\r
+               andi temp2,0x40 ;;end\r
+               brne pro_search_rom_found\r
+               ;read next byte\r
+               ld srbyte,X+\r
+               rjmp pro_serchrom_next_bit\r
+\r
+pro_search_rom_found:\r
+               ldi mode,OWM_READ_COMMAND\r
+               rjmp pro_out_bytep0\r
+\r
+pro_search_rom_r:\r
+               clr smode\r
+               ldi mode,OWM_SEARCH_ROM_S\r
+               ldi bitp,0  ;go to searchrom_s after bit get\r
+               ret\r
+\r
+pro_owid: .DB 0xA3, 0xAA, 0x57, 0xAA, 0x57, 0xAA, 0x57, 0x8A\r
+\r
+\r
+\r
+\r
+\r
+wait_time:\r
+               out TCNT0,zero\r
+wait_time1:\r
+               in temp,TCNT0\r
+               cp temp,param\r
+               brlo wait_time1\r
+               ret\r
+\r
+\r
+.DSEG\r
+sowid: .BYTE 8\r
+scratchpad: .BYTE 130
\ No newline at end of file
diff --git a/programmer_atmega328/programmer_atmega328/programmer_atmega328.asmproj b/programmer_atmega328/programmer_atmega328/programmer_atmega328.asmproj
new file mode 100644 (file)
index 0000000..694b3ae
--- /dev/null
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>\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.AVRAssembler</ToolchainName>\r
+    <ProjectGuid>59B1D629-9DCC-43ed-A0FD-8AB0E4D622AB</ProjectGuid>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <avrdevice>ATmega328PB</avrdevice>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.obj</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <Language>ASSEMBLY</Language>\r
+    <AssemblyName>programmer_atmega328</AssemblyName>\r
+    <Name>programmer_atmega328</Name>\r
+    <RootNamespace>programmer_atmega328</RootNamespace>\r
+    <ToolchainFlavour>Native</ToolchainFlavour>\r
+    <EntryFile>$(MSBuildProjectDirectory)\programmer_atmega328.asm</EntryFile>\r
+    <KeepTimersRunning>true</KeepTimersRunning>\r
+    <OverrideVtor>false</OverrideVtor>\r
+    <CacheFlash>true</CacheFlash>\r
+    <ProgFlashFromRam>true</ProgFlashFromRam>\r
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>\r
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>0</eraseonlaunchrule>\r
+    <AsfFrameworkConfig>\r
+      <framework-data xmlns="">\r
+        <options />\r
+        <configurations />\r
+        <files />\r
+        <documentation help="" />\r
+        <offline-documentation help="" />\r
+        <dependencies>\r
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.31.0" />\r
+        </dependencies>\r
+      </framework-data>\r
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E9516</avrdeviceexpectedsignature>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+          <IspClock>125000</IspClock>\r
+        </InterfaceProperties>\r
+        <InterfaceName>ISP</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
+    <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrAssembler>\r
+  <avrasm.assembler.general.AdditionalIncludeDirectories>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\avrasm\inc</Value>\r
+    </ListValues>\r
+  </avrasm.assembler.general.AdditionalIncludeDirectories>\r
+  <avrasm.assembler.general.IncludeFile>m328PBdef.inc</avrasm.assembler.general.IncludeFile>\r
+</AvrAssembler>\r
+    </ToolchainSettings>\r
+    <OutputType>Executable</OutputType>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
+    <ToolchainSettings>\r
+      <AvrAssembler>\r
+  <avrasm.assembler.general.AdditionalIncludeDirectories>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\avrasm\inc</Value>\r
+    </ListValues>\r
+  </avrasm.assembler.general.AdditionalIncludeDirectories>\r
+  <avrasm.assembler.general.IncludeFile>m328PBdef.inc</avrasm.assembler.general.IncludeFile>\r
+</AvrAssembler>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="programmer_atmega328.asm">\r
+      <SubType>Code</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Assembler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/programmer_atmega328/programmer_atmega328/programmer_atmega328.atsln b/programmer_atmega328/programmer_atmega328/programmer_atmega328.atsln
new file mode 100644 (file)
index 0000000..ac4179e
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.23107.0\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{18226A42-8477-4023-8AD2-40C49DA407C9}") = "programmer_atmega328", "programmer_atmega328.asmproj", "{59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}.Debug|AVR.ActiveCfg = Debug|AVR\r
+               {59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}.Debug|AVR.Build.0 = Debug|AVR\r
+               {59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}.Release|AVR.ActiveCfg = Release|AVR\r
+               {59B1D629-9DCC-43ED-A0FD-8AB0E4D622AB}.Release|AVR.Build.0 = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r