board.c 1.2 KB
Newer Older
Thomas_Fly's avatar
Thomas_Fly 已提交
1 2 3 4 5 6 7
/*
 * Copyright (c) 2006-2020, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
Thomas_Fly's avatar
Thomas_Fly 已提交
8
 * 2021-02-11     supperthomas first version
Thomas_Fly's avatar
Thomas_Fly 已提交
9 10
 *
 */
Thomas_Fly's avatar
Thomas_Fly 已提交
11

Thomas_Fly's avatar
Thomas_Fly 已提交
12 13
#include <rtthread.h>
#include <rthw.h>
Thomas_Fly's avatar
Thomas_Fly 已提交
14
#include <stdio.h>
Thomas_Fly's avatar
Thomas_Fly 已提交
15
#include "board.h"
Thomas_Fly's avatar
Thomas_Fly 已提交
16 17 18 19
#include "mxc_sys.h"
#ifdef RT_USING_SERIAL
#include "drv_usart.h"
#endif
Thomas_Fly's avatar
Thomas_Fly 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

/**
 * This is the timer interrupt service routine.
 *
 */
void SysTick_Handler(void)
{
    /* enter interrupt */
    rt_interrupt_enter();

    rt_tick_increase();

    /* leave interrupt */
    rt_interrupt_leave();
}

Thomas_Fly's avatar
Thomas_Fly 已提交
36
void rt_hw_systick_init(void)
Thomas_Fly's avatar
Thomas_Fly 已提交
37
{
Thomas_Fly's avatar
Thomas_Fly 已提交
38
    uint32_t error;
Thomas_Fly's avatar
Thomas_Fly 已提交
39
    error = SYS_SysTick_Config(SYS_SysTick_GetFreq() / RT_TICK_PER_SECOND, 1, MXC_TMR0);
Thomas_Fly's avatar
Thomas_Fly 已提交
40

Thomas_Fly's avatar
Thomas_Fly 已提交
41 42
    if (error != E_NO_ERROR)
    {
43
        rt_kprintf("ERROR: Ticks is not valid");
Thomas_Fly's avatar
Thomas_Fly 已提交
44
    }
Thomas_Fly's avatar
Thomas_Fly 已提交
45 46 47 48 49
}

void rt_hw_board_init(void)
{

Thomas_Fly's avatar
Thomas_Fly 已提交
50
    rt_hw_systick_init();
Thomas_Fly's avatar
Thomas_Fly 已提交
51 52

#if defined(RT_USING_HEAP)
Thomas_Fly's avatar
Thomas_Fly 已提交
53
    rt_system_heap_init((void *)(HEAP_BEGIN), (void *)(HEAP_END));
Thomas_Fly's avatar
Thomas_Fly 已提交
54
#endif
Thomas_Fly's avatar
Thomas_Fly 已提交
55

Thomas_Fly's avatar
Thomas_Fly 已提交
56
#ifdef RT_USING_SERIAL
Thomas_Fly's avatar
Thomas_Fly 已提交
57
    rt_hw_usart_init();
Thomas_Fly's avatar
Thomas_Fly 已提交
58
#endif
Thomas_Fly's avatar
Thomas_Fly 已提交
59

Thomas_Fly's avatar
Thomas_Fly 已提交
60 61 62
#ifdef RT_USING_CONSOLE
    rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
Thomas_Fly's avatar
Thomas_Fly 已提交
63

Thomas_Fly's avatar
Thomas_Fly 已提交
64 65 66 67 68
#ifdef RT_USING_COMPONENTS_INIT
    rt_components_board_init();
#endif
}