|
29 | 29 |
|
30 | 30 | /* Default register value when reset */
|
31 | 31 | // *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 | + |
37 | 43 | // *INDENT-OFF*
|
38 | 44 | #define REG_WR_OC_DEFAULT_VAL (0x0FUL)
|
39 | 45 | #define REG_WR_IO_DEFAULT_VAL (0xFFUL)
|
40 | 46 | #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) |
42 | 48 |
|
43 | 49 | #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) |
45 | 51 |
|
46 | 52 | /**
|
47 | 53 | * @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
|
117 | 123 | ESP_RETURN_ON_FALSE(ch422g, ESP_ERR_NO_MEM, TAG, "Malloc failed");
|
118 | 124 |
|
119 | 125 | ch422g->base.config.io_count = IO_COUNT;
|
120 |
| - ch422g->base.config.flags.dir_out_bit_zero = 1; |
121 | 126 | ch422g->i2c_num = i2c_num;
|
122 | 127 | ch422g->i2c_address = i2c_address;
|
123 | 128 | 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
|
199 | 204 | uint8_t data = ch422g->regs.wr_set;
|
200 | 205 |
|
201 | 206 | value &= 0xFF;
|
202 |
| - if (value > 0) { |
| 207 | + if (value != 0) { |
203 | 208 | data |= REG_WR_SET_BIT_IO_OE;
|
204 | 209 | } else {
|
205 | 210 | data &= ~REG_WR_SET_BIT_IO_OE;
|
|
0 commit comments