ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
i2c_bus_host.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_HOST
4
6#include "esphome/core/log.h"
7#include "i2c_bus.h"
8
9namespace esphome::i2c {
10
11class HostI2CBus : public I2CBus, public Component {
12 public:
13 ~HostI2CBus() override;
14
15 void setup() override;
16 void dump_config() override;
17 float get_setup_priority() const override { return setup_priority::BUS; }
18
19 ErrorCode write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer,
20 size_t read_count) override;
21
22 void set_device(const std::string &device) { this->device_ = device; }
23 void set_scan(bool scan) { this->scan_ = scan; }
25
26 const std::string &get_device() const { return this->device_; }
27
28 protected:
29 void update_error_(const std::string &error);
31
32 std::string device_;
35 bool initialized_{false};
36 std::string first_error_;
37};
38
39} // namespace esphome::i2c
40
41#endif // USE_HOST
uint8_t address
Definition bl0906.h:4
uint16_le_t frequency
Definition bl0942.h:6
ErrorCode map_errno_to_error_code_(int err)
void set_device(const std::string &device)
float get_setup_priority() const override
void update_error_(const std::string &error)
const std::string & get_device() const
void set_frequency(uint32_t frequency)
ErrorCode write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer, size_t read_count) override
void dump_config() override
void set_scan(bool scan)
This Class provides the methods to read and write bytes from an I2CBus.
Definition i2c_bus.h:29
bool scan_
Should we scan ? Can be set in the yaml.
Definition i2c_bus.h:61
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
Definition i2c_bus.h:12
constexpr float BUS
For communication buses like i2c/spi.
Definition component.h:37
static void uint32_t