Skip to content

Commit 57303c1

Browse files
authored
Merge pull request #1877 from uestczyh222/f4_iic
[Bsp][stm32f4xx-hal]修复I2C在开启优化时出现延时异常的问题
2 parents 7c2a3c9 + ffdd7f9 commit 57303c1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bsp/stm32f4xx-HAL/drivers/drv_i2c.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ static rt_int32_t drv_get_scl(void *data)
7878

7979
static void drv_udelay(rt_uint32_t us)
8080
{
81-
int i = (HAL_RCC_GetHCLKFreq() / 4000000 * us);
82-
while (i)
81+
__IO uint32_t Delay = us * (SystemCoreClock / 8U / 1000000U);
82+
do
8383
{
84-
i--;
85-
}
84+
__NOP();
85+
}
86+
while (Delay --);
8687
}
8788

8889
static const struct rt_i2c_bit_ops drv_bit_ops =

0 commit comments

Comments
 (0)