2021-09-07 20:08:26 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2021-01-04 iysheng first version
|
2021-09-08 13:03:25 +08:00
|
|
|
* 2021-09-07 idk500 suit for Vango V85xx
|
|
|
|
* 2021-09-08 ZhuXW add delay function
|
2021-09-07 20:08:26 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
|
|
|
#include <target.h>
|
|
|
|
#include <board.h>
|
|
|
|
#include <drv_usart.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* System Clock Configuration
|
|
|
|
*/
|
|
|
|
void SystemClock_Config(void)
|
|
|
|
{
|
|
|
|
// SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
|
|
|
|
NVIC_SetPriority(SysTick_IRQn, 0);
|
|
|
|
CLK_InitTypeDef CLK_Struct;
|
|
|
|
|
|
|
|
CLK_Struct.ClockType = CLK_TYPE_AHBSRC \
|
|
|
|
|CLK_TYPE_PLLL \
|
|
|
|
|CLK_TYPE_HCLK \
|
|
|
|
|CLK_TYPE_PCLK;
|
|
|
|
CLK_Struct.AHBSource = CLK_AHBSEL_LSPLL;
|
|
|
|
|
|
|
|
CLK_Struct.PLLL.Frequency = CLK_PLLL_26_2144MHz;
|
|
|
|
CLK_Struct.PLLL.Source = CLK_PLLLSRC_XTALL;
|
|
|
|
CLK_Struct.PLLL.State = CLK_PLLL_ON;
|
|
|
|
CLK_Struct.HCLK.Divider = 1;
|
|
|
|
CLK_Struct.PCLK.Divider = 2;
|
|
|
|
CLK_ClockConfig(&CLK_Struct);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the timer interrupt service routine.
|
|
|
|
*/
|
|
|
|
void SysTick_Handler(void)
|
|
|
|
{
|
|
|
|
/* enter interrupt */
|
|
|
|
rt_interrupt_enter();
|
|
|
|
|
|
|
|
rt_tick_increase();
|
|
|
|
|
|
|
|
/* leave interrupt */
|
|
|
|
rt_interrupt_leave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will initial V85xx board.
|
|
|
|
*/
|
|
|
|
void rt_hw_board_init()
|
|
|
|
{
|
|
|
|
SystemClock_Config();
|
|
|
|
|
|
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
|
|
rt_components_board_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_CONSOLE
|
|
|
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BSP_USING_SDRAM
|
|
|
|
rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END);
|
|
|
|
#else
|
|
|
|
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-09-08 13:03:25 +08:00
|
|
|
void rt_hw_us_delay(rt_uint32_t us)
|
|
|
|
{
|
|
|
|
rt_uint32_t ticks;
|
|
|
|
rt_uint32_t told, tnow, tcnt = 0;
|
|
|
|
rt_uint32_t reload = SysTick->LOAD;
|
|
|
|
|
|
|
|
ticks = us * reload / (1000000 / RT_TICK_PER_SECOND);
|
|
|
|
told = SysTick->VAL;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
tnow = SysTick->VAL;
|
|
|
|
if (tnow != told)
|
|
|
|
{
|
|
|
|
if (tnow < told)
|
|
|
|
{
|
|
|
|
tcnt += told - tnow;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tcnt += reload - tnow + told;
|
|
|
|
}
|
|
|
|
told = tnow;
|
|
|
|
if (tcnt >= ticks)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-07 20:08:26 +08:00
|
|
|
/*@}*/
|