merge stack.c and interrupt.c into cpuport.c
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1687 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
a4efc927e2
commit
61d969f1b9
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* For : Renesas M16C
|
* For : Renesas M16C
|
||||||
* Toolchain : IAR's EW for M16C v3.401
|
* Toolchain : IAR's EW for M16C v3.401
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include "bsp.h"
|
#include "bsp.h"
|
||||||
|
@ -40,7 +40,7 @@ static void rt_thread_entry_led(void* parameter)
|
||||||
int rt_application_init(void)
|
int rt_application_init(void)
|
||||||
{
|
{
|
||||||
/* create led thread */
|
/* create led thread */
|
||||||
rt_thread_init(&led,
|
rt_thread_init(&led,
|
||||||
"led",
|
"led",
|
||||||
rt_thread_entry_led, RT_NULL,
|
rt_thread_entry_led, RT_NULL,
|
||||||
&led_stack[0], sizeof(led_stack),
|
&led_stack[0], sizeof(led_stack),
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2010-04-09 fify the first version
|
* 2010-04-09 fify the first version
|
||||||
*
|
*
|
||||||
* For : Renesas M16C
|
* For : Renesas M16C
|
||||||
* Toolchain : IAR's EW for M16C v3.401
|
* Toolchain : IAR's EW for M16C v3.401
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rthw.h>
|
#include <rthw.h>
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2010-04-09 fify the first version
|
* 2010-04-09 fify the first version
|
||||||
*
|
*
|
||||||
* For : Renesas M16C
|
* For : Renesas M16C
|
||||||
* Toolchain : IAR's EW for M16C v3.401
|
* Toolchain : IAR's EW for M16C v3.401
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "iom16c62p.h"
|
#include "iom16c62p.h"
|
||||||
#include "bsp.h"
|
#include "bsp.h"
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2010-04-20 fify the first version
|
* 2010-04-20 fify the first version
|
||||||
*
|
*
|
||||||
* For : Renesas M16C
|
* For : Renesas M16C
|
||||||
* Toolchain : IAR's EW for M16C v3.401
|
* Toolchain : IAR's EW for M16C v3.401
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PUBLIC rt_hw_timer_handler
|
PUBLIC rt_hw_timer_handler
|
||||||
PUBLIC rt_hw_uart0_receive_handler
|
PUBLIC rt_hw_uart0_receive_handler
|
||||||
|
|
|
@ -207,7 +207,7 @@
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCDiagSuppress</name>
|
<name>CCDiagSuppress</name>
|
||||||
<state></state>
|
<state>Pa050</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCDiagRemark</name>
|
<name>CCDiagRemark</name>
|
||||||
|
@ -1945,10 +1945,7 @@
|
||||||
<name>$PROJ_DIR$\..\..\libcpu\m16c\m16c62p\context_iar.asm</name>
|
<name>$PROJ_DIR$\..\..\libcpu\m16c\m16c62p\context_iar.asm</name>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\..\libcpu\m16c\m16c62p\interrupt.c</name>
|
<name>$PROJ_DIR$\..\..\libcpu\m16c\m16c62p\cpuport.c</name>
|
||||||
</file>
|
|
||||||
<file>
|
|
||||||
<name>$PROJ_DIR$\..\..\libcpu\m16c\m16c62p\stack.c</name>
|
|
||||||
</file>
|
</file>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "bsp.h"
|
#include "bsp.h"
|
||||||
|
|
||||||
|
extern void rt_hw_interrupt_init(void);
|
||||||
extern int rt_application_init(void);
|
extern int rt_application_init(void);
|
||||||
#ifdef RT_USING_FINSH
|
#ifdef RT_USING_FINSH
|
||||||
extern void finsh_system_init(void);
|
extern void finsh_system_init(void);
|
||||||
|
@ -37,6 +38,9 @@ extern void finsh_set_device(const char* device);
|
||||||
*/
|
*/
|
||||||
void rtthread_startup(void)
|
void rtthread_startup(void)
|
||||||
{
|
{
|
||||||
|
/* init hardware interrupt */
|
||||||
|
rt_hw_interrupt_init();
|
||||||
|
|
||||||
/* init board */
|
/* init board */
|
||||||
rt_hw_board_init();
|
rt_hw_board_init();
|
||||||
|
|
||||||
|
@ -54,7 +58,7 @@ void rtthread_startup(void)
|
||||||
|
|
||||||
#ifdef RT_USING_HEAP
|
#ifdef RT_USING_HEAP
|
||||||
#ifdef __ICCM16C__
|
#ifdef __ICCM16C__
|
||||||
rt_system_heap_init(__segment_begin("DATA16_HEAP"),__segment_end("DATA16_HEAP"));
|
rt_system_heap_init(__segment_begin("DATA16_HEAP"), __segment_end("DATA16_HEAP"));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -75,8 +79,8 @@ void rtthread_startup(void)
|
||||||
finsh_set_device("uart0");
|
finsh_set_device("uart0");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* init timer thread */
|
/* init timer thread */
|
||||||
rt_system_timer_thread_init();
|
rt_system_timer_thread_init();
|
||||||
|
|
||||||
/* init idle thread */
|
/* init idle thread */
|
||||||
rt_thread_idle_init();
|
rt_thread_idle_init();
|
||||||
|
@ -94,7 +98,7 @@ int main(void)
|
||||||
rt_hw_interrupt_disable();
|
rt_hw_interrupt_disable();
|
||||||
|
|
||||||
/* init system setting */
|
/* init system setting */
|
||||||
system_init();
|
system_init();
|
||||||
|
|
||||||
/* startup RT-Thread RTOS */
|
/* startup RT-Thread RTOS */
|
||||||
rtthread_startup();
|
rtthread_startup();
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
* http://www.rt-thread.org/license/LICENSE
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2010-03-08 Bernard The first version for LPC17xx
|
* 2010-03-08 Bernard The first version for LPC17xx
|
||||||
* 2010-04-10 fify Modified for M16C
|
* 2010-04-10 fify Modified for M16C
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rthw.h>
|
#include <rthw.h>
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2010-04-09 fify the first version
|
* 2010-04-09 fify the first version
|
||||||
*
|
*
|
||||||
* For : Renesas M16C
|
* For : Renesas M16C
|
||||||
* Toolchain : IAR's EW for M16C v3.401
|
* Toolchain : IAR's EW for M16C v3.401
|
||||||
*/
|
*/
|
||||||
|
|
||||||
;********************************************************************************************************
|
;********************************************************************************************************
|
||||||
; RELOCATABLE EXCEPTION VECTOR TABLE
|
; RELOCATABLE EXCEPTION VECTOR TABLE
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
* For : Renesas M16C
|
* For : Renesas M16C
|
||||||
* Toolchain : IAR's EW for M16C v3.401
|
* Toolchain : IAR's EW for M16C v3.401
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RSEG CSTACK
|
RSEG CSTACK
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* File : cpuport.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2009 - 2011, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2011-02-23 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
extern volatile rt_uint8_t rt_interrupt_nest;
|
||||||
|
|
||||||
|
/* switch flag on interrupt and thread pointer to save switch record */
|
||||||
|
rt_uint32_t rt_interrupt_from_thread;
|
||||||
|
rt_uint32_t rt_interrupt_to_thread;
|
||||||
|
rt_uint32_t rt_thread_switch_interrput_flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will initialize hardware interrupt
|
||||||
|
*/
|
||||||
|
void rt_hw_interrupt_init(void)
|
||||||
|
{
|
||||||
|
/* init interrupt nest, and context in thread sp */
|
||||||
|
rt_interrupt_nest = 0;
|
||||||
|
rt_interrupt_from_thread = 0;
|
||||||
|
rt_interrupt_to_thread = 0;
|
||||||
|
rt_thread_switch_interrput_flag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will initialize thread stack
|
||||||
|
*
|
||||||
|
* @param tentry the entry of thread
|
||||||
|
* @param parameter the parameter of entry
|
||||||
|
* @param stack_addr the beginning stack address
|
||||||
|
* @param texit the function will be called when thread exit
|
||||||
|
*
|
||||||
|
* @return stack address
|
||||||
|
*/
|
||||||
|
rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, rt_uint8_t *stack_addr, void *texit)
|
||||||
|
{
|
||||||
|
rt_uint16_t *pstk16;
|
||||||
|
rt_uint16_t flag;
|
||||||
|
|
||||||
|
flag = 0x0040;
|
||||||
|
pstk16 = (rt_uint16_t *)stack_addr;
|
||||||
|
pstk16--;
|
||||||
|
|
||||||
|
/* Simulate ISR entry */
|
||||||
|
*pstk16-- = (flag&0x00FF) /* ... The lowest byte of the FLAG register */
|
||||||
|
| (((rt_uint32_t)tentry>>8)&0x00000F00) /* ... The highest nibble of the PC register */
|
||||||
|
| ((flag<<4)&0xF000); /* ... The highest nibble of the FLAG register */
|
||||||
|
*pstk16-- = (((rt_uint32_t)tentry)&0x0000FFFF); /* ... The lowest bytes of the PC register */
|
||||||
|
|
||||||
|
/* Save registers onto stack frame */
|
||||||
|
*pstk16-- = (rt_uint16_t)0xFBFB; /* ... FB register */
|
||||||
|
*pstk16-- = (rt_uint16_t)0x3B3B; /* ... SB register */
|
||||||
|
*pstk16-- = (rt_uint16_t)0xA1A1; /* ... A1 register */
|
||||||
|
*pstk16-- = (rt_uint16_t)0xA0A0; /* ... A0 register */
|
||||||
|
*pstk16-- = (rt_uint16_t)0x3333; /* ... R3 register */
|
||||||
|
*pstk16-- = (rt_uint32_t)parameter >> 16L; /* ... Pass argument in R2 register */
|
||||||
|
*pstk16-- = (rt_uint32_t)parameter & 0x0000FFFFL; /* ... Pass argument in R1 register */
|
||||||
|
*pstk16 = (rt_uint16_t)0x0000; /* ... R0 register */
|
||||||
|
|
||||||
|
/* return task's current stack address */
|
||||||
|
return (rt_uint8_t *)pstk16;
|
||||||
|
}
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
* File : interrupt.c
|
|
||||||
* This file is part of RT-Thread RTOS
|
|
||||||
* COPYRIGHT (C) 2009, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* The license and distribution terms for this file may be
|
|
||||||
* found in the file LICENSE in this distribution or at
|
|
||||||
* http://www.rt-thread.org/license/LICENSE
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2010-04-09 fify the first version
|
|
||||||
*
|
|
||||||
* For : Renesas M16C
|
|
||||||
* Toolchain : IAR's EW for M16C v3.401
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <rtthread.h>
|
|
||||||
|
|
||||||
rt_uint16_t rt_interrupt_from_thread;
|
|
||||||
rt_uint16_t rt_interrupt_to_thread;
|
|
||||||
rt_uint16_t rt_thread_switch_interrput_flag;
|
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* File : stack.c
|
|
||||||
* This file is part of RT-Thread RTOS
|
|
||||||
* COPYRIGHT (C) 2009, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* The license and distribution terms for this file may be
|
|
||||||
* found in the file LICENSE in this distribution or at
|
|
||||||
* http://www.rt-thread.org/license/LICENSE
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2010-04-09 fify the first version
|
|
||||||
*
|
|
||||||
* For : Renesas M16C
|
|
||||||
* Toolchain : IAR's EW for M16C v3.401
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <rtthread.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function will initialize thread stack
|
|
||||||
*
|
|
||||||
* @param tentry the entry of thread
|
|
||||||
* @param parameter the parameter of entry
|
|
||||||
* @param stack_addr the beginning stack address
|
|
||||||
* @param texit the function will be called when thread exit
|
|
||||||
*
|
|
||||||
* @return stack address
|
|
||||||
*/
|
|
||||||
rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
|
|
||||||
rt_uint8_t *stack_addr, void *texit)
|
|
||||||
{
|
|
||||||
rt_uint16_t *pstk16;
|
|
||||||
rt_uint16_t flag;
|
|
||||||
|
|
||||||
|
|
||||||
flag = 0x0040;
|
|
||||||
pstk16 = (rt_uint16_t *)stack_addr;
|
|
||||||
pstk16--;
|
|
||||||
|
|
||||||
/* Simulate ISR entry */
|
|
||||||
*pstk16-- = (flag & 0x00FF) /* ... The lowest byte of the FLAG register */
|
|
||||||
| (((rt_uint32_t)tentry >> 8) & 0x00000F00) /* ... The highest nibble of the PC register */
|
|
||||||
| ((flag << 4) & 0xF000); /* ... The highest nibble of the FLAG register */
|
|
||||||
*pstk16-- = (((rt_uint32_t)tentry ) & 0x0000FFFF); /* ... The lowest bytes of the PC register */
|
|
||||||
|
|
||||||
/* Save registers onto stack frame */
|
|
||||||
*pstk16-- = (rt_uint16_t)0xFBFB; /* ... FB register */
|
|
||||||
*pstk16-- = (rt_uint16_t)0x3B3B; /* ... SB register */
|
|
||||||
*pstk16-- = (rt_uint16_t)0xA1A1; /* ... A1 register */
|
|
||||||
*pstk16-- = (rt_uint16_t)0xA0A0; /* ... A0 register */
|
|
||||||
*pstk16-- = (rt_uint16_t)0x3333; /* ... R3 register */
|
|
||||||
*pstk16-- = (rt_uint32_t)parameter >> 16L; /* ... Pass argument in R2 register */
|
|
||||||
*pstk16-- = (rt_uint32_t)parameter & 0x0000FFFFL; /* ... Pass argument in R1 register */
|
|
||||||
*pstk16 = (rt_uint16_t)0x0000; /* ... R0 register */
|
|
||||||
|
|
||||||
/* return task's current stack address */
|
|
||||||
return (rt_uint8_t *)pstk16;
|
|
||||||
}
|
|
Loading…
Reference in New Issue