7static constexpr uint8_t CH423_REG_SYS = 0x24;
8static constexpr uint8_t CH423_SYS_IO_OE = 0x01;
9static constexpr uint8_t CH423_SYS_OD_EN = 0x04;
10static constexpr uint8_t CH423_REG_IO = 0x30;
11static constexpr uint8_t CH423_REG_IO_RD = 0x26;
12static constexpr uint8_t CH423_REG_OCL = 0x22;
13static constexpr uint8_t CH423_REG_OCH = 0x23;
15static const char *
const TAG =
"ch423";
23 if (success && !(this->
sys_params_ & CH423_SYS_IO_OE)) {
27 ESP_LOGE(TAG,
"CH423 not detected");
32 ESP_LOGCONFIG(TAG,
"Initialization complete. Warning: %d, Error: %d", this->
status_has_warning(),
42 ESP_LOGCONFIG(TAG,
"CH423:");
44 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
53 }
else if (pin >= 8 && pin < 24) {
87 uint8_t result = this->
read_reg_(CH423_REG_IO_RD);
98 ESPHOME_snprintf_P(buf,
sizeof(buf), ESPHOME_PSTR(
"write failed for register 0x%X, error %d"),
reg, err);
111 ESPHOME_snprintf_P(buf,
sizeof(buf), ESPHOME_PSTR(
"read failed for register 0x%X, error %d"),
reg, err);
141 return snprintf(buffer,
len,
"EXIO%u via CH423", this->
pin_);
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
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_loop_priority() const override
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.
void digital_write(bool value) override
void set_flags(gpio::Flags flags)
size_t dump_summary(char *buffer, size_t len) const override
bool digital_read() override
void pin_mode(gpio::Flags flags) override
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
@ ERROR_OK
No error found during execution of method.
const float IO
For components that represent GPIO pins like PCF8573.