Skip to content

Commit d3e1624

Browse files
committed
feat: update
1 parent 3c15025 commit d3e1624

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/chip/CH422G.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ void ESP_IOExpander_CH422G::enableOC_PushPull(void)
114114
ch422g->regs.wr_set = data;
115115
}
116116

117+
void ESP_IOExpander_CH422G::enableAllIO_Input(void)
118+
{
119+
esp_io_expander_ch422g_t *ch422g = (esp_io_expander_ch422g_t *)__containerof(handle, esp_io_expander_ch422g_t, base);
120+
uint8_t data = (uint8_t)(ch422g->regs.wr_set & ~REG_WR_SET_BIT_IO_OE);
121+
122+
// WR-SET
123+
CHECK_ERROR_RETURN(
124+
i2c_master_write_to_device(ch422g->i2c_num, CH422G_REG_WR_SET, &data, sizeof(data), pdMS_TO_TICKS(I2C_TIMEOUT_MS))
125+
);
126+
ch422g->regs.wr_set = data;
127+
}
128+
117129
static esp_err_t esp_io_expander_new_i2c_ch422g(i2c_port_t i2c_num, uint32_t i2c_address, esp_io_expander_handle_t *handle)
118130
{
119131
ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, TAG, "Invalid i2c num");

src/chip/CH422G.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ class ESP_IOExpander_CH422G: public ESP_IOExpander {
7979
*
8080
*/
8181
void enableOC_PushPull(void);
82+
83+
/**
84+
* @brief Enable IO0-7 input mode
85+
*
86+
*/
87+
void enableAllIO_Input(void);
8288
};
8389

8490
/**

0 commit comments

Comments
 (0)