Skip to content

Commit c0c0c02

Browse files
authored
Support Clock Speed changing
Clock speed
1 parent 8b969c5 commit c0c0c02

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cores/esp32/esp32-hal-i2c.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "soc/i2c_reg.h"
2424
#include "soc/i2c_struct.h"
2525
#include "soc/dport_reg.h"
26+
#include "soc/rtc.h" // support clk speed switching
2627
#include "esp_attr.h"
2728

2829
//#define I2C_DEV(i) (volatile i2c_dev_t *)((i)?DR_REG_I2C1_EXT_BASE:DR_REG_I2C_EXT_BASE)
@@ -1611,7 +1612,9 @@ i2c_err_t i2cSetFrequency(i2c_t * i2c, uint32_t clk_speed)
16111612
}
16121613
I2C_FIFO_CONF_t f;
16131614

1614-
uint32_t period = (APB_CLK_FREQ/clk_speed) / 2;
1615+
// uint32_t period = (APB_CLK_FREQ/clk_speed) / 2;
1616+
uint32_t period = (rtc_clk_apb_freq_get()/clk_speed) / 2;
1617+
16151618
uint32_t halfPeriod = period/2;
16161619
uint32_t quarterPeriod = period/4;
16171620

0 commit comments

Comments
 (0)