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;
23 if (success && !(this->
sys_params_ & CH423_SYS_IO_OE)) {
26 if (!this->
setup_check(success, LOG_STR(
"CH423 not detected")))
29 ESP_LOGCONFIG(TAG,
"Initialization complete. Warning: %d, Error: %d", this->
status_has_warning(),
45 }
else if (pin >= 8 && pin < 24) {
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
bool ESPHOME_ALWAYS_INLINE setup_check(bool ok)
Marks the component failed with message (default "Communication failed") unless ok; returns ok.
bool status_has_warning() const
bool status_has_error() const
bool status_comm_check(bool ok)
Sets the warning ("Communication failed") when not ok but never clears it; returns ok.
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.
bool read_reg_(uint8_t reg, uint8_t *value)
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
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.