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

📄 main.c

📁 ucos源码
💻 C
字号:
#include	"../../ucos-ii/includes.h"               /* uC/OS interface */

#ifdef SEMIHOSTED
	#define	TASK_STACK_SIZE	(64+SEMIHOSTED_STACK_NEEDS)
#else
	#define		TASK_STACK_SIZE	10*1024
#endif


#define STACKSIZE 128
OS_EVENT *UART_sem;

unsigned int Stack1[STACKSIZE];
unsigned int Stack2[STACKSIZE];
unsigned int Stack3[STACKSIZE];
unsigned int Stack4[STACKSIZE];
unsigned int StackMain[STACKSIZE];





void Task1(void *Id)
{
	INT8U err;


	OSSemPend(UART_sem, 0, &err);
	uHALr_printf("  task%c CALLED.\n", *(char *)Id);
	OSSemPost(UART_sem);
	while(1)
	{

		led1_on();
		led2_off();
		OSTimeDly(1000);
		led1_off();
		led2_on();
		OSTimeDly(1000);
	}
}

void Task4(void *Id)
{
	INT8U err;
	int value;
	char *Msg;
	int i;
	
//	OSSemPend(UART_sem, 0, &err);
//	uHALr_printf("  task%c CALLED.\n", *(char *)Id);
//	OSSemPost(UART_sem);
	
	while(1)
	{
	value=key_read();
	if(value > -1)
  		{
		Digit_Led_Symbol(value);
		OSTimeDly(10);
	 	}
	 	OSTimeDly(10);
	 }
  }

void Task3(void *Id)
{	
	INT8U err;
	INT32U NowTime;
//	OSSemPend(UART_sem, 0, &err);
//	uHALr_printf("  task%c CALLED.\n", *(char *)Id);
//	OSSemPost(UART_sem);
	int i=0;
	while(1)
	{
       		i++;
      	uHALr_printf("           **** %d ****\r",i);
 		OSTimeDly(1090);
	}
}
void Task2(void *Id)
{
	INT8U err;
	int i;
	INT32U NowTime;
//	OSSemPend(UART_sem, 0, &err);
//	uHALr_printf("  task%c CALLED.\n", * (char *)Id);
//	OSSemPost(UART_sem);
	
	while(1)
	{
		for(i=0; i<16; i++)
		{
			OSSemPend(UART_sem, 0, &err);
			NowTime=OSTimeGet();
				OSSemPost(UART_sem);
			OSTimeDly(1300);
		}
	}
}
void TaskStart (void *i)
{

     char Id1 = '1';
     char Id2 = '2';
     char Id3 = '3';
     char Id4 = '4';
     UART_sem=OSSemCreate(1);
     uHALr_InitTimers();            // enable timer counter interrupt
                
     /*
     * create the tasks in uC/OS and assign decreasing
     * priority to them
     */

    OSTaskCreate(Task1, (void *)0, &Stack1[STACKSIZE - 1], 2);
    OSTaskCreate(Task2, (void *)0, &Stack2[STACKSIZE - 1], 3);
    OSTaskCreate(Task3, (void *)0, &Stack3[STACKSIZE - 1], 4);
    OSTaskCreate(Task4, (void *)0, &Stack4[STACKSIZE - 1], 5);
    // Delete current task
    OSTaskDel(OS_PRIO_SELF);
}

int Main(void)//int argc, char **argv
{
	char Id0 = '4';
	ARMTargetInit();
	
	/* needed by uC/OS */
	OSInit();
	
	OSTimeSet(0);
	
	/* create the start task */
	OSTaskCreate(TaskStart,(void *)0, &StackMain[STACKSIZE - 1], 0);
	
	ARMTargetStart();
	
	/* start the operating system */
	OSStart();
	
	return(0);
	
//* End
}                              


⌨️ 快捷键说明

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