File tree 2 files changed +14
-3
lines changed
TARGET_STM/TARGET_STM32H7
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ extern "C" {
48
48
#define I2CAPI_I2C3_CLKSRC RCC_I2C3CLKSOURCE_D2PCLK1
49
49
#define I2CAPI_I2C4_CLKSRC RCC_I2C4CLKSOURCE_D3PCLK1
50
50
51
+ #if (APB1CLK )
52
+ #define APB1CLK_MULTIPLIER (APB1CLK / 54000000)
53
+ #else
54
+ #define APB1CLK_MULTIPLIER (1)
55
+ #endif
56
+
51
57
/* Provide the suitable timing depending on requested frequencie */
52
58
static inline uint32_t get_i2c_timing (int hz )
53
59
{
@@ -64,13 +70,13 @@ static inline uint32_t get_i2c_timing(int hz)
64
70
*/
65
71
switch (hz ) {
66
72
case 100000 :
67
- tim = 0x10916998 ; // Standard mode with Rise time = 120ns, Fall time = 120ns
73
+ tim = 0x10916998 * APB1CLK_MULTIPLIER ; // Standard mode with Rise time = 120ns, Fall time = 120ns
68
74
break ;
69
75
case 400000 :
70
- tim = 0x00B11B54 ; // Fast Mode with Rise time = 120ns, Fall time = 120ns
76
+ tim = 0x00B11B54 * APB1CLK_MULTIPLIER ; // Fast Mode with Rise time = 120ns, Fall time = 120ns
71
77
break ;
72
78
case 1000000 :
73
- tim = 0x0090091B ; // Fast Mode Plus with Rise time = 120ns, Fall time = 10ns
79
+ tim = 0x0090091B * APB1CLK_MULTIPLIER ; // Fast Mode Plus with Rise time = 120ns, Fall time = 10ns
74
80
break ;
75
81
default :
76
82
break ;
Original file line number Diff line number Diff line change 2439
2439
"value" : " USE_PLL_HSE_EXTC" ,
2440
2440
"macro_name" : " CLOCK_SOURCE"
2441
2441
},
2442
+ "abp1_clock" : {
2443
+ "help" : " ABP1 clock to fix I2C speed calculation" ,
2444
+ "value" : " 112500000" ,
2445
+ "macro_name" : " APB1CLK"
2446
+ },
2442
2447
"lpticker_lptim" : {
2443
2448
"help" : " This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer" ,
2444
2449
"value" : 1
You can’t perform that action at this time.
0 commit comments