ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
pca9505.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
9
10namespace esphome::pca9505 {
11
13static constexpr uint8_t PIN_COUNT = 40;
15static constexpr uint8_t BANK_COUNT = PIN_COUNT / 8;
16
17class PCA9505Component final : public gpio_expander::CachedGpioExpanderComponent<uint8_t, PIN_COUNT>,
18 public i2c::I2CDevice {
19 public:
20 void setup() override;
21 void pin_mode(uint8_t pin, gpio::Flags flags);
22
23 void dump_config() override;
24
25 protected:
26 bool digital_read_hw(uint8_t pin) override;
27 void digital_write_hw(uint8_t pin, bool value) override;
28
29 bool read_bank_(uint8_t bank);
30 bool write_bank_(uint8_t reg, uint8_t bank, uint8_t value);
31 bool write_all_banks_(uint8_t reg, uint8_t value);
32
34 uint8_t config_[BANK_COUNT]{};
36 uint8_t output_[BANK_COUNT]{};
38 uint8_t mask_[BANK_COUNT]{};
39};
40
42
43} // namespace esphome::pca9505
44
Base for expanders that cache reads per loop, with the per-bank input store of GpioExpanderInputs.
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
Definition i2c.h:164
bool write_all_banks_(uint8_t reg, uint8_t value)
Definition pca9505.cpp:96
uint8_t output_[BANK_COUNT]
The output state per bank - 1 means HIGH, 0 means LOW.
Definition pca9505.h:36
bool read_bank_(uint8_t bank)
Definition pca9505.cpp:80
uint8_t config_[BANK_COUNT]
The pin config per bank - 1 means OUTPUT, 0 means INPUT.
Definition pca9505.h:34
void pin_mode(uint8_t pin, gpio::Flags flags)
Definition pca9505.cpp:59
uint8_t mask_[BANK_COUNT]
Which pins may pull INT low - 1 means masked, matching the chip.
Definition pca9505.h:38
bool write_bank_(uint8_t reg, uint8_t bank, uint8_t value)
Definition pca9505.cpp:88
void digital_write_hw(uint8_t pin, bool value) override
Definition pca9505.cpp:52
bool digital_read_hw(uint8_t pin) override
Definition pca9505.cpp:50
uint16_t flags
uint32_t value
Definition hal.cpp:59
ESPHOME_EXPANDER_PIN_SUMMARY_DECL(esphome::pca9505::PCA9505Component)