From 70973a0b14e8ff5f8808495a6ed267db2449a0a3 Mon Sep 17 00:00:00 2001 From: "A.M. Rowsell" Date: Wed, 27 Feb 2019 02:31:42 -0500 Subject: [PATCH] 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 --- dht.c | 27 +++++++++++++++++++++++++++ dht.h | 4 ++++ 2 files changed, 31 insertions(+) create mode 100644 dht.c create mode 100644 dht.h diff --git a/dht.c b/dht.c new file mode 100644 index 0000000..34cdea7 --- /dev/null +++ b/dht.c @@ -0,0 +1,27 @@ +#include +#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) { + +} diff --git a/dht.h b/dht.h new file mode 100644 index 0000000..794fc8b --- /dev/null +++ b/dht.h @@ -0,0 +1,4 @@ +#include "os_type.h" + +void ICACHE_FLASH_ATTR setupDHT(uint8_t pin); +void ICACHE_FLASH_ATTR getDHTData(uint8_t pin);