Update documentation and fix small issues.

This commit is contained in:
Rafal Zajac
2017-11-13 16:29:21 +01:00
parent 45ab6f8e61
commit 931aee878b
23 changed files with 65 additions and 163 deletions

View File

@ -8,6 +8,5 @@ Before you can get the temperature and humidity from DHT22 you have to call
`esp_dht22_init`. You need to call it only once unless you change the GPIO
pin setup somewhere else in your code.
See driver documentation in [esp_dht22.h](include/esp_dht22.h) header file
for more details.
See [example program](../../examples/dht22) and driver documentation
in [esp_dht22.h](include/esp_dht22.h) header file for more details.

View File

@ -14,16 +14,17 @@
* under the License.
*/
#include <esp_dht22.h>
#include <esp_gpio.h>
#include <mem.h>
#include <user_interface.h>
#define BUS_LOW(gpio_num) (GPIO_OUT_EN_S = (0x1 << (gpio_num)))
#define BUS_HIGH(gpio_num) (GPIO_OUT_EN_C = (0x1 << (gpio_num)))
#define BUS_RELEASE(gpio_num) (GPIO_OUT_EN_C = (0x1 << (gpio_num)))
#define BUS_READ(gpio_num) ((GPIO_IN & (0x1 << (gpio_num))) != 0)
/**
* Measure number of 10us slots the state was kept.
*

View File

@ -14,6 +14,7 @@
* under the License.
*/
#ifndef ESP_DHT22_H
#define ESP_DHT22_H
@ -40,6 +41,7 @@ typedef enum {
void ets_isr_mask(unsigned intr);
void ets_isr_unmask(unsigned intr);
/**
* Initialize DHT22.
*

View File

@ -18,7 +18,7 @@ anymore.
Most of the operations with the DS18B20 library is based on passing pointers
to the `esp_ow_device` structure which has pointer to `esp_ds18b20_st`
status structure. The `esp_ds18b20_st` keeps track of last scratch pad read
the last temperature conversion.
and last temperature conversion.
```
esp_ow_device *device;
@ -34,12 +34,11 @@ esp_ow_dev *device = esp_ds18b20_new_dev(rom);
```
With DS18B20 temperature measurement takes between 94 and 750ms depending
on resolution. You don't want to block the CPU for that long waiting for
example using some kind of delay. That's why library is using event bus
(esp_eb) to emmit events when the temperature conversion is ready to read.
Check [example program](../../examples/ds18b20_temp) to see how it should be
done.
Temperature measurement with DS18B20 takes between 94 and 750ms depending
on resolution. You don't want to block the CPU for that long using some kind
of delay. That's why library is using event bus (esp_eb) to emmit events when
the temperature conversion is ready.
See driver documentation in [esp_ds18b20.h](include/esp_ds18b20.h) header file
for more details.
Check [example program](../../examples/ds18b20_temp) to see how it should be
done and driver documentation in [esp_ds18b20.h](include/esp_ds18b20.h)
header file for more details.

View File

@ -217,10 +217,15 @@ esp_ds18b20_search(uint8_t gpio_num, bool in_alert, esp_ow_device **list)
esp_ow_device *ICACHE_FLASH_ATTR
esp_ds18b20_new_dev(uint8_t *rom)
{
esp_ow_device *device = os_zalloc(sizeof(esp_ow_device));
esp_ds18b20_st *st = os_zalloc(sizeof(esp_ds18b20_st));
esp_ow_device *device = esp_ow_new_dev(rom);
if (device == NULL) return NULL;
esp_ds18b20_st *st = os_zalloc(sizeof(esp_ds18b20_st));
if (st == NULL) {
os_free(device);
return NULL;
}
os_memcpy(device->rom, rom, 8);
st->last_temp = ESP_DS18B20_TEMP_ERR;
st->retries = -1;
device->custom = st;
@ -228,7 +233,6 @@ esp_ds18b20_new_dev(uint8_t *rom)
return device;
}
esp_ow_device *ICACHE_FLASH_ATTR
esp_ds18b20_get(uint8_t gpio_num)
{

View File

@ -95,7 +95,7 @@ esp_ds18b20_search(uint8_t gpio_num, bool in_alert, esp_ow_device **list);
*
* @param rom The pointer to 8 byte ROM address
*
* @return The device.
* @return The device or NULL on error.
*/
esp_ow_device *ICACHE_FLASH_ATTR
esp_ds18b20_new_dev(uint8_t *rom);

View File

@ -29,5 +29,4 @@ target_include_directories(esp_sht21 PUBLIC
esp_gen_lib(esp_sht21
${ESP_CMAKE_FIND_DIR}
${esp_i2c_LIBRARIES}
${esp_tim_LIBRARIES})
${esp_i2c_LIBRARIES})

View File

@ -14,5 +14,5 @@ Before you can start communicating with SHT21 you have to call
`esp_sht21_init`. You need to call it only once unless you change the GPIO
pins setup somewhere else in your code.
See driver documentation in [esp_sht21.h](include/esp_sht21.h) header file
for more details.
See [example program](../../examples/sht21) and driver documentation in
[esp_sht21.h](include/esp_sht21.h) header file for more details.

View File

@ -15,7 +15,6 @@
*/
#include <esp_sht21.h>
#include <osapi.h>
static uint8_t ICACHE_FLASH_ATTR
calc_crc(uint8_t init, const uint8_t *data, uint8_t len)

View File

@ -18,8 +18,8 @@
#ifndef ESP_SHT21_H
#define ESP_SHT21_H
#include <c_types.h>
#include <esp_i2c.h>
#include <c_types.h>
#define ESP_SHT21_ADDRESS 0x40
// Measure relative humidity. Hold Master Mode.
@ -56,6 +56,7 @@
// RH: 11bit TEMP: 11bit
#define ESP_SHT21_RES0 0x3
/**
* Initialize SHT21.
*