5namespace pi4ioe5v6408 {
7static const uint8_t PI4IOE5V6408_REGISTER_DEVICE_ID = 0x01;
8static const uint8_t PI4IOE5V6408_REGISTER_IO_DIR = 0x03;
9static const uint8_t PI4IOE5V6408_REGISTER_OUT_SET = 0x05;
10static const uint8_t PI4IOE5V6408_REGISTER_OUT_HIGH_IMPEDENCE = 0x07;
11static const uint8_t PI4IOE5V6408_REGISTER_IN_DEFAULT_STATE = 0x09;
12static const uint8_t PI4IOE5V6408_REGISTER_PULL_ENABLE = 0x0B;
13static const uint8_t PI4IOE5V6408_REGISTER_PULL_SELECT = 0x0D;
14static const uint8_t PI4IOE5V6408_REGISTER_IN_STATE = 0x0F;
15static const uint8_t PI4IOE5V6408_REGISTER_INTERRUPT_ENABLE_MASK = 0x11;
16static const uint8_t PI4IOE5V6408_REGISTER_INTERRUPT_STATUS = 0x13;
18static const char *
const TAG =
"pi4ioe5v6408";
21 ESP_LOGCONFIG(TAG,
"Running setup");
23 this->
reg(PI4IOE5V6408_REGISTER_DEVICE_ID) |= 0b00000001;
24 this->
reg(PI4IOE5V6408_REGISTER_OUT_HIGH_IMPEDENCE) = 0b00000000;
28 ESP_LOGE(TAG,
"Failed to read GPIO modes");
33 ESP_LOGE(TAG,
"Failed to read GPIO outputs");
39 ESP_LOGCONFIG(TAG,
"PI4IOE5V6408:");
42 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
71 if (!this->
read_byte(PI4IOE5V6408_REGISTER_OUT_SET, &data)) {
85 if (!this->
read_byte(PI4IOE5V6408_REGISTER_IO_DIR, &data)) {
89#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
90 ESP_LOGV(TAG,
"Read GPIO modes: 0b" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(data));
102 if (!this->
read_byte(PI4IOE5V6408_REGISTER_IN_STATE, &data)) {
124#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
125 ESP_LOGV(TAG,
"Wrote GPIO output: 0b" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(this->
output_mask_));
146#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
148 "Wrote GPIO modes: 0b" BYTE_TO_BINARY_PATTERN
"\n"
149 "Wrote GPIO pullup/pulldown: 0b" BYTE_TO_BINARY_PATTERN
"\n"
150 "Wrote GPIO pull enable: 0b" BYTE_TO_BINARY_PATTERN,
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message="unspecified")
void status_clear_warning()
PI4IOE5V6408Component * parent_
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
bool digital_read_hw(uint8_t pin) override
bool read_gpio_outputs_()
void dump_config() override
uint8_t pull_enable_mask_
The mask to write as input buffer state - 1 means enabled, 0 means disabled.
uint8_t output_mask_
The mask to write as output state - 1 means HIGH, 0 means LOW.
uint8_t pull_up_down_mask_
The mask to write as pullup state - 1 means pullup, 0 means pulldown.
bool digital_read_cache(uint8_t pin) override
void digital_write_hw(uint8_t pin, bool value) override
uint8_t input_mask_
The state read in digital_read_hw - 1 means HIGH, 0 means LOW.
uint8_t mode_mask_
Mask for the pin mode - 1 means output, 0 means input.
void pin_mode(uint8_t pin, gpio::Flags flags)
float get_setup_priority() const override
void digital_write(bool value) override
void pin_mode(gpio::Flags flags) override
std::string dump_summary() const override
bool digital_read() override
const float IO
For components that represent GPIO pins like PCF8573.
Providing packet encoding functions for exchanging data with a remote host.
std::string str_sprintf(const char *fmt,...)