4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-21 01:47:09 +08:00

Merge pull request #1877 from uestczyh222/f4_iic

[Bsp][stm32f4xx-hal]修复I2C在开启优化时出现延时异常的问题
This commit is contained in:
Bernard Xiong 2018-10-11 18:51:08 +08:00 committed by GitHub
commit 57303c14be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,11 +78,12 @@ static rt_int32_t drv_get_scl(void *data)
static void drv_udelay(rt_uint32_t us) static void drv_udelay(rt_uint32_t us)
{ {
int i = (HAL_RCC_GetHCLKFreq() / 4000000 * us); __IO uint32_t Delay = us * (SystemCoreClock / 8U / 1000000U);
while (i) do
{ {
i--; __NOP();
} }
while (Delay --);
} }
static const struct rt_i2c_bit_ops drv_bit_ops = static const struct rt_i2c_bit_ops drv_bit_ops =