Merge pull request #4135 from balanceTWK/master_hal_delay

[BSP][STM32] update void HAL_Delay(__IO uint32_t Delay)
This commit is contained in:
Bernard Xiong 2020-12-30 08:09:49 +08:00 committed by GitHub
commit b2a6dbadf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View File

@ -70,9 +70,19 @@ void HAL_ResumeTick(void)
}
void HAL_Delay(__IO uint32_t Delay)
{
if (rt_thread_self())
{
rt_thread_mdelay(Delay);
}
else
{
for (rt_uint32_t count = 0; count < Delay; count++)
{
rt_hw_us_delay(1000);
}
}
}
/* re-implement tick interface for STM32 HAL */
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
@ -107,10 +117,12 @@ void rt_hw_us_delay(rt_uint32_t us)
start = SysTick->VAL;
reload = SysTick->LOAD;
us_tick = SystemCoreClock / 1000000UL;
do {
do
{
now = SysTick->VAL;
delta = start > now ? start - now : reload + start - now;
} while(delta < us_tick * us);
delta = start >= now ? start - now : reload + start - now;
}
while (delta < us_tick * us);
}
/**

View File

@ -43,7 +43,7 @@ rt_uint8_t rt_thread_ready_table[32];
#ifndef RT_USING_SMP
extern volatile rt_uint8_t rt_interrupt_nest;
static rt_int16_t rt_scheduler_lock_nest;
struct rt_thread *rt_current_thread;
struct rt_thread *rt_current_thread = RT_NULL;
rt_uint8_t rt_current_priority;
#endif /*RT_USING_SMP*/