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 "../common/owSlave_tools.h"\r
 \r
 \r
-extern void OWINIT();\r
-extern void EXTERN_SLEEP();\r
+#define OWST_EXTERN_VARS\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
-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
@@ -84,7 +81,8 @@ volatile pack_t pack;
 \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
@@ -92,15 +90,14 @@ int main(void){
        pack.rrFF=0xFF;\r
        pack.rr00=0;\r
        pack.rr10=0x10;\r
-       PORTA=0xFF;\r
-       PORTB=0xFF;\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
+       _delay_ms(500);\r
+       bmp280Init();\r
+       _delay_ms(50);\r
        bmp280Init();\r
        //DDRB|=(1<<PINB1);\r
        gcontrol=1;\r
@@ -128,23 +125,8 @@ int main(void){
                        //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
-                       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
index 68c6f87..005cf10 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
-  <options />\r
-  <configurations />\r
-  <files />\r
-  <documentation help="" />\r
-  <offline-documentation help="" />\r
-  <dependencies>\r
-    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
-  </dependencies>\r
-</framework-data>\r
+        <options />\r
+        <configurations />\r
+        <files />\r
+        <documentation help="" />\r
+        <offline-documentation help="" />\r
+        <dependencies>\r
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+        </dependencies>\r
+      </framework-data>\r
     </AsfFrameworkConfig>\r
-    <avrtool>custom</avrtool>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\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
-    <avrtoolserialnumber>\r
-    </avrtoolserialnumber>\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\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
+    <ResetRule>0</ResetRule>\r
+    <EraseKey />\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\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
       <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
-      <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
index e379db8..4dc0ba0 100644 (file)
 #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/owSlave_tools.h"\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
@@ -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
-#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
+OWST_WDT_ISR\r
 \r
 typedef union {\r
        volatile uint8_t bytes[8];\r
@@ -132,43 +103,23 @@ volatile pack2_t pack2;
 \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
-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
-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
-    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
@@ -179,69 +130,53 @@ int main(void){
        PORTA=0xFF;\r
        PORTB=0xFF;\r
        OWINIT();\r
+       OWST_EN_PULLUP\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
-       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
+               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
+       TWI_Master_Initialise();\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
+                \r
                if (gcontrol) {\r
-                       wdcounter=3;\r
+                       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
-                                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
-                                config_info2[5]=8;\r
+                                config_info2[5]=12;\r
+                                DS2438_2_VDD=0x01F4;\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.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
+                                DS2438_2_VDD=0x01F4;\r
                         }\r
                        wdcounter=0;\r
                }\r
@@ -269,23 +204,7 @@ int main(void){
                        \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
index 1c18216..c9e90b3 100644 (file)
 #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
-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
-#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
-uint8_t max_adr=0;\r
+OWST_WDT_ISR\r
 \r
 typedef union {\r
        volatile uint8_t bytes[8];\r
@@ -94,10 +71,10 @@ volatile pack_t pack;
 \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
@@ -110,18 +87,11 @@ int main(void){
        OWINIT();\r
        PORTB&=~(1<<PINB1);\r
        DDRB|=(1<<PINB1);\r
-       \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
-       MCUSR=0;\r
        _delay_ms(100);\r
        USI_TWI_Master_Initialise();\r
        CDM7160softReset();\r
@@ -170,22 +140,7 @@ int main(void){
                }\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
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 "../common/owSlave_tools.h"\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
-#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
@@ -84,7 +72,7 @@ volatile pack_t pack;
 \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
@@ -92,14 +80,9 @@ int main(void){
        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
-       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
@@ -108,7 +91,7 @@ int main(void){
        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
@@ -124,27 +107,13 @@ int main(void){
                        //pack.temp++;\r
                        alarmflag=af;\r
                        sei();  \r
+                       gcontrol=0;\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
index a63a3cf..a7f4f2b 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
-  <options />\r
-  <configurations />\r
-  <files />\r
-  <documentation help="" />\r
-  <offline-documentation help="" />\r
-  <dependencies>\r
-    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
-  </dependencies>\r
-</framework-data>\r
+        <options />\r
+        <configurations />\r
+        <files />\r
+        <documentation help="" />\r
+        <offline-documentation help="" />\r
+        <dependencies>\r
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+        </dependencies>\r
+      </framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
@@ -46,7 +46,7 @@
         <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>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
+  <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
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 "../common/I2C/SHT2x.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/calibr.h"\r
+#include "../common/owSlave_tools.h"\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
-       \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
+OWST_TESTSW\r
 \r
 \r
 typedef union {\r
@@ -150,21 +102,17 @@ typedef union {
 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
-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
-    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
@@ -172,40 +120,22 @@ int main(void){
        pack1.rrFF=0xFF;\r
        pack1.rr00=0;\r
        pack1.rr10=0x10;\r
-       PORTA=0xFF;\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<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+       OWST_EN_PULLUP\r
+       OWST_WDR_CONFIG8\r
        if (testSW()) {\r
-               config_info2[5]=8;\r
+               config_info2[5]=12;\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
-       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
+       initSHT2x();\r
        gcontrol=1;\r
        sei();\r
-       //DDRB|=(1<<PINB1);\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
-                       //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
@@ -258,24 +186,7 @@ int main(void){
                        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
index c14dc8d..f7036ac 100644 (file)
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
-    <Compile Include="..\common\I2C\SHT2x.c">\r
+    <Compile Include="..\common\calibr.c">\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 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
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
-    <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
         <InterfaceName>debugWIRE</InterfaceName>\r
       </ToolOptions>\r
       <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
-      <ToolNumber>J41800000779</ToolNumber>\r
+      <ToolNumber>J41800000789</ToolNumber>\r
       <ToolName>Atmel-ICE</ToolName>\r
     </com_atmel_avrdbg_tool_atmelice>\r
     <avrtoolinterface>debugWIRE</avrtoolinterface>\r
     <ExternalProgrammingToolCommand />\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-  <avrgcc.compiler.symbols.DefSymbols>\r
-    <ListValues>\r
-      <Value>DEBUG</Value>\r
-    </ListValues>\r
-  </avrgcc.compiler.symbols.DefSymbols>\r
-  <avrgcc.compiler.directories.IncludePaths>\r
-    <ListValues>\r
-      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
-    </ListValues>\r
-  </avrgcc.compiler.directories.IncludePaths>\r
-  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
-  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
-  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-  <avrgcc.linker.libraries.Libraries>\r
-    <ListValues>\r
-      <Value>libm</Value>\r
-    </ListValues>\r
-  </avrgcc.linker.libraries.Libraries>\r
-  <avrgcc.assembler.general.IncludePaths>\r
-    <ListValues>\r
-      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
-    </ListValues>\r
-  </avrgcc.assembler.general.IncludePaths>\r
-  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
-</AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>DEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+      </AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-  <avrgcc.compiler.symbols.DefSymbols>\r
-    <ListValues>\r
-      <Value>DEBUG</Value>\r
-    </ListValues>\r
-  </avrgcc.compiler.symbols.DefSymbols>\r
-  <avrgcc.compiler.directories.IncludePaths>\r
-    <ListValues>\r
-      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
-    </ListValues>\r
-  </avrgcc.compiler.directories.IncludePaths>\r
-  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
-  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
-  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-  <avrgcc.linker.libraries.Libraries>\r
-    <ListValues>\r
-      <Value>libm</Value>\r
-    </ListValues>\r
-  </avrgcc.linker.libraries.Libraries>\r
-  <avrgcc.assembler.general.IncludePaths>\r
-    <ListValues>\r
-      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
-    </ListValues>\r
-  </avrgcc.assembler.general.IncludePaths>\r
-  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
-</AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>DEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
+          </ListValues>\r
+        </avrgcc.assembler.general.IncludePaths>\r
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+      </AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
index 4927b99..8ffaa53 100644 (file)
 #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
+OWST_EXTERN_VARS\r
 \r
-extern void OWINIT();\r
-extern void EXTERN_SLEEP();\r
+//#define K_Type\r
+#define J_Type\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
+#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
-//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
@@ -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
-#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
@@ -177,20 +138,19 @@ double ADmess() {
        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
-uint8_t userRegister[1];\r
-int16_t sRH,sT;\r
-volatile double temperatureC,humidityRH;\r
-volatile double l;\r
 \r
-uint8_t max_adr=0;\r
+double temperatureC,humidityRH;\r
+double TC;\r
+double l;\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
@@ -198,35 +158,22 @@ int main(void){
        pack1.rr00=0;\r
        pack1.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
+       OWST_EN_PULLUP\r
+       OWST_WDR_CONFIG1        \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
-               config_info2[5]=8;\r
+               config_info2[5]=12;\r
                }else{\r
                config_info2[5]=7;\r
        }\r
-       MCUSR=0;\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
+       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
@@ -247,46 +194,43 @@ int main(void){
                \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
-                                       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
+                       DS2438_2_VDD=0x01F4;\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
-                       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
-                       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
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
-    <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
@@ -63,6 +63,8 @@
       <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
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
-    <Compile Include="..\common\I2C\SHT2x.c">\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\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
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/owSlave_tools.h"\r
 \r
-extern void OWINIT(void);\r
-extern void EXTERN_SLEEP(void);\r
+OWST_EXTERN_VARS\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
-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
+OWST_WDT_ISR\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
        typedef union {\r
@@ -155,12 +142,13 @@ ISR(WATCHDOG_vect) {
 \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
-       uint8_t userRegister[1];\r
-       int16_t sRH,sT;\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
-       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
@@ -290,7 +259,7 @@ ISR(WATCHDOG_vect) {
                        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
@@ -304,27 +273,7 @@ ISR(WATCHDOG_vect) {
                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
@@ -390,14 +339,13 @@ ISR(WATCHDOG_vect) {
 \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
-                                       //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
@@ -456,7 +404,7 @@ ISR(WATCHDOG_vect) {
                                \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
@@ -469,27 +417,13 @@ ISR(WATCHDOG_vect) {
                                sei();\r
                                EXTERN_SLEEP();\r
                        }\r
-                       if ((gcontrol==2)||(gcontrol==3)) {\r
+                       if (gcontrol) {\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
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
-               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
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
-#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
@@ -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
-#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 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
@@ -187,7 +205,7 @@ int main(void){
        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
@@ -240,7 +258,11 @@ int main(void){
 \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_set=0;\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
+#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
index 1dbd395..9166850 100644 (file)
 extern void OWINIT(void);\r
 extern void EXTERN_SLEEP(void);\r
 \r
+\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
@@ -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
-#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
@@ -110,6 +115,16 @@ volatile uint8_t changefromeeprom;
 #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
@@ -164,6 +179,9 @@ ISR(ANA_COMP_vect) {
                        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
@@ -202,7 +220,7 @@ int main(void){
        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
@@ -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
-       #ifdef FHEM_PLATINE\r
+#ifdef FHEM_PLATINE\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
-       #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
-       #ifdef FHEM_PLATINE\r
+#ifdef FHEM_PLATINE\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
-       #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
-               #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
-               #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
@@ -286,9 +310,20 @@ int main(void){
                        }\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
-               asm("SLEEP");\r
+               asm("SLEEP");*/\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&nb