diff options
| author | ZYH <[email protected]> | 2018-10-11 16:47:25 +0800 |
|---|---|---|
| committer | ZYH <[email protected]> | 2018-10-11 16:47:25 +0800 |
| commit | ffdd7f98adf778f7fdfe46bf48d2845de4f559f4 (patch) | |
| tree | 0a59ef609931a5ba25a09ec84110214184f999a7 | |
| parent | d7b70ee9b009d07676ecda97ef4a87aca687ac92 (diff) | |
[Bsp][stm32f4xx-hal]修复I2C在开启优化时出现延时异常的问题
| -rw-r--r-- | bsp/stm32f4xx-HAL/drivers/drv_i2c.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bsp/stm32f4xx-HAL/drivers/drv_i2c.c b/bsp/stm32f4xx-HAL/drivers/drv_i2c.c index f1e4ca5a5f..4cc04ae292 100644 --- a/bsp/stm32f4xx-HAL/drivers/drv_i2c.c +++ b/bsp/stm32f4xx-HAL/drivers/drv_i2c.c @@ -78,11 +78,12 @@ static rt_int32_t drv_get_scl(void *data) static void drv_udelay(rt_uint32_t us) { - int i = (HAL_RCC_GetHCLKFreq() / 4000000 * us); - while (i) + __IO uint32_t Delay = us * (SystemCoreClock / 8U / 1000000U); + do { - i--; - } + __NOP(); + } + while (Delay --); } static const struct rt_i2c_bit_ops drv_bit_ops = |
