X-Git-Url: http://git.smho.de/gw/?p=owSlave2.git;a=blobdiff_plain;f=DS2438_SHT2X%2FDS2438_SHT2X.c;h=632a11214a7503eab87fe61f20d77f66f7323aeb;hp=eb182ef772281b6b6de941c6bff9a0536ab23373;hb=a07a7e7b05471927bf3046ee265792231711f8a4;hpb=286630139d0e6355ad62c7cbb0c9fe827cbb7fa7 diff --git a/DS2438_SHT2X/DS2438_SHT2X.c b/DS2438_SHT2X/DS2438_SHT2X.c index eb182ef..632a112 100644 --- a/DS2438_SHT2X/DS2438_SHT2X.c +++ b/DS2438_SHT2X/DS2438_SHT2X.c @@ -39,8 +39,7 @@ #include #include #include "../common/I2C/USI_TWI_Master.h" -#include "../common/I2C/MAX44009.h" -#include "../common/I2C/SHT2x.h" +#include "../common/I2C/SHT2xV2.h" #include "../common/calibr.h" extern void OWINIT(); @@ -86,8 +85,7 @@ volatile int16_t am2302_temp; volatile uint16_t am2302_hum; uint8_t userRegister[1]; -int16_t sRH,sT; -volatile double temperatureC,humidityRH; +double temperatureC,humidityRH; volatile double l; #if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) @@ -150,47 +148,31 @@ int main(void){ for(i=0;i<64;i++) pack.bytes[i]=0; MCUSR=0; USI_TWI_Master_Initialise(); - SHT2x_SoftReset(); - SHT2x_ReadUserRegister(userRegister); - //(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT; - SHT2x_WriteUserRegister(userRegister); //write changed user reg - // --- measure humidity with "Hold Master Mode (HM)" --- - 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); - + initSHT2x(); + _delay_ms(100); sei(); - while(1) { + while(1) { if (gcontrol) { wdcounter=3; gcontrol=0; } if (wdcounter>2) { - //PORTB|=(1<