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

📄 test.c.bak

📁 uCOSII在motorala单片机上的移植
💻 BAK
字号:
#include	"Includes.h"

static OS_STK AppStartTaskStk[256];
static OS_STK AppDisplayTaskStk[512];
//static OS_STK AppMessageSenderStk[512];
						
static void initMCU(void);
static void enableAppTick(void);
static void AppStartTask(void *pdata);
static void AppDisplayTask(void *pdata);			// display task;
//static void AppMessageSenderTask(void *pdata);

void main(void)
{
	initMCU();	
	initEncoderResource();
	initLCDResource();
    	
    	int a =100;
    	
    	OSInit();   
    	initMessageManager();                 	
        OSTaskCreate(AppStartTask, (void *)0x12345678L, (void *)&AppStartTaskStk[255], 0);
    	
    	OSStart();   

	return;
}
/*
***************************************************************************************************
* Discription:	The basic configuration for MCU, which means requirments for running 
*			the uC/OS-II operating system, can be completed by calling function 
*			initMCU().
* Arguments: 	none.
* Return:		none.
* Notes:		none.
***************************************************************************************************
*/
static void initMCU(void)
{
	*SIM_MCR = 0x42CF;	
	*SIM_SYNCR = 0xD700; //时钟合成器
	/*
	Fref = 4M, Fsys = 24M;
	ECLK = Fsys / 8 = 3M.
	*/		
	*SIM_SYPCR = 0x0044;	
	/*
	bit 7 = 0  software watchdog disable;
	bit 6 = 1  software watchdog clock is prescaled by 512; 24M / 512 ; time base is 64/3uS;
	*/	
	*SIM_PICR = 0x0040;		
	*SIM_PITR = 0x000D;
	
	*TPU_TMCR = 0x02CF;		// interrupt arbitration ID is 15;
	/* 
	bit 15 = 0, enable TPU clocks;
	*/
	*TPU_TICR = 0x0550;		// interrupt level is 5, and interrupt base vector is 80;
	
	OSVectSet(47, (void (*)(void))OSCtxSw); 
	OSVectSet(64, (void (*)(void))OSTickISR);  
	OSVectSet(85, (void (*)(void))rightProcess);
	OSVectSet(86, (void (*)(void))leftProcess);
	OSVectSet(87, (void (*)(void))enterProcess);
	
	return;
}

static void enableAppTick(void)
{	
	*SIM_PICR = 0x0640;		// interrupt level is 6;
	/*
	bit 10~bit 8 = 6, the priority of PIT is 6;
	bit   7~bit 0 = 64, the periodic interrupt vector number is 64; 
	*/
	
 	return;
}

static void  AppStartTask (void *pdata)
{	
    	pdata = pdata; 
         	
    	enableAppTick();                          	
 
    	OSTaskCreate(AppDisplayTask,(void*)0,(OS_STK*)(&AppDisplayTaskStk[512-1]),1);
//    	OSTaskCreate(AppMessageSenderTask,(void*)0,(OS_STK*)(&AppMessageSenderStk[512-1]),2);
    	while (TRUE) 
    	{    
    	 	OSTimeDly(1);                       
    	}
    	
    	return;
}
static void AppDisplayTask(void *pdata)
{
	pdata = pdata;
	
	initDisplayContent();
	initInputContactors();			// TEST ONLY;
	initOccuredEventRecord();		// FOR TEST PURPOSE ONLY;    
	mainWndProcess();
	
	return;
}
/*
static void AppMessageSenderTask(void *pdata)
{
	static INT16U result;
	
	pdata = pdata;
	
	while(TRUE)
	{
		result = getMouseState();
		switch(result)
		{
			case MSG_LEFT:
				sendMessage(MSG_LEFT);
				break;
			case MSG_RIGHT:
				sendMessage(MSG_RIGHT);
				break;
			case MSG_ENTER:
				sendMessage(MSG_ENTER);
				break;
			default:
				sendMessage(MSG_NONE);
		}
		result = 0;
		OSTimeDly(400);   
	}
}
*/

⌨️ 快捷键说明

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