ESPHome  2024.5.2
esp_one_wire.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/hal.h"
4 #include <vector>
5 
6 namespace esphome {
7 namespace dallas {
8 
9 extern const uint8_t ONE_WIRE_ROM_SELECT;
10 extern const int ONE_WIRE_ROM_SEARCH;
11 
12 class ESPOneWire {
13  public:
14  explicit ESPOneWire(InternalGPIOPin *pin);
15 
22  bool reset();
23 
25  void write_bit(bool bit);
26 
28  bool read_bit();
29 
31  void write8(uint8_t val);
32 
34  void write64(uint64_t val);
35 
37  void skip();
38 
40  uint8_t read8();
41 
43  uint64_t read64();
44 
46  void select(uint64_t address);
47 
49  void reset_search();
50 
52  uint64_t search();
53 
55  std::vector<uint64_t> search_vec();
56 
57  protected:
59  inline uint8_t *rom_number8_();
60 
62  uint8_t last_discrepancy_{0};
63  bool last_device_flag_{false};
64  uint64_t rom_number_{0};
65 };
66 
67 } // namespace dallas
68 } // namespace esphome
Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
Definition: gpio.h:84
void reset_search()
Reset the device search.
void skip()
Write a command to the bus that addresses all devices by skipping the ROM.
const int ONE_WIRE_ROM_SEARCH
mopeka_std_values val[4]
bool reset()
Reset the bus, should be done before all write operations.
void write_bit(bool bit)
Write a single bit to the bus, takes about 70µs.
ESPOneWire(InternalGPIOPin *pin)
std::vector< uint64_t > search_vec()
Helper that wraps search in a std::vector.
const uint8_t ONE_WIRE_ROM_SELECT
bool read_bit()
Read a single bit from the bus, takes about 70µs.
void write8(uint8_t val)
Write a word to the bus. LSB first.
uint8_t read8()
Read an 8 bit word from the bus.
uint64_t read64()
Read an 64-bit unsigned integer from the bus.
ISRInternalGPIOPin pin_
Definition: esp_one_wire.h:61
uint64_t search()
Search for a 1-Wire device on the bus. Returns 0 if all devices have been found.
uint8_t * rom_number8_()
Helper to get the internal 64-bit unsigned rom number as a 8-bit integer pointer. ...
void select(uint64_t address)
Select a specific address on the bus for the following command.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
void write64(uint64_t val)
Write a 64 bit unsigned integer to the bus. LSB first.