2018-09-02 18:44:28 +08:00
|
|
|
/*
|
2018-11-16 20:30:56 +08:00
|
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
2018-09-02 18:44:28 +08:00
|
|
|
*
|
2018-11-16 20:30:56 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2018-09-02 18:44:28 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2009-09-22 Bernard add board.h to this bsp
|
|
|
|
* 2018-09-02 xuzhuoyi modify for TMS320F28379D version
|
|
|
|
*/
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include "board.h"
|
2019-03-27 13:09:19 +08:00
|
|
|
#include "drv_sci.h"
|
2018-09-02 18:44:28 +08:00
|
|
|
#include "F28x_Project.h"
|
|
|
|
|
2019-04-10 22:33:25 +08:00
|
|
|
extern rt_uint32_t rt_thread_switch_interrupt_flag;
|
|
|
|
|
2018-09-03 00:03:06 +08:00
|
|
|
extern interrupt void RTOSINT_Handler();
|
|
|
|
|
2019-04-10 22:33:25 +08:00
|
|
|
void trap_rtosint()
|
|
|
|
{
|
|
|
|
if(rt_thread_switch_interrupt_flag)
|
|
|
|
asm(" trap #16");
|
|
|
|
}
|
|
|
|
|
2018-09-02 18:44:28 +08:00
|
|
|
/**
|
|
|
|
* This is the timer interrupt service routine.
|
|
|
|
*
|
|
|
|
*/
|
2019-03-27 13:09:19 +08:00
|
|
|
interrupt void cpu_timer2_isr(void)
|
2018-09-02 18:44:28 +08:00
|
|
|
{
|
2019-04-07 18:19:16 +08:00
|
|
|
CpuTimer2Regs.TCR.all = 0xC000;
|
2018-09-02 18:44:28 +08:00
|
|
|
/* enter interrupt */
|
|
|
|
rt_interrupt_enter();
|
|
|
|
|
|
|
|
rt_tick_increase();
|
|
|
|
/* leave interrupt */
|
|
|
|
rt_interrupt_leave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-04-10 22:33:25 +08:00
|
|
|
* This function will initial TMS320F28379D board.
|
2018-09-02 18:44:28 +08:00
|
|
|
*/
|
|
|
|
void rt_hw_board_init()
|
|
|
|
{
|
|
|
|
/* Configure the system clock @ 84 Mhz */
|
|
|
|
InitSysCtrl();
|
|
|
|
|
|
|
|
DINT;
|
|
|
|
InitPieCtrl();
|
|
|
|
|
|
|
|
IER = 0x0000;
|
|
|
|
IFR = 0x0000;
|
|
|
|
|
|
|
|
InitPieVectTable();
|
|
|
|
|
|
|
|
EALLOW; // This is needed to write to EALLOW protected registers
|
|
|
|
PieVectTable.TIMER2_INT = &cpu_timer2_isr;
|
2018-09-03 00:03:06 +08:00
|
|
|
PieVectTable.RTOS_INT = &RTOSINT_Handler;
|
2018-09-02 18:44:28 +08:00
|
|
|
EDIS;
|
|
|
|
|
|
|
|
InitCpuTimers();
|
|
|
|
ConfigCpuTimer(&CpuTimer2, 200, 1000000 / RT_TICK_PER_SECOND);
|
|
|
|
CpuTimer2Regs.TCR.all = 0x4000;
|
|
|
|
IER |= M_INT14;
|
|
|
|
|
|
|
|
#ifdef RT_USING_HEAP
|
|
|
|
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
|
|
|
|
#endif
|
2019-03-27 13:09:19 +08:00
|
|
|
|
|
|
|
rt_hw_sci_init();
|
|
|
|
|
2018-09-02 18:44:28 +08:00
|
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
|
|
rt_components_board_init();
|
|
|
|
#endif
|
|
|
|
#ifdef RT_USING_CONSOLE
|
|
|
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
|
|
#endif
|
2019-04-10 22:33:25 +08:00
|
|
|
rt_interrupt_leave_sethook((void (*)(void))trap_rtosint);
|
2018-09-02 18:44:28 +08:00
|
|
|
}
|