1
0
mirror of https://github.com/whowechina/chu_pico.git synced 2024-11-27 20:20:50 +01:00

Better timing, I think

This commit is contained in:
whowechina 2023-12-10 12:20:10 +08:00
parent 3a28d85b53
commit 7f991e3d5f
3 changed files with 8 additions and 1 deletions

Binary file not shown.

View File

@ -8,7 +8,7 @@
#define I2C_PORT i2c0
#define I2C_SDA 16
#define I2C_SCL 17
#define I2C_FREQ 733*1000
#define I2C_FREQ 633*1000
#define I2C_HUB_EN 19

View File

@ -17,11 +17,18 @@ static inline void i2c_hub_init()
gpio_init(I2C_HUB_EN);
gpio_set_dir(I2C_HUB_EN, GPIO_OUT);
gpio_put(I2C_HUB_EN, 1);
// reset at start to avoid failed power-on
sleep_ms(10);
gpio_put(I2C_HUB_EN, 0);
sleep_us(50);
gpio_put(I2C_HUB_EN, 1);
}
static inline void i2c_select(i2c_inst_t *i2c_port, uint8_t chn)
{
i2c_write_blocking_until(i2c_port, I2C_HUB_ADDR, &chn, 1, false, time_us_64() + 1000);
sleep_us(1);
}
#endif