summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxuzhuoyi <[email protected]>2019-04-10 22:33:25 +0800
committerxuzhuoyi <[email protected]>2019-04-10 22:33:25 +0800
commit4acd8db61eb366878b849716db25558abaa5325b (patch)
tree5aa795587fc7c76a590a1e14fbe0c5b9785419fd
parent4518a89634044a10b0ad84b605f9d271e2e6d6ed (diff)
[bsp][tms320f28379d] Add finsh init in rt_init_thread
-rw-r--r--bsp/tms320f28379d/applications/application.c9
-rw-r--r--bsp/tms320f28379d/drivers/board.c11
-rw-r--r--bsp/tms320f28379d/drivers/drv_sci.c4
-rw-r--r--libcpu/ti-dsp/c28x/context.s40
-rw-r--r--libcpu/ti-dsp/c28x/cpuport.c4
5 files changed, 56 insertions, 12 deletions
diff --git a/bsp/tms320f28379d/applications/application.c b/bsp/tms320f28379d/applications/application.c
index 4ceb5eef75..5c7b769a4d 100644
--- a/bsp/tms320f28379d/applications/application.c
+++ b/bsp/tms320f28379d/applications/application.c
@@ -12,12 +12,15 @@
#include <board.h>
#include <rtthread.h>
+#ifdef RT_USING_FINSH
+#include "shell.h"
+#endif
+
void rt_init_thread_entry(void* parameter)
{
- /* initialization RT-Thread Components */
- rt_components_init();
+#ifdef RT_USING_FINSH
finsh_system_init();
-
+#endif
}
int rt_application_init()
diff --git a/bsp/tms320f28379d/drivers/board.c b/bsp/tms320f28379d/drivers/board.c
index ee1c9f06af..b83cb7a966 100644
--- a/bsp/tms320f28379d/drivers/board.c
+++ b/bsp/tms320f28379d/drivers/board.c
@@ -13,8 +13,16 @@
#include "drv_sci.h"
#include "F28x_Project.h"
+extern rt_uint32_t rt_thread_switch_interrupt_flag;
+
extern interrupt void RTOSINT_Handler();
+void trap_rtosint()
+{
+ if(rt_thread_switch_interrupt_flag)
+ asm(" trap #16");
+}
+
/**
* This is the timer interrupt service routine.
*
@@ -31,7 +39,7 @@ interrupt void cpu_timer2_isr(void)
}
/**
- * This function will initial STM32 board.
+ * This function will initial TMS320F28379D board.
*/
void rt_hw_board_init()
{
@@ -68,4 +76,5 @@ void rt_hw_board_init()
#ifdef RT_USING_CONSOLE
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
+ rt_interrupt_leave_sethook((void (*)(void))trap_rtosint);
}
diff --git a/bsp/tms320f28379d/drivers/drv_sci.c b/bsp/tms320f28379d/drivers/drv_sci.c
index e345097f06..0920d382f5 100644
--- a/bsp/tms320f28379d/drivers/drv_sci.c
+++ b/bsp/tms320f28379d/drivers/drv_sci.c
@@ -214,7 +214,6 @@ int rt_hw_sci_init(void)
CpuSysRegs.PCLKCR7.bit.SCI_C = 1;
PieVectTable.SCIA_RX_INT = &sciaRxFifoIsr;
- //PieVectTable.SCIA_TX_INT = &sciaTxFifoIsr;
EDIS;
@@ -223,8 +222,7 @@ int rt_hw_sci_init(void)
//
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER9.bit.INTx1 = 1; // PIE Group 9, INT1
- //PieCtrlRegs.PIEIER9.bit.INTx2 = 1; // PIE Group 9, INT2
- IER = 0x100; // Enable CPU INT
+ IER |= 0x100; // Enable CPU INT
EINT;
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
diff --git a/libcpu/ti-dsp/c28x/context.s b/libcpu/ti-dsp/c28x/context.s
index 019b5def13..fc1734f5ca 100644
--- a/libcpu/ti-dsp/c28x/context.s
+++ b/libcpu/ti-dsp/c28x/context.s
@@ -94,11 +94,10 @@ _rt_hw_interrupt_enable:
.asmfunc
_rt_hw_context_switch_interrupt:
-_rt_hw_context_switch:
MOVL XAR0, #0
MOV AR0, AL
MOVL XAR4, *-SP[4]
- ; set rt_thread_switch_interrupt_flag to 1
+ ; set rt_thread_switch_interrupt_flag to 1
MOVL XAR5, #_rt_thread_switch_interrupt_flag
MOVL XAR6, *XAR5
MOVL ACC, XAR6
@@ -114,6 +113,37 @@ _reswitch:
MOVL XAR5, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread
MOVL *XAR5, XAR4
+ ;TRAP #16
+ LRETR
+ .endasmfunc
+
+;
+; void rt_hw_context_switch(rt_uint32 from, rt_uint32 to);
+; r0 --> from
+; r4 --> to
+
+
+ .asmfunc
+_rt_hw_context_switch:
+ MOVL XAR0, #0
+ MOV AR0, AL
+ MOVL XAR4, *-SP[4]
+ ; set rt_thread_switch_interrupt_flag to 1
+ MOVL XAR5, #_rt_thread_switch_interrupt_flag
+ MOVL XAR6, *XAR5
+ MOVL ACC, XAR6
+ CMPB AL, #1
+ B _reswitch2, EQ
+ MOVL XAR6, #1
+ MOVL *XAR5, XAR6
+
+ MOVL XAR5, #_rt_interrupt_from_thread ; set rt_interrupt_from_thread
+ MOVL *XAR5, XAR0
+
+_reswitch2:
+ MOVL XAR5, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread
+ MOVL *XAR5, XAR4
+
TRAP #16
LRETR
.endasmfunc
@@ -159,9 +189,9 @@ _RTOSINT_Handler:
;#endif
MOV AL, *AR0
- MOV AR1, AL
+ MOV AR0, AL
MOVZ AR1, @SP ; get from thread stack pointer
- MOV *AR0, AR1 ; update from thread stack pointer
+ MOV *AR0, AR1 ; update from thread stack pointer
switch_to_thread:
MOV AR1, #_rt_interrupt_to_thread
@@ -175,7 +205,7 @@ switch_to_thread:
;#endif
MOV @SP, AR1
- INC SP
+ ;INC SP
RT_CTX_RESTORE ; pop r4 - r11 register
rtosint_exit:
diff --git a/libcpu/ti-dsp/c28x/cpuport.c b/libcpu/ti-dsp/c28x/cpuport.c
index 8885f647a9..2d42884bed 100644
--- a/libcpu/ti-dsp/c28x/cpuport.c
+++ b/libcpu/ti-dsp/c28x/cpuport.c
@@ -17,6 +17,9 @@ rt_uint32_t rt_thread_switch_interrupt_flag;
/* exception hook */
static rt_err_t (*rt_exception_hook)(void *context) = RT_NULL;
+extern rt_uint16_t rt_hw_get_st0(void);
+extern rt_uint16_t rt_hw_get_st1(void);
+
struct exception_stack_frame
{
rt_uint32_t t_st0;
@@ -59,6 +62,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry,
stk = stack_addr;
stk = (rt_uint8_t *)RT_ALIGN((rt_uint32_t)stk, 8);
//stk -= sizeof(struct stack_frame);
+ stk += 1;
stack_frame = (struct stack_frame *)stk;