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

📄 app.c

📁 ucosii在stm32上的移植
💻 C
📖 第 1 页 / 共 2 页
字号:
	  		 }
	  case 3:{
	  		  sprintf(buf,"%ldM",BSP_CPU_ClkFreq() / 1000000L);
			  lcdWrStr(buf);
			  break;
	  		 }
	  case 4:{
	  		  sprintf(buf,"%4d",OS_TICKS_PER_SEC);
			  lcdWrStr(buf);
			  break;
	  		 }
	  case 5:{
	  		  lcdWrStr("uCOS");
			  break;
	  		 }
	  case 0:
	  default:{
              sprintf(buf, "%4d", OSTimeGet()/100);         // convert value to a string
              lcdWrStr(buf);                                // write value to LCD  
              break;
			  }
		}
	  
	  OSTimeDlyHMSM(0, 0, 0, 10);	  
    }
}

/*
*********************************************************************************************************
*                                            App_TaskKbd()
*
* Description : Monitor the state of the push buttons
*
* Argument(s) : p_arg       Argument passed to 'App_TaskKbd()' by 'OSTaskCreate()'.
*
* Return(s)   : none.
*
* Caller(s)   : This is a task.
*
* Note(s)     : none.
*********************************************************************************************************
*/

static  void  App_TaskKbd (void *p_arg)
{
    INT8U  b1,b2;
	INT8U  err;
    (void)p_arg;

	 
    while (DEF_TRUE) {
	    OSSemPend(InfoSem,0,&err);
        b1 = BSP_PB_GetStatus(BSP_PB_ID_KEY1);
		b2 = BSP_PB_GetStatus(BSP_PB_ID_KEY2);
		if (b1 == 1)	{
		App_DispScr_SignOn();
		} 
		if (b2 == 2)	{
		OSMboxPost(Disp_Box,(void*)0);
		}
		OSTimeDlyHMSM(0, 0, 0, 10); 
    }
}

/*
*********************************************************************************************************
*                                            App_TaskJoystick()
*
* Description : Monitor the state of the Joystick
*
* Argument(s) : p_arg       Argument passed to 'App_TaskKbd()' by 'OSTaskCreate()'.
*
* Return(s)   : none.
*
* Caller(s)   : This is a task.
*
* Note(s)     : none.
*********************************************************************************************************
*/

static  void  App_TaskJoystick (void *p_arg)
{
    INT8U  Joystick=0;

    (void)p_arg;

	 
    while (DEF_TRUE) {
        Joystick = BSP_Joystick_GetStatus();
		if(Joystick!=0) OSMboxPost(Disp_Box,(void*)Joystick);
		OSSemPost(InfoSem);
		OSTimeDlyHMSM(0, 0, 0, 10);
    }
}


/*
*********************************************************************************************************
*                                          App_DispScr_SignOn()
*
* Description : Display uC/OS-II system information on the USART.
*
* Argument(s) : none.
*
* Return(s)   : none.
*
* Caller(s)   : App_TaskKbd().
*
* Note(s)     : none.
*********************************************************************************************************
*/

static  void  App_DispScr_SignOn (void)
{


    printf("\r\n  Micrium uC/OS-II  \r\n");
    printf("  ST STM32 (Cortex-M3)\r\n\r\n");

    printf("  uC/OS-II:  V%ld.%ld%ld\r\n",OSVersion()/100,(OSVersion() % 100) / 10,(OSVersion() % 10));
    printf("  TickRate: %ld  \r\n",OS_TICKS_PER_SEC);
    printf("  CPU Usage: %ld%    \r\n",OSCPUUsage);
    printf("  CPU Speed:%ld MHz  \r\n",BSP_CPU_ClkFreq() / 1000000L);
    printf("  #Ticks: %ld  \r\n",OSTime);
    printf("  #CtxSw: %ld  \r\n\r\n",OSCtxSwCtr);

}

























/*
*********************************************************************************************************
*********************************************************************************************************
*                                          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)
{

}

/*
*********************************************************************************************************
*                                    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)
{

}
#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

#endif

⌨️ 快捷键说明

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