⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_cpu_c.s43

📁 IAR project for MSP430 and uC/OS. All configured to start filling with tasks.
💻 S43
字号:
	NAME	os_cpu_c(16)
	RSEG	CODE(1)
	RSEG	UDATA0(1)
	PUBLIC	OSISRStkPtr
	PUBLIC	OSInitHookBegin
	PUBLIC	OSInitHookEnd
	PUBLIC	OSTCBInitHook
	PUBLIC	OSTaskCreateHook
	PUBLIC	OSTaskDelHook
	PUBLIC	OSTaskIdleHook
	PUBLIC	OSTaskStatHook
	PUBLIC	OSTaskStkInit
	PUBLIC	OSTaskSwHook
	PUBLIC	OSTimeTickHook
	EXTERN	?CL430_1_26_L08
	RSEG	CODE
OSInitHookBegin:
; 1.	/*
; 2.	*********************************************************************************************************
; 3.	*                                                uC/OS-II
; 4.	*                                          The Real-Time Kernel
; 5.	*
; 6.	*                              (c) Copyright 2002, Micrium, Inc., Weston, FL
; 7.	*                                           All Rights Reserved
; 8.	*
; 9.	*                                                TI MSP430
; 10.	*
; 11.	*
; 12.	* File         : OS_CPU_C.C
; 13.	* By           : Jian Chen (yenger@hotmail.com)
; 14.	*                Jean J. Labrosse
; 15.	* Compiler     : IAR System Embedded Workbench for TI MSP430 V1.26A
; 16.	*********************************************************************************************************
; 17.	*/
; 18.	
; 19.	#define  OS_CPU_GLOBALS
; 20.	#include "includes.h"
; 21.	
; 22.	/*
; 23.	*********************************************************************************************************
; 24.	*                                       OS INITIALIZATION HOOK
; 25.	*                                            (BEGINNING)
; 26.	*
; 27.	* Description: This function is called by OSInit() at the beginning of OSInit().
; 28.	*
; 29.	* Arguments  : none
; 30.	*
; 31.	* Note(s)    : 1) Interrupts should be disabled during this call.
; 32.	*********************************************************************************************************
; 33.	*/
; 34.	#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
; 35.	void  OSInitHookBegin (void)
; 36.	{
; 37.	}
	RET		
OSInitHookEnd:
; 38.	#endif
; 39.	
; 40.	/*
; 41.	*********************************************************************************************************
; 42.	*                                       OS INITIALIZATION HOOK
; 43.	*                                               (END)
; 44.	*
; 45.	* Description: This function is called by OSInit() at the end of OSInit().
; 46.	*
; 47.	* Arguments  : none
; 48.	*
; 49.	* Note(s)    : 1) Interrupts should be disabled during this call.
; 50.	*********************************************************************************************************
; 51.	*/
; 52.	#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
; 53.	void  OSInitHookEnd (void)
; 54.	{
; 55.	}
	RET		
OSTaskCreateHook:
; 56.	#endif
; 57.	
; 58.	/*$PAGE*/
; 59.	/*
; 60.	*********************************************************************************************************
; 61.	*                                          TASK CREATION HOOK
; 62.	*
; 63.	* Description: This function is called when a task is created.
; 64.	*
; 65.	* Arguments  : ptcb   is a pointer to the task control block of the task being created.
; 66.	*
; 67.	* Note(s)    : 1) Interrupts are disabled during this call.
; 68.	*********************************************************************************************************
; 69.	*/
; 70.	#if OS_CPU_HOOKS_EN > 0 
; 71.	void  OSTaskCreateHook (OS_TCB *ptcb)
; 72.	{
; 73.	    ptcb = ptcb;                       /* Prevent compiler warning                                     */
; 74.	}
	RET		
OSTaskDelHook:
; 75.	#endif
; 76.	
; 77.	
; 78.	/*
; 79.	*********************************************************************************************************
; 80.	*                                           TASK DELETION HOOK
; 81.	*
; 82.	* Description: This function is called when a task is deleted.
; 83.	*
; 84.	* Arguments  : ptcb   is a pointer to the task control block of the task being deleted.
; 85.	*
; 86.	* Note(s)    : 1) Interrupts are disabled during this call.
; 87.	*********************************************************************************************************
; 88.	*/
; 89.	#if OS_CPU_HOOKS_EN > 0 
; 90.	void  OSTaskDelHook (OS_TCB *ptcb)
; 91.	{
; 92.	    ptcb = ptcb;                       /* Prevent compiler warning                                     */
; 93.	}
	RET		
OSTaskIdleHook:
; 94.	#endif
; 95.	
; 96.	/*
; 97.	*********************************************************************************************************
; 98.	*                                             IDLE TASK HOOK
; 99.	*
; 100.	* Description: This function is called by the idle task.  This hook has been added to allow you to do  
; 101.	*              such things as STOP the CPU to conserve power.
; 102.	*
; 103.	* Arguments  : none
; 104.	*
; 105.	* Note(s)    : 1) Interrupts are enabled during this call.
; 106.	*********************************************************************************************************
; 107.	*/
; 108.	#if OS_CPU_HOOKS_EN > 0 && OS_VERSION >= 251
; 109.	void  OSTaskIdleHook (void)
; 110.	{
; 111.	    LPM0;                                         /* Enter low power mode                              */
	BIS	#16,SR	
; 112.	}
	RET		
OSTaskStatHook:
; 113.	#endif
; 114.	
; 115.	/*
; 116.	*********************************************************************************************************
; 117.	*                                           STATISTIC TASK HOOK
; 118.	*
; 119.	* Description: This function is called every second by uC/OS-II's statistics task.  This allows your 
; 120.	*              application to add functionality to the statistics task.
; 121.	*
; 122.	* Arguments  : none
; 123.	*********************************************************************************************************
; 124.	*/
; 125.	
; 126.	#if OS_CPU_HOOKS_EN > 0 
; 127.	void  OSTaskStatHook (void)
; 128.	{
; 129.	}
	RET		
OSTaskStkInit:
; 130.	#endif
; 131.	
; 132.	/*$PAGE*/
; 133.	/*
; 134.	*********************************************************************************************************
; 135.	*                                        INITIALIZE A TASK'S STACK
; 136.	*
; 137.	* Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
; 138.	*              stack frame of the task being created.  This function is highly processor specific.
; 139.	*
; 140.	* Arguments  : task          is a pointer to the task code
; 141.	*
; 142.	*              pdata         is a pointer to a user supplied data area that will be passed to the task
; 143.	*                            when the task first executes.
; 144.	*
; 145.	*              ptos          is a pointer to the top of stack.  It is assumed that 'ptos' points to
; 146.	*                            a 'free' entry on the task stack.  If OS_STK_GROWTH is set to 1 then 
; 147.	*                            'ptos' will contain the HIGHEST valid address of the stack.  Similarly, if
; 148.	*                            OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
; 149.	*                            of the stack.
; 150.	*
; 151.	*              opt           specifies options that can be used to alter the behavior of OSTaskStkInit().
; 152.	*                            (see uCOS_II.H for OS_TASK_OPT_???).
; 153.	*
; 154.	* Returns    : Always returns the location of the new top-of-stack' once the processor registers have
; 155.	*              been placed on the stack in the proper order.
; 156.	*
; 157.	* Note(s)    : The register passing convention for the IAR compiler is that the LEFTMOST two parameters
; 158.	*              are passed in registers:
; 159.	*              1st parameter:  R12 for a 16-bit value or,  R13:R12 for a 32-bit value
; 160.	*              2nd parameter:  R14 for a 16-bit value or,  R15:R14 for a 32-bit value
; 161.	*********************************************************************************************************
; 162.	*/
; 163.	
; 164.	OS_STK  *OSTaskStkInit (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT16U opt)
; 165.	{
; 166.	    INT16U  *top;
; 167.	
; 168.	
; 169.	    opt    = opt;                 
; 170.	    top    = (INT16U *)ptos;
	MOV	2(SP),R13	
; 171.	    top--;  
	ADD	#-2,R13	
; 172.	    *top = (INT16U)task;
	MOV	R12,0(R13)	
; 173.	    top--;
	ADD	#-2,R13	
; 174.	    *top = (INT16U)task;                          /* Interrupt return pointer                          */
	MOV	R12,0(R13)	
; 175.	    top--;
	ADD	#-2,R13	
; 176.	    *top = (INT16U)0x0008;                        /* Status register                                   */
	MOV	#8,0(R13)	
; 177.	    top--;
	ADD	#-2,R13	
; 178.	    *top = (INT16U)0x0404;
	MOV	#1028,0(R13)	
; 179.	    top--;
	ADD	#-2,R13	
; 180.	    *top = (INT16U)0x0505;
	MOV	#1285,0(R13)	
; 181.	    top--;
	ADD	#-2,R13	
; 182.	    *top = (INT16U)0x0606;
	MOV	#1542,0(R13)	
; 183.	    top--;
	ADD	#-2,R13	
; 184.	    *top = (INT16U)0x0707;
	MOV	#1799,0(R13)	
; 185.	    top--;
	ADD	#-2,R13	
; 186.	    *top = (INT16U)0x0808;
	MOV	#2056,0(R13)	
; 187.	    top--;
	ADD	#-2,R13	
; 188.	    *top = (INT16U)0x0909;
	MOV	#2313,0(R13)	
; 189.	    top--;
	ADD	#-2,R13	
; 190.	    *top = (INT16U)0x1010;
	MOV	#4112,0(R13)	
; 191.	    top--;
	ADD	#-2,R13	
; 192.	    *top = (INT16U)0x1111;
	MOV	#4369,0(R13)	
; 193.	    top--;
	ADD	#-2,R13	
; 194.	    *top = (INT16U)0x1212;                        
	MOV	#4626,0(R13)	
; 195.	    top--;
	ADD	#-2,R13	
; 196.	    *top = (INT16U)0x1313;
	MOV	#4883,0(R13)	
; 197.	    top--;
	ADD	#-2,R13	
; 198.	    *top = (INT16U)pdata;                         /* Pass 'pdata' through register R14                 */
	MOV	R14,0(R13)	
; 199.	    top--;
	ADD	#-2,R13	
; 200.	    *top = (INT16U)0x1515;
	MOV	#5397,0(R13)	
; 201.	    return ((OS_STK *)top);    
	MOV	R13,R12	
; 202.	}
	RET		
OSTaskSwHook:
; 203.	
; 204.	/*$PAGE*/
; 205.	/*
; 206.	*********************************************************************************************************
; 207.	*                                           TASK SWITCH HOOK
; 208.	*
; 209.	* Description: This function is called when a task switch is performed.  This allows you to perform other
; 210.	*              operations during a context switch.
; 211.	*
; 212.	* Arguments  : none
; 213.	*
; 214.	* Note(s)    : 1) Interrupts are disabled during this call.
; 215.	*              2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
; 216.	*                 will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the 
; 217.	*                 task being switched out (i.e. the preempted task).
; 218.	*********************************************************************************************************
; 219.	*/
; 220.	#if OS_CPU_HOOKS_EN > 0
; 221.	void  OSTaskSwHook (void)
; 222.	{
; 223.	}
	RET		
OSTCBInitHook:
; 224.	#endif
; 225.	
; 226.	/*
; 227.	*********************************************************************************************************
; 228.	*                                           OSTCBInit() HOOK
; 229.	*
; 230.	* Description: This function is called by OS_TCBInit() after setting up most of the TCB.
; 231.	*
; 232.	* Arguments  : ptcb    is a pointer to the TCB of the task being created.
; 233.	*
; 234.	* Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
; 235.	*********************************************************************************************************
; 236.	*/
; 237.	#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
; 238.	void  OSTCBInitHook (OS_TCB *ptcb)
; 239.	{
; 240.	    ptcb = ptcb;                                           /* Prevent Compiler warning                 */
; 241.	}
	RET		
OSTimeTickHook:
; 242.	#endif
; 243.	
; 244.	
; 245.	/*
; 246.	*********************************************************************************************************
; 247.	*                                               TICK HOOK
; 248.	*
; 249.	* Description: This function is called every tick.
; 250.	*
; 251.	* Arguments  : none
; 252.	*
; 253.	* Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
; 254.	*********************************************************************************************************
; 255.	*/
; 256.	#if OS_CPU_HOOKS_EN > 0
; 257.	void  OSTimeTickHook (void)
; 258.	{
; 259.	}
	RET		
; 260.	#endif
	RSEG	UDATA0
OSISRStkPtr:
	DS	2
	END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -