2018-09-02 18:44:28 +08:00
|
|
|
/*
|
2022-08-21 01:16:41 +08:00
|
|
|
* Copyright (c) 2006-2022, 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
|
2022-08-21 01:16:41 +08:00
|
|
|
* 2022-06-21 guyunjie fix bugs in trap_rtosint and enable interrupt nesting
|
2022-08-30 03:35:23 +08:00
|
|
|
* 2022-08-21 yuqi adding onboard devices initialization code
|
2018-09-02 18:44:28 +08:00
|
|
|
*/
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include "board.h"
|
2019-03-27 13:09:19 +08:00
|
|
|
#include "drv_sci.h"
|
2022-10-09 11:24:05 +08:00
|
|
|
#include "drv_gpio.h"
|
2018-09-02 18:44:28 +08:00
|
|
|
#include "F28x_Project.h"
|
|
|
|
|
2022-08-21 01:16:41 +08:00
|
|
|
#ifndef RT_USING_SMP
|
2024-10-24 05:08:29 +08:00
|
|
|
extern volatile rt_atomic_t rt_interrupt_nest;
|
2022-08-21 01:16:41 +08:00
|
|
|
#endif
|
|
|
|
|
2019-04-10 22:33:25 +08:00
|
|
|
extern rt_uint32_t rt_thread_switch_interrupt_flag;
|
|
|
|
|
2022-10-20 11:41:13 +08:00
|
|
|
extern interrupt void rtosint_handler();
|
2019-04-10 22:33:25 +08:00
|
|
|
|
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;
|
2022-08-21 01:16:41 +08:00
|
|
|
|
2018-09-02 18:44:28 +08:00
|
|
|
rt_interrupt_enter();
|
|
|
|
|
|
|
|
rt_tick_increase();
|
2022-10-20 11:41:13 +08:00
|
|
|
|
2018-09-02 18:44:28 +08:00
|
|
|
rt_interrupt_leave();
|
|
|
|
}
|
|
|
|
|
2022-10-09 11:24:05 +08:00
|
|
|
extern interrupt void XINT1_Handler(void);
|
|
|
|
extern interrupt void XINT2_Handler(void);
|
2018-09-02 18:44:28 +08:00
|
|
|
/**
|
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();
|
|
|
|
|
2022-08-30 03:35:23 +08:00
|
|
|
#ifdef _FLASH
|
|
|
|
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (Uint32)&RamfuncsLoadSize);
|
|
|
|
InitFlash();
|
|
|
|
#endif
|
2018-09-02 18:44:28 +08:00
|
|
|
EALLOW; // This is needed to write to EALLOW protected registers
|
|
|
|
PieVectTable.TIMER2_INT = &cpu_timer2_isr;
|
2022-10-20 11:41:13 +08:00
|
|
|
PieVectTable.RTOS_INT = &rtosint_handler;
|
2022-10-09 11:24:05 +08:00
|
|
|
|
|
|
|
#ifdef BSP_USING_XINT1
|
|
|
|
PieVectTable.XINT1_INT = &XINT1_Handler;
|
|
|
|
#endif
|
|
|
|
#ifdef BSP_USING_XINT2
|
|
|
|
PieVectTable.XINT2_INT = &XINT2_Handler;
|
|
|
|
#endif
|
|
|
|
#ifdef BSP_USING_XINT3
|
|
|
|
PieVectTable.XINT3_INT = &XINT3_Handler;
|
|
|
|
#endif
|
|
|
|
#ifdef BSP_USING_XINT4
|
|
|
|
PieVectTable.XINT4_INT = &XINT4_Handler;
|
|
|
|
#endif
|
|
|
|
#ifdef BSP_USING_XINT5
|
|
|
|
PieVectTable.XINT5_INT = &XINT5_Handler;
|
|
|
|
#endif
|
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;
|
2022-10-09 11:24:05 +08:00
|
|
|
IER |= M_INT1;
|
2018-09-02 18:44:28 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_HEAP
|
2022-08-30 03:35:23 +08:00
|
|
|
rt_system_heap_init(&__ebss_end, &(__heap_end));
|
2018-09-02 18:44:28 +08:00
|
|
|
#endif
|
2019-03-27 13:09:19 +08:00
|
|
|
|
2022-08-30 03:35:23 +08:00
|
|
|
#ifdef RT_USING_SERIAL
|
2019-03-27 13:09:19 +08:00
|
|
|
rt_hw_sci_init();
|
2022-08-30 03:35:23 +08:00
|
|
|
#endif
|
2019-03-27 13:09:19 +08:00
|
|
|
|
2022-10-09 11:24:05 +08:00
|
|
|
#ifdef RT_USING_PIN
|
|
|
|
rt_hw_pin_init();
|
|
|
|
#endif
|
|
|
|
|
2018-09-02 18:44:28 +08:00
|
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
|
|
rt_components_board_init();
|
|
|
|
#endif
|
2022-01-08 23:29:41 +08:00
|
|
|
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
|
2018-09-02 18:44:28 +08:00
|
|
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
|
|
#endif
|
|
|
|
}
|
2022-08-30 03:35:23 +08:00
|
|
|
|
|
|
|
int _args_main()
|
|
|
|
{
|
|
|
|
/* _args_main is the entry point called by _c_int00. We define it
|
|
|
|
* here to override the one defined by the compiler in args_main.c */
|
|
|
|
|
|
|
|
extern int rtthread_startup();
|
|
|
|
|
|
|
|
/* startup RT-Thread RTOS */
|
|
|
|
rtthread_startup();
|
|
|
|
/* never reach here*/
|
|
|
|
return 0;
|
|
|
|
}
|