46 lines
1.3 KiB
C
Executable File
46 lines
1.3 KiB
C
Executable File
#pragma once
|
|
|
|
#include "esp_err.h"
|
|
#include "esp_log.h"
|
|
#include "driver/rmt_tx.h"
|
|
#include "driver/rmt_rx.h"
|
|
#include "driver/gpio.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "freertos/queue.h"
|
|
#include "esp_timer.h"
|
|
|
|
#define ZH_ONEWIRE_SLAVE_INIT_CONFIG_DEFAULT() \
|
|
{ \
|
|
.bus_pin = GPIO_NUM_5, \
|
|
.task_priority = 4, \
|
|
.stack_size = 2048}
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
typedef enum
|
|
{
|
|
ZH_DS1820 = 0x10 // DS1920, DS1820, DS18S20, DS18B20.
|
|
} zh_onewire_slave_device_type_t;
|
|
|
|
typedef struct
|
|
{
|
|
zh_onewire_slave_device_type_t device_type;
|
|
uint8_t device_rom[8];
|
|
} zh_onewire_slave_device_handler_t;
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t bus_pin; // Onewire bus GPIO connection. @attention Must be pull-up to the VCC via 4.7K resistor.
|
|
uint8_t task_priority; // Task priority for the onewire messages processing. @note It is not recommended to set a value less than 4.
|
|
uint16_t stack_size; // Stack size for task for the onewire messages processing. @note The minimum size is 2048 bytes.
|
|
} zh_onewire_slave_init_config_t;
|
|
|
|
esp_err_t zh_onewire_slave_init(const zh_onewire_slave_init_config_t *config);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |