ESPHome  2024.11.1
one_wire_bus.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/hal.h"
4 #include "esphome/core/log.h"
5 #include <vector>
6 
7 namespace esphome {
8 namespace one_wire {
9 
10 class OneWireBus {
11  public:
18  virtual bool reset() = 0;
19 
21  virtual void write8(uint8_t val) = 0;
22 
24  virtual void write64(uint64_t val) = 0;
25 
27  void skip();
28 
30  virtual uint8_t read8() = 0;
31 
33  virtual uint64_t read64() = 0;
34 
36  bool select(uint64_t address);
37 
39  const std::vector<uint64_t> &get_devices();
40 
42  void search();
43 
45  const LogString *get_model_str(uint8_t model);
46 
47  protected:
48  std::vector<uint64_t> devices_;
49 
51  void dump_devices_(const char *tag);
52 
54  virtual void reset_search() = 0;
55 
57  virtual uint64_t search_int() = 0;
58 };
59 
60 } // namespace one_wire
61 } // namespace esphome
void skip()
Write a command to the bus that addresses all devices by skipping the ROM.
virtual void write64(uint64_t val)=0
Write a 64 bit unsigned integer to the bus. LSB first.
virtual void reset_search()=0
Reset the device search.
virtual bool reset()=0
Reset the bus, should be done before all write operations.
bool select(uint64_t address)
Select a specific address on the bus for the following command.
mopeka_std_values val[4]
void search()
Search for 1-Wire devices on the bus.
void dump_devices_(const char *tag)
log the found devices
const LogString * get_model_str(uint8_t model)
Get the description string for this model.
const std::vector< uint64_t > & get_devices()
Return the list of found devices.
virtual void write8(uint8_t val)=0
Write a word to the bus. LSB first.
virtual uint64_t search_int()=0
Search for a 1-Wire device on the bus. Returns 0 if all devices have been found.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
uint8_t address
Definition: bl0906.h:211
virtual uint8_t read8()=0
Read an 8 bit word from the bus.
std::vector< uint64_t > devices_
Definition: one_wire_bus.h:48
virtual uint64_t read64()=0
Read an 64-bit unsigned integer from the bus.