Esempio n. 1
0
// this task is the initial task running, started by main(). It begins the system tick timer
// and creates all the other task. Then it deletes itself.
void StartupTask(void* pdata)
{
    INT8U err;
    
    DEBUGMSG(1,("StartupTask: begin\n\r"));
    DEBUGMSG(1,("StartupTask: tick timer\n\r"));
    // Initialize BSP functions   
    BSP_Init();                                                 
    // re-init the UART so we can use the serial port
    initUART0(38400, UART_8N1, UART_FIFO_OFF, getFcclk());
    // initialize the driver sub-system
    err = OSDRV_SubsysInit(DriverTable, DRIVER_COUNT);
    if (err != OS_DRV_NO_ERR) {
        RETAILMSG(1,("StartupTask: Failed to initialize driver subsystem: %d\n\r", err));
        //park here
        while(TRUE);
    }
    SemPrint = OSSemCreate(1);
	  // create the the test tasks
      // we have OS_STK_GROWTH set to 1, so the stack grows from high to low
    DEBUGMSG(1,("StartupTask: Creating the tasks...\n\r"));
    OSTaskCreate(PlayTask, (void*)0, (void*)&TaskPlayStk[APP_TASK_DEFAULT_STK_SIZE-1], APP_TASK_PLAY_PRIO);

#ifdef OS_TASK_STAT_EN
      //create a CPU monitor task 
    OSStatInit ();
//??    OSTaskCreate(MonTask, (void*)0, (void*)&TaskMonStk[APP_TASK_DEFAULT_STK_SIZE-1], APP_TASK_MON_PRIO);
#endif //OS_TASK_STAT_EN
    
      // delete ourselves, letting the work be done in the new tasks.
    DEBUGMSG(1,("StartupTask: deleting self\n\r"));
	OSTaskDel(OS_PRIO_SELF);  
}
/*
*********************************************************************************************************
*                                              STARTUP TASK
*********************************************************************************************************
*/
void  TaskStart (void *pdata)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif
    char       s[100];
    INT16S     key;


    pdata = pdata;                                         /* Prevent compiler warning                 */

    TaskStartDispInit();                                   /* Initialize the display                   */

    OS_ENTER_CRITICAL();								   /* Used to disable interrupts (see chapter 13)*/
    PC_VectSet(0x08, OSTickISR);                           /* Install uC/OS-II's clock tick ISR        */
    PC_SetTickRate(OS_TICKS_PER_SEC);                      /* Reprogram tick rate                      */
    OS_EXIT_CRITICAL();									   /* Re-enable interrupts*/

    OSStatInit();                                          /* Initialize uC/OS-II's statistics         */

    TaskStartCreateTasks();                                /* Create all the application tasks         */

    for (;;) {


        if (PC_GetKey(&key) == TRUE) {                     /* See if key has been pressed              */
            if (key == 0x1B) {                             /* Yes, see if it's the ESCAPE key          */
                PC_DOSReturn();                            /* Return to DOS                            */
            }
        }

        OSCtxSwCtr = 0;                                    /* Clear context switch counter             */
        OSTimeDlyHMSM(0, 0, 1, 0);                         /* Wait one second                          */
    }
}
Esempio n. 3
0
void start_task(void *pdata)
{
	OS_CPU_SR cpu_sr=0;

	pdata=pdata;

	OSStatInit();//初始化统计任务

	OS_ENTER_CRITICAL();//进入临界区,中断无法打断
	
	/**********************bootloader************************************/
	
	OSTaskCreate(led1_task,//指向任务代码的指针
				(void *)0,//任务开始执行时,传递给任务参数的指针
				(OS_STK *)&LED1_TASK_STK[LED1_STK_SIZE-1],//分配给任务堆栈的栈顶指针
				LED1_TASK_PRIO);//分配给任务的优先级
				
	OSTaskCreate(led2_task,//指向任务代码的指针
				(void *)0,//任务开始执行时,传递给任务参数的指针
				(OS_STK *)&LED2_TASK_STK[LED2_STK_SIZE-1],//分配给任务堆栈的栈顶指针
				LED2_TASK_PRIO);//分配给任务的优先级
				
	OSTaskCreate(key_task,//指向任务代码的指针
				(void *)0,//任务开始执行时,传递给任务参数的指针
				(OS_STK *)&KEY_TASK_STK[KEY_STK_SIZE-1],//分配给任务堆栈的栈顶指针
				KEY_TASK_PRIO);//分配给任务的优先级
				
	/********************************************************************/
				
	OSTaskSuspend(START_TASK_PRIO);//挂起开始任务
	OS_EXIT_CRITICAL()//退出临界区 可以被中断打断
}
Esempio n. 4
0
static  void  AppTaskStart (void *p_arg)
{
   (void)p_arg;

    BSP_Init();                                                 /* Initialize BSP functions                             */
    CPU_Init();                                                 /* Initialize the uC/CPU services                       */
    
    BSP_Tick_Init();                                            /* Start Tick Initialization                            */

    Mem_Init();                                                 /* Initialize memory managment module                   */
    Math_Init();                                                /* Initialize mathematical module                       */


#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                               /* Determine CPU capacity                               */
#endif

    BSP_LED_Off(0);
    
#if (APP_CFG_SERIAL_EN == DEF_ENABLED)    
    App_SerialInit();                                           /* Initialize Serial communication for application ...  */
#endif

    APP_TRACE_INFO(("Creating Application Events...\n\r"));
    AppEventCreate();                                          /* Create Application Events                            */

    APP_TRACE_INFO(("Creating Application Tasks...\n\r"));
    AppTaskCreate();                                           /* Create application tasks                             */
    
    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.       */
        BSP_LED_Toggle(0);
        OSTimeDlyHMSM(0, 0, 0, 100);
    }
}
Esempio n. 5
0
/*******************************************************************************
* Function Name  : TaskStart
* Description    : UCOS-II.
* Input          : *pdata.
* Output         : None
* Return         : None
*******************************************************************************/
void TaskStart(void *pdata)
{
    //u16 tp_xvalue = 0, tp_yvalue = 0;
    //INT8U  err = 0;

    pdata = pdata;                   // 防止编译器告警
    SysTick_Configuration();         // 初始化系统节拍(1ms)
    OSStatInit();                    // 初始化统计任务
    TaskStartCreateTasks();          // 建立其他任务

    /* 初始化TFT, 设置TFT背光 */
    TFT_Init();
    TFT_SetBlackLight(TFT_BL_PERCENT_90);

    TFT_Clear(Blue);

    TFT_DisplayD36x48(10,  150, '2', White, Blue);
    TFT_DisplayD36x48(46,  150, '1', White, Blue);
    TFT_DisplayD36x48(82,  150, ':', White, Blue);
    TFT_DisplayD36x48(118, 150, '5', White, Blue);
    TFT_DisplayD36x48(154, 150, '8', White, Blue);
    TFT_DisplayString(200, 182, "2011", White, Blue);

    TFT_DisplayString(30, 218, "Wendnesday, Septermber 23", White, Blue);
    TFT_DrawHLine(30, 236, 230, Blue);

    while(1)
    {
        //printf("Start task is running!\r\n");
        /* 任务延时500ms */
        OSTimeDlyHMSM(0, 0, 20, 0);
    }
}
Esempio n. 6
0
/*
 ***************************************************************
 * 名称: start_task 
 * 功能: 启动任务
 * 输入: 1. *pdata:任务参数
 * 输出: NULL 
 * 返回: NULL 
 * 描述: 无 
 ***************************************************************
 */
void start_task(void *pdata)
{
    OS_CPU_SR cpu_sr = 0;
	
	pdata = pdata; 		  
	
	TaskInit();
	
	OSStatInit();					// 初始化统计任务.这里会延时1秒钟左右	
 	
	OS_ENTER_CRITICAL();			// 进入临界区(无法被中断打断)    
 	
	OSTaskCreate(uart3_task, 
				(void *)0, 
				(OS_STK*)&UART3_TASK_STK[UART3_STK_SIZE-1], 
				UART3_TASK_PRIO);
	
	OSTaskCreate(can1_task, 
				(void *)0, 
				(OS_STK*)&CAN1_TASK_STK[CAN1_STK_SIZE-1], 
				CAN1_TASK_PRIO);	
 
	OSTaskCreate(beep_task, 
				(void *)0, 
				(OS_STK*)&BEEP_TASK_STK[BEEP_STK_SIZE-1], 
				BEEP_TASK_PRIO);
 	
	OSTaskSuspend(START_TASK_PRIO);	// 挂起起始任务.
	
	OS_EXIT_CRITICAL();				// 退出临界区(可以被中断打断)
}	  
Esempio n. 7
0
File: main.c Progetto: Gewin/Ucos
void MainTask(void *pdata) //Main Task create taks0 and task1
{
	#if OS_CRITICAL_METHOD == 3		/* Allocate storage for CPU status register */
		OS_CPU_SR  cpu_sr;
	#endif
	OS_ENTER_CRITICAL();

	Timer0Init();				//initial timer0 for ucos time tick
	ISRInit();				//initial interrupt prio or enable or disable

	OS_EXIT_CRITICAL();

	OSPrintfInit();				//use task to print massage to Uart 

	OSStatInit();
	OSTaskCreate (Task0,(void *)0, &Task0Stk[Task0StkLengh - 1], Task0Prio);	
	OSTaskCreate (Task1,(void *)0, &Task1Stk[Task1StkLengh - 1], Task1Prio);	
	OSTaskCreate (Task2,(void *)0, &Task2Stk[Task2StkLengh - 1], Task2Prio);	 
	OSTaskCreate (Task3,(void *)0, &Task3Stk[Task2StkLengh - 1], Task3Prio);	 
	while(1)
	{
		OSPrintf("\nEnter Main Task\n");
		OSTimeDly(OS_TICKS_PER_SEC);
	}
}
Esempio n. 8
0
//开始任务
void AppStartTask(void *pdata)
{
  OS_CPU_SR cpu_sr=0;
	pdata = pdata; 		  
	msg_test=OSMboxCreate((void*)0);	//创建消息邮箱
	sem_test=OSSemCreate(0);		//创建信号量	
	OSStatInit();					//初始化统计任务.这里会延时1秒钟左右	
 	OS_ENTER_CRITICAL();			//进入临界区(无法被中断打断)    
    OSTaskCreate(AppLEDTask,(void *)0,
                &APP_LED_STK[TASK_STK_SIZE-1],
                APP_LED_TASK_PRIO); //建立LED1任务
    OSTaskCreate(AppMBOXTask,(void *)0,
                &APP_MBOX_STK[TASK_STK_SIZE-1],
                APP_MBOX_TASK_PRIO); //建立邮箱接收显示任务
    OSTaskCreate(AppSEMTask,(void *)0,
                &APP_SEM_STK[TASK_STK_SIZE-1],
                APP_SEM_TASK_PRIO); //建立信号量接收显示任务
    OSTaskCreate(AppWDOGTask,(void *)0,
                &APP_WDOG_STK[TASK_STK_SIZE-1],
                APP_WDOG_TASK_PRIO); //建立看门狗任务
    OSTaskCreate(AppPostTask,(void *)0,
                &APP_POST_STK[TASK_STK_SIZE-1],
                APP_POST_TASK_PRIO); //建立邮箱,信号量投递任务
  UART_printf("uCOSII MBox&Sem DemoTest\r\n");
 	OSTaskSuspend(APP_START_TASK_PRIO);	//挂起起始任务.
	OS_EXIT_CRITICAL();				//退出临界区(可以被中断打断)
}
Esempio n. 9
0
/*
**************************************************************************************************************
*                                              STARTUP TASK
**************************************************************************************************************
*/
void TaskStart (void *data)
{
    INT8U   i;
    INT8U   err;
    char    s[10];

    data = data;                                        /* Prevent compiler warning                         */

    VT102DispClrScr();                                  /* Clear the screen                                 */
    VT102DispStr(26,  1, "uC/OS-II, The Real-Time Kernel", COLOR_WHITE, COLOR_RED);
    VT102DispStr(33,  2, "Jean J. Labrosse", COLOR_WHITE, COLOR_BLACK);
    VT102DispStr(29,  3, "AVR port by Ole Saether", COLOR_WHITE, COLOR_BLACK);
    VT102DispStr(29,  4, "gcc port by Jesper Hansen", COLOR_WHITE, COLOR_BLACK);
    VT102DispStr(1,  23, "Determining  CPU's capacity ...", COLOR_WHITE, COLOR_BLACK);

    OSStatInit();                                       /* Initialize uC/OS-II's statistics                 */
    
    for (i = 0; i < N_TASKS; i++) {                     /* Create N_TASKS identical tasks                   */
        TaskData[i] = '0' + i;                          /* Each task will display its own letter            */
        OSTaskCreate(Task, (void *)&TaskData[i], (void *)&TaskStk[i][TASK_STK_SIZE - 1], i + 1);
    }
    VT102DispStr(1, 23, "#Tasks          : xxxxx  CPU Usage: xxx %", COLOR_WHITE, COLOR_BLACK);
    VT102DispStr(1, 24, "#Task switch/sec: xxxxx", COLOR_WHITE, COLOR_BLACK);
    for (;;) {
        SPrintDec(s, (INT16U)OSTaskCtr, 5);             /* Display #tasks running                           */
        VT102DispStr(19, 23, s, COLOR_WHITE, COLOR_BLUE);
        SPrintDec(s, (INT16U)OSCPUUsage, 3);            /* Display CPU usage in %                           */
        VT102DispStr(37, 23, s, COLOR_WHITE, COLOR_BLUE);
        SPrintDec(s, (INT16U)OSCtxSwCtr, 5);            /* Display #context switches per second             */
        VT102DispStr(19, 24, s, COLOR_WHITE, COLOR_BLUE);
        OSCtxSwCtr = 0;
        OSTimeDlyHMSM(0, 0, 1, 0);                      /* Wait one second                                  */
    }
}
Esempio n. 10
0
/**
  * @brief  The startup task.  The uC/OS-II ticker should only be initialize 
  *         once multitasking starts.
  * @param  p_arg  Argument passed to 'App_TaskStart()' by 'OSTaskCreate()'.
  * @retval None
  */
static  void  App_TaskStart (void *p_arg)
{
  (void)p_arg;
  /* Initialize BSP functions. */
  BSP_Init();                                    
  /* Initialize the SysTick. */	
  OS_CPU_SysTickInit();                                       

#if (OS_TASK_STAT_EN > 0)
  /* Determine CPU capacity. */
  OSStatInit();                                               
#endif
  /* Create application events. */
  App_EventCreate();                                          
  /* Create application tasks. */
  App_TaskCreate();                                           

  while (DEF_TRUE) 
  {
    STM_EVAL_LEDToggle(LED4);
    OSTimeDlyHMSM(0, 0, 0, led_dly_cout);
    STM_EVAL_LEDToggle(LED6);
    OSTimeDlyHMSM(0, 0, 0, led_dly_cout);
    STM_EVAL_LEDToggle(LED5);
    OSTimeDlyHMSM(0, 0, 0, led_dly_cout);
    STM_EVAL_LEDToggle(LED3);
    OSTimeDlyHMSM(0, 0, 0, led_dly_cout);
  }
}
Esempio n. 11
0
static  void App_TaskStart(void* p_arg)
{
   


   (void) p_arg;

   //初始化ucos时钟节拍
   OS_CPU_SysTickInit();                                       /* Initialize the SysTick.       */

//使能ucos 的统计任务
#if (OS_TASK_STAT_EN > 0)
   //----统计任务初始化函数  
   OSStatInit();                                               /* Determine CPU capacity.                              */
#endif
   //建立其他的任务
   App_TaskCreate();

   while (1)
   {
      //1秒一次循环
	  OSTimeDlyHMSM(0, 0,10, 0);

   }
}
Esempio n. 12
0
static  void App_TaskStart(void* p_arg)//负责读取传感器
{

	(void) p_arg;
	
	//初始化ucos时钟节拍
	OS_CPU_SysTickInit();                                       /* Initialize the SysTick.       */
	
	//使能ucos 的统计任务
	#if (OS_TASK_STAT_EN > 0)
	//----统计任务初始化函数  
	OSStatInit();                                               /* Determine CPU capacity.                              */
	#endif
	LED_Init();
	//建立其他的任务
	//LED_P8x16Str(0,0,"Hello",0);	
	//LED_P8x16Str(0,1,"Dolphin",0);
	//AD9850_Write_Serial(10000,0,0);
	App_TaskCreate();

	while (1)
	{
		
		MPU6050_Read_GYRO(&MPU6050_g);	//780us
		MPU6050_Read_ACCEL(&MPU6050_a);	//
		HMC5883L_MultRead(&hmc5883l);	//
		LED_N_STATUS(1,1);
		AHRS_position(&hmc5883l,&MPU6050_a,&MPU6050_g,&EulerAngle_Current);//164us for fast invsqrt 256us for 1.0 / sqrt.
		//350us with EulerAngle
		//IMU_getYawPitchRoll(&EulerAngle_Current);//178us
		LED_N_STATUS(1,0);
		OSTimeDlyHMSM(0, 0, 0, 10);//5ms	
		//LED_N_STATUS(1,1);	
	}
}
Esempio n. 13
0
File: test.c Progetto: palmerc/lab
void  TaskStart (void *pdata)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif
    INT16S     key;


    pdata = pdata;                                         /* Prevent compiler warning                 */

    TaskStartDispInit();                                   /* Setup the display                        */

    OSStatInit();                                          /* Initialize uC/OS-II's statistics         */

    MsgQueue = OSQCreate(&MsgQueueTbl[0], MSG_QUEUE_SIZE); /* Create a message queue                   */

    TaskStartCreateTasks();

    for (;;) {
        TaskStartDisp();                                  /* Update the display                       */

        if (PC_GetKey(&key)) {                             /* See if key has been pressed              */
            if (key == 0x1B) {                             /* Yes, see if it's the ESCAPE key          */
                exit(0);                                   /* Yes, return to DOS                       */
            }
        }

        OSCtxSwCtr = 0;                                    /* Clear the context switch counter         */
        OSTimeDly(OS_TICKS_PER_SEC);                       /* Wait one second                          */
    }
}
Esempio n. 14
0
/*
*********************************************************************************************************
*                                   TASK START FUNCTION
*********************************************************************************************************
*/
void TaskStart(void * pdata)
{
#if OS_CRITICAL_METHOD == 3         /* Allocate storage for CPU status register             */
  OS_CPU_SR  cpu_sr;
#endif

  pdata = pdata;

  printf("Task start!\r\n");
  OS_ENTER_CRITICAL();
  os_timer_init();
  OS_EXIT_CRITICAL();
  
#if OS_TASK_STAT_EN > 0
  OSStatInit();                   /* Initialize Statistics Task */
#endif
  
  TaskStartCreateTasks();         /* Create Tasks */
  
  for(;;) {
    printf("OS context switch counter:%d\r\n", OSCtxSwCtr);
    printf("OS CPU Usage:%d%%\r\n", OSCPUUsage);
    OSCtxSwCtr = 0;
    OSTimeDly(OS_TICKS_PER_SEC);
  }
}
static  void  AppTaskFirst (void *p_arg)
{
	if (DEBUG)
		xil_printf("DEBUG: INSIDE AppTaskFirst\n\r");

	p_arg = p_arg;				/* Prevent compiler warning by doing something with argument */
	
	BSP_InitIO();				/* Initialize the I/Os                                       */

#if OS_TASK_STAT_EN > 0
    OSStatInit();				/* Initialize uC/OS-II's statistics                          */
#endif

    AppTaskCreate();            /* La resta de tasques de l'aplicació es crean normalment       */
                                /* dins d'una altra funció per tal de mantenir neta la secció  */
                                /* de codi corresponent a la funció m                           */

	int	led = 0; // S3A400 - initialize LED selector

    while (1) {
		if (DEBUG)
			xil_printf("DEBUG: INSIDE AppTaskFirst while\n\r");
		//BSP_LEDToggle(led + 1); // S3A400 - Light selected LED, all others off
		
        OSTimeDlyHMSM(0,0,5,0); // Release the CPU (every 5 second)

		//led = (led + 1) % LEDS;				// S3A400 - Select next LED
    }
}
Esempio n. 16
0
/*
*********************************************************************************************************
*                                          App_TaskStart()
*
* Description : This is an example of a startup task.  As mentioned in the book's text, you MUST
*               initialize the ticker only once multitasking has started.
*
* Argument(s) : p_arg   is the argument passed to 'App_TaskStart()' by 'OSTaskCreateExt()'.
*
* Return(s)   : none.
*
* Caller(s)   : This is a task.
*
* Notes       : (1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
static  void  App_TaskStart (void *p_arg)
{   
    (void)p_arg;                                                /* See Note #1                                              */

    BSP_Init();                                                 /* Initialize BSP functions                                 */

    OS_CPU_SysTickInit();                                       /* Initialize the SysTick                                   */

#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                               /* Determine CPU capacity                                   */
#endif

    MEM_Init();

    End_Init();

    GUI_Init(); 

    TIME_Init();

    MENU_Init();

    App_EventCreate();                                          /* Create application events                                */

    App_TaskCreate();                                           /* Create application tasks                                 */
        
    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop            */
        beep();

        OSTimeDlyHMSM(0, 0, 0, 50);
    }
}
Esempio n. 17
0
/*************************************************************************
*                             野火嵌入式开发工作室
*
*  函数名称:Task_Start
*  功能说明:启动任务,初始化滴答时钟
*  参数说明:p_arg       没用
*  函数返回:无
*  修改时间:2012-2-10
*  备    注:
*************************************************************************/
void Task_Start(void *p_arg)
{
  /**************** 初始化 系统滴答时钟 :用于定时任务调度****************/
  u32  cnts;
  cnts = core_clk_mhz * ( (u32)1000000u / (u32)OS_TICKS_PER_SEC );       /* Determine nbr SysTick increments.                    */
  OS_CPU_SysTickInit(cnts);                                                     /* Init uC/OS periodic time src (SysTick).              */


#if (OS_TASK_STAT_EN > 0)
  /*       开启统计任务           */
  OSStatInit();
#endif


  (void)p_arg;    // 'p_arg' 并没有用到,防止编译器提示警告
  

  /******************* 用户任务区 ************************/
  u32 i = 0;
  
  OLED_Init(); 
  OLED_P6x8Str(0,0,"This is a test",0);
  
  while(1)
  {
    sprintf(mystr,"count:%d",i++); 
    OLED_P6x8Str(0,3,mystr,0);
    OSTimeDlyHMSM(0, 0, 0, 10);
  }
}
Esempio n. 18
0
void TaskStart(void *pdata){
	rSUBSRCPND = rSUBSRCPND;
	rSRCPND = rSRCPND;
	rINTPND = rINTPND;
	pdata = pdata;
	
	S3C_StartTimer4();
	
	SwiHandle(1);
	SwiHandle(3);	//Enable Interrupt
	
	rGPBDAT = (15<<5);

	OSStatInit();
	
	OSTaskCreate(Task_UART0TX,(void *)0,&Stk_Task_UART0TX[99],11);
	OSTaskCreate(Task_UART0Rx,(void *)0,&Stk_Task_UART0Rx[99],12);
	OSTaskCreate(Task_LEDMAN,(void *)0,&Stk_Task_LEDMAN[99],13);
	OSTaskCreate(Task_BEEPMAN,(void *)0,&Stk_Task_BEEPMAN[99],14);
	OSTaskCreate(Task_LCDMAN,(void *)0,&Stk_Task_LCDMAN[99],15);
	
	while(1){
		OSTaskSuspend(OSPrioCur);
	}

}
Esempio n. 19
0
int main(void)
{
#if (OS_TASK_NAME_EN > 0)
    CPU_INT08U  err;
#endif   

	SYS_UnlockReg();

    BSP_Init();                                                 /* Initialize BSP functions                             */

    BSP_Set_PLL_Freq(CLK_XTL_12M, PLL_DEFAULT_HZ);				/* Configure PLL                                        */
    BSP_Set_System_Clock(CLK_PLL, 0);                      		/* Select HCLK source clock as PLL                      */
    
    SYS_LockReg();

    OSInit();                                                   /* Initialize "uC/OS-II, The Real-Time Kernel"          */

    CPU_Init();                                                 /* Initialize the uC/CPU services                       */
    
    Mem_Init();                                                 /* Initialize memory managment module                   */
    Math_Init();                                                /* Initialize mathematical module                       */

#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                               /* Determine CPU capacity                               */
#endif
    
    OSTaskCreateExt((void (*)(void *)) AppTask_1,            /* Create the test task                                */
                    (void           *) 0,
                    (OS_STK         *)&StackOfTask_1[TASK_STACK_SIZE - 1],
                    (INT8U           ) TASK_1_PRIO,
                    (INT16U          ) TASK_1_PRIO,
                    (OS_STK         *)&StackOfTask_1[0],
                    (INT32U          ) TASK_STACK_SIZE,
                    (void           *) 0,
                    (INT16U          )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));

    OSTaskCreateExt((void (*)(void *)) AppTask_2,           /* Create the start task                                */
                    (void           *) 0,
                    (OS_STK         *)&StackOfTask_2[TASK_STACK_SIZE - 1],
                    (INT8U           ) TASK_2_PRIO,
                    (INT16U          ) TASK_2_PRIO,
                    (OS_STK         *)&StackOfTask_2[0],
                    (INT32U          ) TASK_STACK_SIZE,
                    (void           *) 0,
                    (INT16U          )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));

#if (OS_TASK_NAME_EN > 0)
    OSTaskNameSet(TASK_1_PRIO, "Task 1", &err);
    OSTaskNameSet(TASK_2_PRIO, "Task 2", &err);
#endif

    OSStart();                                                  /* Start multitasking (i.e. give control to uC/OS-II)   */
    
    return (1);
}
Esempio n. 20
0
static  void  AppTaskStart (void *p_arg)
{
#if CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL
    CPU_SR  cpu_sr;
#endif
    CPU_INT08U  i;
    CPU_INT08U  j;

    (void)p_arg;

    BSP_InitIO();                                                       /* Initialize BSP functions                                 */

#if PROBE_COM_METHOD_RS232 == DEF_FALSE
    UART_Init();                                                        /* Initialize serial port                                   */
#endif

#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                                       /* Determine CPU capacity                                   */
#endif

#if (uC_PROBE_OS_PLUGIN > 0) || (uC_PROBE_COM_MODULE > 0)
    AppProbeInit();                                                     /* Initialize uC/Probe modules                              */
#endif

    AppTaskCreate();                                                    /* Create application tasks                                 */

    while (OS_TRUE) {                                                   /* Task body, always written as an infinite loop.            */
        for (j = 0; j < 2; j++) {
            for (i = 1; i < 9; i++) {
                LED_Toggle(i);
                OSTimeDlyHMSM(0, 0, 0, ADC_GetVal() + 10);
            }

            for (i = 0; i < 8; i++) {
                LED_Toggle(0);
                OSTimeDlyHMSM(0, 0, 0, ADC_GetVal() + 10);
            }
        }

        for ( ; j > 0; j--) {
            for (i = 9; i > 0; --i) {
                LED_Toggle(i);
                OSTimeDlyHMSM(0, 0, 0, ADC_GetVal() + 10);
            }

            for (i = 0; i < 8; i++) {
                LED_Toggle(0);
                OSTimeDlyHMSM(0, 0, 0, ADC_GetVal() + 10);
            }
        }
    }
}
Esempio n. 21
0
//start任务
void start_task(void *pdata)
{
	OS_CPU_SR cpu_sr;
	pdata = pdata ;
	
	OSStatInit();  			//初始化统计任务
	OS_ENTER_CRITICAL();  	//关中断
	OSTaskCreate(led_task,(void*)0,(OS_STK*)&LED_TASK_STK[LED_STK_SIZE-1],LED_TASK_PRIO); 	//创建LED任务
	OSTaskCreate(key_task,(void*)0,(OS_STK*)&KEY_TASK_STK[KEY_STK_SIZE-1],KEY_TASK_PRIO); 	//创建KEY任务
	OSTaskCreate(display_task,(void*)0,(OS_STK*)&DISPLAY_TASK_STK[DISPLAY_STK_SIZE-1],DISPLAY_TASK_PRIO); //显示任务
	OSTaskSuspend(OS_PRIO_SELF); //挂起start_task任务
	OS_EXIT_CRITICAL();  //开中断
}
Esempio n. 22
0
/*
********************************************************************************
**起始任务,优先级1
********************************************************************************
*/
static void TaskStart(void *p_arg)
{
    (void)p_arg;
    BSP_Init();
   
#if (OS_TASK_STAT_EN > 0)
     OSStatInit();
#endif
    OSTaskCreate(Task1,(void*)0,&Task1Stk[TASK1_STK_SIZE-1],2);  // 在起始任务中创建Task1,优先级2 	 
    
	D1_H;D2_H;D3_H;D4_H;D5_H;D6_H;D7_H;D1_H;D8_H;D9_H;D10_H;D11_H;D12_H;D13_H;D14_H;D15_H;D16_H;D18_H;
    while(1)
    {
	   OSTimeDly(10);
       OSTaskSuspend(OS_PRIO_SELF);	  // 挂起自身
    }    
}
Esempio n. 23
0
static	void App_TaskStart(void* p_arg)
{
	 (void) p_arg;
	 OS_CPU_SysTickInit();																			 /* Initialize the SysTick.			 */
#if (OS_TASK_STAT_EN > 0)
	 OSStatInit();																							 /* Determine CPU capacity.															*/
#endif
	 App_TaskCreate();
	 while (1)
	 {
//			LED_LED1_ON();
//			OSTimeDlyHMSM(0, 0, 0, 100);
			
//			LED_LED1_OFF();
			OSTimeDlyHMSM(0, 0, 0, 1);
	 }
}
Esempio n. 24
0
void DestructorTask(void* pdata)
{
   auto INT8U Error;
   auto unsigned int i;

   // Initialize the statistics task
	OSStatInit();

   OSSchedLock();
   for(i = 0; i < OS_MAX_TASKS - 1; i++)
      Error = OSTaskCreateExt(GenericTask, NULL, i, 0, 512, NULL, OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
	OSSchedUnlock();

   // Set counter to 0 so that we can start deleting tasks from the highest to
   // lowest priority.

   // if i rolls over and becomes 0 again, this task will be safe since OSTaskDelReq
   // will return OS_TASK_NOT_EXIST
	for(i = 0; ; i++)
	{
      // if there is still a task other than this task, the statistics task, or the idle task,
      // delete it.
		if(i < OS_MAX_TASKS)
		{
			Error = OSTaskDelReq(i);
			if(Error == OS_NO_ERR)
			{
				while(Error != OS_TASK_NOT_EXIST)
				{
				   Error = OSTaskDelReq(i);
         		OSTimeDly(OS_TICKS_PER_SEC / 5);				  // delay for a bit
				}
				   if (i < 20)
						DispStr((i * 4) + 2, 7, "d");
					if (i >= 20 && i < 40)
						DispStr(((i % 20) * 4)  + 2, 10, "d");
					if (i >= 40 && i < 60)
						DispStr(((i % 20) * 4) + 2, 13, "d");
			}
	   }
		// if all tasks have been deleted, delete this task leaving only idle and stat tasks
		if(i == OS_MAX_TASKS)
			OSTaskDel(OS_PRIO_SELF);
   }
}
Esempio n. 25
0
File: main.c Progetto: Mazetti/asf
static  void  app_task (void *p_arg)
{
	(void)p_arg;

	BSP_Init();       /* Initialize BSP functions */

#if OS_TASK_STAT_EN > 0
	OSStatInit();     /* Determine CPU capacity */
#endif

	OSTimeDlyHMSM(0, 0, 0, 200);

	app_engine(); /* This function never returns */
	while (true) {
		/* Just in case of errouneous return, an infinite loop */
		OSTimeDlyHMSM(0, 0, 0, 200);
	}
}
Esempio n. 26
0
void TaskStart (void *data)
{
    auto UBYTE  i;
    // Create N_TASKS identical tasks
    for (i = 0; i < N_TASKS; i++) {
        TaskData[i] = i;          // Each task has its own number
        OSTaskCreate(Task, (void *)&TaskData[i], TASK_STK_SIZE, 11+i);
    }
    InitTimerInt();  // Setup Timer A internal interrupts
    OSStatInit();    // Initialize statistics task
    DispStr(0, 12, "#Tasks          : xxxxx  CPU Usage: xxxxx %");
    DispStr(0, 13, "#Task switch/sec: xxxxx");
    DispStr(0, 14, "<-PRESS 'Q' TO QUIT->");
    for (;;) {
        UpdateStat();
        OSTimeDly(OS_TICKS_PER_SEC);  // Wait one second
    }
}
Esempio n. 27
0
File: TEST.C Progetto: voileravi/zen
void TaskStart (void *pvdata)
{
    pvdata=pvdata;    // prevents compiler warnings

    OSTimerInit();          // Timer can not be started until the OS has been started.
    _enable_interrupts();   // This is the 5509 master interrupt enable. Individual IE bits have
    // been set in other routines, i.e., OSTimerInit() sets up its bits.
    OSStatInit();

    for(;;)
    {
        a=a/2;
        OSSemPend(MySem,0,&err);
//        printf("This is the first task function\n");
        err = OSSemPost(MySem);
        OSTimeDly(30);
    }
}
Esempio n. 28
0
static void startup_task(void *p_arg)
{
	BSP_Init(); //包含了中断向量的初始化
	CPU_Init(); //

	//根据官方代码,时钟要在这里初始化
	RCC_ClocksTypeDef rcc_clocks;
	RCC_GetClocksFreq(&rcc_clocks);
	SysTick_Config(rcc_clocks.HCLK_Frequency / OS_TICKS_PER_SEC);
	Mem_Init();
#if(OS_TASK_STAT_EN > 0)
	OSStatInit(); // Determine CPU capacity.
#endif


	/*TODO:create application tasks here*/
	
	OSTaskDel(OS_PRIO_SELF);
}
Esempio n. 29
0
static  void  AppTaskStart (void *p_arg)
{
    (void)p_arg;

    BSP_Init();                                                         /* Initialize BSP functions                                 */

#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                                       /* Determine CPU capacity                                   */
#endif

    AppDispInit();                                                      /* Initialize the Display layout                            */

    AppTaskCreate();                                                    /* Create application tasks                                 */
    
    while (1) {                                                         /* Task body, always written as an infinite loop.           */
        AppDispUpdate();  
        OSTimeDlyHMSM(0, 0, 0, 100);
    }
}
/*! \fn       void app_task_start(void *pdata)
*
*  \brief     起始任务
*
*  \param     无
*
*  \exception 无
*
*  \return    无
*/
void app_task_start(void *pdata)
{
    /* 防止编译器告警 */
    pdata = pdata;
    /* 配置systick */
    systick_configuration();
    /* 初始化统计任务 */
    OSStatInit();
    /*! 初始化LED */
    led_init();
    /*! 初始化串口 */
    uart_init();
    /* 打印TaskStart */
    DEBUG_MSG("\r\nD: Start uCosII success!\r\n");
    debug_msg(NULL, __FILE__, __LINE__);
    /* 创建消息队列 */
    //pMsg = OSQCreate(MsgQueue, MSG_QUEUE_SIZE);
    //if((OS_EVENT *)0 == pMsg)
    //{
    //    DEBUG_MSG("\r\nE: OSQCreate error!\r\n");
    //    while(1);
    //}
    
    
    /*! 初始化I2C */
    i2c_init(I2C1);
    /*! MPU9150 */
    mpu9150_test();
    
    /* 建立其他任务 */
    create_tasks();
    
    /*! 任务循环 */
    for( ; ; )
    {
        /* 任务延时 */
        OSTimeDlyHMSM(0, 0, 0, 500);
        //LED2 = LED1;
        LED1 = ~LED1;
        /* suspend task */
        //OSTaskSuspend(OS_PRIO_SELF);
    }
}