diff options
| author | LZerro <[email protected]> | 2024-04-30 08:46:12 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-29 20:46:12 -0400 |
| commit | f190cba0ab75a18a96002ded96054c435c21be47 (patch) | |
| tree | 79611031f34d819c77317b9905c9669de1786c51 /components | |
| parent | 4c9d3be98acafeebe1d530bdb8f71222706ef4ad (diff) | |
[i2c] adjust the timing for I2C initialization
Diffstat (limited to 'components')
| -rw-r--r-- | components/drivers/i2c/i2c-bit-ops.c | 6 | ||||
| -rw-r--r-- | components/drivers/include/drivers/i2c-bit-ops.h | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/components/drivers/i2c/i2c-bit-ops.c b/components/drivers/i2c/i2c-bit-ops.c index 1a36ee643e..005cf9035e 100644 --- a/components/drivers/i2c/i2c-bit-ops.c +++ b/components/drivers/i2c/i2c-bit-ops.c @@ -376,6 +376,12 @@ static rt_ssize_t i2c_bit_xfer(struct rt_i2c_bus_device *bus, rt_uint32_t i; rt_uint16_t ignore_nack; + if((ops->i2c_pin_init_flag == RT_FALSE) && (ops->pin_init != RT_NULL)) + { + ops->pin_init(); + ops->i2c_pin_init_flag = RT_TRUE; + } + if (num == 0) return 0; for (i = 0; i < num; i++) diff --git a/components/drivers/include/drivers/i2c-bit-ops.h b/components/drivers/include/drivers/i2c-bit-ops.h index ef278caa2c..2b4ea57990 100644 --- a/components/drivers/include/drivers/i2c-bit-ops.h +++ b/components/drivers/include/drivers/i2c-bit-ops.h @@ -27,6 +27,9 @@ struct rt_i2c_bit_ops rt_uint32_t delay_us; /* scl and sda line delay */ rt_uint32_t timeout; /* in tick */ + + void (*pin_init)(void); + rt_bool_t i2c_pin_init_flag; }; rt_err_t rt_i2c_bit_add_bus(struct rt_i2c_bus_device *bus, |
