ESPHome 2025.5.0
Loading...
Searching...
No Matches
tca9555.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/hal.h"
7
8namespace esphome {
9namespace tca9555 {
10
12 public i2c::I2CDevice,
13 public gpio_expander::CachedGpioExpander<uint8_t, 16> {
14 public:
15 TCA9555Component() = default;
16
18 void setup() override;
19 void pin_mode(uint8_t pin, gpio::Flags flags);
20
21 float get_setup_priority() const override;
22
23 void dump_config() override;
24
25 void loop() override;
26
27 protected:
28 bool digital_read_hw(uint8_t pin) override;
29 bool digital_read_cache(uint8_t pin) override;
30 void digital_write_hw(uint8_t pin, bool value) override;
31
33 uint16_t mode_mask_{0x00};
35 uint16_t output_mask_{0x00};
37 uint16_t input_mask_{0x00};
38
39 bool read_gpio_modes_();
40 bool write_gpio_modes_();
41 bool read_gpio_outputs_();
42};
43
45class TCA9555GPIOPin : public GPIOPin, public Parented<TCA9555Component> {
46 public:
47 void setup() override;
48 void pin_mode(gpio::Flags flags) override;
49 bool digital_read() override;
50 void digital_write(bool value) override;
51 std::string dump_summary() const override;
52
53 void set_pin(uint8_t pin) { this->pin_ = pin; }
54 void set_inverted(bool inverted) { this->inverted_ = inverted; }
55 void set_flags(gpio::Flags flags) { this->flags_ = flags; }
56
57 gpio::Flags get_flags() const override { return this->flags_; }
58
59 protected:
60 uint8_t pin_;
63};
64
65} // namespace tca9555
66} // namespace esphome
Helper class to easily give an object a parent of type T.
Definition helpers.h:538
A class to cache the read state of a GPIO expander.
Definition cached_gpio.h:18
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
bool digital_read_hw(uint8_t pin) override
Definition tca9555.cpp:76
bool digital_read_cache(uint8_t pin) override
Definition tca9555.cpp:134
uint16_t mode_mask_
Mask for the pin mode - 1 means output, 0 means input.
Definition tca9555.h:33
void setup() override
Check i2c availability and setup masks.
Definition tca9555.cpp:18
uint16_t input_mask_
The state read in digital_read_hw - 1 means HIGH, 0 means LOW.
Definition tca9555.h:37
float get_setup_priority() const override
Definition tca9555.cpp:136
uint16_t output_mask_
The mask to write as output state - 1 means HIGH, 0 means LOW.
Definition tca9555.h:35
void digital_write_hw(uint8_t pin, bool value) override
Definition tca9555.cpp:98
void pin_mode(uint8_t pin, gpio::Flags flags)
Definition tca9555.cpp:36
Helper class to expose a TCA9555 pin as an internal input GPIO pin.
Definition tca9555.h:45
void digital_write(bool value) override
Definition tca9555.cpp:141
void pin_mode(gpio::Flags flags) override
Definition tca9555.cpp:139
void set_inverted(bool inverted)
Definition tca9555.h:54
void set_flags(gpio::Flags flags)
Definition tca9555.h:55
gpio::Flags get_flags() const override
Definition tca9555.h:57
std::string dump_summary() const override
Definition tca9555.cpp:142
void set_pin(uint8_t pin)
Definition tca9555.h:53
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7