-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdht.h
66 lines (55 loc) · 1.81 KB
/
dht.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef _DHT_H
#define _DHT_H
/*
Author: Nima Askari
WebSite: http://www.github.com/NimaLTD
Instagram: http://instagram.com/github.NimaLTD
Youtube: https://www.youtube.com/channel/UCUhY7qY1klJm1d2kulr9ckw
Version: 2.0.1
Reversion History:
(2.0.1)
Fix STM32F4 gpio register.
(2.0.0)
Rewrite completly and Add external interrupt to reading pulses.
(1.0.0)
First Release.
*/
#ifdef __cplusplus
extern "C" {
#endif
//#########################################################################################################################
#include <stdbool.h>
#include "tim.h"
//#########################################################################################################################
typedef enum
{
DHT_Type_DHT11 = 0,
DHT_Type_DHT12,
DHT_Type_DHT21,
DHT_Type_DHT22,
DHT_Type_AM2301,
DHT_Type_AM2305
}DHT_Type_t;
typedef struct
{
TIM_HandleTypeDef *tim;
GPIO_TypeDef *gpio;
uint16_t pin;
DHT_Type_t type;
uint8_t data[84];
uint16_t cnt;
uint32_t time;
uint32_t lastCNT;
float temperature;
float humidity;
bool dataValid;
}DHT_t;
//#########################################################################################################################
void DHT_pinChangeCallBack(DHT_t *dht);
void DHT_init(DHT_t *dht, DHT_Type_t type, TIM_HandleTypeDef *tim, uint16_t timerBusFrequencyMHz, GPIO_TypeDef *gpio, uint16_t pin);
bool DHT_readData(DHT_t *dht, float *Temperature, float *Humidity);
//#########################################################################################################################
#ifdef __cplusplus
}
#endif
#endif