98 #if !defined(SENS_DHT_NUMBER_OF_SENSORS)
99 #define SENS_DHT_NUMBER_OF_SENSORS ( 0 )
103 #if (SENS_DHT_NUMBER_OF_SENSORS > 0)
106 #if !defined(SENS_DHT_PIN_ARRAY_SIZE)
107 #define SENS_DHT_PIN_ARRAY_SIZE ( 256 )
111 #if !defined(SENS_DHT_TYPE)
112 #define SENS_DHT_TYPE ( 2 )
115 #if (SENS_DHT_PIN_ARRAY_SIZE!=4) && (SENS_DHT_PIN_ARRAY_SIZE!=8) && (SENS_DHT_PIN_ARRAY_SIZE!=16) && (SENS_DHT_PIN_ARRAY_SIZE!=32) && (SENS_DHT_PIN_ARRAY_SIZE!=64) & (SENS_DHT_PIN_ARRAY_SIZE!=128) && (SENS_DHT_PIN_ARRAY_SIZE!=256)
116 #error "SENS_DHT_PIN_ARRAY_SIZE must be 4,8,16,32,64,128 or 256!"
119 #if (SENS_DHT_NUMBER_OF_SENSORS >= 40)
120 #error "SENS_DHT_NUMBER_OF_SENSORS must be less than 40!"
125 typedef struct __attribute__((__packed__)) SENS_DHT_
135 unsigned char error : 1;
136 unsigned char newTemperature : 1;
137 unsigned char newHumidity : 1;
138 unsigned char fill3 : 1;
140 unsigned char fill4to6 : 3;
141 unsigned char initialized : 1;
145 unsigned char clearEachCycle : 4;
146 unsigned char fill4to7 : 4;
154 typedef struct __attribute__((aligned(2), packed)) SENS_DHT_INFO_
159 WORD tickLastPinChange;
161 WORD pinArr[SENS_DHT_PIN_ARRAY_SIZE];
173 unsigned char pwrSwtInverted : 1;
174 unsigned char fill1to7 : 7;
181 DHT_SENSOR sens[SENS_DHT_NUMBER_OF_SENSORS];
185 extern SENS_DHT_INFO dhtInfo;
217 BYTE sensDht_init(BYTE portIdSens, WORD startupDelay, BYTE portPowerSwitch, BOOL powerSwitchInverted);
244 #define sensDht_isr_MACRO(tick15bit_8us) \
245 tick15bit_8us = tick15bit_8us & 0x7fff; \
247 if ((portReadBitadr_MACRO(dhtInfo.bitadrPin))!=0) \
248 tick15bit_8us |= 0x8000; \
249 dhtInfo.pinArr[dhtInfo.pinPut] = tick15bit_8us; \
251 if (SENS_DHT_PIN_ARRAY_SIZE==256) \
254 dhtInfo.pinPut = (dhtInfo.pinPut+1) & (~(SENS_DHT_PIN_ARRAY_SIZE)); \
265 void sensDht_fbrTask();
278 void sensDht_addSensor(BYTE idxSensor, BYTE portIdSens);
284 void sensDht_startRead();
292 BOOL __INLINE_FUNCTION__ sensDht_hasNewHumidity(BYTE idxSensor) {
294 ret = dhtInfo.sens[idxSensor].flags.newHumidity;
295 dhtInfo.sens[idxSensor].flags.newHumidity = FALSE;
305 BOOL __INLINE_FUNCTION__ sensDht_hasNewTemperature(BYTE idxSensor) {
307 ret = dhtInfo.sens[idxSensor].flags.newTemperature;
308 dhtInfo.sens[idxSensor].flags.newTemperature = FALSE;
321 #if (SENS_DHT_TYPE == 2) //DHT22
322 #define sensDht_getHumidityX10(idxSensor) ((WORD)*((WORD*)&(dhtInfo.sens[idxSensor].data[0])))
323 #elif (SENS_DHT_TYPE == 1) //DHT11
324 #define sensDht_getHumidityX10(idxSensor) (((WORD*)&(dhtInfo.sens[].data[0]))[0] * 10)
336 #if (SENS_DHT_TYPE == 2) //DHT22
337 #define sensDht_getHumidityInteger(idxSensor) (((WORD)*((WORD*)&(dhtInfo.sens[idxSensor].data[0])))/10)
338 #elif (SENS_DHT_TYPE == 1) //DHT11
339 #define sensDht_getHumidityInteger(idxSensor) (dhtInfo.sens[idxSensor].data[0])
351 #if (SENS_DHT_TYPE == 2) //DHT22
352 #define sensDht_getHumidityDecimal(idxSensor) (((WORD)*((WORD*)&(dhtInfo.sens[idxSensor].data[0])))%10)
353 #elif (SENS_DHT_TYPE == 1) //DHT11
354 #define sensDht_getHumidityDecimal(idxSensor) (dhtInfo.sens[idxSensor].data[1])
366 #if (SENS_DHT_TYPE == 2) //DHT22
367 #define sensDht_getTemperatureX10(idxSensor) ((WORD)*((WORD*)&(dhtInfo.sens[idxSensor].data[2])))
368 #elif (SENS_DHT_TYPE == 1) //DHT11
369 #define sensDht_getTemperatureX10(idxSensor) (((WORD*)&(dhtInfo.sens[idxSensor].data[2]))[0] * 10)
381 #if (SENS_DHT_TYPE == 2) //DHT22
382 #define sensDht_getTemperatureInteger(idxSensor) (((WORD)*((WORD*)&(dhtInfo.sens[idxSensor].data[2])))/10)
383 #elif (SENS_DHT_TYPE == 1) //DHT11
384 #define sensDht_getTemperatureInteger(idxSensor) (dhtInfo.sens[idxSensor].data[2])
396 #if (SENS_DHT_TYPE == 2) //DHT22
397 #define sensDht_getTemperatureDecimal(idxSensor) (((WORD)*((WORD*)&(dhtInfo.sens[idxSensor].data[2])))%10)
398 #elif (SENS_DHT_TYPE == 1) //DHT11
399 #define sensDht_getTemperatureDecimal(idxSensor) (dhtInfo.sens[idxSensor].data[3])
412 BOOL sensDht_isIdle();
418 #define sensDht_getStatus() (dhtInfo.status)
421 #endif //#if (SENS_DHT_NUMBER_OF_SENSORS > 0)
423 #endif //#ifndef NZ_SENS_DHT_H