Added DHT prototypes.

Added the beginning of the DHT code which will likely be used
in part 4 of the tutorial series.

Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
This commit is contained in:
A.M. Rowsell 2019-02-27 02:31:42 -05:00
commit 70973a0b14
Signed by: amr
GPG key ID: 0B6E2D8375CF79A9
2 changed files with 31 additions and 0 deletions

27
dht.c Normal file
View file

@ -0,0 +1,27 @@
#include <stdint.h>
#include "user_interface.h"
#include "os_type.h"
#include "osapi.h"
#include "gpio.h"
#include "dht.h"
#define DHTBus BIT4
LOCAL uint8_t ICACHE_FLASH_ATTR getBitNum(uint32_t bit) {
uint32_t localBit = bit;
for(uint8_t i = 0; i <= 16; i++) {
localBit >>= i;
if(bit & 0x01) {
return i;
}
}
return -1; // if we reached this spot we received a bad number
}
void ICACHE_FLASH_ATTR setupDHT(void) {
gpio_output_set(0, DHTBus, 0, DHTBus); // set up DHTBus as active low output
ETS_GPIO_INTR_ATTACH(func, NULL);
}
void ICACHE_FLASH_ATTR getDHTData(void) {
}