9static constexpr uint8_t INPUT_REG = 0x00;
10static constexpr uint8_t OUTPUT_REG = 0x08;
11static constexpr uint8_t INVERT_REG = 0x10;
12static constexpr uint8_t CONFIG_REG = 0x18;
13static constexpr uint8_t MASK_REG = 0x20;
14static constexpr uint8_t AUTO_INCREMENT = 0x80;
21 ESP_LOGE(TAG,
"PCA9505 not detected at 0x%02X", this->
address_);
36 for (uint8_t &bank : this->
mask_) {
45 ESP_LOGCONFIG(TAG,
"PCA9505:");
55 const uint8_t bank = pin / 8;
56 const uint8_t mask = 1 << (pin % 8);
62 const uint8_t bank = pin / 8;
63 const uint8_t mask = 1 << (pin % 8);
67 this->
mask_[bank] &= ~mask;
72 this->
mask_[bank] |= mask;
87 LOG_STR(
"Failed to read input register"));
95 LOG_STR(
"Failed to write register"));
102 uint8_t values[BANK_COUNT];
103 for (uint8_t &bank : values) {
107 LOG_STR(
"Failed to write register"));
void mark_failed()
Mark this component as failed.
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
void setup_interrupt_pin_()
InternalGPIOPin * interrupt_pin_
void enable_polling_loop_()
Call from pin_mode() for an input pin: without an interrupt pin the loop polls instead.
ErrorCode write_register(uint8_t a_register, const uint8_t *data, size_t len) const
writes an array of bytes to a specific register in the I²C device
uint8_t address_
store the address of the device on the bus
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
bool write_all_banks_(uint8_t reg, uint8_t value)
uint8_t output_[BANK_COUNT]
The output state per bank - 1 means HIGH, 0 means LOW.
bool read_bank_(uint8_t bank)
uint8_t config_[BANK_COUNT]
The pin config per bank - 1 means OUTPUT, 0 means INPUT.
void pin_mode(uint8_t pin, gpio::Flags flags)
uint8_t mask_[BANK_COUNT]
Which pins may pull INT low - 1 means masked, matching the chip.
bool digital_read_cache(uint8_t pin) override
uint8_t input_[BANK_COUNT]
The input pin states per bank - 1 means HIGH, 0 means LOW.
void dump_config() override
bool write_bank_(uint8_t reg, uint8_t bank, uint8_t value)
void digital_write_hw(uint8_t pin, bool value) override
bool digital_read_hw(uint8_t pin) override
@ ERROR_OK
No error found during execution of method.
ESPHOME_LOG_TAG(TAG, "pca9505")
ESPHOME_ALWAYS_INLINE constexpr void assign_bits(T &value, std::type_identity_t< T > mask, bool on)
Set the bits of mask in value when on is true, clear them otherwise.