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

📄 os_cpu_c.c

📁 提供了一些ADSP-217x或ADSP-218x DSP芯片的编程事例
💻 C
字号:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*				   ADSP-21xx Specific Code version 1.0	
*
* File : OS_CPU_C.C
* By   : Jaap de Jong (jdj@nedap.nl)
*	 Nedap Retail Support
*	 Parallelweg 2d
*	 Postbox 102
*	 7140 AC Groenlo
*	 Netherlands
* Based on 'ADSP-21065L SHARC Specific Code version 1.0' by Bertrand Hurst, Francois Veuve, Cedric Bornand
*********************************************************************************************************
*/
#define  OS_CPU_GLOBALS
#include "includes.h"


/*
*********************************************************************************************************
*                                        INITIALIZE A TASK'S STACK
*
* Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
*              stack frame of the task being created.  This function is highly processor specific.
*
* Arguments  : task          is a pointer to the task code
*
*              pdata         is a pointer to a user supplied data area that will be passed to the task
*                            when the task first executes.
*
*              ptos          is a pointer to the top of stack.  It is assumed that 'ptos' points to
*                            a 'free' entry on the task stack.  If OS_STK_GROWTH is set to 1 then 
*                            'ptos' will contain the HIGHEST valid address of the stack.  Similarly, if
*                            OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
*                            of the stack.
*
*              opt           specifies options that can be used to alter the behavior of OSTaskStkInit().
*                            (see uCOS_II.H for OS_TASK_OPT_???).
*
* Returns    : Always returns the location of the new top-of-stack' once the processor registers have
*              been placed on the stack in the proper order.
*
* Note(s)    : Registers are initialized to make them easy to differentiate with a debugger. Some of them
*              need a special value so that when a task starts it will have a working set of registers.
*********************************************************************************************************
*/
void *OSTaskStkInit (void (*task)(void *pd), void *pdata, void *ptos, INT16U opt)
{
	INT16U *stk;			

	stk    = (void*)ptos;
	opt    = opt; 			/* prevent compiler warning */
	
   	/* registers */
	*stk-- = (INT16U)(pdata);	/* 01 ar = pdata */
	*stk-- = (INT16U)0x02;		/* 02 ax0 */
	*stk-- = (INT16U)0x03;		/* 03 ax1 */
	*stk-- = (INT16U)0x04;		/* 04 ay0 */
	*stk-- = (INT16U)0x05;		/* 05 ay1 */
	*stk-- = (INT16U)0;		/* 06 astat = 0 */
	*stk-- = (INT16U)0x24;		/* 07 af */

	*stk-- = (INT16U)(task);	/* 08 pc = desired task */
	*stk-- = (INT16U)(*OSTaskDel);	/* 09 pc = *OSTaskDel in case this task ends */
	*stk-- = (INT16U)2;		/* 24 npc = 2 */
/*	*stk-- = (INT16U)(*OSTaskDel);	/* 09 pc = *OSTaskDel in case this task ends */
/*	*stk-- = (INT16U)2;		/* 24 npc = 2 */
	
	*stk-- = (INT16U)0x25;		/* 25 mr0 */
	*stk-- = (INT16U)0x26;		/* 26 mr1 */ 
	*stk-- = (INT16U)0x27;		/* 27 mr2 */
	*stk-- = (INT16U)0x28;		/* 28 mf */
	*stk-- = (INT16U)0x29;		/* 29 mx0 */
	*stk-- = (INT16U)0x30;		/* 30 mx1 */
	*stk-- = (INT16U)0x31;		/* 31 my0 */
	*stk-- = (INT16U)0x32;		/* 32 my1 */
	*stk-- = (INT16U)0x33;		/* 33 px */
	*stk-- = (INT16U)0x34;		/* 34 sb */
	*stk-- = (INT16U)0x35;		/* 35 se */
	*stk-- = (INT16U)0x36;		/* 36 si */
	*stk-- = (INT16U)0x37;		/* 37 sr0 */
	*stk-- = (INT16U)0x38;		/* 38 sr1 */

	*stk-- = (INT16U)0x39;		/* 39 i0 */
	*stk-- = (INT16U)0x40;		/* 40 i1 */
	*stk-- = (INT16U)0x41;		/* 41 i2 */
	*stk-- = (INT16U)0x42;		/* 42 i3 */
	*stk-- = (INT16U)0x43;		/* 43 i5 */
	*stk-- = (INT16U)0x44;		/* 44 i6 */
	*stk-- = (INT16U)0x45;		/* 45 i7 */

	*stk-- = (INT16U)0;		/* 46 l0 = 0 */
	*stk-- = (INT16U)0;		/* 47 l1 = 0 */
	*stk-- = (INT16U)0;		/* 48 l2 = 0 */
	*stk-- = (INT16U)0;		/* 49 l3 = 0 */
	*stk-- = (INT16U)0;		/* 50 l5 = 0 */
	*stk-- = (INT16U)0;		/* 51 l6 = 0 */
	*stk-- = (INT16U)0;		/* 52 l7 = 0 */

	*stk-- = (INT16U)0x53;		/* 53 m0 */
	*stk-- = (INT16U)1;		/* 54 m1 = 1 */
	*stk-- = (INT16U)0;		/* 55 m2 = 0 */
	*stk-- = (INT16U)0x56;		/* 56 m3 */
	*stk-- = (INT16U)0x57;		/* 57 m4 */
	*stk-- = (INT16U)0x58;		/* 58 m5 */
	*stk-- = (INT16U)0;		/* 59 m6 = 0 */
	*stk-- = (INT16U)0x60;		/* 60 m7 */
	
	return ((void *)stk);

}


#if OS_CPU_HOOKS_EN
/**********************************************************************************************************
*                                          TASK CREATION HOOK
*
* Description: Called when a task is created. May be used to add new features
* Arguments  : ptcb = ptr to the TCB of the newly created task
**********************************************************************************************************/
void OSTaskCreateHook (OS_TCB *ptcb)
{
    ptcb = ptcb;                       /* Prevent compiler warning                                     */
}


/**********************************************************************************************************
*                                           TASK DELETION HOOK
*
* Description: Called when a task is deleted. May be used to add new features
* Arguments  : ptcb = ptr to the TCB of the just deleted task
**********************************************************************************************************/
void OSTaskDelHook (OS_TCB *ptcb)
{
    ptcb = ptcb;			/* Prevent compiler warning */
}


/**********************************************************************************************************
*                                           TASK SWITCH HOOK
* Description: Called each time a task switch occurs. May be used to add new features
**********************************************************************************************************/
void OSTaskSwHook (void)
{
}


/**********************************************************************************************************
*                                           STATISTIC TASK HOOK
* Description: Called each second by the statistic's task of uC/OS-II. May be used to add new features
**********************************************************************************************************/
void OSTaskStatHook (void)
{
}


/**********************************************************************************************************
*                                               TICK HOOK
* Description: Called each clock's tick.  May be used to add new features
**********************************************************************************************************/
void OSTimeTickHook (void)
{
}
#endif

/********************************** End of file *********************************************************/

⌨️ 快捷键说明

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