Merge pull request #5148 from loogg/mlw-fx
fix the tick of drv_common.c in stm32 bsp
This commit is contained in:
commit
e7f4a1177a
|
@ -28,20 +28,19 @@ static void reboot(uint8_t argc, char **argv)
|
|||
MSH_CMD_EXPORT(reboot, Reboot System);
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
extern __IO uint32_t uwTick;
|
||||
static uint32_t _systick_ms = 1;
|
||||
|
||||
/* SysTick configuration */
|
||||
void rt_hw_systick_init(void)
|
||||
{
|
||||
#if defined (SOC_SERIES_STM32H7)
|
||||
HAL_SYSTICK_Config((HAL_RCCEx_GetD1SysClockFreq()) / RT_TICK_PER_SECOND);
|
||||
#elif defined (SOC_SERIES_STM32MP1)
|
||||
HAL_SYSTICK_Config(HAL_RCC_GetSystemCoreClockFreq() / RT_TICK_PER_SECOND);
|
||||
#else
|
||||
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / RT_TICK_PER_SECOND);
|
||||
#endif
|
||||
#if !defined (SOC_SERIES_STM32MP1)
|
||||
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
|
||||
#endif
|
||||
HAL_SYSTICK_Config(SystemCoreClock / RT_TICK_PER_SECOND);
|
||||
|
||||
NVIC_SetPriority(SysTick_IRQn, 0xFF);
|
||||
|
||||
_systick_ms = 1000u / RT_TICK_PER_SECOND;
|
||||
if(_systick_ms == 0)
|
||||
_systick_ms = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +52,9 @@ void SysTick_Handler(void)
|
|||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
HAL_IncTick();
|
||||
if(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)
|
||||
HAL_IncTick();
|
||||
|
||||
rt_tick_increase();
|
||||
|
||||
/* leave interrupt */
|
||||
|
@ -62,7 +63,15 @@ void SysTick_Handler(void)
|
|||
|
||||
uint32_t HAL_GetTick(void)
|
||||
{
|
||||
return rt_tick_get_millisecond();
|
||||
if(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)
|
||||
HAL_IncTick();
|
||||
|
||||
return uwTick;
|
||||
}
|
||||
|
||||
void HAL_IncTick(void)
|
||||
{
|
||||
uwTick += _systick_ms;
|
||||
}
|
||||
|
||||
void HAL_SuspendTick(void)
|
||||
|
@ -91,6 +100,8 @@ void HAL_Delay(__IO uint32_t Delay)
|
|||
/* re-implement tick interface for STM32 HAL */
|
||||
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
||||
{
|
||||
rt_hw_systick_init();
|
||||
|
||||
/* Return function status */
|
||||
return HAL_OK;
|
||||
}
|
||||
|
@ -163,14 +174,8 @@ RT_WEAK void rt_hw_board_init()
|
|||
/* HAL_Init() function is called at the beginning of the program */
|
||||
HAL_Init();
|
||||
|
||||
/* enable interrupt */
|
||||
__set_PRIMASK(0);
|
||||
/* System clock initialization */
|
||||
SystemClock_Config();
|
||||
/* disable interrupt */
|
||||
__set_PRIMASK(1);
|
||||
|
||||
rt_hw_systick_init();
|
||||
|
||||
/* Heap initialization */
|
||||
#if defined(RT_USING_HEAP)
|
||||
|
|
Loading…
Reference in New Issue