4MHz - Some New double Double Devices
authorTobias <tm@tm3d.de>
Fri, 7 Apr 2017 07:26:18 +0000 (09:26 +0200)
committerTobias <tm@tm3d.de>
Fri, 7 Apr 2017 07:26:18 +0000 (09:26 +0200)
36 files changed:
DS18B20_BMP280_DS2438_SHT/DS18B20_BMP280_DS2438_SHT.cproj
DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c
DS18B20_MAX44009_DS2438_SHT/DS18B20_MAX44009_DS2438_SHT.cproj
DS18B20_VOC_DS2438_SHT direct/DS18B20_DS2438.c
DS18B20_VOC_DS2438_SHT/DS18B20_DS2438.c
DS2423_DS2413/DS2423_DS2413.atsln [new file with mode: 0644]
DS2423_DS2413/DS2423_DS2413.c [new file with mode: 0644]
DS2423_DS2413/DS2423_DS2413.cproj [new file with mode: 0644]
DS2423_DS2413/Makefile [new file with mode: 0644]
DS2423_DS2423/DS2423_DS2423.atsln [new file with mode: 0644]
DS2423_DS2423/DS2423_DS2423.c [new file with mode: 0644]
DS2423_DS2423/DS2423_DS2423.cproj [new file with mode: 0644]
DS2423_DS2423/Makefile [new file with mode: 0644]
DS2423_komische platine/DS2423.c
DS2423_komische platine/DS2423.cproj
DS2438_DHT22/DS2438_DHT22.c
DS2438_DHT22/DS2438_DHT22.cproj
DS2438_SHT2X/DS2438_SHT2X.c
DS2438_VOC_DS2438_SHT_Wiregate/DS2438_DS2438.c [new file with mode: 0644]
DS2438_VOC_DS2438_SHT_Wiregate/DS2438_VOC_DS2438_SHT.atsln [new file with mode: 0644]
DS2438_VOC_DS2438_SHT_Wiregate/DS2438_VOC_DS2438_SHT.cproj [new file with mode: 0644]
DS2438_VOC_DS2438_SHT_Wiregate/Makefile [new file with mode: 0644]
DS2450_BMP280/DS2450_BMP280.atsln [new file with mode: 0644]
DS2450_BMP280/DS2450_BMP280.c [new file with mode: 0644]
DS2450_BMP280/DS2450_BMP280.cproj [new file with mode: 0644]
DS2450_BMP280/Makefile [new file with mode: 0644]
DS2450_SHT2X_BMP280/DS2450_SHT2X_BMP280.cproj
common/OWConfig.s
common/OWDS2401_DS2413.S [new file with mode: 0644]
common/OWDS2423.S
common/OWDS2423_DS2413.S [new file with mode: 0644]
common/OWDS2423_DS2423.S [new file with mode: 0644]
common/OWDS2438_DS2438.S [new file with mode: 0644]
common/OWPinInterrupt.s
common/OWRomFunctionsDual.s
common/OWSet_ATTINYX4.s

index 2594168..68c6f87 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
-        <options />\r
-        <configurations />\r
-        <files />\r
-        <documentation help="" />\r
-        <offline-documentation help="" />\r
-        <dependencies>\r
-          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />\r
-        </dependencies>\r
-      </framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>custom</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
     </Compile>\r
   </ItemGroup>\r
   <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
-</Project>\r
+</Project>
\ No newline at end of file
index 191de8f..e379db8 100644 (file)
@@ -194,7 +194,7 @@ int main(void){
                }else{\r
                config_info2[5]=7;\r
        }\r
-       \r
+       pack2.page3[0]=0xF1;\r
 \r
        MCUSR=0;\r
        USI_TWI_Master_Initialise();\r
index 1c7737c..f17ec23 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
       <framework-data>\r
-        <options />\r
-        <configurations />\r
-        <files />\r
-        <documentation help="" />\r
-        <offline-documentation help="" />\r
-        <dependencies>\r
-          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />\r
-        </dependencies>\r
-      </framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
index 06e2fdd..4448c39 100644 (file)
 #define F_CPU 8000000UL\r
 #include <avr/io.h>\r
 #include <avr/interrupt.h>\r
-#include <util/delay.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/SHT2x.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
 #include "../common/calibr.h"\r
 \r
 extern void OWINIT(void);\r
@@ -50,10 +50,11 @@ extern void EXTERN_SLEEP(void);
 \r
 volatile uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/\r
 volatile uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/\r
-volatile uint8_t config_info1[26]={0x08,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,17,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};      \r
-volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 11,0x08, 0x02,0x07,0x00,0x07,17,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};        \r
-       \r
-#if (owid>128) \r
+                                        //18\r
+volatile uint8_t config_info1[26]={0x08,18, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,17,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 11,0x08, 0x02,0x07,0x00,0x07,17,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+\r
+#if (owid>128)\r
 #error "Variable not correct"\r
 #endif\r
 \r
@@ -66,383 +67,367 @@ volatile uint8_t wdcounter=1;
 \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
+       #else\r
+       ISR(WDT_vect) {\r
+               #endif\r
+               wdcounter++;\r
+               if (reset_indicator==1) reset_indicator++;\r
+               else if (reset_indicator==2) mode=0;\r
 \r
 \r
-}\r
+       }\r
 \r
 \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
+       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
-               int16_t current;  //6\r
-               uint8_t threshold; //8\r
-               \r
-               uint8_t page1[8]; //9\r
+       typedef union {\r
                #if  defined(__AVR_ATtiny25__)\r
+               volatile uint8_t bytes[16];\r
                #else\r
-               uint8_t page2[8]; //17\r
-               union{ \r
-                       uint8_t page3[8]; //25\r
-                       struct {\r
-                               uint16_t R0;\r
-                               uint16_t VS;\r
-                               uint8_t cmode;\r
-                               int16_t ip;\r
-                               uint8_t free;\r
+               volatile uint8_t bytes[64];\r
+               #endif\r
+               struct {\r
+                       uint8_t status;  //1\r
+                       int16_t temp;  //2\r
+                       uint16_t voltage;  //4\r
+                       int16_t current;  //6\r
+                       uint8_t threshold; //8\r
+                       \r
+                       uint8_t page1[8]; //9\r
+                       #if  defined(__AVR_ATtiny25__)\r
+                       #else\r
+                       uint8_t page2[8]; //17\r
+                       union{\r
+                               uint8_t page3[8]; //25\r
+                               struct {\r
+                                       uint16_t R0;\r
+                                       uint16_t VS;\r
+                                       uint8_t cmode;\r
+                                       int16_t ip;\r
+                                       uint8_t free;\r
+                               };\r
                        };\r
-               };\r
-               union{ \r
-                       uint8_t page4[8];  //33\r
-                       struct {\r
-                               uint16_t tol_s8;\r
-                               uint16_t tol_d;\r
-                               uint16_t r_day_max;\r
-                               uint16_t r_week_max;\r
+                       union{\r
+                               uint8_t page4[8];  //33\r
+                               struct {\r
+                                       uint16_t tol_s8;\r
+                                       uint16_t tol_d;\r
+                                       uint16_t r_day_max;\r
+                                       uint16_t r_week_max;\r
+                               };\r
                        };\r
+                       uint8_t page5[8];  //41\r
+                       uint8_t page6[8];  //49\r
+                       uint8_t page7[8];  //57\r
+                       \r
+                       #endif\r
                };\r
-               uint8_t page5[8];  //41\r
-               uint8_t page6[8];  //49\r
-               uint8_t page7[8];  //57\r
+       } pack2_t;\r
+       volatile pack2_t pack2;\r
+\r
+\r
+\r
+\r
+       volatile int16_t am2302_temp;\r
+       volatile uint16_t am2302_hum;\r
+\r
+\r
+       uint8_t userRegister[1];\r
+       int16_t sRH,sT;\r
+       double temperatureC,humidityRH,hhum;\r
+       volatile double l;\r
+\r
+\r
+       uint16_t weekmaxarr[8];\r
+\r
+       //Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte\r
+       inline double interp(double t, double h) {\r
+               double h2;\r
+               double t2;\r
+               h2=h*h;\r
+               t2=t*t;\r
+               return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591;\r
+       }\r
+\r
+       double R0;\r
+       uint16_t mr;\r
+       uint8_t startup=10;\r
+       double ip;\r
+       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
-               #endif\r
-       };\r
-} pack2_t;\r
-volatile pack2_t pack2;\r
-\r
-\r
-\r
-\r
-volatile int16_t am2302_temp;\r
-volatile uint16_t am2302_hum;\r
-\r
-\r
-uint8_t userRegister[1];\r
-int16_t sRH,sT;\r
-double temperatureC,humidityRH,hhum;\r
-double l;\r
-\r
-\r
-uint16_t weekmaxarr[8];\r
-\r
-//Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte\r
-inline double interp(double t, double h) {\r
-       double h2;\r
-        double t2;\r
-       h2=h*h;\r
-       t2=t*t;\r
-       return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591;\r
-}\r
-\r
-double R0;\r
-uint16_t mr;\r
-uint8_t startup=10;\r
-double ip;\r
-\r
-\r
-int testSW(void) {\r
-       uint8_t r;\r
-       DDRB&=~(1<<PORTB0);  //Eingang\r
-        __asm__ __volatile__ ("nop"); \r
-        PORTB|=(1<<PORTB0); //Pullup\r
-        __asm__ __volatile__ ("nop"); \r
-        __asm__ __volatile__ ("nop"); \r
-        __asm__ __volatile__ ("nop"); \r
-        __asm__ __volatile__ ("nop"); \r
-        __asm__ __volatile__ ("nop"); \r
-        r=PINB&(1<<PORTB0);\r
-        __asm__ __volatile__ ("nop"); \r
-        PORTB&=~(1<<PORTB0); \r
-        __asm__ __volatile__ ("nop"); \r
-       DDRB|=(1<<PORTB0);  //Eingang\r
-       return (r==0);  //Offen mal HIH4030\r
-        \r
-        \r
-}\r
-\r
-#define EEPROM_R0 0\r
-#define EEPROM_R0d 2\r
-#define EEPROM_R0w 4\r
-#define EEPROM_dol 6\r
-\r
-\r
-uint16_t readEEPROM(uint8_t addr,uint16_t def) {\r
-       uint16_t hr;\r
-       while(EECR & (1<<EEPE));\r
-       EEARL=addr+1;\r
-       EECR |= (1<<EERE);\r
-       hr=EEDR;\r
-       if (hr!=0xFF) {\r
-               hr=hr<<8;\r
+               \r
+       }\r
+\r
+       #define EEPROM_R0 0\r
+       #define EEPROM_R0d 2\r
+       #define EEPROM_R0w 4\r
+       #define EEPROM_dol 6\r
+\r
+\r
+       uint16_t readEEPROM(uint8_t addr,uint16_t def) {\r
+               uint16_t hr;\r
                while(EECR & (1<<EEPE));\r
-               EEARL=addr;\r
+               EEARL=addr+1;\r
                EECR |= (1<<EERE);\r
-               hr|=EEDR;\r
-               return hr;\r
-       }\r
-       return def;\r
-}\r
-\r
-void writeEEPROM(uint8_t addr,uint16_t val) {\r
-       while(EECR & (1<<EEPE));\r
-       EECR = (0<<EEPM1)|(0<<EEPM0);\r
-       EEARL = addr;\r
-       EEDR = val&0xFF;\r
-       EECR |= (1<<EEMPE);\r
-       EECR |= (1<<EEPE);\r
-       while(EECR & (1<<EEPE));\r
-       EECR = (0<<EEPM1)|(0<<EEPM0);\r
-       EEARL = addr+1;\r
-       EEDR = val>>8;\r
-       EECR |= (1<<EEMPE);\r
-       EECR |= (1<<EEPE);\r
-}\r
-\r
-int main(void){\r
-       PORTA=0xFF;\r
-       PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
-       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
-       OWINIT();\r
-       DDRB|=(1<<PINB1);//Ausgang und 1\r
-       DDRA|=(1<<PINA0);\r
-       \r
-       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
-       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
-       //(1<<WDP0) |(1<<WDP2) | (1<<WDP1);    // Set Timeout to ~2 seconds\r
-       (1<<WDP3) | (1<<WDP0);    // Set Timeout to ~8 seconds\r
-\r
-       MCUSR=0;\r
-\r
-       ADMUX=0b00001110; //ADC1 +   ADC3 -\r
-       ADCSRA = (1<<ADEN);//|\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
-\r
-       pack2.cmode=0;\r
-       pack2.R0=readEEPROM(EEPROM_R0,1);\r
-       R0=pack2.R0/100.0;\r
-               \r
-       pack2.r_day_max=readEEPROM(EEPROM_R0d,1);\r
-       pack2.r_week_max=readEEPROM(EEPROM_R0w,1);\r
-       pack2.tol_d=readEEPROM(EEPROM_dol,0); \r
-       pack2.tol_s8=0;  //Tag faengt mit Einschalten an\r
-       for(uint8_t i=0;i<7;i++) {\r
-               weekmaxarr[i]=pack2.r_week_max;\r
+               hr=EEDR;\r
+               if (hr!=0xFF) {\r
+                       hr=hr<<8;\r
+                       while(EECR & (1<<EEPE));\r
+                       EEARL=addr;\r
+                       EECR |= (1<<EERE);\r
+                       hr|=EEDR;\r
+                       return hr;\r
+               }\r
+               return def;\r
        }\r
 \r
-       if (testSW()) {\r
-               config_info2[5]=8;\r
-       }else{\r
-               config_info2[5]=7;\r
+       void writeEEPROM(uint8_t addr,uint16_t val) {\r
+               while(EECR & (1<<EEPE));\r
+               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+               EEARL = addr;\r
+               EEDR = val&0xFF;\r
+               EECR |= (1<<EEMPE);\r
+               EECR |= (1<<EEPE);\r
+               while(EECR & (1<<EEPE));\r
+               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+               EEARL = addr+1;\r
+               EEDR = val>>8;\r
+               EECR |= (1<<EEMPE);\r
+               EECR |= (1<<EEPE);\r
        }\r
 \r
-       USI_TWI_Master_Initialise();\r
-       \r
-       SHT2x_SoftReset();\r
-       SHT2x_ReadUserRegister(userRegister);\r
-       SHT2x_WriteUserRegister(userRegister); //write changed user reg\r
-       gcontrol=1;\r
-       sei();\r
-       //DDRB|=(1<<PINB1);\r
-    while(1)   {\r
-               if (pack1.config==0x1F) {\r
-                       pack1.config=0x7F;\r
-                       R0=1;\r
-                       pack2.R0=0;\r
-                       writeEEPROM(EEPROM_R0,0);\r
-               } \r
-               if (pack1.config==0x05) {\r
-                       pack1.config=0x7F;                              \r
-                       pack2.r_day_max=1;\r
-                       pack2.r_week_max=1;\r
-                       pack2.tol_d=0;\r
-                       pack2.tol_s8=0;  //Tag faengt mit Einschalten an        \r
-                       R0=1;   \r
-                       writeEEPROM(EEPROM_R0,0xFF);\r
-                       writeEEPROM(EEPROM_R0d,0xFF);  //Maximum des Tages\r
-                       writeEEPROM(EEPROM_R0w,0xFF); //Maximum der Letzten 7 Tage\r
-                       writeEEPROM(EEPROM_dol,0xFF); //Anzahl der Betriebstage         \r
-                       for(uint8_t i=0;i<7;i++) {\r
-                               weekmaxarr[i]=1;\r
-                       }                               \r
-               } \r
-               if (wdcounter>0) {\r
-                       pack2.tol_s8++;\r
-                       if (pack2.tol_s8>(10000))  {//10800 ist theortisch der Tag aber meistens zu lang\r
-                               pack2.tol_s8=0;\r
-                               pack2.tol_d++;  //rund 180 Jahre :-)\r
-                               pack2.r_week_max=0;\r
-                               weekmaxarr[7]=pack2.r_day_max;\r
-                               for(uint8_t i=0;i<7;i++) {\r
-                                       weekmaxarr[i]=weekmaxarr[i+1];\r
-                                       //maximum of week\r
-                                       if (weekmaxarr[i]>pack2.r_week_max) pack2.r_week_max=weekmaxarr[i];\r
-                               }\r
-                               if (pack2.tol_d>7) {\r
-                                       pack2.R0=pack2.r_week_max;\r
-                               } else {\r
-                                       pack2.R0=pack2.r_day_max;\r
-                               }\r
-                               //R0=//R0-0.5*(pack2.R0/100-R0);\r
-                               R0=R0-(R0-pack2.R0/100.0)*0.5   ;\r
-                               pack2.R0=R0*100;\r
-                               writeEEPROM(EEPROM_R0,pack2.R0);\r
-                               writeEEPROM(EEPROM_R0d,pack2.r_day_max);  //Maximum des Tages\r
-                               writeEEPROM(EEPROM_R0w,pack2.r_week_max); //Maximum der Letzten 7 Tage\r
-                               writeEEPROM(EEPROM_dol,pack2.tol_d); //Anzahl der Betriebstage\r
-                               pack2.r_day_max=0;\r
-                       }\r
-                       if (startup!=0) startup--;\r
-                       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
-                       ip=interp(temperatureC,humidityRH);\r
-                       pack2.ip=ip*1000;\r
-                       humidityRH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
-                       //humidityRH=humidityRH*10.0;\r
-                       temperatureC =temperatureC *10.0-2;\r
-\r
-\r
-                       if (testSW()) {\r
-                                am2302_hum= humidityRH*10.0;\r
-                                am2302_temp=temperatureC*25.6;\r
-                                //am2302_temp=am2302_temp-45;\r
-                                config_info2[5]=8;     \r
+       int main(void){\r
+               PORTA=0xFF-(1<<PINA1);\r
+               PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+               DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+               OWINIT();\r
+               DDRB|=(1<<PINB1);//Ausgang und 1\r
+               DDRA|=(1<<PINA0);\r
+               \r
+               WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+               WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+               //(1<<WDP0) |(1<<WDP2) | (1<<WDP1);    // Set Timeout to ~2 seconds\r
+               (1<<WDP3) | (1<<WDP0);    // Set Timeout to ~8 seconds\r
+\r
+               MCUSR=0;\r
+\r
+               //ADMUX=0b00001110; //ADC1 +   ADC3 -\r
+               ADMUX=0x01 ; //PA3 single and  3V\r
+               ADCSRA = (1<<ADEN)|(1<<ADPS1)|(1<<ADPS0);//|\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
+\r
+               pack2.cmode=0;\r
+               pack2.R0=readEEPROM(EEPROM_R0,1);\r
+               R0=pack2.R0/100.0;\r
+               \r
+               pack2.r_day_max=readEEPROM(EEPROM_R0d,1);\r
+               pack2.r_week_max=readEEPROM(EEPROM_R0w,1);\r
+               pack2.tol_d=readEEPROM(EEPROM_dol,0);\r
+               pack2.tol_s8=0;  //Tag faengt mit Einschalten an\r
+               for(uint8_t i=0;i<7;i++) {\r
+                       weekmaxarr[i]=pack2.r_week_max;\r
+               }\r
+\r
+               if (testSW()) {\r
+                       config_info2[5]=12;\r
                        }else{\r
-                               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
-                               config_info2[5]=7;\r
+                       config_info2[5]=7;\r
+               }\r
+\r
+               USI_TWI_Master_Initialise();\r
+               \r
+               initSHT2x();\r
+               _delay_ms(100);\r
+               gcontrol=1;\r
+               sei();\r
+               while(1)   {\r
+                       if (pack1.config==0x1F) {  //Reset R0\r
+                               pack1.config=0x7F;\r
+                               R0=1;\r
+                               pack2.R0=0;\r
+                               writeEEPROM(EEPROM_R0,0);\r
                        }\r
-                       //PORTB&=~(1<<PINB1);\r
-                       mr=0;\r
-//Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________\r
-                       PORTB&=~(1<<PINB1); //Auf 0 Ziehen\r
-                       _delay_us(150);\r
-                       _delay_us(150);\r
-                       PORTB|=(1<<PINB1);\r
-//ENDE Kritische Sektion !______________________________\r
-                       //l=mr/2.0*2.048/4096; \r
-                       // l maximal 2  mr max 4096  //mr 2V=8000 \r
-                       \r
-                       if (pack2.cmode) { //cmode=0 V 0..2 V cmode=1 V 1.5..3.5V\r
-                               //l+=1.5; //Spannung real\r
-                               mr+=6000;\r
-                       } \r
-                       //if (l>1.8) {\r
-                       if (mr>7200) {                          \r
-                               if (pack2.cmode==0) {\r
-//                                     MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_CH1);\r
-                                       pack2.cmode=1;\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
-                       //if (l<1.6) {\r
-                       if (mr<6400) {  \r
-                               if (pack2.cmode==1) {\r
-       //                              MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M);\r
-                                       pack2.cmode=0;\r
+                       if (wdcounter>0) {  //8s\r
+                               pack2.tol_s8++;\r
+                               if (pack2.tol_s8>(10000))  {//10800 ist theortisch der Tag aber meistens zu lang\r
+                                       pack2.tol_s8=0;\r
+                                       pack2.tol_d++;  //rund 180 Jahre :-)\r
+                                       pack2.r_week_max=0;\r
+                                       weekmaxarr[7]=pack2.r_day_max;\r
+                                       for(uint8_t i=0;i<7;i++) {\r
+                                               weekmaxarr[i]=weekmaxarr[i+1];\r
+                                               //maximum of week\r
+                                               if (weekmaxarr[i]>pack2.r_week_max) pack2.r_week_max=weekmaxarr[i];\r
+                                       }\r
+                                       if (pack2.tol_d>7) {\r
+                                               pack2.R0=pack2.r_week_max;\r
+                                       } else {\r
+                                               pack2.R0=pack2.r_day_max;\r
+                                       }\r
+                                       //R0=//R0-0.5*(pack2.R0/100-R0);\r
+                                       R0=R0-(R0-pack2.R0/100.0)*0.5   ;\r
+                                       pack2.R0=R0*100;\r
+                                       writeEEPROM(EEPROM_R0,pack2.R0);\r
+                                       writeEEPROM(EEPROM_R0d,pack2.r_day_max);  //Maximum des Tages\r
+                                       writeEEPROM(EEPROM_R0w,pack2.r_week_max); //Maximum der Letzten 7 Tage\r
+                                       writeEEPROM(EEPROM_dol,pack2.tol_d); //Anzahl der Betriebstage\r
+                                       pack2.r_day_max=0;\r
+                               }\r
+                               if (startup!=0) startup--;\r
+                               getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                               ip=interp(temperatureC,humidityRH);\r
+                               pack2.ip=ip*1000;\r
+                               double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
+                               double TC =temperatureC *10.0-2;\r
+\r
+\r
+                               if (testSW()) {\r
+                                       am2302_hum=RH;\r
+                                       am2302_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
+                                       config_info2[5]=7;\r
                                }\r
+                               mr=0;\r
+                               //Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________\r
+                               PORTB&=~(1<<PINB1); //Auf 0 Ziehen\r
+                               _delay_us(500);\r
+                               for(uint8_t i=0;i<32;i++) {\r
+                                       ADCSRA|=(1<<ADSC);\r
+                                       while ((ADCSRA&(1<<ADSC)));\r
+                                       mr+=ADC;\r
+                                }\r
+                               PORTB|=(1<<PINB1);\r
+                               //ENDE Kritische Sektion !______________________________\r
+\r
+                               pack2.VS=mr*3/128;  //VS in Volt = VS/256\r
+                               l=mr*3.0/32768.0;  //Spannung in v\r
+                               l=( 3/l- 1) *30; //l is resistance\r
+                               if (lainit) {\r
+                                       la[0]=la[1]=la[2]=la[3]=l;  //smaller code\r
+                                       lainit=0;\r
+                               } else {\r
+                                       la[0]=la[1];\r
+                                       la[1]=la[2];\r
+                                       la[2]=la[3];\r
+                                       la[3]=l;\r
+                               }\r
+                               double lasum=la[0]+la[1]+la[2]+la[3];\r
+                               l=lasum/4.0;\r
+                               \r
+                               pack2.current=l*100;\r
+                               \r
+                               l=l/ip;\r
                                \r
+                               if (startup==0){\r
+                                       if (l>R0) {\r
+                                               R0=l;\r
+                                               pack2.R0=R0*100;\r
+                                               writeEEPROM(EEPROM_R0,pack2.R0);\r
+\r
+                                       }\r
+                                       if (l*100>pack2.r_day_max) {\r
+                                               pack2.r_day_max=l*100;\r
+                                       }\r
+                               } else if (l<R0) l=R0; //negative Werte am Anfang verhintern\r
+                               l=exp((1-(l/R0))*6.05)-1;// exp((1-($val)/55)*5.75);  (5.75 geht Ã¼ber 125 6.05 geht bis 240... mittlere Linie im Datenblatt)\r
+                               l=l*8.0; //fuer DS18B20*/\r
+                               wdcounter=0;\r
                                \r
                        }\r
-                       pack2.VS=mr*5/2;\r
-                       l=mr/4000.0;\r
-                       l=( 3/l- 1) *30;\r
-                       pack2.current=l*100;\r
                        \r
-                       l=l/ip;\r
-                       \r
-                       if (startup==0){\r
-                               if (l>R0) {\r
-                                       R0=l;\r
-                                       pack2.R0=R0*100;\r
-                                       writeEEPROM(EEPROM_R0,pack2.R0);\r
+                       if (gcontrol==1) {\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
+                               EXTERN_SLEEP();\r
+                       }\r
+                       if ((gcontrol==2)||(gcontrol==3)) {\r
+                               gcontrol=0;\r
+                               \r
+                       }\r
 \r
-                               }\r
-                               if (l*100>pack2.r_day_max) {\r
-                                       pack2.r_day_max=l*100;\r
-                               }\r
-                       } else if (l<R0) l=R0; //negative Werte am Anfang verhintern\r
-                       l=R0/l;\r
-                       l=log(l);\r
-                       l=l*160*4; //fuer DS18B20\r
-                       wdcounter=0;\r
-                       \r
-               }\r
-       \r
-               if (gcontrol==1) {\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
-                       EXTERN_SLEEP();         \r
-               }\r
-               if ((gcontrol==2)||(gcontrol==3)) {\r
-                       gcontrol=0;\r
                        \r
-               }\r
-\r
-               \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\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
+                       #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
+                       #endif\r
+                       {\r
+\r
+                               MCUCR|=(1<<SE)|(1<<SM1);\r
+                               MCUCR&=~(1<<ISC01);\r
+                       } else {\r
+                               MCUCR|=(1<<SE);\r
+                               MCUCR&=~(1<<SM1);\r
+                       }\r
+                       asm("SLEEP");\r
                }\r
-               asm("SLEEP");\r
-   }\r
 \r
 \r
-}\r
+       }\r
index a85c988..3726641 100644 (file)
@@ -269,7 +269,7 @@ int main(void){
        }\r
 \r
        if (testSW()) {\r
-               config_info2[5]=8;\r
+               config_info2[5]=12;\r
        }else{\r
                config_info2[5]=7;\r
        }\r
@@ -285,13 +285,13 @@ int main(void){
        sei();\r
        //DDRB|=(1<<PINB1);\r
     while(1)   {\r
-               if (pack1.config==0x1F) {\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) {\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
@@ -306,7 +306,7 @@ int main(void){
                                weekmaxarr[i]=1;\r
                        }                               \r
                } \r
-               if (wdcounter>0) {\r
+               if (wdcounter>0) {  //8s\r
                        pack2.tol_s8++;\r
                        if (pack2.tol_s8>(10000))  {//10800 ist theortisch der Tag aber meistens zu lang\r
                                pack2.tol_s8=0;\r
@@ -337,15 +337,13 @@ int main(void){
                        ip=interp(temperatureC,humidityRH);\r
                        pack2.ip=ip*1000;\r
                        double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
-                       //humidityRH=humidityRH*10.0;\r
                        double TC =temperatureC *10.0-2;\r
 \r
 \r
                        if (testSW()) {\r
-                                am2302_hum=RH*10.0;\r
+                                am2302_hum=RH;\r
                                 am2302_temp=TC*25.6;\r
-                                //am2302_temp=am2302_temp-45;\r
-                                config_info2[5]=8;     \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
@@ -353,7 +351,6 @@ int main(void){
                                am2302_temp=TC*25.6;\r
                                config_info2[5]=7;\r
                        }\r
-                       //PORTB&=~(1<<PINB1);\r
                        mr=0;\r
 //Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________\r
                        PORTB&=~(1<<PINB1); //Auf 0 Ziehen\r
@@ -404,7 +401,8 @@ int main(void){
                                        pack2.r_day_max=l*100;\r
                                }\r
                        } else if (l<R0) l=R0; //negative Werte am Anfang verhintern\r
-                       l=exp((1-(l/R0))*6.05);// exp((1-($val)/55)*5.75);  (5.75 geht Ã¼ber 125 6.05 geht bis 240... mittlere Linie im Datenblatt)\r
+                       l=exp((1-(l/R0))*6.05)-1;// exp((1-($val)/55)*5.75);  (5.75 geht Ã¼ber 125 6.05 geht bis 240... mittlere Linie im Datenblatt)\r
+                       //l=(l/R0*100.0);\r
                        l=l*8; //fuer DS18B20\r
                        wdcounter=0;\r
                        \r
diff --git a/DS2423_DS2413/DS2423_DS2413.atsln b/DS2423_DS2413/DS2423_DS2413.atsln
new file mode 100644 (file)
index 0000000..0c04b02
--- /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}") = "DS2423_DS2413", "DS2423_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/DS2423_DS2413/DS2423_DS2413.c b/DS2423_DS2413/DS2423_DS2413.c
new file mode 100644 (file)
index 0000000..29800f8
--- /dev/null
@@ -0,0 +1,279 @@
+// 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
+\r
+extern void OWINIT(void);\r
+extern void EXTERN_SLEEP(void);\r
+#define FHEM_PLATINE\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
+uint8_t config_info1[26]={9,13,9,13,9,13,9,13,0x02,19,19,19,19,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
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+\r
+\r
+uint8_t pin_state;\r
+uint8_t pin_set;\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[45];\r
+       struct {\r
+               uint16_t addr;\r
+               uint8_t status;\r
+               uint8_t scratch[32];//3\r
+               uint32_t counter;  //35\r
+               uint32_t zero;   //39\r
+               uint16_t crc;  //43\r
+       };\r
+} counterpack_t;\r
+counterpack_t pack1;\r
+\r
+\r
+\r
+volatile uint8_t lastcps;\r
+typedef union {\r
+       uint32_t c32[4];\r
+       uint8_t c8[16];\r
+} counters_t;\r
+\r
+volatile counters_t counters1;\r
+\r
+\r
+volatile uint8_t istat;\r
+volatile uint8_t changefromeeprom;\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_CH3 (1<<PINA2)\r
+#define PIN_CH2 (1<<PINA1)\r
+#define PIN_PIOA (1<<PINA3)\r
+#define PIN_PIOB (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
+#else\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
+#endif\r
+\r
+#define TEST_TIMER  ((TIMSK0 & (1<<TOIE0))==0)\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]++;     }\r
+       if (((PIN_REG&PIN_CH3)==0)&&((istat&PIN_CH3)==PIN_CH3)) {       counters1.c32[3]++;     }\r
+       if ((PIN_REG&PIN_PIOA)==0)      pin_state&=~0x1; else pin_state|=0x01;\r
+       if ((PIN_REG&PIN_PIOB)==0)      pin_state&=~0x4; else pin_state|=0x04;\r
+       //Reset Switch on the FHEM_BOARD\r
+       #ifdef FHEM_PLATINE  //clear counter\r
+       if ((((PINA&(1<<PINA6)))==0)&&((istat&(1<<PINA6))==(1<<PINA6)))   {\r            _delay_ms(100);\r                if (((PINA&(1<<PINA6)))==0) {\r                  LPORT_CH3|=LPIN_CH3;\r                   _delay_ms(100);\r                        counters1.c32[2]=0;\r                    counters1.c32[3]=0;\r                    //count Resets\r                 counters1.c32[0]++;\r                    LPORT_CH3&=~LPIN_CH3;\r          }\r              GIFR|=(1<<PCIF0);\r      }\r      #endif\r\r
+       istat=PIN_REG;\r
+       changefromeeprom=1;\r
+}\r
+\r
+\r
+ISR(ANA_COMP_vect) {\r
+       if (changefromeeprom==0) return;\r
+       if ((ACSR&(1<<ACO))!=0) {\r
+               _delay_ms(5);\r
+               if ((ACSR&(1<<ACO))!=0) {\r
+                       counters1.c32[1]++;\r                    CLKPR=0x80;//Switch to 4 MHz\r
+                       CLKPR=01;\r
+                       \r
+                       PORTB|=(1<<PINB1);\r
+                       EEARH=0;\r
+                       for(uint8_t i=0;i<16;i++) {\r
+                               uint8_t addr=i;\r
+                               while(EECR & (1<<EEPE));\r
+                               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+                               EEARL = i;\r
+                               EEDR = counters1.c8[addr];\r
+                               EECR |= (1<<EEMPE);\r
+                               EECR |= (1<<EEPE);\r
+                       }\r
+                       changefromeeprom=0;\r
+                       PORTB&=~(1<<PINB1);\r
+                       CLKPR=0x80;\r
+                       CLKPR=0;\r
+                       GIFR|=(1<<INTF0);\r
+               }\r
+       }\r
+       \r
+}\r
+\r
+\r
+int main(void){\r
+       #ifdef FHEM_PLATINE\r
+       PRR|=(1<<PRUSI);  //Switch off usi, dont switch of ADC cause Multiplexer is used for the correct AIN1 pin\r
+       #else\r
+       PRR|=(1<<PRUSI)|(1<<PRADC);  //Switch off usi and adc for save Power\r
+       #endif\r
+       OWINIT();\r
+       \r
+       pack1.zero=0;\r
+       counters1.c32[0]=0;\r
+       counters1.c32[2]=0;\r
+       counters1.c32[1]=0;\r
+       counters1.c32[3]=0;\r
+       \r
+       changefromeeprom=1;\r
+       #if  defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+\r
+       PORTB|=0xFF-(1<<PINB2); //Make PullUp an all Pins but not OW_PIN\r
+       PORTA|=0xFF;\r
+\r
+       #ifndef _CPULLUP_  // pullup\r
+       PORTA&=~(PIN_PIOA|PIN_PIOB);\r
+       PORTA&=~(PIN_CH2|PIN_CH3);\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
+\r
+       GIMSK|=(1<<PCIE0);\r
+       PCMSK0=(PIN_PIOA|PIN_PIOB|PIN_CH2|PIN_CH3); //Nicht ganz korrekt aber die Bits liegen gleich\r
+\r
+       \r
+       \r
+       istat=PINA;\r
+       #endif\r
+\r
+       EEARH=0;\r
+       uint8_t addr;\r
+       for(uint8_t i=0;i<16;i++) {\r
+               addr=i;\r
+               while(EECR & (1<<EEPE));\r
+               EEARL=i;\r
+               EECR |= (1<<EERE);\r
+               counters1.c8[addr]=EEDR;\r
+       }\r
+       changefromeeprom=0;  //Daten neu eingelesen\r
+       for (uint8_t i=0;i<4;i++) {\r
+               if (counters1.c32[i]==0xFFFFFFFF) {\r
+                       counters1.c32[i]=0;\r
+                       changefromeeprom=1;  //Daten geaendert\r
+               }\r
+               //counters.c32[i]=0;\r
+       }\r
+\r
+       //ACSR|=(1<<ACD);  //Disable Comparator\r
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+#ifdef FHEM_PLATINE\r
+       DIDR0|=(1<<ADC0D);\r
+       PORTA&=~(1<<PINA0);//Disable Pullup\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
+       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
+       //Switch std AIN1 to A0\r
+       ADCSRA&=~(1<<ADEN);\r
+       ADCSRB=(1<<ACME);\r
+       ADMUX=0;\r
+       //Taster\r
+       DDRA&=~(1<<PINA6);\r     PCMSK0|=(1<<PCINT6);\r   PORTA|=(1<<PINA6); //Pullup\r
+\r
+\r
+       LPORT_CH0|=LPIN_CH0;\r   _delay_ms(500);\r        LPORT_CH0&=~LPIN_CH0;\r
+#endif\r
+       pin_state=0x0F;\r
+       sei();\r
+       while(1)   {\r
+\r
+               if (pin_set&1) {\r
+                       counters1.c32[3]=0;\r
+                       pin_set&=~1;\r
+                       changefromeeprom=1;\r
+               }\r
+               if (pin_set&2) {\r
+                       counters1.c32[2]=0;\r
+                       pin_set&=~2;\r
+                       changefromeeprom=1;\r
+               }\r
+               /*if (counters1.c32[2]==0) {\r
+                       pin_state|=2;\r
+               } else pin_state&=~2;\r
+               if (counters1.c32[3]==0) {\r
+                       pin_state|=8;\r
+               } else pin_state&=~8;*/\r
+\r
+#ifdef FHEM_PLATINE\r
+               if (LPORT_CH2&LPIN_CH2) {\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
+                               counters1.c32[i]=0;\r
+                       }\r
+                       //count Resets\r                 counters1.c32[0]++;\r                    changefromeeprom=1;\r
+               }\r
+#endif\r
+               MCUCR|=(1<<SE);\r
+               MCUCR&=~(1<<SM1);\r
+               asm("SLEEP");\r
+       }\r
+\r
+\r
+}\r
+\r
diff --git a/DS2423_DS2413/DS2423_DS2413.cproj b/DS2423_DS2413/DS2423_DS2413.cproj
new file mode 100644 (file)
index 0000000..7d5dc2b
--- /dev/null
@@ -0,0 +1,143 @@
+<?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>DS2423_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>1</eraseonlaunchrule>\r
+    <AsfFrameworkConfig>\r
+      <framework-data>\r
+        <options />\r
+        <configurations />\r
+        <files />\r
+        <documentation help="" />\r
+        <offline-documentation help="" />\r
+        <dependencies>\r
+          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+        </dependencies>\r
+      </framework-data>\r
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>debugWIRE</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
+      <ToolNumber>J41800000789</ToolNumber>\r
+      <ToolName>Atmel-ICE</ToolName>\r
+    </com_atmel_avrdbg_tool_atmelice>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\r
+    <com_atmel_avrdbg_tool_simulator>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>\r
+        </InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType>com.atmel.avrdbg.tool.simulator</ToolType>\r
+      <ToolNumber>\r
+      </ToolNumber>\r
+      <ToolName>Simulator</ToolName>\r
+    </com_atmel_avrdbg_tool_simulator>\r
+    <ExternalProgrammingToolCommand />\r
+    <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>DEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\OWDS2423_DS2413.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2423_DS2413.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2423_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
diff --git a/DS2423_DS2413/Makefile b/DS2423_DS2413/Makefile
new file mode 100644 (file)
index 0000000..a8708ea
--- /dev/null
@@ -0,0 +1,202 @@
+# Hey Emacs, this is a -*- makefile -*-
+
+# AVR-GCC Makefile template, derived from the WinAVR template (which
+# is public domain), believed to be neutral to any flavor of "make"
+# (GNU make, BSD make, SysV make)
+
+
+MCU = attiny84
+FORMAT = ihex
+TARGET =DS2423_DS2423
+SRC = DS2423_DS2423.c
+ASRC = ../common/OWDS2423_DS2423.S
+
+# Name of this Makefile (used for "make depend").
+MAKEFILE = Makefile
+
+
+CFLAGS = -x c -funsigned-char -funsigned-bitfields -I. -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall   -std=gnu99 -MD -MP 
+
+#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
+
+
+#Additional libraries.
+
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+PRINTF_LIB = 
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+SCANF_LIB = 
+
+MATH_LIB = -lm
+
+# External memory options
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref
+#LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+LDFLAGS = -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=$(MCU)
+
+# Programming support using avrdude. Settings and variables.
+
+#AVRDUDE_PROGRAMMER = stk500
+#AVRDUDE_PORT = /dev/term/a
+
+#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+#AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+#AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
+
+
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+#AVRDUDE = avrdude
+REMOVE = rm -f
+MV = mv -f
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+# Default target.
+all: build
+
+build: elf hex eep
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+#eep: $(TARGET).eep
+lss: $(TARGET).lss 
+sym: $(TARGET).sym
+
+
+# Program the device.  
+program: $(TARGET).hex $(TARGET).eep
+       $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000 
+
+
+coff: $(TARGET).elf
+       $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+       $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
+
+
+.SUFFIXES: .elf .hex .eep .lss .sym
+
+.elf.hex:
+       $(OBJCOPY) -O $(FORMAT) $< $@
+#      $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+.elf.eep:
+       -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+       --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+.elf.lss:
+       $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+.elf.sym:
+       $(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+$(TARGET).elf: $(OBJ)
+       $(CC)  $(OBJ) --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+.c.o:
+       $(CC) -c $(ALL_CFLAGS) $< -o $@ 
+
+
+# Compile: create assembler files from C source files.
+.c.s:
+       $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+.S.o:
+       $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+# Target: clean project.
+clean:
+       $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
+       $(TARGET).map $(TARGET).sym $(TARGET).lss \
+       $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d)
+
+depend:
+       if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
+       then \
+               sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
+                       $(MAKEFILE).$$$$ && \
+               $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
+       fi
+       echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
+               >> $(MAKEFILE); \
+       $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
+
+.PHONY:        all build elf hex eep lss sym program coff extcoff clean depend
+
+
diff --git a/DS2423_DS2423/DS2423_DS2423.atsln b/DS2423_DS2423/DS2423_DS2423.atsln
new file mode 100644 (file)
index 0000000..c3fc382
--- /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}") = "DS2423_DS2423", "DS2423_DS2423.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/DS2423_DS2423/DS2423_DS2423.c b/DS2423_DS2423/DS2423_DS2423.c
new file mode 100644 (file)
index 0000000..68fb010
--- /dev/null
@@ -0,0 +1,291 @@
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgment: 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
+\r
+extern void OWINIT(void);\r
+extern void EXTERN_SLEEP(void);\r
+\r
+//#define FHEM_PLATINE\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
+#if RAMEND>260 //defined(__AVR_ATtiny84__)   ||defined(__AVR_ATtiny84A__)  \r
+uint8_t config_info1[26]={9,13,9,13,9,13,9,13,0x02,19,19,19,19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //+2 for CRC\r
+uint8_t config_info2[26]={9,13,9,13,9,13,9,13,0x02,19,19,19,19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //+2 for CRC\r
+#endif\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
+\r
+\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[45];\r
+       struct {\r
+               uint16_t addr;\r
+               uint8_t status;\r
+               uint8_t scratch[32];//3\r
+               uint32_t counter;  //35\r
+               uint32_t zero;   //39\r
+               uint16_t crc;  //43\r
+       };\r
+} counterpack_t;\r
+counterpack_t pack1;\r
+\r
+//The Memory of both  Chips is the same, beause of the small memory of ATTiny44\r
+#define pack2 pack1 \r
+\r
+volatile uint8_t lastcps;\r
+typedef union {\r
+       uint32_t c32[4];\r
+       uint8_t c8[16];\r
+} counters_t;\r
+\r
+volatile counters_t counters1,counters2;\r
+\r
+\r
+volatile uint8_t istat;\r
+volatile uint8_t changefromeeprom;\r
+\r
+#if  defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||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_CH3 (1<<PINA2)\r
+#define PIN_CH2 (1<<PINA1)\r
+#define PIN_CH1 (1<<PINA4)\r
+#define PIN_CH0 (1<<PINA3)\r
+//LEDS\r#define LPIN_CH2 (1<<PINB0)\r#define LDD_CH2 DDRB\r#define LPORT_CH2 PORTB\r#define LPIN_CH3 (1<<PINA5)\r#define LDD_CH3 DDRA\r#define LPORT_CH3 PORTA\r#define LPIN_CH0 (1<<PINA7)\r#define LDD_CH0 DDRA\r#define LPORT_CH0 PORTA\r#define LPIN_CH1 (1<<PINB1)\r#define LDD_CH1 DDRB\r#define LPORT_CH1 PORTB\r
+\r
+#define LED2_ON LPORT_CH2|=LPIN_CH2;\r
+#else\r
+#define LED2_ON\r
+#define PIN_CH2 (1<<PINA4)\r
+#define PIN_CH3 (1<<PINA5)\r
+#define PIN_CH0 (1<<PINA6)\r
+#define PIN_CH1 (1<<PINA7)\r
+#endif\r
+\r
+#define TEST_TIMER  ((TIMSK0 & (1<<TOIE0))==0)\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_CH0)==0)&&((istat&PIN_CH0)==PIN_CH0)) {       counters2.c32[2]++;     LED2_ON}\r
+       if (((PIN_REG&PIN_CH1)==0)&&((istat&PIN_CH1)==PIN_CH1)) {       counters2.c32[3]++;     LED2_ON}\r
+       \r
+       //Reset Switch on the FHEM_BOARD\r
+       #ifdef FHEM_PLATINE  //clear counter\r
+       if ((((PINA&(1<<PINA6)))==0)&&((istat&(1<<PINA6))==(1<<PINA6)))   {\r            _delay_ms(100);\r                if (((PINA&(1<<PINA6)))==0) {\r                  LPORT_CH3|=LPIN_CH3;\r                   _delay_ms(100);\r                        counters1.c32[2]=0;\r                    counters1.c32[3]=0;\r                    counters2.c32[2]=0;\r                    counters2.c32[3]=0;\r                    //counters1.c32[0]=0;\r                  //counters1.c32[1]=0;\r                  //counters2.c32[0]=0;\r                  //counters2.c32[1]=0;\r                  //count Resets\r                 counters1.c32[0]++;\r                    counters2.c32[0]++;\r                    LPORT_CH3&=~LPIN_CH3;\r          }\r              GIFR|=(1<<PCIF0);\r      }\r      #endif\r istat=PIN_REG;\r
+       changefromeeprom=1;\r
+\r
+}\r
+\r
+\r
+ISR(ANA_COMP_vect) {\r
+       if (changefromeeprom==0) return;\r
+       if ((ACSR&(1<<ACO))!=0) {\r
+               _delay_ms(5);\r
+               if ((ACSR&(1<<ACO))!=0) {\r
+                       //Count Savings\r
+                       counters1.c32[1]++;\r                    counters2.c32[1]=counters1.c32[1];\r                     CLKPR=0x80;//Switch to 4 MHz\r
+                       CLKPR=01;\r
+                       \r
+                       PORTB|=(1<<PINB1);\r
+                       EEARH=0;\r
+                       for(uint8_t i=0;i<16;i++) {\r
+                               uint8_t addr=i;\r
+                               while(EECR & (1<<EEPE));\r
+                               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+                               EEARL = i;\r
+                               EEDR = counters1.c8[addr];\r
+                               EECR |= (1<<EEMPE);\r
+                               EECR |= (1<<EEPE);\r
+                       }\r
+                       for(uint8_t i=16;i<32;i++) {\r
+                               uint8_t addr=i-16;\r
+                               while(EECR & (1<<EEPE));\r
+                               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+                               EEARL = i;\r
+                               EEDR = counters2.c8[addr];\r
+                               EECR |= (1<<EEMPE);\r
+                               EECR |= (1<<EEPE);\r
+                       }\r
+                       changefromeeprom=0;\r
+                       PORTB&=~(1<<PINB1);\r
+                       CLKPR=0x80;\r
+                       CLKPR=0;\r
+                       GIFR|=(1<<INTF0);\r
+               }\r
+       }\r
+       \r
+}\r
+\r
+\r
+int main(void){\r
+       #ifdef FHEM_PLATINE\r
+       PRR|=(1<<PRUSI);  //Switch off usi, dont switch of ADC cause Multiplexer is used for the correct AIN1 pin\r
+       #else\r
+       PRR|=(1<<PRUSI)|(1<<PRADC);  //Switch off usi and adc for save Power\r
+       #endif\r
+       OWINIT();\r
+       \r
+       pack1.zero=0;\r
+       pack2.zero=0;\r
+       counters1.c32[0]=0;\r
+       counters1.c32[2]=0;\r
+       counters1.c32[1]=0;\r
+       counters1.c32[3]=0;\r
+       counters2.c32[0]=0;\r
+       counters2.c32[2]=0;\r
+       counters2.c32[1]=0;\r
+       counters2.c32[3]=0;\r
+       changefromeeprom=1;\r
+       \r
+       #if  defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+\r
+       PORTB|=0xFF-(1<<PINB2); //Make PullUp an all Pins but not OW_PIN\r
+       PORTA|=0xFF;\r
+\r
+       #ifndef _CPULLUP_  // pullup\r
+       PORTA&=~(PIN_CH0|PIN_CH1);\r
+       PORTA&=~(PIN_CH2|PIN_CH3);\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
+\r
+       GIMSK|=(1<<PCIE0);\r
+       PCMSK0=(PIN_CH0|PIN_CH1|PIN_CH2|PIN_CH3); //Nicht ganz korrekt aber die Bits liegen gleich\r
+\r
+       \r
+       \r
+       istat=PINA;\r
+       #endif\r
+\r
+       EEARH=0;\r
+       uint8_t addr;\r
+       for(uint8_t i=0;i<16;i++) {\r
+               addr=i;\r
+               while(EECR & (1<<EEPE));\r
+               EEARL=i;\r
+               EECR |= (1<<EERE);\r
+               counters1.c8[addr]=EEDR;\r
+       }\r
+       for(uint8_t i=16;i<32;i++) {\r
+               addr=i-16;\r
+               while(EECR & (1<<EEPE));\r
+               EEARL=i;\r
+               EECR |= (1<<EERE);\r
+               counters2.c8[addr]=EEDR;\r
+       }\r
+       changefromeeprom=0;  //Daten neu eingelesen\r
+       for (uint8_t i=0;i<4;i++) {\r
+               if (counters1.c32[i]==0xFFFFFFFF) {\r
+                       counters1.c32[i]=0;\r
+                       changefromeeprom=1;  //Daten geaendert\r
+               }\r
+               //counters.c32[i]=0;\r
+       }\r
+       for (uint8_t i=0;i<4;i++) {\r
+               if (counters2.c32[i]==0xFFFFFFFF) {\r
+                       counters2.c32[i]=0;\r
+                       changefromeeprom=1;  //Daten geaendert\r
+               }\r
+               //counters.c32[i]=0;\r
+       }\r
+\r
+       //ACSR|=(1<<ACD);  //Disable Comparator\r
+       ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+#ifdef FHEM_PLATINE\r
+       DIDR0|=(1<<ADC0D);\r
+       PORTA&=~(1<<PINA0);//Disable Pullup\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
+       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
+       //Switch std AIN1 to A0\r
+       ADCSRA&=~(1<<ADEN);\r
+       ADCSRB=(1<<ACME);\r
+       ADMUX=0;\r
+       //Taster\r
+       DDRA&=~(1<<PINA6);\r     PCMSK0|=(1<<PCINT6);\r   PORTA|=(1<<PINA6); //Pullup\r
+\r
+\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
+               if (LPORT_CH2&LPIN_CH2) {\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
+                                       counters1.c32[i]=0;\r
+                                       counters2.c32[i]=0;\r
+                               }\r
+                               //count Resets\r                         changefromeeprom=1;\r
+                       }\r
+               }\r
+#endif\r
+               MCUCR|=(1<<SE);\r
+               MCUCR&=~(1<<SM1);\r
+               asm("SLEEP");\r
+       }\r
+\r
+\r
+}\r
diff --git a/DS2423_DS2423/DS2423_DS2423.cproj b/DS2423_DS2423/DS2423_DS2423.cproj
new file mode 100644 (file)
index 0000000..607908d
--- /dev/null
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\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>ATtiny44A</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>DS2423_DS2423</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>\r
+    </avrtool>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>\r
+        </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>\r
+    </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>0x1E930D</avrdeviceexpectedsignature>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>DEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\OWDS2423_DS2423.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2423_DS2423.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2423_DS2423.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/DS2423_DS2423/Makefile b/DS2423_DS2423/Makefile
new file mode 100644 (file)
index 0000000..a8708ea
--- /dev/null
@@ -0,0 +1,202 @@
+# Hey Emacs, this is a -*- makefile -*-
+
+# AVR-GCC Makefile template, derived from the WinAVR template (which
+# is public domain), believed to be neutral to any flavor of "make"
+# (GNU make, BSD make, SysV make)
+
+
+MCU = attiny84
+FORMAT = ihex
+TARGET =DS2423_DS2423
+SRC = DS2423_DS2423.c
+ASRC = ../common/OWDS2423_DS2423.S
+
+# Name of this Makefile (used for "make depend").
+MAKEFILE = Makefile
+
+
+CFLAGS = -x c -funsigned-char -funsigned-bitfields -I. -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall   -std=gnu99 -MD -MP 
+
+#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
+
+
+#Additional libraries.
+
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+PRINTF_LIB = 
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+SCANF_LIB = 
+
+MATH_LIB = -lm
+
+# External memory options
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref
+#LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+LDFLAGS = -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=$(MCU)
+
+# Programming support using avrdude. Settings and variables.
+
+#AVRDUDE_PROGRAMMER = stk500
+#AVRDUDE_PORT = /dev/term/a
+
+#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+#AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+#AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
+
+
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+#AVRDUDE = avrdude
+REMOVE = rm -f
+MV = mv -f
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+# Default target.
+all: build
+
+build: elf hex eep
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+#eep: $(TARGET).eep
+lss: $(TARGET).lss 
+sym: $(TARGET).sym
+
+
+# Program the device.  
+program: $(TARGET).hex $(TARGET).eep
+       $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000 
+
+
+coff: $(TARGET).elf
+       $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+       $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
+
+
+.SUFFIXES: .elf .hex .eep .lss .sym
+
+.elf.hex:
+       $(OBJCOPY) -O $(FORMAT) $< $@
+#      $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+.elf.eep:
+       -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+       --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+.elf.lss:
+       $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+.elf.sym:
+       $(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+$(TARGET).elf: $(OBJ)
+       $(CC)  $(OBJ) --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+.c.o:
+       $(CC) -c $(ALL_CFLAGS) $< -o $@ 
+
+
+# Compile: create assembler files from C source files.
+.c.s:
+       $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+.S.o:
+       $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+# Target: clean project.
+clean:
+       $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
+       $(TARGET).map $(TARGET).sym $(TARGET).lss \
+       $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d)
+
+depend:
+       if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
+       then \
+               sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
+                       $(MAKEFILE).$$$$ && \
+               $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
+       fi
+       echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
+               >> $(MAKEFILE); \
+       $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
+
+.PHONY:        all build elf hex eep lss sym program coff extcoff clean depend
+
+
index 13b33dc..11f51db 100644 (file)
@@ -54,7 +54,7 @@ extern uint8_t gcontrol;
 extern uint8_t reset_indicator;\r
 \r
 \r
-volatile uint8_t wdcounter;\r
+\r
 \r
 \r
 \r
@@ -80,7 +80,7 @@ typedef union {
 volatile counters_t counters;\r
 \r
 volatile uint8_t istat;\r
-\r
+volatile uint8_t changefromeeprom;\r
 #define PCINT_VECTOR PCINT0_vect\r
 #define PIN_REG PINA\r
 #define PIN_DDR DDRA\r
@@ -111,8 +111,8 @@ ISR(PCINT0_vect) {
        if (((PIN_REG&PIN_CH1)==0)&&((istat&PIN_CH1)==PIN_CH1)) {       counters.c32[1]++;      LPORT_CH2|=LPIN_CH2;}\r
        if (((PIN_REG&PIN_CH2)==0)&&((istat&PIN_CH2)==PIN_CH2)) {       counters.c32[2]++;      LPORT_CH2|=LPIN_CH2;}\r
        if (((PIN_REG&PIN_CH3)==0)&&((istat&PIN_CH3)==PIN_CH3)) {       counters.c32[3]++;      LPORT_CH2|=LPIN_CH2;}\r
-\r
-       if (((PORT_EE&PIN_EE)==0)&&((istat&PIN_EE)==PIN_EE))  {\r
+       changefromeeprom=1;\r
+/*     if (((PORT_EE&PIN_EE)==0)&&((istat&PIN_EE)==PIN_EE))  {\r
                \r
                _delay_ms(50);\r
        if (((PORT_EE&PIN_EE)==0))  {\r
@@ -135,7 +135,7 @@ ISR(PCINT0_vect) {
 \r
        }\r
        GIFR|=(1<<PCIF0);\r
-       }\r
+       }*/\r
        if ((((PINA&(1<<PINA6)))==0)&&((istat&(1<<PINA6))==(1<<PINA6)))   {\r
                _delay_ms(100);\r
                if (((PINA&(1<<PINA6)))==0) {\r
@@ -155,7 +155,34 @@ ISR(PCINT0_vect) {
        \r
 }\r
 \r
-\r
+ISR(ANA_COMP_vect) {\r
+       if (changefromeeprom==0) return;\r
+       if ((ACSR&(1<<ACO))!=0) {\r
+               _delay_ms(5);\r
+               if ((ACSR&(1<<ACO))!=0) {\r
+                       CLKPR=0x80;//Switch to 4 MHz\r
+                       CLKPR=01;\r
+                       \r
+                       PORTB|=(1<<PINB1);\r
+                       EEARH=0;\r
+                       for(uint8_t i=0;i<16;i++) {\r
+                               uint8_t addr=i^0x0C;\r
+                               while(EECR & (1<<EEPE));\r
+                               EECR = (0<<EEPM1)|(0<<EEPM0);\r
+                               EEARL = i;\r
+                               EEDR = counters.c8[addr];\r
+                               EECR |= (1<<EEMPE);\r
+                               EECR |= (1<<EEPE);\r
+                       }\r
+                       changefromeeprom=0;\r
+                       PORTB&=~(1<<PINB1);\r
+                       CLKPR=0x80;\r
+                       CLKPR=0;\r
+                       GIFR|=(1<<INTF0);\r
+               }\r
+       }\r
+       \r
+}\r
 int main(void){\r
     PRR|=(1<<PRUSI)|(1<<PRADC);  //Switch off usi and adc for save Power\r
        OWINIT();\r
@@ -211,26 +238,31 @@ int main(void){
                EECR |= (1<<EERE);\r
                counters.c8[addr]=EEDR;\r
        }\r
+       changefromeeprom=0;  //Daten neu eingelesen\r
        for (uint8_t i=0;i<4;i++) {\r
-               if (counters.c32[i]==0xFFFFFFFF) counters.c32[i]=0;\r
+               if (counters.c32[i]==0xFFFFFFFF) {\r
+                       counters.c32[i]=0;\r
+                       changefromeeprom=1;  //Daten geaendert\r
+               }\r
                //counters.c32[i]=0;\r
        }\r
 \r
-   \r
+       DIDR0|=(1<<ADC0D); // Disable Digital input AD0\r
+       ACSR&=~(1<<ACD); //Enable Comperator\r
+       ADCSRB|=(1<<ACME); // Set other negative input\r
+       ADCSRA&=~(1<<ADEN); //Disable A/D for change the negetive comperator input\r
+       ADMUX&=~((1<<MUX0)|(1<<MUX1)|(1<<MUX2)|(1<<MUX3)|(1<<MUX4)|(1<<MUX5)); //Set do ADC0\r
+       ACSR|=(1<<ACIE)|(1<<ACIS1)|(1<<ACIS0)|(1<<ACBG); //Enabble comperator interrupt Rising edge....(1<<ACIS0)\r
+  \r
        sei();\r
     while(1)   {\r
            if (LPORT_CH2&LPIN_CH2) {\r
                        _delay_ms(50);\r
                        LPORT_CH2&=~LPIN_CH2;\r
                }\r
-               //Test if timer active and no sleep then Idle else Power Down\r
-               if (TEST_TIMER&&(mode==0)) {\r
-                       MCUCR|=(1<<SE)|(1<<SM1); //Power Down, only low level on 1-Wire and pin change on PCINT wakes up\r
-                       MCUCR&=~(1<<ISC01);\r
-               } else {\r
-                       MCUCR|=(1<<SE);\r
-                       MCUCR&=~(1<<SM1); \r
-               }\r
+               MCUCR|=(1<<SE);\r
+               MCUCR&=~(1<<SM1);\r
                asm("SLEEP");\r
+               \r
    }\r
 }
\ No newline at end of file
index 7adde5a..47916ba 100644 (file)
@@ -5,7 +5,7 @@
     <ProjectVersion>7.0</ProjectVersion>\r
     <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>\r
     <ProjectGuid>{26106a5a-6618-4774-943f-65c46ddb610b}</ProjectGuid>\r
-    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdevice>ATtiny44</avrdevice>\r
     <avrdeviceseries>none</avrdeviceseries>\r
     <OutputType>Executable</OutputType>\r
     <Language>C</Language>\r
     <BootSegment>2</BootSegment>\r
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
-      <framework-data xmlns="">\r
+      <framework-data>\r
         <options />\r
         <configurations />\r
         <files />\r
         <documentation help="" />\r
         <offline-documentation help="" />\r
         <dependencies>\r
-          <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
     <avrtoolinterface>debugWIRE</avrtoolinterface>\r
     <ExternalProgrammingToolCommand />\r
     <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
-    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+    <avrdeviceexpectedsignature>0x1E9207</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.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=attiny44 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny44"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>DEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <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=attiny44 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny44"</avrgcc.common.Device>\r
+  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+  <avrgcc.compiler.symbols.DefSymbols>\r
+    <ListValues>\r
+      <Value>DEBUG</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.symbols.DefSymbols>\r
+  <avrgcc.compiler.directories.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+    </ListValues>\r
+  </avrgcc.compiler.directories.IncludePaths>\r
+  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+  <avrgcc.linker.libraries.Libraries>\r
+    <ListValues>\r
+      <Value>libm</Value>\r
+    </ListValues>\r
+  </avrgcc.linker.libraries.Libraries>\r
+  <avrgcc.assembler.general.IncludePaths>\r
+    <ListValues>\r
+      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>\r
+    </ListValues>\r
+  </avrgcc.assembler.general.IncludePaths>\r
+  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+</AvrGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
index d928313..e850887 100644 (file)
@@ -253,6 +253,7 @@ uint8_t am2302() {
                \r
                uint8_t i;\r
                for(i=0;i<64;i++) pack.bytes[i]=0;\r
+               pack.page3[0]=0xF1; //Wiregate Code\r
                MCUSR=0;\r
                \r
                uint8_t err;\r
index 8631da1..3dc3802 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <ExternalProgrammingToolCommand />\r
     <AsfFrameworkConfig>\r
-      <framework-data xmlns="">\r
-        <options />\r
-        <configurations />\r
-        <files />\r
-        <documentation help="" />\r
-        <offline-documentation help="" />\r
-        <dependencies>\r
-          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.27.3" />\r
-        </dependencies>\r
-      </framework-data>\r
+      <framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <avrtoolserialnumber>J41800000789</avrtoolserialnumber>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
     <ToolchainSettings>\r
       <AvrGcc>\r
-  <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\gcc\dev\attiny84a"</avrgcc.common.Device>\r
-  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
-  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
-  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
-  <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
-  <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
-  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
-  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
-  <avrgcc.compiler.symbols.DefSymbols>\r
-    <ListValues>\r
-      <Value>NDEBUG</Value>\r
-    </ListValues>\r
-  </avrgcc.compiler.symbols.DefSymbols>\r
-  <avrgcc.compiler.directories.IncludePaths>\r
-    <ListValues>\r
-      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
-    </ListValues>\r
-  </avrgcc.compiler.directories.IncludePaths>\r
-  <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
-  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
-  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
-  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
-  <avrgcc.linker.libraries.Libraries>\r
-    <ListValues>\r
-      <Value>libm</Value>\r
-    </ListValues>\r
-  </avrgcc.linker.libraries.Libraries>\r
-  <avrgcc.assembler.general.IncludePaths>\r
-    <ListValues>\r
-      <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.79\include</Value>\r
-    </ListValues>\r
-  </avrgcc.assembler.general.IncludePaths>\r
-</AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=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
+        <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 632a112..349736e 100644 (file)
@@ -146,6 +146,7 @@ int main(void){
        \r
     uint8_t i;\r
     for(i=0;i<64;i++) pack.bytes[i]=0;\r
+       pack.page3[0]=0xF1;\r
        MCUSR=0;\r
        USI_TWI_Master_Initialise();\r
        initSHT2x();\r
diff --git a/DS2438_VOC_DS2438_SHT_Wiregate/DS2438_DS2438.c b/DS2438_VOC_DS2438_SHT_Wiregate/DS2438_DS2438.c
new file mode 100644 (file)
index 0000000..00a58ef
--- /dev/null
@@ -0,0 +1,486 @@
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
+//!!!!!Max Program size 7551 Byte\r
+\r
+#define F_CPU 8000000UL\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>  \r
+#include <avr/wdt.h>\r
+#include <avr/sleep.h>\r
+#include <avr/pgmspace.h>\r
+#include "../common/I2C/USI_TWI_Master.h"\r
+#include "../common/I2C/MAX1164x.h"\r
+#include "../common/I2C/SHT2xV2.h"\r
+#include "../common/calibr.h"\r
+\r
+extern void OWINIT(void);\r
+extern void EXTERN_SLEEP(void);\r
+\r
+\r
+\r
+volatile uint8_t owid1[8]={0x26, 0x3B, 0xDA, 0x84, 0x00, 0x00, 0x03, 0xA2};/**/\r
+volatile uint8_t owid2[8]={0x26, 0x3C, 0xDA, 0x84, 0x00, 0x00, 0x03, 0x27};/**/\r
+volatile uint8_t config_info1[26]={0x01,0x06, 0x05,0x08, 0x8,19, 0x00,0x00, 0x02,7,0x00,17,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};    \r
+volatile uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 11,0x08, 0x02,0x07,0x00,0x07,17,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};        \r
+       \r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+volatile uint8_t wdcounter=1;\r
+\r
+\r
+typedef union {\r
+       #if  defined(__AVR_ATtiny25__)\r
+       volatile uint8_t bytes[16];\r
+       #else\r
+       volatile uint8_t bytes[64];\r
+       #endif\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               int16_t current;  //6\r
+               uint8_t threshold; //8\r
+               union {\r
+               uint8_t page1[8]; //9\r
+               struct {\r
+                       uint32_t etm;\r
+                       uint8_t ica;\r
+                       uint16_t offset;\r
+                       uint8_t f1;\r
+               };\r
+               };\r
+               #if  defined(__AVR_ATtiny25__)\r
+               #else\r
+               union {\r
+                               uint8_t page2[8]; //17\r
+                               struct  {\r
+                               uint32_t dis; \r
+                               uint32_t eoc;\r
+                               };\r
+                               };\r
+                       \r
+               uint8_t page3[8]; //25\r
+               \r
+               uint8_t page4[8];  //33\r
+               uint8_t page5[8];  //41\r
+               uint8_t page6[8];  //49\r
+               uint8_t page7[8];  //57\r
+               \r
+               #endif\r
+       };\r
+} pack1_t;\r
+volatile pack1_t pack1;\r
+\r
+\r
+\r
+\r
+typedef union {\r
+       #if  defined(__AVR_ATtiny25__)\r
+       volatile uint8_t bytes[16];\r
+       #else\r
+       volatile uint8_t bytes[64];\r
+       #endif\r
+       struct {\r
+               uint8_t status;  //1\r
+               int16_t temp;  //2\r
+               uint16_t voltage;  //4\r
+               int16_t current;  //6\r
+               uint8_t threshold; //8\r
+               \r
+               uint8_t page1[8]; //9\r
+               #if  defined(__AVR_ATtiny25__)\r
+               #else\r
+               uint8_t page2[8]; //17\r
+               uint8_t page3[8]; //25\r
+               \r
+               uint8_t page4[8];  //33\r
+               uint8_t page5[8];  //41\r
+               uint8_t page6[8];  //49\r
+               uint8_t page7[8];  //57\r
+               \r
+               #endif\r
+       };\r
+} pack2_t;\r
+volatile pack2_t pack2;\r
+\r
+#define TIME_CORR 5\r
+volatile int8_t time_corr_count=TIME_CORR;\r
+\r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+ISR(WATCHDOG_vect) {\r
+       #else\r
+       ISR(WDT_vect) {\r
+               #endif\r
+               pack1.etm++;\r
+               time_corr_count--;\r
+               if ((pack1.page1[0]&0x7)==0) {\r
+                        wdcounter++;\r
+                       } \r
+                       if (time_corr_count<=0) {\r
+                               //wdcounter++;\r
+                               pack1.etm+=1;\r
+                               time_corr_count=TIME_CORR;\r
+                       }\r
+       /*      if ((pack1.page1[0]&0x0F)==0) {\r
+                        pack1.etm+=2;\r
+\r
+               }*/\r
+/*             if ((pack1.page1[0]&0x1F)==0) {\r
+                       pack1.etm--;\r
+               }*/\r
+\r
+               if (reset_indicator==1) reset_indicator++;\r
+               else if (reset_indicator==2) mode=0;\r
+\r
+\r
+       }\r
+\r
+\r
+\r
+uint16_t pR0;\r
+uint16_t pVS;\r
+uint8_t pcmode;\r
+int16_t pip;\r
+\r
+uint16_t ptol_s8;\r
+uint16_t ptol_d;\r
+uint16_t pr_day_max;\r
+uint16_t pr_week_max;\r
+\r
+\r
+volatile int16_t DS2438_1_TEMP;\r
+volatile uint16_t DS2438_1_VAD;\r
+volatile int16_t DS2438_2_TEMP;\r
+volatile uint16_t DS2438_2_VAD;\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+double temperatureC,humidityRH,hhum;\r
+double l;\r
+\r
+uint8_t max_adr=0;\r
+#define CH0_M MAX1164x_C_SCAN0|MAX1164x_C_SGL\r
+#define CH1_M MAX1164x_C_SCAN0|MAX1164x_C_SGL|MAX1164x_C_CS0\r
+#define CH0_CH1 MAX1164x_C_SCAN0\r
+//|MAX1164x_C_CS0\r
+\r
+uint16_t weekmaxarr[8];\r
+\r
+//Kompensieren der Abhänigkeit von RS/RO von Temperatur und Luftfeuchte\r
+inline double interp(double t, double h) {\r
+       double h2;\r
+        double t2;\r
+       h2=h*h;\r
+       t2=t*t;\r
+       return 4.76111e-9*h2*t2-3.96956e-7*h2*t+0.0000408889*h2-1.07132e-6*h*t2+0.000115968*h*t-0.0101333*h+0.000163806*t2-0.0241179*t+1.80591;\r
+}\r
+\r
+double R0;\r
+uint16_t mr;\r
+uint8_t startup=10;\r
+double ip;\r
+\r
+\r
+int testSW(void) {\r
+       uint8_t r;\r
+       DDRB&=~(1<<PORTB0);  //Eingang\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB|=(1<<PORTB0); //Pullup\r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        __asm__ __volatile__ ("nop"); \r
+        r=PINB&(1<<PORTB0);\r
+        __asm__ __volatile__ ("nop"); \r
+        PORTB&=~(1<<PORTB0); \r
+        __asm__ __volatile__ ("nop"); \r
+       DDRB|=(1<<PORTB0);  //Eingang\r
+       return (r==0);  //Offen mal HIH4030\r
+        \r
+        \r
+}\r
+\r
+#define EEPROM_R0 0\r
+#define EEPROM_R0d 2\r
+#define EEPROM_R0w 4\r
+#define EEPROM_dol 6\r
+\r
+\r
+uint16_t readEEPROM(uint8_t addr,uint16_t def) {\r
+       uint16_t hr;\r
+       while(EECR & (1<<EEPE));\r
+       EEARL=addr+1;\r
+       EECR |= (1<<EERE);\r
+       hr=EEDR;\r
+       if (hr!=0xFF) {\r
+               hr=hr<<8;\r
+               while(EECR & (1<<EEPE));\r
+               EEARL=addr;\r
+               EECR |= (1<<EERE);\r
+               hr|=EEDR;\r
+               return hr;\r
+       }\r
+       return def;\r
+}\r
+\r
+void writeEEPROM(uint8_t addr,uint16_t val) {\r
+       while(EECR & (1<<EEPE));\r
+       EECR = (0<<EEPM1)|(0<<EEPM0);\r
+       EEARL = addr;\r
+       EEDR = val&0xFF;\r
+       EECR |= (1<<EEMPE);\r
+       EECR |= (1<<EEPE);\r
+       while(EECR & (1<<EEPE));\r
+       EECR = (0<<EEPM1)|(0<<EEPM0);\r
+       EEARL = addr+1;\r
+       EEDR = val>>8;\r
+       EECR |= (1<<EEMPE);\r
+       EECR |= (1<<EEPE);\r
+}\r
+\r
+int main(void){\r
+    PRR|=(1<<PRADC);  // adc for save Power\r
+       PORTA=0xFF;\r
+       PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+       OWINIT();\r
+       DDRB|=(1<<PINB1);//Ausgang und 1\r
+       DDRA|=(1<<PINA0);\r
+       \r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       //(1<<WDP0) |(1<<WDP2) | (1<<WDP1);    // Set Timeout to ~2 seconds\r
+       (1<<WDP2) | (1<<WDP1);    // Set Timeout to ~1 seconds\r
+\r
+       MCUSR=0;\r
+\r
+       pack1.temp=0x0550;\r
+       pack2.page3[0]=0xF1;\r
+       pcmode=0;\r
+       pR0=readEEPROM(EEPROM_R0,1);\r
+       R0=pR0/100.0;\r
+               \r
+       pr_day_max=readEEPROM(EEPROM_R0d,1);\r
+       pr_week_max=readEEPROM(EEPROM_R0w,1);\r
+       ptol_d=readEEPROM(EEPROM_dol,0); \r
+       ptol_s8=0;  //Tag faengt mit Einschalten an\r
+       for(uint8_t i=0;i<7;i++) {\r
+               weekmaxarr[i]=pr_week_max;\r
+       }\r
+\r
+       if (testSW()) {\r
+               config_info2[5]=12;\r
+       }else{\r
+               config_info2[5]=7;\r
+       }\r
+\r
+       USI_TWI_Master_Initialise();\r
+       initSHT2x();\r
+       _delay_ms(100);\r
+       MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M);//#define MAX1164x_C_CS0\r
+       _delay_ms(30); //Internal Referenz start\r
+       //2970 -> 1,5V  \r
+       gcontrol=1;\r
+       sei();\r
+       //DDRB|=(1<<PINB1);\r
+    while(1)   {\r
+/*             if (pack1.config==0x1F) {  //Reset R0\r
+                       pack1.config=0x7F;\r
+                       R0=1;\r
+                       pR0=0;\r
+                       writeEEPROM(EEPROM_R0,0);\r
+               } \r
+               if (pack1.config==0x05) {  //Reset all Data\r
+                       pack1.config=0x7F;                              \r
+                       pr_day_max=1;\r
+                       pr_week_max=1;\r
+                       ptol_d=0;\r
+                       ptol_s8=0;  //Tag faengt mit Einschalten an     \r
+                       R0=1;   \r
+                       writeEEPROM(EEPROM_R0,0xFF);\r
+                       writeEEPROM(EEPROM_R0d,0xFF);  //Maximum des Tages\r
+                       writeEEPROM(EEPROM_R0w,0xFF); //Maximum der Letzten 7 Tage\r
+                       writeEEPROM(EEPROM_dol,0xFF); //Anzahl der Betriebstage         \r
+                       for(uint8_t i=0;i<7;i++) {\r
+                               weekmaxarr[i]=1;\r
+                       }                               \r
+               } */\r
+               if (wdcounter>0) {  //8s\r
+                       ptol_s8++;\r
+                       \r
+                       //pack1.dis+=8;\r
+                       //pack1.eoc+=8;\r
+                       if (ptol_s8>(10000))  {//10800 ist theortisch der Tag aber meistens zu lang\r
+                               ptol_s8=0;\r
+                               ptol_d++;  //rund 180 Jahre :-)\r
+                               pr_week_max=0;\r
+                               weekmaxarr[7]=pr_day_max;\r
+                               for(uint8_t i=0;i<7;i++) {\r
+                                       weekmaxarr[i]=weekmaxarr[i+1];\r
+                                       //maximum of week\r
+                                       if (weekmaxarr[i]>pr_week_max) pr_week_max=weekmaxarr[i];\r
+                               }\r
+                               if (ptol_d>7) {\r
+                                       pR0=pr_week_max;\r
+                               } else {\r
+                                       pR0=pr_day_max;\r
+                               }\r
+                               //R0=//R0-0.5*(pack2.R0/100-R0);\r
+                               R0=R0-(R0-pR0/100.0)*0.5        ;\r
+                               pR0=R0*100;\r
+                               writeEEPROM(EEPROM_R0,pR0);\r
+                               writeEEPROM(EEPROM_R0d,pr_day_max);  //Maximum des Tages\r
+                               writeEEPROM(EEPROM_R0w,pr_week_max); //Maximum der Letzten 7 Tage\r
+                               writeEEPROM(EEPROM_dol,ptol_d); //Anzahl der Betriebstage\r
+                               pr_day_max=0;\r
+                       }\r
+                       if (startup!=0) startup--;\r
+                       getSHT2xHumTemp(&temperatureC,&humidityRH);\r
+                       ip=interp(temperatureC,humidityRH);\r
+                       pip=ip*1000;\r
+                       double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0;\r
+                       double TC =temperatureC *10.0-2;\r
+\r
+\r
+                       if (testSW()) {\r
+                                DS2438_2_VAD=RH;\r
+                                DS2438_2_TEMP=TC*25.6;\r
+                                \r
+                                config_info2[5]=12;    //10V = 100%\r
+                       }else{\r
+                               hhum=(1.0546-0.000216*TC)*(RH);\r
+                               //am2302_hum=0.318*hhum +76.0;\r
+                               DS2438_2_VAD=0.31*hhum +80;\r
+                               DS2438_2_TEMP=TC*25.6;\r
+                               config_info2[5]=7;\r
+                       }\r
+                       DS2438_1_TEMP=DS2438_2_TEMP;\r
+                       mr=0;\r
+//Kritische Sektion !___Ein Breakpoint in dieser Section kann den TGS8100 zerstoeren!___________________________\r
+                       PORTB&=~(1<<PINB1); //Auf 0 Ziehen\r
+                       _delay_us(150);\r
+                       mr+=MAX1164x_read();\r
+                       _delay_us(150);\r
+                       mr+=MAX1164x_read();\r
+                       PORTB|=(1<<PINB1);\r
+//ENDE Kritische Sektion !______________________________\r
+                       //l=mr/2.0*2.048/4096; \r
+                       // l maximal 2  mr max 4096  //mr 2V=8000 \r
+                       \r
+                       if (pcmode) { //cmode=0 V 0..2 V cmode=1 V 1.5..3.5V\r
+                               //l+=1.5; //Spannung real\r
+                               mr+=6000;\r
+                       } \r
+                       //if (l>1.8) {\r
+                       if (mr>7200) {                          \r
+                               if (pcmode==0) {\r
+                                       MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_CH1);\r
+                                       pcmode=1;\r
+                               }\r
+                       }\r
+                       //if (l<1.6) {\r
+                       if (mr<6400) {  \r
+                               if (pcmode==1) {\r
+                                       MAX1164x_config(MAX1164x_S_SEL2|MAX1164x_S_SEL0,CH0_M);\r
+                                       pcmode=0;\r
+                               }\r
+                               \r
+                               \r
+                       }\r
+                       pVS=mr*5/2;\r
+                       l=mr/4000.0;\r
+                       l=( 3/l- 1) *30;\r
+                       pack2.current=l*100;\r
+                       \r
+                       l=l/ip;\r
+                       \r
+                       if (startup==0){\r
+                               if (l>R0) {\r
+                                       R0=l;\r
+                                       pR0=R0*100;\r
+                                       writeEEPROM(EEPROM_R0,pR0);\r
+\r
+                               }\r
+                               if (l*100>pr_day_max) {\r
+                                       pr_day_max=l*100;\r
+                               }\r
+                       } else if (l<R0) l=R0; //negative Werte am Anfang verhintern\r
+                       l=exp((1-(l/R0))*6.05)-1;// exp((1-($val)/55)*5.75);  (5.75 geht Ã¼ber 125 6.05 geht bis 240... mittlere Linie im Datenblatt)\r
+                       //l=(l/R0*100.0);\r
+                       l=l*0.5*35; //fuer DS2438\r
+                       if (l==0) l=1;\r
+                       gcontrol=1;\r
+                       wdcounter=0;\r
+                       \r
+               }\r
+       \r
+               if (gcontrol==1) {\r
+                       uint16_t w=l;\r
+                       DS2438_1_VAD=w;\r
+                       \r
+                       gcontrol=0;\r
+               }\r
+               if ((gcontrol==2)||(gcontrol==3)) {\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
+   }\r
+\r
+\r
+}\r
diff --git a/DS2438_VOC_DS2438_SHT_Wiregate/DS2438_VOC_DS2438_SHT.atsln b/DS2438_VOC_DS2438_SHT_Wiregate/DS2438_VOC_DS2438_SHT.atsln
new file mode 100644 (file)
index 0000000..5e69bf6
--- /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_VOC_DS2438_SHT", "DS2438_VOC_DS2438_SHT.cproj", "{7A5672FE-8226-4158-B931-E1F36B9A8858}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.ActiveCfg = Debug|AVR\r
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Debug|AVR.Build.0 = Debug|AVR\r
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.ActiveCfg = Release|AVR\r
+               {7A5672FE-8226-4158-B931-E1F36B9A8858}.Release|AVR.Build.0 = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2438_VOC_DS2438_SHT_Wiregate/DS2438_VOC_DS2438_SHT.cproj b/DS2438_VOC_DS2438_SHT_Wiregate/DS2438_VOC_DS2438_SHT.cproj
new file mode 100644 (file)
index 0000000..c1970fc
--- /dev/null
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectVersion>7.0</ProjectVersion>\r
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>\r
+    <ProjectGuid>{7a5672fe-8226-4158-b931-e1f36b9a8858}</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS18B20_DS2438</AssemblyName>\r
+    <Name>DS2438_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
+  </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\MAX1164x.c">\r
+      <SubType>compile</SubType>\r
+      <Link>MAX1164x.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\SHT2xV2.c">\r
+      <SubType>compile</SubType>\r
+      <Link>SHT2xV2.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>USI_TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\OWDS2438_DS2438.S">\r
+      <SubType>compile</SubType>\r
+      <Link>OWDS2438_DS2438.S</Link>\r
+    </Compile>\r
+    <Compile Include="DS2438_DS2438.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2438_VOC_DS2438_SHT_Wiregate/Makefile b/DS2438_VOC_DS2438_SHT_Wiregate/Makefile
new file mode 100644 (file)
index 0000000..9aa6429
--- /dev/null
@@ -0,0 +1,202 @@
+# Hey Emacs, this is a -*- makefile -*-
+
+# AVR-GCC Makefile template, derived from the WinAVR template (which
+# is public domain), believed to be neutral to any flavor of "make"
+# (GNU make, BSD make, SysV make)
+
+
+MCU = attiny84
+FORMAT = ihex
+TARGET =DS2438_VOC_DS2438_SHT
+SRC = ../common/calibr.c ../common/I2C/MAX1164x.c ../common/I2C/SHT2xV2.c ../common/I2C/USI_TWI_Master.c DS2438_DS2438.c
+ASRC = ../common/OWDS2438_DS2438.S
+
+# Name of this Makefile (used for "make depend").
+MAKEFILE = Makefile
+
+
+CFLAGS = -x c -funsigned-char -funsigned-bitfields -I. -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall   -std=gnu99 -MD -MP 
+
+#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
+
+
+#Additional libraries.
+
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+PRINTF_LIB = 
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+SCANF_LIB = 
+
+MATH_LIB = -lm
+
+# External memory options
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref
+#LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+LDFLAGS = -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=$(MCU)
+
+# Programming support using avrdude. Settings and variables.
+
+#AVRDUDE_PROGRAMMER = stk500
+#AVRDUDE_PORT = /dev/term/a
+
+#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+#AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+#AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
+
+
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+#AVRDUDE = avrdude
+REMOVE = rm -f
+MV = mv -f
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+# Default target.
+all: build
+
+build: elf hex eep
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+#eep: $(TARGET).eep
+lss: $(TARGET).lss 
+sym: $(TARGET).sym
+
+
+# Program the device.  
+program: $(TARGET).hex $(TARGET).eep
+       $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000 
+
+
+coff: $(TARGET).elf
+       $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+       $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
+
+
+.SUFFIXES: .elf .hex .eep .lss .sym
+
+.elf.hex:
+       $(OBJCOPY) -O $(FORMAT) $< $@
+#      $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+.elf.eep:
+       -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+       --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+.elf.lss:
+       $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+.elf.sym:
+       $(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+$(TARGET).elf: $(OBJ)
+       $(CC)  $(OBJ) --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+.c.o:
+       $(CC) -c $(ALL_CFLAGS) $< -o $@ 
+
+
+# Compile: create assembler files from C source files.
+.c.s:
+       $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+.S.o:
+       $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+# Target: clean project.
+clean:
+       $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
+       $(TARGET).map $(TARGET).sym $(TARGET).lss \
+       $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d)
+
+depend:
+       if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
+       then \
+               sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
+                       $(MAKEFILE).$$$$ && \
+               $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
+       fi
+       echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
+               >> $(MAKEFILE); \
+       $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
+
+.PHONY:        all build elf hex eep lss sym program coff extcoff clean depend
+
+
diff --git a/DS2450_BMP280/DS2450_BMP280.atsln b/DS2450_BMP280/DS2450_BMP280.atsln
new file mode 100644 (file)
index 0000000..2ab645d
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Atmel Studio Solution File, Format Version 11.00\r
+VisualStudioVersion = 14.0.23107.0\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "DS2450_BMP280", "DS2450_BMP280.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|AVR = Debug|AVR\r
+               Release|AVR = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR\r
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR\r
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR\r
+               {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/DS2450_BMP280/DS2450_BMP280.c b/DS2450_BMP280/DS2450_BMP280.c
new file mode 100644 (file)
index 0000000..420d789
--- /dev/null
@@ -0,0 +1,291 @@
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+//  * Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+//  * Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the\r
+//    distribution.\r
+//  * All advertising materials mentioning features or use of this\r
+//    software must display the following acknowledgement: This product\r
+//    includes software developed by tm3d.de and its contributors.\r
+//  * Neither the name of tm3d.de nor the names of its contributors may\r
+//    be used to endorse or promote products derived from this software\r
+//    without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
+#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/BMP280.h"\r
+extern void OWINIT();\r
+extern void EXTERN_SLEEP();\r
+\r
+uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/\r
+uint8_t config_info[26]={0x02,16,0x01,14, 0,0, 0x0,0,0x02,14,14,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+#if (owid>128) \r
+#error "Variable not correct"\r
+#endif\r
+\r
+extern uint8_t mode;\r
+extern uint8_t gcontrol;\r
+extern uint8_t reset_indicator;\r
+extern uint8_t alarmflag;\r
+volatile uint8_t wdcounter=10;\r
+\r
+\r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+ISR(WATCHDOG_vect) {\r
+#else\r
+ISR(WDT_vect) {\r
+#endif \r
+       wdcounter++;\r
+       if (reset_indicator==1) reset_indicator++;\r
+       else if (reset_indicator==2) mode=0;\r
+}\r
+\r
+typedef union {\r
+       volatile uint8_t bytes[0x20];\r
+       struct {\r
+               //Page0\r
+               uint16_t A;  //0\r
+               uint16_t B;  //2\r
+               uint16_t C;  //4\r
+               uint16_t D;  //6\r
+               //Page1\r
+               uint8_t CSA1;\r
+               uint8_t CSA2;\r
+               uint8_t CSB1;\r
+               uint8_t CSB2;\r
+               uint8_t CSC1;\r
+               uint8_t CSC2;\r
+               uint8_t CSD1;\r
+               uint8_t CSD2;\r
+               //Page2\r
+               uint8_t LA;\r
+               uint8_t HA;\r
+               uint8_t LB;\r
+               uint8_t HB;\r
+               uint8_t LC;\r
+               uint8_t HC;\r
+               uint8_t LD;\r
+               uint8_t HD;\r
+               //Page3\r
+               uint8_t FC1;\r
+               uint8_t FC2;\r
+               uint8_t FC3;\r
+               uint8_t FC4;\r
+               uint8_t VCCP;\r
+               uint8_t FC5;\r
+               uint8_t FC6;\r
+               uint8_t FC7;\r
+               uint8_t convc1;\r
+               uint8_t convc2;\r
+               \r
+               \r
+       };\r
+} pack_t;\r
+volatile pack_t pack;\r
+\r
+\r
+\r
+volatile int16_t am2302_temp;\r
+volatile uint16_t am2302_hum;\r
+\r
+\r
+uint8_t userRegister[1];\r
+int16_t sRH,sT;\r
+volatile double temperatureC,humidityRH;\r
+uint32_t P;\r
+int32_t t;\r
+\r
+\r
+\r
+\r
+int main(void){\r
+       pack.A=0;\r
+       pack.B=0;\r
+       pack.C=0;\r
+       pack.D=0;\r
+       pack.CSA1=0x08;\r
+       pack.CSA2=0x8C;\r
+       pack.CSB1=0x08;\r
+       pack.CSB2=0x8C;\r
+       pack.CSC1=0x08;\r
+       pack.CSC2=0x8C;\r
+       pack.CSD1=0x08;\r
+       pack.CSD2=0x8C;\r
+       pack.HA=0xFF;\r
+       pack.LA=0x00;\r
+       pack.HB=0xFF;\r
+       pack.LB=0x00;\r
+       pack.HC=0xFF;\r
+       pack.LC=0x00;\r
+       pack.HD=0xFF;\r
+       pack.LD=0x00;\r
+       pack.VCCP=0;\r
+    PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom\r
+       DDRB|=(1<<PORTB0); //Als Ausgang und 0\r
+       PORTA=0xFF;  //All Pull up;\r
+        PRR|=(1<<PRADC);  // adc for save Power\r
+\r
+       ACSR|=(1<<ACD);  //Disable Comparator\r
+       OWINIT();\r
+\r
+       MCUCR &=~(1<<PUD); //All Pins Pullup...\r
+       MCUCR |=(1<<BODS);\r
+       WDTCSR |= ((1<<WDCE) );   // Enable the WD Change Bit//| (1<<WDE)\r
+       WDTCSR |=   (1<<WDIE) |              // Enable WDT Interrupt\r
+       (1<<WDP3) | (1<<WDP0);   // Set Timeout to ~8 seconds\r
+       \r
+       gcontrol=1;\r
+       \r
+       USI_TWI_Master_Initialise();\r
+       bmp280Init();\r
+       \r
+       sei();\r
+       \r
+       //DDRB|=(1<<PINB1);\r
+\r
+    while(1)   {\r
+       \r
+       if (wdcounter>3) {      \r
+               bmp280ConvertInt(&t,&P,1);\r
+       \r
+               wdcounter=0;\r
+       }\r
+       \r
+\r
+               \r
+               \r
+\r
+\r
+               if (gcontrol) {\r
+                       //PORTB|=(1<<PINB1);\r
+                       uint8_t bb=1;\r
+                       uint8_t bb1=1;\r
+                       for(uint8_t i=0;i<4;i++){\r
+                               if (pack.convc1&bb1) {\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0;pack.bytes[i*2+1]=0;}\r
+                                       bb=bb<<1;\r
+                                       if (pack.convc2&(bb)) {pack.bytes[i*2]=0xFF;pack.bytes[i*2+1]=0xFF;}\r
+                                       bb=bb<<1;\r
+                               } else bb=bb<<2;\r
+                               bb1=bb1<<1;                             \r
+                       }\r
+                       //CHanel A\r
+                       if (pack.convc1&1) {\r
+                               /*if (pack.CSA2&0x01)   ADMUX=0; else ADMUX=0x80;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.A=ADC;sei();*/\r
+                               cli();pack.A=P/100.0*32.0;sei();\r
+                               wdcounter=10;\r
+                               alarmflag=0;\r
+                               if (pack.CSA2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HA) {alarmflag=1;pack.CSA2|=0x20;}\r
+                               if (pack.CSA2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LA) {alarmflag=1;pack.CSA2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&2) {\r
+                               /*if (pack.CSB2&0x01)   ADMUX=1; else ADMUX=0x81;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.B=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               uint16_t ct=(t)+32767;\r
+                               cli();pack.B=ct;sei();\r
+                               if (pack.CSB2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HB) {alarmflag=1;pack.CSB2|=0x20;}\r
+                               if (pack.CSB2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LB) {alarmflag=1;pack.CSB2|=0x10;}\r
+                       }\r
+\r
+                       if (pack.convc1&4) {\r
+                               /*if (pack.CSC2&0x01)   ADMUX=2; else ADMUX=0x82;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.C=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               cli();pack.C=0;sei();\r
+                               if (pack.CSC2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HC) {alarmflag=1;pack.CSC2|=0x20;}\r
+                               if (pack.CSC2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LC) {alarmflag=1;pack.CSC2|=0x10;}\r
+                       } \r
+                       if (pack.convc1&8) {\r
+                               /*if (pack.CSD2&0x01)   ADMUX=3; else ADMUX=0x83;\r
+                               _delay_us(100);\r
+                               ADCSRA|=(1<<ADSC);\r
+                               while ((ADCSRA&(1<<ADSC)));\r
+                               cli();pack.D=ADC;sei();*/\r
+                               wdcounter=10;\r
+                               cli();pack.D=0;sei();\r
+                               if (pack.CSD2&0x08)  //AEH\r
+                                       if (pack.bytes[1]>pack.HD) {alarmflag=1;pack.CSD2|=0x20;}\r
+                               if (pack.CSD2&0x04)  //AEL\r
+                                       if (pack.bytes[1]<pack.LD) {alarmflag=1;pack.CSD2|=0x10;}\r
+                       }\r
+                       \r
+                       EXTERN_SLEEP();\r
+                       //PORTB&=~(1<<PINB1);\r
+               }\r
+\r
+               /*uint8_t bb=1;\r
+               for(uint8_t i=0;i<4;i++) {\r
+                       if (pack.bytes[8+i*2]&0x80) {  //Chanel as output\r
+                               if (pack.bytes[8+i*2]&0x40) {\r
+                                       DDRA|=bb;\r
+                               } else {\r
+                                       DDRA&=~bb;\r
+                               }\r
+                       } else {\r
+                               DDRA&=~bb;\r
+                       }\r
+                       bb=bb*2;\r
+               }*/\r
+               \r
+#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
+                       if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
+#endif                 \r
+#if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
+                       if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
+#endif\r
+                         {\r
+\r
+                       MCUCR|=(1<<SE)|(1<<SM1);\r
+                       MCUCR&=~(1<<ISC01);\r
+               } else {\r
+                       MCUCR|=(1<<SE);\r
+                       MCUCR&=~(1<<SM1);\r
+               }\r
+       //      asm("SLEEP");\r
+   }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/DS2450_BMP280/DS2450_BMP280.cproj b/DS2450_BMP280/DS2450_BMP280.cproj
new file mode 100644 (file)
index 0000000..2a27eb4
--- /dev/null
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">\r
+  <PropertyGroup>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectVersion>7.0</ProjectVersion>\r
+    <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>\r
+    <ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>\r
+    <avrdevice>ATtiny84A</avrdevice>\r
+    <avrdeviceseries>none</avrdeviceseries>\r
+    <OutputType>Executable</OutputType>\r
+    <Language>C</Language>\r
+    <OutputFileName>$(MSBuildProjectName)</OutputFileName>\r
+    <OutputFileExtension>.elf</OutputFileExtension>\r
+    <OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>\r
+    <AssemblyName>DS2450</AssemblyName>\r
+    <Name>DS2450_BMP280</Name>\r
+    <RootNamespace>DS2450</RootNamespace>\r
+    <ToolchainFlavour>Native</ToolchainFlavour>\r
+    <KeepTimersRunning>true</KeepTimersRunning>\r
+    <OverrideVtor>false</OverrideVtor>\r
+    <CacheFlash>true</CacheFlash>\r
+    <ProgFlashFromRam>true</ProgFlashFromRam>\r
+    <RamSnippetAddress>0x20000000</RamSnippetAddress>\r
+    <UncachedRange />\r
+    <preserveEEPROM>true</preserveEEPROM>\r
+    <OverrideVtorValue>exception_table</OverrideVtorValue>\r
+    <BootSegment>2</BootSegment>\r
+    <eraseonlaunchrule>1</eraseonlaunchrule>\r
+    <ExternalProgrammingToolCommand />\r
+    <AsfFrameworkConfig>\r
+      <framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+  </dependencies>\r
+</framework-data>\r
+    </AsfFrameworkConfig>\r
+    <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
+    <avrtoolserialnumber>J41800000779</avrtoolserialnumber>\r
+    <avrdeviceexpectedsignature>0x1E930C</avrdeviceexpectedsignature>\r
+    <com_atmel_avrdbg_tool_atmelice>\r
+      <ToolOptions>\r
+        <InterfaceProperties>\r
+        </InterfaceProperties>\r
+        <InterfaceName>debugWIRE</InterfaceName>\r
+      </ToolOptions>\r
+      <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>\r
+      <ToolNumber>J41800000779</ToolNumber>\r
+      <ToolName>Atmel-ICE</ToolName>\r
+    </com_atmel_avrdbg_tool_atmelice>\r
+    <avrtoolinterface>debugWIRE</avrtoolinterface>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>NDEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
+    <ToolchainSettings>\r
+      <AvrGcc>\r
+        <avrgcc.common.Device>-mmcu=attiny84a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny84a"</avrgcc.common.Device>\r
+        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>\r
+        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>\r
+        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>\r
+        <avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>\r
+        <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>\r
+        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>\r
+        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>\r
+        <avrgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>DEBUG</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.symbols.DefSymbols>\r
+        <avrgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.0.68\include</Value>\r
+          </ListValues>\r
+        </avrgcc.compiler.directories.IncludePaths>\r
+        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>\r
+        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>\r
+        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>\r
+        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>\r
+        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>\r
+        <avrgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>libm</Value>\r
+          </ListValues>\r
+        </avrgcc.linker.libraries.Libraries>\r
+        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>\r
+      </AvrGcc>\r
+    </ToolchainSettings>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\common\I2C\BMP280.c">\r
+      <SubType>compile</SubType>\r
+      <Link>BMP280.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\common\I2C\USI_TWI_Master.c">\r
+      <SubType>compile</SubType>\r
+      <Link>USI_TWI_Master.c</Link>\r
+    </Compile>\r
+    <Compile Include="DS2450_BMP280.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="OWDS2450.S">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
+</Project>
\ No newline at end of file
diff --git a/DS2450_BMP280/Makefile b/DS2450_BMP280/Makefile
new file mode 100644 (file)
index 0000000..fbcebe4
--- /dev/null
@@ -0,0 +1,202 @@
+# Hey Emacs, this is a -*- makefile -*-
+
+# AVR-GCC Makefile template, derived from the WinAVR template (which
+# is public domain), believed to be neutral to any flavor of "make"
+# (GNU make, BSD make, SysV make)
+
+
+MCU = attiny84
+FORMAT = ihex
+TARGET =DS2450_BMP280
+SRC = ../common/I2C/BMP280.c ../common/I2C/USI_TWI_Master.c DS2450_BMP280.c
+ASRC = OWDS2450.S
+
+# Name of this Makefile (used for "make depend").
+MAKEFILE = Makefile
+
+
+CFLAGS = -x c -funsigned-char -funsigned-bitfields -I. -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall   -std=gnu99 -MD -MP 
+
+#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
+
+
+#Additional libraries.
+
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+PRINTF_LIB = 
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+SCANF_LIB = 
+
+MATH_LIB = -lm
+
+# External memory options
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref
+#LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+LDFLAGS = -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=$(MCU)
+
+# Programming support using avrdude. Settings and variables.
+
+#AVRDUDE_PROGRAMMER = stk500
+#AVRDUDE_PORT = /dev/term/a
+
+#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+#AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+#AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
+
+
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+#AVRDUDE = avrdude
+REMOVE = rm -f
+MV = mv -f
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+# Default target.
+all: build
+
+build: elf hex eep
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+#eep: $(TARGET).eep
+lss: $(TARGET).lss 
+sym: $(TARGET).sym
+
+
+# Program the device.  
+program: $(TARGET).hex $(TARGET).eep
+       $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000 
+
+
+coff: $(TARGET).elf
+       $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+       $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
+
+
+.SUFFIXES: .elf .hex .eep .lss .sym
+
+.elf.hex:
+       $(OBJCOPY) -O $(FORMAT) $< $@
+#      $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+.elf.eep:
+       -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+       --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+.elf.lss:
+       $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+.elf.sym:
+       $(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+$(TARGET).elf: $(OBJ)
+       $(CC)  $(OBJ) --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+.c.o:
+       $(CC) -c $(ALL_CFLAGS) $< -o $@ 
+
+
+# Compile: create assembler files from C source files.
+.c.s:
+       $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+.S.o:
+       $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+# Target: clean project.
+clean:
+       $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
+       $(TARGET).map $(TARGET).sym $(TARGET).lss \
+       $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d)
+
+depend:
+       if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
+       then \
+               sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
+                       $(MAKEFILE).$$$$ && \
+               $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
+       fi
+       echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
+               >> $(MAKEFILE); \
+       $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
+
+.PHONY:        all build elf hex eep lss sym program coff extcoff clean depend
+
+
index 54ca3e6..3a27365 100644 (file)
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <ExternalProgrammingToolCommand />\r
     <AsfFrameworkConfig>\r
-      <framework-data xmlns="">\r
-        <options />\r
-        <configurations />\r
-        <files />\r
-        <documentation help="" />\r
-        <offline-documentation help="" />\r
-        <dependencies>\r
-          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.27.3" />\r
-        </dependencies>\r
-      </framework-data>\r
+      <framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <avrtoolserialnumber>J41800000779</avrtoolserialnumber>\r
index 9fd65c7..8b8928f 100644 (file)
@@ -57,7 +57,7 @@
 #define zh 31\r
 \r
 .extern owid,8\r
-.extern config_info,16\r
+.extern config_info,26\r
 \r
 .comm mode,1  ; Aktueller Zustand nach dem die Unterprogramme aufgerufen werden\r
 .comm srbyte,1 ; aktuelles Byte fuer Searchrom\r
diff --git a/common/OWDS2401_DS2413.S b/common/OWDS2401_DS2413.S
new file mode 100644 (file)
index 0000000..ba48f60
--- /dev/null
@@ -0,0 +1,199 @@
+\r
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
+\r
+#define _CHANGEABLE_ID_\r
+#define _ZERO_POLLING_\r
+//#define _HANDLE_CC_COMMAND_\r
+//#define _DB_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC8.s"\r
+\r
+.extern pin_state,1\r
+.extern pin_set,1\r
+.comm resv1,1\r
+\r
+\r
+.macro CHIP_INIT       ;r_temp is pushed other Registers should be saved\r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_accessread\r
+               rjmp h_accesswrite\r
+               rjmp h_accesswrite_read\r
+.endm\r
+\r
+#include "../common/OWRomFunctionsDual.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_ACCESSREAD OW_FIRST_COMMAND+0\r
+#define OW_ACCESSWRITE OW_FIRST_COMMAND+1\r
+#define OW_ACCESSWRITE_READ OW_FIRST_COMMAND+2\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+#ifdef _HANDLE_CC_COMMAND_\r
+/*h_readcommand12:\r
+       clr r_bytep\r
+       cset 0x44,hrc_set_convertT12\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end*/\r
+#endif\r
+\r
+\r
+h_readcommand1:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+\r
+/*     cset 0xBE,OW_READ_SCRATCHPAD_ADR1\r
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR1\r
+       cjmp 0x44,hrc_set_convertT1\r
+       cjmp 0xB4,hrc_set_convertV1*/\r
+       FW_CONFIG_INFO1\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+\r
+\r
+\r
+\r
+\r
+h_readcommand2:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cjmp 0xF5,hrc_accessread\r
+       cset 0x5A,OW_ACCESSWRITE\r
+/*     cset 0xBE,OW_READ_SCRATCHPAD_ADR2\r
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2\r
+       cjmp 0x44,hrc_set_convertT2\r
+       cjmp 0xB4,hrc_set_convertV2*/\r
+       FW_CONFIG_INFO2\r
+       //cljmp 0x85,hrc_fw_configinfo2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       rjmp handle_end_sleep\r
+\r
+\r
+hrc_accessread:\r
+       ldi r_sendflag,1\r
+       ldi r_mode,OW_ACCESSREAD\r
+h_accessread:\r
+       lds r_temp,pin_state\r
+       andi r_temp,0x0F\r
+       mov r_rwbyte,r_temp\r
+       com r_rwbyte\r
+       swap r_rwbyte\r
+       andi r_rwbyte,0xF0\r
+       or r_rwbyte,r_temp\r
+       rjmp handle_end\r
+\r
+\r
+\r
+\r
+h_accesswrite_read:\r
+       rjmp handle_end_sleep\r
+       \r
+\r
+\r
+h_accesswrite:\r
+       cpi  r_bytep,1\r
+       breq h_accesswrite_compl\r
+       sts resv1,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_accesswrite_compl:\r
+       com r_rwbyte\r
+       lds r_temp,resv1\r
+       cp r_temp,r_rwbyte\r
+       brne h_accesswrite_error\r
+       sts  pin_set,r_rwbyte\r
+       ldi r_mode,OW_ACCESSWRITE_READ\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_sendflag,1\r
+       rjmp handle_end_inc\r
+h_accesswrite_error:\r
+       rjmp handle_end_sleep\r
+/*\r
+;---------------------------------------------------\r
+;   WRITE SCRATCHPAD\r
+;---------------------------------------------------\r
+h_writescratchpad_adr2:\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+#if  defined(__AVR_ATtiny25__)\r
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen\r
+#endif\r
+       sts block,r_rwbyte\r
+       ldi r_mode,OW_WRITE_SCRATCHPAD2\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end \r
+h_writescratchpad2:\r
+       cpi  r_bytep,8\r
+       breq h_writescratchpad_all2\r
+       lds  r_temp,block\r
+       add  r_temp,r_bytep\r
+       configZ pack2,r_temp\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_writescratchpad_all2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+       */\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end\r
index 1abee6a..32be7dc 100644 (file)
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
 \r
-\r
+//#define __4MHZ__\r
 #define _CHANGEABLE_ID_\r
 #define _ZERO_POLLING_\r
+//#define _DB_\r
 #include "../common/OWConfig.s"\r
 #include "../common/OWCRC16.s"\r
 \r
diff --git a/common/OWDS2423_DS2413.S b/common/OWDS2423_DS2413.S
new file mode 100644 (file)
index 0000000..c0370a4
--- /dev/null
@@ -0,0 +1,451 @@
+\r
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
+\r
+#define _CHANGEABLE_ID_\r
+#define _ZERO_POLLING_\r
+//#define _HANDLE_CC_COMMAND_\r
+//#define _DB_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack1,45\r
+.extern counters1,16\r
+\r
+//.extern pack2,45\r
+.extern counters2,16\r
+\r
+#define pack2 pack1 \r
+;same EEPROM for Attiny44 \r
+.extern pin_state,1\r
+.extern pin_set,1\r
+.comm resv1,1\r
+.macro CHIP_INIT       ;r_temp is pushed other Registers should be saved\r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_writescratchpad1\r
+               rjmp h_writescratchpad_crc1\r
+               rjmp h_readscratchpad1\r
+               rjmp h_copyscratchpad1\r
+               rjmp h_readmemory_addr1\r
+               rjmp h_readmemory1\r
+               rjmp h_readmemorycounter_addr1\r
+               rjmp h_readmemorycounter1\r
+               rjmp h_readmemorycounter_ex1\r
+\r
+               rjmp h_accessread2\r
+               rjmp h_accesswrite2\r
+               rjmp h_accesswrite_read2\r
+.endm\r
+\r
+#include "../common/OWRomFunctionsDual.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+0\r
+#define OW_WRITE_SCRATCHPAD_CRC1 OW_FIRST_COMMAND+1\r
+#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+2\r
+#define OW_COPY_SCRATCHPAD1 OW_FIRST_COMMAND+3\r
+#define OW_READ_MEMORY_ADDR1 OW_FIRST_COMMAND+4\r
+#define OW_READ_MEMORY1 OW_FIRST_COMMAND+5\r
+#define OW_READ_MEMORYCOUNTER_ADDR1 OW_FIRST_COMMAND+6\r
+#define OW_READ_MEMORYCOUNTER1 OW_FIRST_COMMAND+7\r
+#define OW_READ_MEMORYCOUNTER_EX1 OW_FIRST_COMMAND+8\r
+\r
+#define OW_ACCESSREAD2 OW_FIRST_COMMAND+9\r
+#define OW_ACCESSWRITE2 OW_FIRST_COMMAND+10\r
+#define OW_ACCESSWRITE_READ2 OW_FIRST_COMMAND+11\r
+\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+h_readcommand1:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0x0F,OW_WRITE_SCRATCHPAD1\r
+       cjmp 0xAA,hrc_set_readscratchpad1\r
+       cset 0x5A,OW_COPY_SCRATCHPAD1\r
+       cset 0xF0,OW_READ_MEMORY_ADDR1\r
+       cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR1\r
+       FW_CONFIG_INFO1\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+hrc_set_readscratchpad1:\r
+       ldi r_mode,OW_READ_SCRATCHPAD1\r
+       ldi r_sendflag,1\r
+       rjmp h_readscratchpad1\r
+\r
+h_writescratchpad1:\r
+       configZ pack1,r_bytep\r
+       inc  r_bytep\r
+       st   Z,r_rwbyte\r
+       cpi  r_bytep,2\r
+       breq h_writescratchpad_block1\r
+       brsh h_writescratchpad_set_eoffset1 ;;33\r
+       rjmp handle_end  ;handle_end zu weit entfernt fuer br...\r
+h_writescratchpad_set_eoffset1:\r
+       cpi  r_bytep,35\r
+       breq h_writescratchpad_setcrc1\r
+       mov r_temp,r_bytep\r
+       subi r_temp,4\r
+       sts pack1+2,r_temp ;AA und PF cleared\r
+       rjmp handle_end\r
+;Start writeing to 32 Byte Block ; skip status byte    \r
+h_writescratchpad_block1:\r
+       lds r_temp,pack1 ; Adresse low byte\r
+       andi r_temp,0x1F ;32 byte\r
+       add r_bytep,r_temp ;Zur angegebenen Startadresse springen\r
+       ;ori r_temp,0x20 ; Set PF flag\r
+       sts pack1+2,r_temp  ;E4:E0 vorher setzen\r
+       ; Byte 3 ueberspringen\r
+       rjmp handle_end_inc\r
+\r
+h_writescratchpad_setcrc1:\r
+       ;copy crc to pack\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack1+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp ; invertieren , komischer name.....\r
+       sts pack1+44,r_temp\r
+       ldi  r_mode,OW_WRITE_SCRATCHPAD_CRC1\r
+       ldi r_sendflag,1\r
+       ldi r_bytep,43\r
+h_writescratchpad_crc1:\r
+       cpi r_bytep,45\r
+       breq h_writescratchpad_crc_end1\r
+       configZ pack1,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_writescratchpad_crc_end1:\r
+       rjmp handle_end_sleep\r
+       \r
+       \r
+h_readscratchpad1:\r
+       cpi r_bytep,35\r
+       breq h_readscratchpad_end1\r
+       cpi r_bytep,3\r
+       brne h_readscratchpad_read_byte1\r
+h_readscratchpad_set_offset1:\r
+       lds r_temp,pack1\r
+       andi r_temp,0x1F\r
+       ldi r_temp2,3\r
+       add r_temp,r_temp2\r
+       mov r_bytep,r_temp\r
+h_readscratchpad_read_byte1:\r
+       configZ pack1,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_readscratchpad_end1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+h_copyscratchpad1:\r
+       cpi  r_bytep,3\r
+       brsh h_copyscratchpad_ok1\r
+       configZ pack1,r_bytep\r
+       inc  r_bytep\r
+       ld   r_temp,Z\r
+       cp r_temp,r_rwbyte\r
+       brne h_copyscratchpad_nok1\r
+       cpi  r_bytep,3\r
+       breq h_copyscratchpad_ok1\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end\r
+h_copyscratchpad_ok1:\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_sendflag,1\r
+       rjmp handle_end\r
+h_copyscratchpad_nok1:\r
+       lds r_temp,pack1+3\r
+       andi r_temp,~0x80\r
+       sts pack1+3,r_temp\r
+       rjmp handle_end_sleep\r
+\r
+\r
+h_readmemory_addr1:\r
+       cpi r_bytep,0\r
+       brne h_readmrmory_addr_byte11\r
+       sts pack1,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_readmrmory_addr_byte11:\r
+       sts pack1+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORY1\r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemory21\r
+h_readmemory1:\r
+       lds r_bytep,pack1\r
+       lds r_temp2,pack1+1\r
+       inc r_bytep\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1\r
+       rjmp h_readmemory_end1\r
+       sts pack1+1,r_temp\r
+       sts pack1,r_bytep\r
+h_readmemory21:\r
+       lds r_bytep,pack1\r
+       andi r_bytep,0x1F\r
+       configZ pack1+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemory_end1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+h_readmemorycounter_addr1:\r
+       cpi r_bytep,0\r
+       brne h_readmrmorycounter_addr_byte11\r
+       sts pack1,r_rwbyte\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmrmorycounter_addr_byte11:\r
+       sts pack1+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORYCOUNTER1\r
+       ;ldi r_bcount,1 \r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemorycounter21\r
+h_readmemorycounter1:\r
+       lds r_bytep,pack1\r
+       lds r_temp2,pack1+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       mov r_temp,r_bytep\r
+       andi r_temp,0x1F\r
+       breq h_readmemorycounter_next1\r
+       sts pack1+1,r_temp2\r
+       sts pack1,r_bytep\r
+h_readmemorycounter21:  ;Lesen von dem worauf die erstenzwei bytes zeigen\r
+       lds r_bytep,pack1\r
+       andi r_bytep,0x1F\r
+       configZ pack1+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+//h_readmemorycounter_end:\r
+//     ldi  r_mode,OW_SLEEP\r
+//     clr r_sendflag\r
+//     rjmp handle_end\r
+h_readmemorycounter_next1:  ; rest lesen\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER_EX1\r
+       ldi r_bytep,34\r
+       lds r_temp2,pack1\r
+       lds r_temp,pack1+1\r
+       lsl r_temp2\r
+       rol r_temp\r
+       cpi r_temp,3\r
+       brne h_readmemorycounter_cFF1\r
+       andi r_temp2,0xC0\r
+       swap r_temp2\r
+\r
+       ;cpi r_temp,0xE0\r
+\r
+       configZ counters1,r_temp2\r
+       ld r_temp,Z+\r
+       sts pack1+35,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack1+36,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack1+37,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack1+38,r_temp     \r
+       rjmp h_readmemorycounter_ex1\r
+h_readmemorycounter_cFF1:\r
+       ldi r_temp,0xFF\r
+       sts pack1+35,r_temp     \r
+       sts pack1+36,r_temp     \r
+       sts pack1+37,r_temp     \r
+       sts pack1+38,r_temp     \r
+\r
+h_readmemorycounter_ex1:\r
+       inc r_bytep\r
+       cpi r_bytep,45\r
+       breq h_readmemorycounter_ex_end1\r
+       cpi r_bytep,43\r
+       brne h_readmemorycounter_ex21\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack1+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts pack1+44,r_temp\r
+h_readmemorycounter_ex21:\r
+       ;ldi r_bcount,1\r
+       configZ pack1,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemorycounter_ex_end1:\r
+       lds r_bytep,pack1\r
+       lds r_temp2,pack1+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1 ;am ene von allem \r
+       rjmp h_readmemorycounter_ex_sleep1\r
+       CRCInit1\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER1\r
+       sts pack1+1,r_temp2\r
+       sts pack1,r_bytep\r
+       rjmp h_readmemorycounter21\r
+h_readmemorycounter_ex_sleep1:\r
+       ldi r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+\r
+\r
+\r
+\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+\r
+\r
+h_readcommand2:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cjmp 0xF5,hrc_accessread2\r
+       cset 0x5A,OW_ACCESSWRITE2\r
+/*     cset 0xBE,OW_READ_SCRATCHPAD_ADR2\r
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2\r
+       cjmp 0x44,hrc_set_convertT2\r
+       cjmp 0xB4,hrc_set_convertV2*/\r
+       FW_CONFIG_INFO2\r
+       //cljmp 0x85,hrc_fw_configinfo2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       rjmp handle_end_sleep\r
+\r
+\r
+hrc_accessread2:\r
+       ldi r_sendflag,1\r
+       ldi r_mode,OW_ACCESSREAD2\r
+h_accessread2:\r
+       lds r_temp,pin_state\r
+       andi r_temp,0x0F\r
+       mov r_rwbyte,r_temp\r
+       com r_rwbyte\r
+       swap r_rwbyte\r
+       andi r_rwbyte,0xF0\r
+       or r_rwbyte,r_temp\r
+       rjmp handle_end\r
+\r
+\r
+\r
+\r
+h_accesswrite_read2:\r
+       rjmp handle_end_sleep\r
+       \r
+\r
+\r
+h_accesswrite2:\r
+       cpi  r_bytep,1\r
+       breq h_accesswrite_compl2\r
+       sts resv1,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_accesswrite_compl2:\r
+       com r_rwbyte\r
+       lds r_temp,resv1\r
+       cp r_temp,r_rwbyte\r
+       brne h_accesswrite_error2\r
+       sts  pin_set,r_rwbyte\r
+       ldi r_mode,OW_ACCESSWRITE_READ2\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_sendflag,1\r
+       rjmp handle_end_inc\r
+h_accesswrite_error2:\r
+       rjmp handle_end_sleep\r
+/*\r
+;---------------------------------------------------\r
+;   WRITE SCRATCHPAD\r
+;---------------------------------------------------\r
+h_writescratchpad_adr2:\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+#if  defined(__AVR_ATtiny25__)\r
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen\r
+#endif\r
+       sts block,r_rwbyte\r
+       ldi r_mode,OW_WRITE_SCRATCHPAD2\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end \r
+h_writescratchpad2:\r
+       cpi  r_bytep,8\r
+       breq h_writescratchpad_all2\r
+       lds  r_temp,block\r
+       add  r_temp,r_bytep\r
+       configZ pack2,r_temp\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_writescratchpad_all2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+       */\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end\r
diff --git a/common/OWDS2423_DS2423.S b/common/OWDS2423_DS2423.S
new file mode 100644 (file)
index 0000000..f261e5f
--- /dev/null
@@ -0,0 +1,635 @@
+\r
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
+\r
+#define _CHANGEABLE_ID_\r
+#define _ZERO_POLLING_\r
+#if  defined(__AVR_ATtiny84__)  ||defined(__AVR_ATtiny84A__)  \r
+#else\r
+#define _NO_CONFIGBYTES_\r
+#define _DIS_FLASH_\r
+#endif\r
+//#define _HANDLE_CC_COMMAND_\r
+//#define _DB_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack1,45\r
+.extern counters1,16\r
+\r
+//.extern pack2,45\r
+.extern counters2,16\r
+\r
+#define pack2 pack1 \r
+;same EEPROM for Attiny44 \r
+\r
+.macro CHIP_INIT       ;r_temp is pushed other Registers should be saved\r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_writescratchpad1\r
+               rjmp h_writescratchpad_crc1\r
+               rjmp h_readscratchpad1\r
+               rjmp h_copyscratchpad1\r
+               rjmp h_readmemory_addr1\r
+               rjmp h_readmemory1\r
+               rjmp h_readmemorycounter_addr1\r
+               rjmp h_readmemorycounter1\r
+               rjmp h_readmemorycounter_ex1\r
+\r
+               rjmp h_writescratchpad2\r
+               rjmp h_writescratchpad_crc2\r
+               rjmp h_readscratchpad2\r
+               rjmp h_copyscratchpad2\r
+               rjmp h_readmemory_addr2\r
+               rjmp h_readmemory2\r
+               rjmp h_readmemorycounter_addr2\r
+               rjmp h_readmemorycounter2\r
+               rjmp h_readmemorycounter_ex2\r
+.endm\r
+\r
+#include "../common/OWRomFunctionsDual.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+0\r
+#define OW_WRITE_SCRATCHPAD_CRC1 OW_FIRST_COMMAND+1\r
+#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+2\r
+#define OW_COPY_SCRATCHPAD1 OW_FIRST_COMMAND+3\r
+#define OW_READ_MEMORY_ADDR1 OW_FIRST_COMMAND+4\r
+#define OW_READ_MEMORY1 OW_FIRST_COMMAND+5\r
+#define OW_READ_MEMORYCOUNTER_ADDR1 OW_FIRST_COMMAND+6\r
+#define OW_READ_MEMORYCOUNTER1 OW_FIRST_COMMAND+7\r
+#define OW_READ_MEMORYCOUNTER_EX1 OW_FIRST_COMMAND+8\r
+\r
+#define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+9\r
+#define OW_WRITE_SCRATCHPAD_CRC2 OW_FIRST_COMMAND+10\r
+#define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+11\r
+#define OW_COPY_SCRATCHPAD2 OW_FIRST_COMMAND+12\r
+#define OW_READ_MEMORY_ADDR2 OW_FIRST_COMMAND+13\r
+#define OW_READ_MEMORY2 OW_FIRST_COMMAND+14\r
+#define OW_READ_MEMORYCOUNTER_ADDR2 OW_FIRST_COMMAND+15\r
+#define OW_READ_MEMORYCOUNTER2 OW_FIRST_COMMAND+16\r
+#define OW_READ_MEMORYCOUNTER_EX2 OW_FIRST_COMMAND+17\r
+\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+h_readcommand1:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0x0F,OW_WRITE_SCRATCHPAD1\r
+       cjmp 0xAA,hrc_set_readscratchpad1\r
+       cset 0x5A,OW_COPY_SCRATCHPAD1\r
+       cset 0xF0,OW_READ_MEMORY_ADDR1\r
+       cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR1\r
+       FW_CONFIG_INFO1\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+hrc_set_readscratchpad1:\r
+       ldi r_mode,OW_READ_SCRATCHPAD1\r
+       ldi r_sendflag,1\r
+       rjmp h_readscratchpad1\r
+\r
+h_writescratchpad1:\r
+       configZ pack1,r_bytep\r
+       inc  r_bytep\r
+       st   Z,r_rwbyte\r
+       cpi  r_bytep,2\r
+       breq h_writescratchpad_block1\r
+       brsh h_writescratchpad_set_eoffset1 ;;33\r
+       rjmp handle_end  ;handle_end zu weit entfernt fuer br...\r
+h_writescratchpad_set_eoffset1:\r
+       cpi  r_bytep,35\r
+       breq h_writescratchpad_setcrc1\r
+       mov r_temp,r_bytep\r
+       subi r_temp,4\r
+       sts pack1+2,r_temp ;AA und PF cleared\r
+       rjmp handle_end\r
+;Start writeing to 32 Byte Block ; skip status byte    \r
+h_writescratchpad_block1:\r
+       lds r_temp,pack1 ; Adresse low byte\r
+       andi r_temp,0x1F ;32 byte\r
+       add r_bytep,r_temp ;Zur angegebenen Startadresse springen\r
+       ;ori r_temp,0x20 ; Set PF flag\r
+       sts pack1+2,r_temp  ;E4:E0 vorher setzen\r
+       ; Byte 3 ueberspringen\r
+       rjmp handle_end_inc\r
+\r
+h_writescratchpad_setcrc1:\r
+       ;copy crc to pack\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack1+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp ; invertieren , komischer name.....\r
+       sts pack1+44,r_temp\r
+       ldi  r_mode,OW_WRITE_SCRATCHPAD_CRC1\r
+       ldi r_sendflag,1\r
+       ldi r_bytep,43\r
+h_writescratchpad_crc1:\r
+       cpi r_bytep,45\r
+       breq h_writescratchpad_crc_end1\r
+       configZ pack1,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_writescratchpad_crc_end1:\r
+       rjmp handle_end_sleep\r
+       \r
+       \r
+h_readscratchpad1:\r
+       cpi r_bytep,35\r
+       breq h_readscratchpad_end1\r
+       cpi r_bytep,3\r
+       brne h_readscratchpad_read_byte1\r
+h_readscratchpad_set_offset1:\r
+       lds r_temp,pack1\r
+       andi r_temp,0x1F\r
+       ldi r_temp2,3\r
+       add r_temp,r_temp2\r
+       mov r_bytep,r_temp\r
+h_readscratchpad_read_byte1:\r
+       configZ pack1,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_readscratchpad_end1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+h_copyscratchpad1:\r
+       cpi  r_bytep,3\r
+       brsh h_copyscratchpad_ok1\r
+       configZ pack1,r_bytep\r
+       inc  r_bytep\r
+       ld   r_temp,Z\r
+       cp r_temp,r_rwbyte\r
+       brne h_copyscratchpad_nok1\r
+       cpi  r_bytep,3\r
+       breq h_copyscratchpad_ok1\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end\r
+h_copyscratchpad_ok1:\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_sendflag,1\r
+       rjmp handle_end\r
+h_copyscratchpad_nok1:\r
+       lds r_temp,pack1+3\r
+       andi r_temp,~0x80\r
+       sts pack1+3,r_temp\r
+       rjmp handle_end_sleep\r
+\r
+\r
+h_readmemory_addr1:\r
+       cpi r_bytep,0\r
+       brne h_readmrmory_addr_byte11\r
+       sts pack1,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_readmrmory_addr_byte11:\r
+       sts pack1+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORY1\r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemory21\r
+h_readmemory1:\r
+       lds r_bytep,pack1\r
+       lds r_temp2,pack1+1\r
+       inc r_bytep\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1\r
+       rjmp h_readmemory_end1\r
+       sts pack1+1,r_temp\r
+       sts pack1,r_bytep\r
+h_readmemory21:\r
+       lds r_bytep,pack1\r
+       andi r_bytep,0x1F\r
+       configZ pack1+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemory_end1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+h_readmemorycounter_addr1:\r
+       cpi r_bytep,0\r
+       brne h_readmrmorycounter_addr_byte11\r
+       sts pack1,r_rwbyte\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmrmorycounter_addr_byte11:\r
+       sts pack1+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORYCOUNTER1\r
+       ;ldi r_bcount,1 \r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemorycounter21\r
+h_readmemorycounter1:\r
+       lds r_bytep,pack1\r
+       lds r_temp2,pack1+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       mov r_temp,r_bytep\r
+       andi r_temp,0x1F\r
+       breq h_readmemorycounter_next1\r
+       sts pack1+1,r_temp2\r
+       sts pack1,r_bytep\r
+h_readmemorycounter21:  ;Lesen von dem worauf die erstenzwei bytes zeigen\r
+       lds r_bytep,pack1\r
+       andi r_bytep,0x1F\r
+       configZ pack1+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+//h_readmemorycounter_end:\r
+//     ldi  r_mode,OW_SLEEP\r
+//     clr r_sendflag\r
+//     rjmp handle_end\r
+h_readmemorycounter_next1:  ; rest lesen\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER_EX1\r
+       ldi r_bytep,34\r
+       lds r_temp2,pack1\r
+       lds r_temp,pack1+1\r
+       lsl r_temp2\r
+       rol r_temp\r
+       cpi r_temp,3\r
+       brne h_readmemorycounter_cFF1\r
+       andi r_temp2,0xC0\r
+       swap r_temp2\r
+\r
+       ;cpi r_temp,0xE0\r
+\r
+       configZ counters1,r_temp2\r
+       ld r_temp,Z+\r
+       sts pack1+35,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack1+36,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack1+37,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack1+38,r_temp     \r
+       rjmp h_readmemorycounter_ex1\r
+h_readmemorycounter_cFF1:\r
+       ldi r_temp,0xFF\r
+       sts pack1+35,r_temp     \r
+       sts pack1+36,r_temp     \r
+       sts pack1+37,r_temp     \r
+       sts pack1+38,r_temp     \r
+\r
+h_readmemorycounter_ex1:\r
+       inc r_bytep\r
+       cpi r_bytep,45\r
+       breq h_readmemorycounter_ex_end1\r
+       cpi r_bytep,43\r
+       brne h_readmemorycounter_ex21\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack1+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts pack1+44,r_temp\r
+h_readmemorycounter_ex21:\r
+       ;ldi r_bcount,1\r
+       configZ pack1,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemorycounter_ex_end1:\r
+       lds r_bytep,pack1\r
+       lds r_temp2,pack1+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1 ;am ene von allem \r
+       rjmp h_readmemorycounter_ex_sleep1\r
+       CRCInit1\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER1\r
+       sts pack1+1,r_temp2\r
+       sts pack1,r_bytep\r
+       rjmp h_readmemorycounter21\r
+h_readmemorycounter_ex_sleep1:\r
+       ldi r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+\r
+\r
+\r
+\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+\r
+\r
+\r
+\r
+h_readcommand2:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0x0F,OW_WRITE_SCRATCHPAD2\r
+       cjmp 0xAA,hrc_set_readscratchpad2\r
+       cset 0x5A,OW_COPY_SCRATCHPAD2\r
+       cset 0xF0,OW_READ_MEMORY_ADDR2\r
+       cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR2\r
+       FW_CONFIG_INFO2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+hrc_set_readscratchpad2:\r
+       ldi r_mode,OW_READ_SCRATCHPAD2\r
+       ldi r_sendflag,1\r
+       rjmp h_readscratchpad2\r
+\r
+h_writescratchpad2:\r
+       configZ pack2,r_bytep\r
+       inc  r_bytep\r
+       st   Z,r_rwbyte\r
+       cpi  r_bytep,2\r
+       breq h_writescratchpad_block2\r
+       brsh h_writescratchpad_set_eoffset2 ;;33\r
+       rjmp handle_end  ;handle_end zu weit entfernt fuer br...\r
+h_writescratchpad_set_eoffset2:\r
+       cpi  r_bytep,35\r
+       breq h_writescratchpad_setcrc2\r
+       mov r_temp,r_bytep\r
+       subi r_temp,4\r
+       sts pack2+2,r_temp ;AA und PF cleared\r
+       rjmp handle_end\r
+;Start writeing to 32 Byte Block ; skip status byte    \r
+h_writescratchpad_block2:\r
+       lds r_temp,pack2 ; Adresse low byte\r
+       andi r_temp,0x1F ;32 byte\r
+       add r_bytep,r_temp ;Zur angegebenen Startadresse springen\r
+       ;ori r_temp,0x20 ; Set PF flag\r
+       sts pack2+2,r_temp  ;E4:E0 vorher setzen\r
+       ; Byte 3 ueberspringen\r
+       rjmp handle_end_inc\r
+\r
+h_writescratchpad_setcrc2:\r
+       ;copy crc to pack2\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack2+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp ; invertieren , komischer name.....\r
+       sts pack2+44,r_temp\r
+       ldi  r_mode,OW_WRITE_SCRATCHPAD_CRC2\r
+       ldi r_sendflag,1\r
+       ldi r_bytep,43\r
+h_writescratchpad_crc2:\r
+       cpi r_bytep,45\r
+       breq h_writescratchpad_crc_end2\r
+       configZ pack2,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_writescratchpad_crc_end2:\r
+       rjmp handle_end_sleep\r
+       \r
+       \r
+h_readscratchpad2:\r
+       cpi r_bytep,35\r
+       breq h_readscratchpad_end2\r
+       cpi r_bytep,3\r
+       brne h_readscratchpad_read_byte2\r
+h_readscratchpad_set_offset2:\r
+       lds r_temp,pack2\r
+       andi r_temp,0x1F\r
+       ldi r_temp2,3\r
+       add r_temp,r_temp2\r
+       mov r_bytep,r_temp\r
+h_readscratchpad_read_byte2:\r
+       configZ pack2,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_readscratchpad_end2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+h_copyscratchpad2:\r
+       cpi  r_bytep,3\r
+       brsh h_copyscratchpad_ok2\r
+       configZ pack2,r_bytep\r
+       inc  r_bytep\r
+       ld   r_temp,Z\r
+       cp r_temp,r_rwbyte\r
+       brne h_copyscratchpad_nok2\r
+       cpi  r_bytep,3\r
+       breq h_copyscratchpad_ok2\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end\r
+h_copyscratchpad_ok2:\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_sendflag,1\r
+       rjmp handle_end\r
+h_copyscratchpad_nok2:\r
+       lds r_temp,pack2+3\r
+       andi r_temp,~0x80\r
+       sts pack2+3,r_temp\r
+       rjmp handle_end_sleep\r
+\r
+\r
+h_readmemory_addr2:\r
+       cpi r_bytep,0\r
+       brne h_readmrmory_addr_byte12\r
+       sts pack2,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_readmrmory_addr_byte12:\r
+       sts pack2+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORY2\r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemory22\r
+h_readmemory2:\r
+       lds r_bytep,pack2\r
+       lds r_temp2,pack2+1\r
+       inc r_bytep\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1\r
+       rjmp h_readmemory_end2\r
+       sts pack2+1,r_temp\r
+       sts pack2,r_bytep\r
+h_readmemory22:\r
+       lds r_bytep,pack2\r
+       andi r_bytep,0x1F\r
+       configZ pack2+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemory_end2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+h_readmemorycounter_addr2:\r
+       cpi r_bytep,0\r
+       brne h_readmrmorycounter_addr_byte12\r
+       sts pack2,r_rwbyte\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmrmorycounter_addr_byte12:\r
+       sts pack2+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORYCOUNTER2\r
+       ;ldi r_bcount,1 \r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemorycounter22\r
+h_readmemorycounter2:\r
+       lds r_bytep,pack2\r
+       lds r_temp2,pack2+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       mov r_temp,r_bytep\r
+       andi r_temp,0x1F\r
+       breq h_readmemorycounter_next2\r
+       sts pack2+1,r_temp2\r
+       sts pack2,r_bytep\r
+h_readmemorycounter22:  ;Lesen von dem worauf die erstenzwei bytes zeigen\r
+       lds r_bytep,pack2\r
+       andi r_bytep,0x1F\r
+       configZ pack2+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+//h_readmemorycounter_end:\r
+//     ldi  r_mode,OW_SLEEP\r
+//     clr r_sendflag\r
+//     rjmp handle_end\r
+h_readmemorycounter_next2:  ; rest lesen\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER_EX2\r
+       ldi r_bytep,34\r
+       lds r_temp2,pack2\r
+       lds r_temp,pack2+1\r
+       //lsr r_temp\r
+       //ror r_temp2\r
+\r
+       lsl r_temp2\r
+       rol r_temp\r
+       cpi r_temp,3\r
+       brne h_readmemorycounter_cFF2\r
+       andi r_temp2,0xC0\r
+       swap r_temp2\r
+\r
+       ;cpi r_temp,0xE0\r
+\r
+       configZ counters2,r_temp2\r
+       ld r_temp,Z+\r
+       sts pack2+35,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack2+36,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack2+37,r_temp     \r
+       ld r_temp,Z+\r
+       sts pack2+38,r_temp     \r
+       rjmp h_readmemorycounter_ex2\r
+h_readmemorycounter_cFF2:\r
+       ldi r_temp,0xFF\r
+       sts pack2+35,r_temp     \r
+       sts pack2+36,r_temp     \r
+       sts pack2+37,r_temp     \r
+       sts pack2+38,r_temp     \r
+\r
+h_readmemorycounter_ex2:\r
+       inc r_bytep\r
+       cpi r_bytep,45\r
+       breq h_readmemorycounter_ex_end2\r
+       cpi r_bytep,43\r
+       brne h_readmemorycounter_ex22\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack2+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts pack2+44,r_temp\r
+h_readmemorycounter_ex22:\r
+       ;ldi r_bcount,1\r
+       configZ pack2,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemorycounter_ex_end2:\r
+       lds r_bytep,pack2\r
+       lds r_temp2,pack2+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1 ;am ene von allem \r
+       rjmp h_readmemorycounter_ex_sleep2\r
+       CRCInit1\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER2\r
+       sts pack2+1,r_temp2\r
+       sts pack2,r_bytep\r
+       rjmp h_readmemorycounter22\r
+h_readmemorycounter_ex_sleep2:\r
+       ldi r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end\r
diff --git a/common/OWDS2438_DS2438.S b/common/OWDS2438_DS2438.S
new file mode 100644 (file)
index 0000000..3c00e1b
--- /dev/null
@@ -0,0 +1,351 @@
+\r
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
+\r
+#define _CHANGEABLE_ID_\r
+#define _ZERO_POLLING_\r
+//#define _HANDLE_CC_COMMAND_\r
+//#define _DB_\r
+\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC8.s"\r
+\r
+\r
+#if  defined(__AVR_ATtiny25__)\r
+.extern pack2,16\r
+.extern pack1,16\r
+#else\r
+.extern pack2,64\r
+.extern pack1,64\r
+#endif\r
+.extern  DS2438_1_TEMP,2\r
+.extern  DS2438_1_VAD,2\r
+.extern  DS2438_2_TEMP,2\r
+.extern  DS2438_2_VAD,2\r
+.comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)\r
+\r
+\r
+.macro CHIP_INIT       ;r_temp is pushed other Registers should be saved\r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_readscratchpad_adr1\r
+               rjmp h_readscratchpad1\r
+               rjmp h_writescratchpad_adr1\r
+               rjmp h_writescratchpad1\r
+               rjmp h_readscratchpad_adr2\r
+               rjmp h_readscratchpad2\r
+               rjmp h_writescratchpad_adr2\r
+               rjmp h_writescratchpad2\r
+.endm\r
+\r
+#include "../common/OWRomFunctionsDual.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_READ_SCRATCHPAD_ADR1 OW_FIRST_COMMAND+0\r
+#define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+1\r
+#define OW_WRITE_SCRATCHPAD_ADR1 OW_FIRST_COMMAND+2\r
+#define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+3\r
+#define OW_READ_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+4\r
+#define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+5\r
+#define OW_WRITE_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+6\r
+#define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+7\r
+\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+#ifdef _HANDLE_CC_COMMAND_\r
+h_readcommand12:\r
+       clr r_bytep\r
+       cset 0x44,hrc_set_convertT12\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+#endif\r
+\r
+\r
+h_readcommand1:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xBE,OW_READ_SCRATCHPAD_ADR1\r
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR1\r
+       cjmp 0x44,hrc_set_convertT1\r
+       cjmp 0xB4,hrc_set_convertV1\r
+       FW_CONFIG_INFO1\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       rjmp handle_end_sleep\r
+\r
+\r
+hrc_set_convertT1:\r
+       ldi r_temp,1\r
+       sts gcontrol,r_temp\r
+       lds r_temp,DS2438_1_TEMP\r
+       sts pack1+1,r_temp\r
+       lds r_temp,DS2438_1_TEMP+1\r
+       sts pack1+2,r_temp\r
+       rjmp handle_end_sleep\r
+hrc_set_convertV1:\r
+       lds r_temp,pack1\r
+       sbrs r_temp,3\r
+       rjmp hrc_set_convertVV1\r
+       ldi r_temp,0xF4  //5V\r
+       sts pack1+3,r_temp\r
+       ldi r_temp,0x01\r
+       sts pack1+4,r_temp\r
+       rjmp hrc_set_convertend1\r
+hrc_set_convertVV1:\r
+       ldi r_temp,3\r
+       sts gcontrol,r_temp\r
+       lds r_temp,DS2438_1_VAD\r
+       sts pack1+3,r_temp\r
+       lds r_temp,DS2438_1_VAD+1\r
+       sts pack1+4,r_temp\r
+hrc_set_convertend1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   READ SCRATCHPAD\r
+;---------------------------------------------------\r
+\r
+h_readscratchpad_adr1:\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+#if  defined(__AVR_ATtiny25__)\r
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen\r
+#endif\r
+       sts block,r_rwbyte\r
+       ldi r_sendflag,1\r
+       ldi r_mode,OW_READ_SCRATCHPAD1\r
+       CRCInit2\r
+h_readscratchpad1:\r
+       cpi  r_bytep,8\r
+       breq h_readscratchpad_crc1\r
+       cpi  r_bytep,9\r
+       breq h_readscratchpad_all1\r
+       lds  r_temp,block\r
+       add  r_temp,r_bytep\r
+       configZ pack1,r_temp\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_readscratchpad_crc1:\r
+       lds  r_rwbyte,crc\r
+       rjmp handle_end_inc\r
+h_readscratchpad_all1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   WRITE SCRATCHPAD\r
+;---------------------------------------------------\r
+h_writescratchpad_adr1:\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+#if  defined(__AVR_ATtiny25__)\r
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen\r
+#endif\r
+       sts block,r_rwbyte\r
+       ldi r_mode,OW_WRITE_SCRATCHPAD1\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end \r
+h_writescratchpad1:\r
+       cpi  r_bytep,8\r
+       breq h_writescratchpad_all1\r
+       lds  r_temp,block\r
+       add  r_temp,r_bytep\r
+       configZ pack1,r_temp\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_writescratchpad_all1:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+#ifdef _HANDLE_CC_COMMAND_\r
+hrc_set_convertT12:\r
+       ldi r_temp,3\r
+       sts gcontrol,r_temp\r
+       lds r_temp,DS2438_2_TEMP\r
+       sts pack2+1,r_temp\r
+       lds r_temp,DS2438_2_TEMP+1\r
+       sts pack2+2,r_temp\r
+       lds r_temp,DS2438_1_TEMP\r
+       sts pack1+1,r_temp\r
+       lds r_temp,DS2438_1_TEMP+1\r
+       sts pack1+2,r_temp\r
+       rjmp handle_end_sleep\r
+#endif\r
+\r
+\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+;*****************************************************************************************************************************************************************************************\r
+\r
+\r
+\r
+\r
+\r
+h_readcommand2:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0xBE,OW_READ_SCRATCHPAD_ADR2\r
+       cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2\r
+       cjmp 0x44,hrc_set_convertT2\r
+       cjmp 0xB4,hrc_set_convertV2\r
+       FW_CONFIG_INFO2\r
+       //cljmp 0x85,hrc_fw_configinfo2\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       rjmp handle_end_sleep\r
+\r
+\r
+hrc_set_convertT2:\r
+       ldi r_temp,2\r
+       sts gcontrol,r_temp\r
+       lds r_temp,DS2438_2_TEMP\r
+       sts pack2+1,r_temp\r
+       lds r_temp,DS2438_2_TEMP+1\r
+       sts pack2+2,r_temp\r
+       rjmp handle_end_sleep\r
+hrc_set_convertV2:\r
+       lds r_temp,pack2\r
+       sbrs r_temp,3\r
+       rjmp hrc_set_convertVV2\r
+       ldi r_temp,0xF4\r
+       sts pack2+3,r_temp\r
+       ldi r_temp,0x01\r
+       sts pack2+4,r_temp\r
+       rjmp hrc_set_convertend2\r
+hrc_set_convertVV2:\r
+       ldi r_temp,3\r
+       sts gcontrol,r_temp\r
+       lds r_temp,DS2438_2_VAD\r
+       sts pack2+3,r_temp\r
+       lds r_temp,DS2438_2_VAD+1\r
+       sts pack2+4,r_temp\r
+hrc_set_convertend2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   READ SCRATCHPAD\r
+;---------------------------------------------------\r
+\r
+h_readscratchpad_adr2:\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+#if  defined(__AVR_ATtiny25__)\r
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen\r
+#endif\r
+       sts block,r_rwbyte\r
+       ldi r_sendflag,1\r
+       ldi r_mode,OW_READ_SCRATCHPAD2\r
+       CRCInit2\r
+h_readscratchpad2:\r
+       cpi  r_bytep,8\r
+       breq h_readscratchpad_crc2\r
+       cpi  r_bytep,9\r
+       breq h_readscratchpad_all2\r
+       lds  r_temp,block\r
+       add  r_temp,r_bytep\r
+       configZ pack2,r_temp\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_readscratchpad_crc2:\r
+       lds  r_rwbyte,crc\r
+       rjmp handle_end_inc\r
+h_readscratchpad_all2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+;---------------------------------------------------\r
+;   WRITE SCRATCHPAD\r
+;---------------------------------------------------\r
+h_writescratchpad_adr2:\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+       lsl r_rwbyte\r
+#if  defined(__AVR_ATtiny25__)\r
+       andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen\r
+#endif\r
+       sts block,r_rwbyte\r
+       ldi r_mode,OW_WRITE_SCRATCHPAD2\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end \r
+h_writescratchpad2:\r
+       cpi  r_bytep,8\r
+       breq h_writescratchpad_all2\r
+       lds  r_temp,block\r
+       add  r_temp,r_bytep\r
+       configZ pack2,r_temp\r
+       st   Z,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_writescratchpad_all2:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+#include "../common/OWPinInterrupt.s"\r
+.end\r
index df8952d..69f84f3 100644 (file)
@@ -85,6 +85,7 @@ send_bit_low_loop:
        cpi r_temp,(~OWT_MIN_RESET)+OWT_WRITE ;aller zwei us zaehlt der timer\r
        brlo send_bit_low_loop ;wenn kleiner \r
        cbi OW_DDR,OW_PINN  ;Leitung auf hochohmig \r
+\r
        rjmp iend\r
 \r
 receive_bit: ;or reset \r
@@ -100,7 +101,9 @@ receive_bit: ;or reset
        ori r_rwbyte,0x80\r
        ldi r_temp2,0 ;fuer CRC Berechnung\r
 receive_bit_crc:\r
+       sdb\r
        CRCR\r
+       \r
        lsl r_bcount\r
        brne recive_bit_no_handle ;bcount nicht 0\r
        ;naechstes byte ....\r
index 3c2d152..6f1e709 100644 (file)
@@ -213,13 +213,13 @@ hrc_set_searchrom:
        rjmp h_searchrom_next_bit\r
 \r
 hrc_start_read_command: ;Skip rom und Matchrom ok...\r
+       CRCInit1\r
        lds r_temp,srbyte\r
        cpi r_temp,1\r
        breq hrc_start_read_command1\r
        cpi r_temp,2\r
        breq hrc_start_read_command2\r
        rjmp handle_end_sleep\r
-       CRCInit1\r
 hrc_start_read_command1:\r
        ldi r_mode,OW_READ_COMMAND1\r
        rjmp handle_end\r
@@ -241,17 +241,24 @@ hrc_set_alarm_search:
        rjmp handle_end_sleep\r
 \r
 hrc_fw_configinfo1:\r
+#ifdef _NO_CONFIGBYTES_\r
+       rjmp handle_end_sleep\r
+#else\r
        ldi r_mode,OW_FWCONFIGINFO1\r
        ldi r_sendflag,1\r
        CRCInit2\r
        rjmp h_fwconfiginfo1\r
+#endif\r
 \r
 hrc_fw_configinfo2:\r
+#ifdef _NO_CONFIGBYTES_\r
+       rjmp handle_end_sleep\r
+#else\r
        ldi r_mode,OW_FWCONFIGINFO2\r
        ldi r_sendflag,1\r
        CRCInit2\r
        rjmp h_fwconfiginfo2\r
-\r
+#endif\r
 \r
 ;---------------------------------------------------\r
 ;   MATCH ROM\r
@@ -395,10 +402,26 @@ h_searchromr:  ; stelle um auf empfangen
 ;---------------------------------------------------\r
 \r
 h_fwconfiginfo1:\r
+#ifdef _NO_CONFIGBYTES_\r
+h_fwconfiginfo2:\r
+       rjmp handle_end_sleep\r
+#else\r
        configZ config_info1,r_bytep\r
        rjmp h_fwconfiginfo_go\r
 h_fwconfiginfo2:\r
        configZ config_info2,r_bytep\r
+/*#ifdef _CRC16_\r
+       cpi  r_bytep,24\r
+       breq h_fwconfiginfo_crc\r
+       cpi  r_bytep,26\r
+       breq h_fwconfiginfo_all\r
+//h_fwconfiginfo_end:\r
+       //configZ config_info1,r_bytep  //crc16 wird in config_info1 gespeichert, auch bei config_info2 \r
+       configZ config_info2,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+#endif\r
+*/\r
 \r
 h_fwconfiginfo_go:\r
        cpi  r_bytep,24\r
@@ -414,8 +437,10 @@ h_fwconfiginfo_go:
        breq h_fwconfiginfo_all\r
 #warning No CRC known code implemented\r
 #endif\r
+\r
 h_fwconfiginfo_end:\r
        //configZ config_info1,r_bytep  //crc16 wird in config_info1 gespeichert, auch bei config_info2 \r
+       //configZ config_info1,r_bytep\r
        ld   r_rwbyte,Z\r
        rjmp handle_end_inc\r
 h_fwconfiginfo_crc:\r
@@ -429,11 +454,15 @@ h_fwconfiginfo_crc:
        lds r_temp,crc+1\r
        com r_temp\r
        sts config_info1+25,r_temp\r
-       rjmp h_fwconfiginfo_end\r
+       ldi r_mode,OW_FWCONFIGINFO1  //auch CRC vom Dev 2 wird in Configinfo 1 geschrieben also da weiter machen\r
+       configZ config_info1,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+\r
 #endif\r
 h_fwconfiginfo_all:\r
        rjmp handle_end_sleep\r
-\r
+#endif\r
 \r
 ;---------------------------------------------------\r
 ;   CHANGE ROM FUNCTIONS\r
@@ -554,11 +583,10 @@ spause:
 .global OWINIT\r
 OWINIT:\r
        \r
-#ifndef _DIS_FLASH_\r
 ; check for bootloader jumper\r
        ;vor allen anderen Registerconfigs\r
        push r_temp\r
-\r
+#ifndef _DIS_FLASH_\r
        ldi r_temp,(1<<PUD) ;enable pullup \r
        out _SFR_IO_ADDR(MCUCR) ,r_temp\r
        sbi _SFR_IO_ADDR(PORTA),PINA5 ;internal pullup on PINA5\r
@@ -635,6 +663,7 @@ owinit_odgen2:
        dec r_bytep\r
        brne owinit_odgen1\r
        ;copy ids in config bytes\r
+#ifndef _NO_CONFIGBYTES_\r
        ldi  xl,lo8(owid1)\r
        ldi  xh,hi8(owid1)\r
        ldi      yl,lo8(config_info2+17)\r
@@ -655,7 +684,7 @@ owinit_cpconfig2:
        st Y+,r_rwbyte\r
        dec r_temp\r
        brne owinit_cpconfig2\r
-\r
+#endif\r
 \r
        ldi r_temp,0\r
        sts mode,r_temp\r
index 6440eae..48282c4 100644 (file)
 //#define OWT_PRESENT 50\r
 //#define OWT_WRITE 18\r
 //#define OWT_READ 4\r
-\r
+#ifdef __4MHZ__\r
+#define OWT_MIN_RESET 80\r
+#define OWT_RESET2 17\r
+#define OWT_RESET_PRESENT 15\r
+#define OWT_PRESENT 10\r
+#define OWT_WRITE 16\r
+#define OWT_READ 5\r
+#define OWT_ZP_WAIT_LOW_TO 36  ; Zeit fuer die Maximale Lowzeit bei der Zerro Polling pruefung. Ist die Leitung laenger low, ist es vieleicht ein Reset \r
+#define OWT_ZP_WAIT_HIGH_TO 54 ; Zeit fuer die Maximale Hight zeit bis zu einem Low Impuls vom Master. Nach laengeren Pausen wird nicht mehr gepollt sondern der Interrup vererndet.\r
+#else\r
 #define OWT_MIN_RESET 180\r
 #define OWT_RESET2 80\r
 #define OWT_RESET_PRESENT 30\r
@@ -74,7 +83,7 @@
 #define OWT_READ 12\r
 #define OWT_ZP_WAIT_LOW_TO 60  ; Zeit fuer die Maximale Lowzeit bei der Zerro Polling pruefung. Ist die Leitung laenger low, ist es vieleicht ein Reset \r
 #define OWT_ZP_WAIT_HIGH_TO 90 ; Zeit fuer die Maximale Hight zeit bis zu einem Low Impuls vom Master. Nach laengeren Pausen wird nicht mehr gepollt sondern der Interrup vererndet.\r
-\r
+#endif\r
 \r
 .macro CLEAR_TOV_FLAG\r
        ldi r_temp,1\r
        ldi r_temp,0x80;\r
        out _SFR_IO_ADDR(CLKPR),r_temp\r
        //ldi r_temp,(1<<CLKPS0)\r
+#ifdef __4MHZ__\r
+       ldi r_temp,0x01;\r
+#else\r
        ldi r_temp,0\r
+#endif\r
        out _SFR_IO_ADDR(CLKPR),r_temp\r
        ;Disable Timer int\r
        ldi r_temp,0\r