DS2423 FHEM LEDs
[owSlave2.git] / DS2423_DS2423 / DS2423_DS2423.c
index 68fb010..1dbd395 100644 (file)
@@ -47,7 +47,7 @@ extern void EXTERN_SLEEP(void);
 \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
+#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
@@ -75,7 +75,7 @@ typedef union {
 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
+#define pack2 pack1\r
 \r
 volatile uint8_t lastcps;\r
 typedef union {\r
@@ -162,6 +162,9 @@ ISR(ANA_COMP_vect) {
                        PORTB&=~(1<<PINB1);\r
                        CLKPR=0x80;\r
                        CLKPR=0;\r
+#ifdef FHEM_PLATINE\r
+                       LPORT_CH1|=LPIN_CH1;\r
+#endif\r
                        GIFR|=(1<<INTF0);\r
                }\r
        }\r
@@ -246,16 +249,16 @@ int main(void){
        //ACSR|=(1<<ACD);  //Disable Comparator\r
        ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
        MCUCR &=~(1<<PUD); //All Pins Pullup...\r
-#ifdef FHEM_PLATINE\r
+       #ifdef FHEM_PLATINE\r
        DIDR0|=(1<<ADC0D);\r
        PORTA&=~(1<<PINA0);//Disable Pullup\r
-#else\r
+       #else\r
        DIDR0|=(1<<ADC2D)|(1<<ADC1D); // Disable Digital input on Analog AIN0/AIN1  (PINA1 / PINA2)\r
        PORTA&=~(1<<PINA2); //AIN1\r
-#endif\r
+       #endif\r
        ACSR&=~(1<<ACD);\r
        ACSR|=(1<<ACIE)|(1<<ACIS1)|(1<<ACIS0)|(1<<ACBG); //Enabble comperator interrupt Rising edge....(1<<ACIS0) -> minus of Comperator falls down -> output of Comperator rises\r
-#ifdef FHEM_PLATINE\r
+       #ifdef FHEM_PLATINE\r
        //Switch std AIN1 to A0\r
        ADCSRA&=~(1<<ADEN);\r
        ADCSRB=(1<<ACME);\r
@@ -265,13 +268,14 @@ int main(void){
 \r
 \r
        LPORT_CH0|=LPIN_CH0;\r   _delay_ms(500);\r        LPORT_CH0&=~LPIN_CH0;\r
-#endif\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 (LPORT_CH1&LPIN_CH1) {\r                      _delay_ms(50);\r                 LPORT_CH1&=~LPIN_CH1;\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
@@ -281,7 +285,7 @@ int main(void){
                                //count Resets\r                         changefromeeprom=1;\r
                        }\r
                }\r
-#endif\r
+               #endif\r
                MCUCR|=(1<<SE);\r
                MCUCR&=~(1<<SM1);\r
                asm("SLEEP");\r