ESPHome 2026.5.0-dev
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
28
29 protected:
30 static void IRAM_ATTR gpio_intr(TCA9555Component *arg);
31 bool digital_read_hw(uint8_t pin) override;
32 bool digital_read_cache(uint8_t pin) override;
33 void digital_write_hw(uint8_t pin, bool value) override;
34
36 uint16_t mode_mask_{0x00};
38 uint16_t output_mask_{0x00};
40 uint16_t input_mask_{0x00};
41
42 bool read_gpio_modes_();
43 bool write_gpio_modes_();
44 bool read_gpio_outputs_();
45
47};
48
50class TCA9555GPIOPin : public GPIOPin, public Parented<TCA9555Component> {
51 public:
52 void setup() override;
53 void pin_mode(gpio::Flags flags) override;
54 bool digital_read() override;
55 void digital_write(bool value) override;
56 size_t dump_summary(char *buffer, size_t len) const override;
57
58 void set_pin(uint8_t pin) { this->pin_ = pin; }
59 void set_inverted(bool inverted) { this->inverted_ = inverted; }
61
62 gpio::Flags get_flags() const override { return this->flags_; }
63
64 protected:
65 uint8_t pin_;
68};
69
70} // namespace tca9555
71} // namespace esphome
Helper class to easily give an object a parent of type T.
Definition helpers.h:2013
A class to cache the read state of a GPIO expander.
Definition cached_gpio.h:29
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
bool digital_read_hw(uint8_t pin) override
Definition tca9555.cpp:92
void set_interrupt_pin(InternalGPIOPin *pin)
Definition tca9555.h:27
bool digital_read_cache(uint8_t pin) override
Definition tca9555.cpp:150
uint16_t mode_mask_
Mask for the pin mode - 1 means output, 0 means input.
Definition tca9555.h:36
InternalGPIOPin * interrupt_pin_
Definition tca9555.h:46
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:40
float get_setup_priority() const override
Definition tca9555.cpp:152
uint16_t output_mask_
The mask to write as output state - 1 means HIGH, 0 means LOW.
Definition tca9555.h:38
void digital_write_hw(uint8_t pin, bool value) override
Definition tca9555.cpp:114
void pin_mode(uint8_t pin, gpio::Flags flags)
Definition tca9555.cpp:44
static void IRAM_ATTR gpio_intr(TCA9555Component *arg)
Definition tca9555.cpp:35
Helper class to expose a TCA9555 pin as an internal input GPIO pin.
Definition tca9555.h:50
void digital_write(bool value) override
Definition tca9555.cpp:157
size_t dump_summary(char *buffer, size_t len) const override
Definition tca9555.cpp:158
void pin_mode(gpio::Flags flags) override
Definition tca9555.cpp:155
void set_inverted(bool inverted)
Definition tca9555.h:59
void set_flags(gpio::Flags flags)
Definition tca9555.h:60
gpio::Flags get_flags() const override
Definition tca9555.h:62
void set_pin(uint8_t pin)
Definition tca9555.h:58
uint16_t flags
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:1045