Skip to content

Commit 0893e54

Browse files
committed
[bsp][stm32f1xx-hal]修复当开启优化时m3_m4_delay_us延时失效问题
1 parent 6e5751d commit 0893e54

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bsp/stm32f10x-HAL/drivers/board.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ void SystemClock_Config(void)
115115

116116
static void m3_m4_delay_us(rt_uint32_t us)
117117
{
118-
int i = (HAL_RCC_GetHCLKFreq() / 4000000 * us);
119-
while (i)
118+
__IO uint32_t Delay = us * (SystemCoreClock / 8U / 1000000U);
119+
do
120120
{
121-
i--;
122-
}
121+
__NOP();
122+
}
123+
while (Delay --);
123124
}
124125

125126
void HAL_Delay(__IO uint32_t Delay)

0 commit comments

Comments
 (0)