board.c 1.7 KB
Newer Older
L
luo jiao 已提交
1
/*
2
 * Copyright (c) 2006-2021, RT-Thread Development Team
L
luo jiao 已提交
3
 *
4
 * SPDX-License-Identifier: Apache-2.0
L
luo jiao 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * Change Logs:
 * Date           Author       Notes
 * 2009-01-05     Bernard      first implementation
 */
#include <stdint.h>
#include <rthw.h>
#include <rtthread.h>
#include <board.h>

/**
  * @brief  This function is executed in case of error occurrence.
  * @param  None
  * @retval None
  */
void Error_Handler(void)
{
L
luo jiao 已提交
22 23 24 25 26 27
    /* USER CODE BEGIN Error_Handler */
    /* User can add his own implementation to report the HAL error return state */
    while (1)
    {
    }
    /* USER CODE END Error_Handler */
L
luo jiao 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
}

/** System Clock Configuration
*/
void SystemClock_Config(void)
{
    SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
    NVIC_SetPriority(SysTick_IRQn, 0);
}

/**
 * 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 GD32 board.
 */
void rt_hw_board_init()
{
L
luo jiao 已提交
58
    /* NVIC Configuration */
L
luo jiao 已提交
59 60 61 62 63 64 65 66
#define NVIC_VTOR_MASK              0x3FFFFF80
#ifdef  VECT_TAB_RAM
    /* Set the Vector Table base location at 0x10000000 */
    SCB->VTOR  = (0x10000000 & NVIC_VTOR_MASK);
#else  /* VECT_TAB_FLASH  */
    /* Set the Vector Table base location at 0x08000000 */
    SCB->VTOR  = (0x08000000 & NVIC_VTOR_MASK);
#endif
L
luo jiao 已提交
67

L
luo jiao 已提交
68
    SystemClock_Config();
L
luo jiao 已提交
69

L
luo jiao 已提交
70 71 72 73 74
#ifdef RT_USING_COMPONENTS_INIT
    rt_components_board_init();
#endif

#ifdef RT_USING_CONSOLE
L
luo jiao 已提交
75
    rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
L
luo jiao 已提交
76
#endif
L
luo jiao 已提交
77

mysterywolf's avatar
mysterywolf 已提交
78
#ifdef RT_USING_HEAP
L
luo jiao 已提交
79 80 81 82 83
    rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
#endif
}

/*@}*/