Skip to content

Commit 3c15025

Browse files
committed
feat: update
1 parent 5ba1a03 commit 3c15025

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/chip/CH422G.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,25 @@
2929

3030
/* Default register value when reset */
3131
// *INDENT-OFF*
32-
#define REG_WR_SET_DEFAULT_VAL (0x01UL) // Bit: | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
33-
// |---------|---|---|---------|---|----------|---|---------|
34-
// Value: | [SLEEP] | 0 | 0 | [OD_EN] | 0 | [A_SCAN] | 0 | [IO_OE] |
35-
// |---------|---|---|---------|---|----------|---|---------|
36-
// Default: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
32+
// #define REG_WR_SET_DEFAULT_VAL (0x01UL) // Bit: | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
33+
// // |---------|---|---|---------|---|----------|---|---------|
34+
// // Value: | [SLEEP] | 0 | 0 | [OD_EN] | 0 | [A_SCAN] | 0 | [IO_OE] |
35+
// // |---------|---|---|---------|---|----------|---|---------|
36+
// // Default: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
37+
#define REG_WR_SET_DEFAULT_VAL (0x01UL) // Bit: | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
38+
// | --- | --- | --- | --- | ------- | ------- | -------- | ------- |
39+
// Value: | / | / | / | / | [SLEEP] | [OD_EN] | [A_SCAN] | [IO_OE] |
40+
// | --- | --- | --- | --- | ------- | ------- | -------- | ------- |
41+
// Default: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
42+
3743
// *INDENT-OFF*
3844
#define REG_WR_OC_DEFAULT_VAL (0x0FUL)
3945
#define REG_WR_IO_DEFAULT_VAL (0xFFUL)
4046
#define REG_OUT_DEFAULT_VAL ((REG_WR_OC_DEFAULT_VAL << 8) | REG_WR_IO_DEFAULT_VAL)
41-
#define REG_DIR_DEFAULT_VAL (0xFFUL)
47+
#define REG_DIR_DEFAULT_VAL (0xFFFUL)
4248

4349
#define REG_WR_SET_BIT_IO_OE (1 << 0)
44-
#define REG_WR_SET_BIT_OD_EN (1 << 4)
50+
#define REG_WR_SET_BIT_OD_EN (1 << 2)
4551

4652
/**
4753
* @brief Device Structure Type
@@ -117,7 +123,6 @@ static esp_err_t esp_io_expander_new_i2c_ch422g(i2c_port_t i2c_num, uint32_t i2c
117123
ESP_RETURN_ON_FALSE(ch422g, ESP_ERR_NO_MEM, TAG, "Malloc failed");
118124

119125
ch422g->base.config.io_count = IO_COUNT;
120-
ch422g->base.config.flags.dir_out_bit_zero = 1;
121126
ch422g->i2c_num = i2c_num;
122127
ch422g->i2c_address = i2c_address;
123128
ch422g->regs.wr_set = REG_WR_SET_DEFAULT_VAL;
@@ -199,7 +204,7 @@ static esp_err_t write_direction_reg(esp_io_expander_handle_t handle, uint32_t v
199204
uint8_t data = ch422g->regs.wr_set;
200205

201206
value &= 0xFF;
202-
if (value > 0) {
207+
if (value != 0) {
203208
data |= REG_WR_SET_BIT_IO_OE;
204209
} else {
205210
data &= ~REG_WR_SET_BIT_IO_OE;

0 commit comments

Comments
 (0)