X-Git-Url: https://git.smho.de/gw/?p=owSlave2.git;a=blobdiff_plain;f=DS2450_SHT2X_BMP280_MAX44009%2FDS2450_SHT2X_BMP280_MAX44009.c;h=2d10504a86cfd761856faa4ed10b48d67f243fd5;hp=73cca746550977d840c7cad3e58efa8fbd93c58e;hb=refs%2Fheads%2Fmaster;hpb=a6a04f58e4afd20f206fdf4a8a7b3ce4062f1b67 diff --git a/DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.c b/DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.c index 73cca74..2d10504 100644 --- a/DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.c +++ b/DS2450_SHT2X_BMP280_MAX44009/DS2450_SHT2X_BMP280_MAX44009.c @@ -1,5 +1,5 @@ -// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de +// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -39,35 +39,23 @@ #include #include #include "../common/I2C/USI_TWI_Master.h" -#include "../common/I2C/SHT2x.h" +#include "../common/I2C/SHT2xV2.h" #include "../common/I2C/BMP280.h" #include "../common/I2C/MAX44009.h" -extern void OWINIT(); -extern void EXTERN_SLEEP(); +#include "../common/owSlave_tools.h" +#include "../common/calibr.h" + +OWST_EXTERN_VARS uint8_t owid[8]={0x20, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x02, 0x5D};/**/ -uint8_t config_info[16]={0x01,14,0x04,0x08, 0x03,15, 0x02,16,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info[26]={0x01,14,0x04,0x08, 0x03,15, 0x02,16,0x02,7,7,15,14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; #if (owid>128) #error "Variable not correct" #endif -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; -volatile uint8_t wdcounter=10; - +OWST_WDT_ISR -#if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) -ISR(WATCHDOG_vect) { -#else -ISR(WDT_vect) { -#endif - wdcounter++; - if (reset_indicator==1) reset_indicator++; - else if (reset_indicator==2) mode=0; -} typedef union { volatile uint8_t bytes[0x20]; @@ -114,14 +102,10 @@ volatile pack_t pack; -volatile int16_t am2302_temp; -volatile uint16_t am2302_hum; -uint8_t userRegister[1]; -int16_t sRH,sT; -volatile double temperatureC,humidityRH; -volatile double l; + double temperatureC,humidityRH; + double l; uint32_t P; int32_t t; uint8_t max_adr=0; @@ -129,6 +113,7 @@ uint8_t max_adr=0; int main(void){ + OWST_INIT_USI_ON pack.A=0; pack.B=0; pack.C=0; @@ -150,35 +135,17 @@ int main(void){ pack.HD=0xFF; pack.LD=0x00; pack.VCCP=0; - PORTB=0xFF-(1<3) { - SHT2x_MeasurePoll(HUMIDITY, &sRH); - // --- measure temperature with "Polling Mode" (no hold master) --- - SHT2x_MeasurePoll(TEMP, &sT); - //-- calculate humidity and temperature -- - temperatureC = SHT2x_CalcTemperatureC(sT); - humidityRH = SHT2x_CalcRH(sRH); + getSHT2xHumTemp(&temperatureC,&humidityRH); + humidityRH=calibr_hum(temperatureC,-0.2,humidityRH); + temperatureC =temperatureC -0.2; bmp280ConvertInt(&t,&P,1); l=MAX44009getlux(max_adr); if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045 @@ -245,7 +209,8 @@ int main(void){ while ((ADCSRA&(1<pack.HB) {alarmflag=1;pack.CSB2|=0x20;} if (pack.CSB2&0x04) //AEL @@ -272,7 +237,8 @@ int main(void){ while ((ADCSRA&(1<pack.HD) {alarmflag=1;pack.CSD2|=0x20;} if (pack.CSD2&0x04) //AEL @@ -297,21 +263,7 @@ int main(void){ bb=bb*2; }*/ -#if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) - if (((TIMSK & (1<