Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_sensDhtBlock.h
Go to the documentation of this file.
1 
79 #ifndef NZ_SENS_DHT_BLOCK_H
80 #define NZ_SENS_DHT_BLOCK_H
81 
82 #if defined(SENS_DHT_BLOCK_ENABLE)
83 
85 #define SENS_DHT_TYPE_DHT11 ( 1 )
86 #define SENS_DHT_TYPE_DHT22 ( 2 )
87 
88 typedef struct __attribute__((__packed__)) SENS_DHT_
89 {
90  BYTE data[5];
91  BYTE sm;
92 
93  union {
94  struct
95  {
96  unsigned char type : 4; //Sensor type
97  unsigned char error : 1;
98  unsigned char hasData : 1; //Set if sensor data has been read
99  unsigned char pwrSwtInverted : 1; //Power switch is inverted
100  unsigned char fill7to7 : 1;
101  } flags;
102  BYTE flagsVal;
103  };
104 
105  BYTE fill; //Fill required to get WORDs below on word boundaries
106  WORD tmrDelay; //Timer for read
107  WORD bitadrPwrSwt; //bitadr for power switch LAT register, or BITADR_NA if not used
108 
109 } DHT_SENSOR;
110 
111 
112 // DHT Sensor Error code
113 typedef enum
114 {
115  SENS_DHT_ERR_NONE = 0, // No Error
116  SENS_DHT_ERR_BUSY, // Module is currencly busy
117  SENS_DHT_ERR_INVALID_PORT, // Invalid port
118  SENS_DHT_ERR_PORT_LOW, // Port is low, but should be high
119  SENS_DHT_ERR_NO_RESPONCE, // No responce from DHT sensors
120  SENS_DHT_ERR_CRC // No responce from DHT sensors
121 } SENS_DHT_ERROR;
122 
123 
125 
126 
148 BYTE sensDht_init(WORD startupDelay, BYTE portPowerSwitch, BOOL powerSwitchInverted);
149 
150 
158 void sensDht_addSensor(BYTE portIdSens);
159 
160 
166 BOOL sensDht_isReady();
167 
168 
174 void sensDht_task();
175 
176 
190 BYTE sensDht_read(BYTE type, BYTE portIdSens);
191 
192 
202 WORD sensDht_getHumidityX10(void);
203 
204 
214 WORD sensDht_getHumidityInteger(void);
215 
216 
226 WORD sensDht_getHumidityDecimal(void);
227 
228 
238 WORD sensDht_getTemperatureX10(void);
239 
240 
250 WORD sensDht_getTemperatureInteger(void);
251 
252 
262 WORD sensDht_getTemperatureDecimal(void);
263 
264 
269 #define sensDht_getStatus() (dhtInfo.status)
270 
271 #endif //#if defined(SENS_DHT_BLOCK_ENABLE)
272 #endif //#ifndef NZ_SENS_DHT_BLOCK_H