Skip to content

Commit daa30cd

Browse files
Update I2C data mode and master bus timing settings
- Changed data mode to MSB first - Updated master bus timing functions for better performance
1 parent 7a3b461 commit daa30cd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cores/esp32/esp32-hal-i2c-slave.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t
316316
}
317317

318318
i2c_ll_slave_init(i2c->dev);
319-
i2c_ll_set_fifo_mode(i2c->dev, true);
319+
i2c_ll_set_data_mode(i2c->dev, I2C_DATA_MODE_MSB_FIRST, I2C_DATA_MODE_MSB_FIRST);
320320
i2c_ll_set_slave_addr(i2c->dev, slaveID, false);
321321
i2c_ll_set_tout(i2c->dev, I2C_LL_MAX_TIMEOUT);
322322
i2c_slave_set_frequency(i2c, frequency);
@@ -337,7 +337,7 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t
337337

338338
i2c_ll_disable_intr_mask(i2c->dev, I2C_LL_INTR_MASK);
339339
i2c_ll_clear_intr_mask(i2c->dev, I2C_LL_INTR_MASK);
340-
i2c_ll_set_fifo_mode(i2c->dev, true);
340+
i2c_ll_set_data_mode(i2c->dev, I2C_DATA_MODE_MSB_FIRST, I2C_DATA_MODE_MSB_FIRST);
341341

342342
if (!i2c->intr_handle) {
343343
uint32_t flags = ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED;
@@ -515,16 +515,16 @@ static bool i2c_slave_set_frequency(i2c_slave_struct_t *i2c, uint32_t clk_speed)
515515

516516
i2c_hal_clk_config_t clk_cal;
517517
#if SOC_I2C_SUPPORT_APB
518-
i2c_ll_cal_bus_clk(APB_CLK_FREQ, clk_speed, &clk_cal);
518+
i2c_ll_master_cal_bus_clk(APB_CLK_FREQ, clk_speed, &clk_cal);
519519
i2c_ll_set_source_clk(i2c->dev, SOC_MOD_CLK_APB); /*!< I2C source clock from APB, 80M*/
520520
#elif SOC_I2C_SUPPORT_XTAL
521521
i2c_ll_cal_bus_clk(XTAL_CLK_FREQ, clk_speed, &clk_cal);
522522
i2c_ll_set_source_clk(i2c->dev, SOC_MOD_CLK_XTAL); /*!< I2C source clock from XTAL, 40M */
523523
#endif
524524
i2c_ll_set_txfifo_empty_thr(i2c->dev, a);
525525
i2c_ll_set_rxfifo_full_thr(i2c->dev, SOC_I2C_FIFO_LEN - a);
526-
i2c_ll_set_bus_timing(i2c->dev, &clk_cal);
527-
i2c_ll_set_filter(i2c->dev, 3);
526+
i2c_ll_master_set_bus_timing(i2c->dev, &clk_cal);
527+
i2c_ll_master_set_filter(i2c->dev, 3);
528528
return true;
529529
}
530530

0 commit comments

Comments
 (0)