8static constexpr uint8_t CH423_REG_SYS = 0x24;
9static constexpr uint8_t CH423_SYS_IO_OE = 0x01;
10static constexpr uint8_t CH423_SYS_OD_EN = 0x04;
11static constexpr uint8_t CH423_REG_IO = 0x30;
12static constexpr uint8_t CH423_REG_IO_RD = 0x26;
13static constexpr uint8_t CH423_REG_OCL = 0x22;
14static constexpr uint8_t CH423_REG_OCH = 0x23;
24 if (success && !(this->
sys_params_ & CH423_SYS_IO_OE)) {
32 ESP_LOGCONFIG(TAG,
"Initialization complete. Warning: %d, Error: %d", this->
status_has_warning(),
48 }
else if (pin >= 8 && pin < 24) {
78 uint8_t result = this->
read_reg_(CH423_REG_IO_RD);
89 ESPHOME_snprintf_P(buf,
sizeof(buf), ESPHOME_PSTR(
"write failed for register 0x%X, error %d"),
reg, err);
102 ESPHOME_snprintf_P(buf,
sizeof(buf), ESPHOME_PSTR(
"read failed for register 0x%X, error %d"),
reg, err);
void mark_failed()
Mark this component as failed.
void status_set_warning()
bool status_has_warning() const
bool status_has_error() const
void status_clear_warning()
uint8_t read_reg_(uint8_t reg)
void digital_write(uint8_t pin, bool value)
Helper function to write the value of a pin.
bool write_reg_(uint8_t reg, uint8_t value)
void setup() override
Check i2c availability and setup masks.
uint8_t pin_read_flags_
Flags to check if read previously during this loop.
uint8_t input_bits_
Copy of last read values.
uint8_t sys_params_
System parameters.
bool digital_read(uint8_t pin)
Helper function to read the value of a pin.
float get_setup_priority() const override
void pin_mode(uint8_t pin, gpio::Flags flags)
Helper function to set the pin mode of a pin.
void dump_config() override
void loop() override
Poll for input changes periodically.
uint32_t output_bits_
The mask to write as output state - 1 means HIGH, 0 means LOW.
virtual ErrorCode write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer, size_t read_count)=0
This virtual method writes bytes to an I2CBus from an array, then reads bytes into an array of ReadBu...
I2CBus * bus_
pointer to I2CBus instance
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
ESPHOME_LOG_TAG(TAG, "ch423")
@ ERROR_OK
No error found during execution of method.
constexpr float IO
For components that represent GPIO pins like PCF8573.
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.