\r
-// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de\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
#include <avr/pgmspace.h>\r
#include "../common/I2C/USI_TWI_Master.h"\r
#include "../common/I2C/MAX44009.h"\r
+#include "../common/owSlave_tools.h"\r
\r
-\r
-extern void OWINIT();\r
-\r
-extern void EXTERN_SLEEP();\r
-\r
-\r
+OWST_EXTERN_VARS\r
+//-D__4MHZ__\r
uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/\r
-uint8_t config_info[16]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
+uint8_t config_info[26]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\r
\r
-#if (owid>128) \r
-#error "Variable not correct"\r
-#endif\r
-\r
-extern uint8_t mode;\r
-extern uint8_t gcontrol;\r
-extern uint8_t reset_indicator;\r
-extern uint8_t alarmflag;\r
-\r
\r
uint8_t max_adr=0;\r
\r
\r
\r
int main(void){\r
- PRR|=(1<<PRADC); // adc for save Power\r
+ OWST_INIT_USI_ON\r
pack.temp=0x0550;\r
pack.config=0x7F;\r
pack.TH=75;\r
pack.rrFF=0xFF;\r
pack.rr00=0;\r
pack.rr10=0x10;\r
- PORTA=0xFF;\r
- PORTB=0xFF;\r
- OWINIT();\r
-\r
- MCUCR &=~(1<<PUD); //All Pins Pullup...\r
- MCUCR |=(1<<BODS);\r
\r
- MCUSR=0;\r
+ OWINIT();\r
+ OWST_EN_PULLUP\r
USI_TWI_Master_Initialise();\r
if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;\r
\r
sei();\r
while(1) {\r
\r
- if (gcontrol) {\r
+ if ((gcontrol&1)==1) {\r
//PORTB|=(1<<PINB1); //Dauer 2.3ms\r
volatile double l=MAX44009getlux(max_adr); \r
if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045\r
//pack.temp++;\r
alarmflag=af;\r
sei(); \r
+ gcontrol=0;\r
EXTERN_SLEEP(); \r
//PORTB&=~(1<<PINB1);\r
}\r
\r
\r
-#if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)\r
- if (((TIMSK & (1<<TOIE0))==0)&& (mode==0))\r
-#endif \r
-#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) ||defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__)\r
- if (((TIMSK0 & (1<<TOIE0))==0)&& (mode==0))\r
-#endif\r
- {\r
-\r
- MCUCR|=(1<<SE)|(1<<SM1);\r
- MCUCR&=~(1<<ISC01);\r
- } else {\r
- MCUCR|=(1<<SE);\r
- MCUCR&=~(1<<SM1);\r
- }\r
- //MCUCR&=~(1<<ISC01);\r
- asm("SLEEP");\r
+ OWST_MAIN_END\r
}\r
\r
\r