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

📄 main.c

📁 一款基于μC/OS-II 的源代码
💻 C
字号:
/****************************************Copyright (c)****************************************************
**                               Guangzhou ZHIYUAN electronics Co.,LTD.
**                                     
**                                 http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File Name:               Main.c
** Last modified Date:      2007.01.18
** Last Version:            1.0
** Description:             The main function example template  主函数例子模版
** 
**--------------------------------------------------------------------------------------------------------
** Created By:              Steven Zhou 周绍刚
** Created date:            2007.01.18
** Version:                 1.0
** Descriptions:            The original version 初始版本
**
**--------------------------------------------------------------------------------------------------------
** Modified by:             Kang qinhua
** Modified date:           2008.01.21
** Version:                 v1.1
** Description:             The second version 第二版
**
*********************************************************************************************************/
#include <includes.h>

/*********************************************************************************************************
  CONSTANTS 常量
*********************************************************************************************************/

/*********************************************************************************************************
  VARIABLES 变量
*********************************************************************************************************/
static OS_STK  Task_StartStk[TASK_START_STK_SIZE];                      /*  The stack of start task     */
                                                                        /*  启动任务的堆栈              */
static OS_STK  Task_LedStk[TASK_LED_STK_SIZE]; 

/*********************************************************************************************************
   FUNCTION PROTOTYPES 函数声明
*********************************************************************************************************/
static void taskStart (void  *parg);                                    /*  The start task  启动任务    */
static void taskLed (void  *parg);

/*********************************************************************************************************
** Function name:           main	   
** Descriptions:            uC/OS移植模板	
** input parameters:        无
** output parameters:       无      
** Returned value:          无 
** Created by:				Steven Zhou 周绍刚
** Created Date:			2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:           
**-------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
int main (void)
{
    intDisAll();                                                        /* Disable all the interrupts   */
                                                                        /* 关闭所有中断                 */

    OSInit();                                                           /*  Initialize the kernel of uC */
                                                                        /*  OS-II 初始化uC/OS-II的内核  */

    OSTaskCreate ( taskStart,                                          
		           (void *)0, 
				   &Task_StartStk[TASK_START_STK_SIZE-1], 
				   TASK_START_PRIO );                                   /*  Initialize the start task   */
                                                                        /*  初始化启动任务              */  
    OSStart();                                                          /*  Start uC/OS-II 启动uC/OS-II */
    return(0) ;
}

/*********************************************************************************************************
** Function name:           Task_Start	   
** Descriptions:            Start task	
** input parameters:        *p_arg
** output parameters:       无      
** Returned value:          无 
** Created by:				Steven Zhou 周绍刚
** Created Date:			2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:           
**-------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
static  void  taskStart (void  *parg)
{   
    (void)parg;
    targetInit();                                                       /*  Initialize the target's MCU */
                                                                        /*  初始化目标单片机            */
    #if OS_TASK_STAT_EN > 0
        OSStatInit();                                                   /*  Enable statistics           */
                                                                        /*  使能统计功能                */
    #endif

    /*
     *  Create the other tasks here. 在这里创建其他任务
     */
	OSTaskCreate (taskLed, (void *)0,   		
			      &Task_LedStk[TASK_LED_STK_SIZE-1], 
				  TASK_LED_PRIO);                                       /*  初始化taskLed任务           */  	
			        
    while (1) {                             
        OSTaskSuspend(OS_PRIO_SELF);                                    /*  The start task can be pended*/
                                                                        /*  here. 启动任务可在这里挂起  */
    }
}

/*********************************************************************************************************
  The other tasks 其他任务
*********************************************************************************************************/
/*
 *  Add the other tasks here . 在这里增加其他任务
 */

/*********************************************************************************************************
** Function name:           taskLed	   
** Descriptions:            LED 任务	
** input parameters:        *parg
** output parameters:       无      
** Returned value:          无	 
** Created by:			    Steven Zhou 周绍刚
** Created Date:		    2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:           
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
static  void  taskLed (void  *parg)
{
    (void)parg;
    while (1) {
		ledOn(1);          					                            /*  点亮LED1                    */          	
		OSTimeDly(OS_TICKS_PER_SEC / 2); 			                    /*  延时0.5秒                   */               	
		ledOff(1);                                                      /*  关闭LED1                    */           	
		OSTimeDly(OS_TICKS_PER_SEC / 2);  		                        /*  延时0.5秒                   */			
	}
}

/*********************************************************************************************************
  END FILE
*********************************************************************************************************/









⌨️ 快捷键说明

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