extern uint8_t gcontrol;
extern uint8_t reset_indicator;
extern uint8_t alarmflag;
-volatile uint8_t wdcounter;
+volatile uint8_t wdcounter=3;
#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__)
volatile uint16_t am2302_hum;
+int testSW(void) {
+ uint8_t r;
+ DDRB&=~(1<<PORTB0); //Eingang
+ __asm__ __volatile__ ("nop");
+ PORTB|=(1<<PORTB0); //Pullup
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ r=PINB&(1<<PORTB0);
+ __asm__ __volatile__ ("nop");
+ PORTB&=~(1<<PORTB0);
+ __asm__ __volatile__ ("nop");
+ DDRB|=(1<<PORTB0); //Eingang
+ return (r==0);
+
+
+}
+
uint8_t userRegister[1];
int16_t sRH,sT;
volatile double temperatureC,humidityRH;
int main(void){
PRR|=(1<<PRADC); // adc for save Power
+ PORTA=0xFF;
+ PORTB=0xFF-(1<<PORTB0); //Schalter kann gegen Masse sein und zieht dann immer Strom
+ DDRB|=(1<<PORTB0); //Als Ausgang und 0
+
pack1.temp=0x0550;
pack1.config=0x7F;
pack1.TH=75;
PORTB=0xFF;
OWINIT();
+ ACSR|=(1<<ACD); //Disable Comparator
+ ADCSRB|=(1<<ACME); //Disable Analog multiplexer
MCUCR &=~(1<<PUD); //All Pins Pullup...
MCUCR |=(1<<BODS);
+
WDTCSR |= ((1<<WDCE) ); // Enable the WD Change Bit//| (1<<WDE)
WDTCSR |= (1<<WDIE) | // Enable WDT Interrupt
- (1<<WDP2) | (1<<WDP1); // Set Timeout to ~1 seconds
+ (1<<WDP3) | (1<<WDP0); // Set Timeout to ~8 seconds
+ if (testSW()) {
+ config_info2[5]=8;
+ }else{
+ config_info2[5]=7;
+ }
+
MCUSR=0;
USI_TWI_Master_Initialise();
gcontrol=1;
sei();
while(1) {
- if (wdcounter>0) {
+ if ((gcontrol==2)||(gcontrol==3)) {
+ wdcounter=3;
+ gcontrol=0;
+ }
+ if (wdcounter>3) {
SHT2x_MeasurePoll(HUMIDITY, &sRH);
// --- measure temperature with "Polling Mode" (no hold master) ---
SHT2x_MeasurePoll(TEMP, &sT);
sei();
EXTERN_SLEEP();
}
- if ((gcontrol==2)||(gcontrol==3)) {
- gcontrol=0;
-
- }
+
#if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)