Merge pull request #4135 from balanceTWK/master_hal_delay
[BSP][STM32] update void HAL_Delay(__IO uint32_t Delay)
This commit is contained in:
commit
b2a6dbadf4
|
@ -71,7 +71,17 @@ 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 */
|
||||
|
@ -90,7 +100,7 @@ void _Error_Handler(char *s, int num)
|
|||
{
|
||||
/* USER CODE BEGIN Error_Handler */
|
||||
/* User can add his own implementation to report the HAL error return state */
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
/* USER CODE END Error_Handler */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue