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

📄 app.c

📁 MCB2300_ucgui_LCD320240.rar LPC2368的uc/gui的移植
💻 C
字号:
/*
*********************************************************************************************************
*   										   EXAMPLE CODE
*
*   					   (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
*   			All rights reserved.  Protected by international copyright laws.
*   			Knowledge of the source code may NOT be used to develop a similar product.
*   			Please help us continue to provide the Embedded community with the finest
*   			software available.  Your honesty is greatly appreciated.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*
*   										  EXAMPLE CODE
*
*   										  NXP LPC2378
*   											 on the
*   								   Keil MCB2300 Evaluation Board
*
* Filename  	: app_cfg.h
* Version   	: V1.00
* Programmer(s) : BAN
*********************************************************************************************************
*/

#include <includes.h>

/*
*********************************************************************************************************
*   										 LOCAL DEFINES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*   									   LOCAL DATA TYPES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*   									LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/

/* ----------------- APPLICATION GLOBALS ------------------ */
#include "GUI.H"
#include "DIALOG.H"
#include "WM.h"

#include "button.h"
#include "progbar.h"

#include "LISTBOX.h"
#include "FrameWin.h"
#include "GUIDEMO.H"

//***************************************************************************
/* allocate memory for tasks' stacks */
#ifdef SEMIHOSTED
#define STACKSIZE   	(SEMIHOSTED_STACK_NEEDS+64)
#else
//#define  TASK_STACK_SIZE	(  256+64 )
#define  TASK_STACK_SIZE	(  512+64 )
//#define  TASK_STACK_SIZE	( 8192+64 )
#endif

//***************************************************************************
OS_STK Main_Task_Stack[TASK_STACK_SIZE];
void Main_Task(void *Id) ;
#define Main_Task_PRIO  	 4

OS_STK Task_LED_Stack[TASK_STACK_SIZE];
void Task_LED(void *Id) ;
#define Task_LED_PRIO   	6

void GUI_ExecTask(void *pdata);
OS_STK  GUI_ExecTaskStk[1024];
#define GUI_ExecTaskPrio (OS_LOWEST_PRIO-10)

OS_EVENT *UART0_SEM ;		//UART 0信号量
OS_EVENT *Key_Mbox ;		//按键消息邮箱
OS_EVENT *OK_Mbox;			//按键消息邮箱





/*
*********************************************************************************************************
*   									 LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/


static 	void GUI_ExecTask(void *pdata);


/******************************************************************************
【功能说明】主任务,在本任务中启动系统定时器并创建其他任务
******************************************************************************/
void Main_Task(void *Id)
{
	U8 err = 0,i;

	BSP_Init(); 												/* Initialize BSP functions 								*/

	OSStatInit();

	OSTaskCreate(Task_LED, (void *) 0, (OS_STK *) &Task_LED_Stack[TASK_STACK_SIZE - 1], Task_LED_PRIO) ;

	OSTaskCreate(GUI_ExecTask, (void *) 0, (OS_STK *) &GUI_ExecTaskStk[1024], GUI_ExecTaskPrio) ;

	while (DEF_TRUE)
	{
		/* Task body, always written as an infinite loop.   		*/

		for (i = 1; i <= 4; i++)
		{
			LED_On(i);
			OSTimeDlyHMSM(0, 0, 0, 500);
			LED_Off(i);
		}

		for (i = 1; i <= 4; i++)
		{
			LED_On(5 - i);
			OSTimeDlyHMSM(0, 0, 0, 500);
			LED_Off(5 - i);
		}
	}
}

/******************************************************************************
【功能说明】本任务使LED来回闪烁
******************************************************************************/
void Task_LED(void *Id)
{
	U8 i;

	while (DEF_TRUE)
	{
		/* Task body, always written as an infinite loop.   		*/

		for (i = 7; i >= 4; i--)
		{
			LED_On(i);
			OSTimeDlyHMSM(0, 0, 0, 200);
			LED_Off(i);
		}

		for (i = 4; i <= 7; i++)
		{
			LED_On(i);
			OSTimeDlyHMSM(0, 0, 0, 200);
			LED_Off(i);
		}
	}
}
/*
*********************************************************************************************************
*   								 LOCAL CONFIGURATION ERRORS
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*   											 main()
*
* Description : This is the standard entry point for C code.  It is assumed that your code will call
*   			main() once you have performed all necessary initialization.
*
* Argument(s) : none
*
* Return(s)   : none
*********************************************************************************************************
*/

int main(void)
{
	U8 ver = 0;

	CPU_INT08U  err;

	BSP_IntDisAll();											/* Disable all interrupts until we are ready to accept them */
	/* Initialize "uC/OS-II, The Real-Time Kernel"  			*/
	OSInit();		//uCOS-II初始化

	//Uart_Printf("OS Initing\n");

	//OSTimeSet(0);
	//Uart_Printf("OS Time setting\n");

	//ver = OSVersion();
	//Uart_Printf("OS Version: %d\n",ver);

	//创建信号量
	UART0_SEM = OSSemCreate(1) ;		//UART 0 信号量

	//创建消息邮箱
	Key_Mbox = OSMboxCreate((void *) 0);

	//创建信号量
	OK_Mbox = OSMboxCreate((void *) 0);

	//创建主任务
	OSTaskCreate(Main_Task, (void *) 0, (OS_STK *) &Main_Task_Stack[TASK_STACK_SIZE - 1], Main_Task_PRIO) ;

	GUI_Init();

	OSStart();		//Start uCOS-II 											   /* Start multitasking (i.e. give control to uC/OS-II)	   */
}

/******************************************************************************
【功能说明】UCGUI
******************************************************************************/
void GUI_ExecTask(void *pdata)
{
	//U8 err;
	//U32 *msg;
	pdata = pdata;
	/*
	#define GUI_BLACK   	  0x000000
	#define GUI_BLUE		  0xFF0000
	#define GUI_GREEN   	  0x00ff00
	#define GUI_CYAN		  0xffff00
	#define GUI_RED 		  0x0000FF
	#define GUI_MAGENTA 	  0x8b008b
	#define GUI_BROWN   	  0x2a2aa5
	#define GUI_DARKGRAY	  0x404040
	#define GUI_GRAY		  0x808080
	#define GUI_LIGHTGRAY     0xd3d3d3
	#define GUI_LIGHTBLUE     0xff8080
	#define GUI_LIGHTGREEN    0x80ff80
	#define GUI_LIGHTCYAN     0x80ffff
	#define GUI_LIGHTRED	  0x8080ff
	#define GUI_LIGHTMAGENTA  0xff80ff
	#define GUI_YELLOW  	  0x00ffff
	#define GUI_WHITE   	  0xffffff
	#define GUI_INVALID_COLOR 0xfffffff 
	*/

	for (; ;)
	{
		GUIDEMO_main();
	}
}

/*
*********************************************************************************************************
*   									   AppTerminalRx()
*
* Description : Callback function for uC/OS-View
*
* Argument(s) : rx_data 	The received data.
*
* Return(s)   : none.
*********************************************************************************************************
*/

#if (OS_VIEW_MODULE > 0)
static  void AppTerminalRx(CPU_INT08U rx_data)
{
}
#endif


/*
*********************************************************************************************************
*********************************************************************************************************
**  									   uC/OS-II APP HOOKS
*********************************************************************************************************
*********************************************************************************************************
*/

#if (OS_APP_HOOKS_EN > 0)
/*
*********************************************************************************************************
*   								   TASK CREATION HOOK (APPLICATION)
*
* Description : This function is called when a task is created.
*
* Argument(s) : ptcb   is a pointer to the task control block of the task being created.
*
* Note(s)     : (1) Interrupts are disabled during this call.
*********************************************************************************************************
*/

void App_TaskCreateHook(OS_TCB *ptcb)
{
#if (OS_VIEW_MODULE > 0)
	OSView_TaskCreateHook(ptcb);
#endif
}

/*
*********************************************************************************************************
*   								 TASK DELETION HOOK (APPLICATION)
*
* Description : This function is called when a task is deleted.
*
* Argument(s) : ptcb   is a pointer to the task control block of the task being deleted.
*
* Note(s)     : (1) Interrupts are disabled during this call.
*********************************************************************************************************
*/

void App_TaskDelHook(OS_TCB *ptcb)
{
	(void) ptcb;
}

/*
*********************************************************************************************************
*   								   IDLE TASK HOOK (APPLICATION)
*
* Description : This function is called by OSTaskIdleHook(), which is called by the idle task.  This hook
*   			has been added to allow you to do such things as STOP the CPU to conserve power.
*
* Argument(s) : none.
*
* Note(s)     : (1) Interrupts are enabled during this call.
*********************************************************************************************************
*/

#if OS_VERSION >= 251
void App_TaskIdleHook(void)
{
}
#endif

/*
*********************************************************************************************************
*   									 STATISTIC TASK HOOK (APPLICATION)
*
* Description : This function is called by OSTaskStatHook(), which is called every second by uC/OS-II's
*   			statistics task.  This allows your application to add functionality to the statistics task.
*
* Argument(s) : none.
*********************************************************************************************************
*/

void App_TaskStatHook(void)
{
}

/*
*********************************************************************************************************
*   									 TASK SWITCH HOOK (APPLICATION)
*
* Description : This function is called when a task switch is performed.  This allows you to perform other
*   			operations during a context switch.
*
* Argument(s) : none.
*
* Note(s)     : (1) Interrupts are disabled during this call.
*
*   			(2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
*   				will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
*   			   task being switched out (i.e. the preempted task).
*********************************************************************************************************
*/

#if OS_TASK_SW_HOOK_EN > 0
void App_TaskSwHook(void)
{
#if (OS_VIEW_MODULE > 0)
	OSView_TaskSwHook();
#endif
}
#endif

/*
*********************************************************************************************************
*   								  OS_TCBInit() HOOK (APPLICATION)
*
* Description : This function is called by OSTCBInitHook(), which is called by OS_TCBInit() after setting
*   			up most of the TCB.
*
* Argument(s) : ptcb	is a pointer to the TCB of the task being created.
*
* Note(s)     : (1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/

#if OS_VERSION >= 204
void App_TCBInitHook(OS_TCB *ptcb)
{
	(void) ptcb;
}
#endif

/*
*********************************************************************************************************
*   									 TICK HOOK (APPLICATION)
*
* Description : This function is called every tick.
*
* Argument(s) : none.
*
* Note(s)     : (1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/

#if OS_TIME_TICK_HOOK_EN > 0
void App_TimeTickHook(void)
{
#if (OS_VIEW_MODULE > 0)
	OSView_TickHook();
#endif
}
#endif
#endif

⌨️ 快捷键说明

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