2020-06-24 19:54:42 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2006-2019, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2017-07-24 Tanek the first version
|
|
|
|
* 2018-11-12 Ernest Chen modify copyright
|
2020-07-01 23:44:57 +08:00
|
|
|
* 2020-06-27 AHTYDHD modify to adapt in TM4C123
|
2020-06-24 19:54:42 +08:00
|
|
|
*/
|
2020-07-01 23:44:57 +08:00
|
|
|
|
2020-06-24 19:54:42 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2020-07-01 23:44:57 +08:00
|
|
|
#include "inc/hw_sysctl.h"
|
|
|
|
#include "inc/hw_memmap.h"
|
|
|
|
#include "driverlib/fpu.h"
|
|
|
|
#include "driverlib/sysctl.h"
|
|
|
|
#include "driverlib/systick.h"
|
2020-06-24 19:54:42 +08:00
|
|
|
#include "board.h"
|
|
|
|
|
|
|
|
uint32_t SystemCoreClock;
|
|
|
|
|
2020-07-01 23:44:57 +08:00
|
|
|
/* this function set the system clock */
|
2020-06-24 19:54:42 +08:00
|
|
|
void SystemCoreClockUpdate(void)
|
|
|
|
{
|
2020-07-01 23:44:57 +08:00
|
|
|
FPULazyStackingEnable();
|
|
|
|
/* Set the clocking to run directly from the crystal. 50MHz*/
|
2020-06-24 19:54:42 +08:00
|
|
|
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
|
2020-07-01 23:44:57 +08:00
|
|
|
SYSCTL_OSC_MAIN);
|
|
|
|
SystemCoreClock = SysCtlClockGet();
|
2020-06-24 19:54:42 +08:00
|
|
|
}
|
|
|
|
|
2020-07-01 23:44:57 +08:00
|
|
|
/* this funtion set the Systick and enable systick int */
|
2020-06-24 19:54:42 +08:00
|
|
|
void SysTickConfig()
|
|
|
|
{
|
2020-07-01 23:44:57 +08:00
|
|
|
SysTickDisable();
|
|
|
|
SysTickPeriodSet(SystemCoreClock / RT_TICK_PER_SECOND);
|
2020-06-24 19:54:42 +08:00
|
|
|
SysTickIntEnable();
|
2020-07-01 23:44:57 +08:00
|
|
|
SysTickEnable();
|
2020-06-24 19:54:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will initial your board.
|
|
|
|
*/
|
|
|
|
void rt_hw_board_init()
|
|
|
|
{
|
|
|
|
/* System Clock Update */
|
|
|
|
SystemCoreClockUpdate();
|
|
|
|
/* System Tick Configuration */
|
|
|
|
SysTickConfig();
|
|
|
|
|
|
|
|
#ifdef RT_USING_SERIAL
|
2020-07-01 23:44:57 +08:00
|
|
|
rt_hw_usart_init();
|
2020-06-24 19:54:42 +08:00
|
|
|
#endif
|
|
|
|
#ifdef RT_USING_PIN
|
2020-07-01 23:44:57 +08:00
|
|
|
rt_hw_pin_init();
|
2020-06-24 19:54:42 +08:00
|
|
|
#endif
|
|
|
|
#ifdef RT_USING_PWM
|
2020-07-01 23:44:57 +08:00
|
|
|
rt_hw_pwm_init();
|
2020-06-24 19:54:42 +08:00
|
|
|
#endif
|
|
|
|
/* Call components board initial (use INIT_BOARD_EXPORT()) */
|
|
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
|
|
rt_components_board_init();
|
|
|
|
#endif
|
2020-07-01 23:44:57 +08:00
|
|
|
/* set the console device */
|
|
|
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
2020-06-24 19:54:42 +08:00
|
|
|
|
|
|
|
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
|
|
|
|
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void SysTick_Handler(void)
|
|
|
|
{
|
|
|
|
/* enter interrupt */
|
|
|
|
rt_interrupt_enter();
|
|
|
|
rt_tick_increase();
|
|
|
|
/* leave interrupt */
|
|
|
|
rt_interrupt_leave();
|
|
|
|
}
|