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

📄 app.c

📁 移植到freescale 9s12系列单片机的uCOSII
💻 C
字号:
/*
*********************************************************************************************************
*                                               uC/OS-II
*                                         The Real-Time Kernel
*
*                                (c) Copyright 2004, Micrium, Weston, FL
*                                          All Rights Reserved
*
*
*                                          MC9S12NE64  Sample code
*
* File : APP.C
* By   : Eric Shufro
*********************************************************************************************************
*/

#include <includes.h>

/*
*********************************************************************************************************
*                                                CONSTANTS
*********************************************************************************************************
*/


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

static  void  AppStartTask(void *p_arg);
static  void  AppTaskCreate(void);
static  void  AppTask1(void *p_arg);
static  void  AppTask2(void *p_arg);

#if OS_VIEW_MODULE > 0
static  void  AppTerminalRx(INT8U rx_data);
#endif


/*
*********************************************************************************************************
*                                                VARIABLES
*********************************************************************************************************
*/

OS_STK        AppStartTaskStk[TASK_STK_SIZE];
OS_STK        AppTask1Stk[TASK_STK_SIZE];
OS_STK        AppTask2Stk[TASK_STK_SIZE];

/*
*********************************************************************************************************
*                                                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 68HC12 and C initialization.
* Arguments   : none
*********************************************************************************************************
*/

void main (void)
{
    INT8U  err;


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

    OSTaskCreateExt(AppStartTask, 
                    (void *)0, 
                    (OS_STK *)&AppStartTaskStk[TASK_STK_SIZE-1], 
                    TASK_START_PRIO, 
                    TASK_START_PRIO,
                    (OS_STK *)&AppStartTaskStk[0],
                    TASK_STK_SIZE,
                    (void *)0,
                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);

#if OS_TASK_NAME_SIZE > 16
    OSTaskNameSet(TASK_START_PRIO, "Start Task", &err);
#endif

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


/*$PAGE*/
/*
*********************************************************************************************************
*                                            STARTUP TASK
*
* 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.
*
* Arguments   : p_arg   is the argument passed to 'AppStartTask()' by 'OSTaskCreateExt()'.
*
* 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.
*               2) Interrupts are enabled once the task start because the I-bit of the CCR register was
*                  set to 0 by 'OSTaskCreate()'.
*********************************************************************************************************
*/

static void  AppStartTask (void *p_arg)
{
    (void)p_arg;

    BSP_Init();                             /* Initialize the BSP such as OS Ticker and PLL            */
    
#if OS_TASK_STAT_EN > 0
    OSStatInit();                           /* If enabled, initialize the statistics task              */
#endif

#if OS_VIEW_MODULE > 0
    OSView_Init(19200);                     /* Initialize OSView if the module is enabled              */
    OSView_TerminalRxSetCallback(AppTerminalRx);
    OSView_RxIntEn();                       /* Enable receiver interrupts                              */
#endif

    AppTaskCreate();

    while (TRUE) {                          /* Task body, always written as an infinite loop.          */
        OSTimeDlyHMSM(0, 0, 1, 0);
    }
}


/*$PAGE*/
/*
*********************************************************************************************************
*                                     CREATE APPLICATION TASKS
*
* Description : none
* Arguments   : none
* Notes       : none
*********************************************************************************************************
*/
static  void  AppTaskCreate (void)
{
    INT8U  err;


    OSTaskCreateExt(AppTask1, 
                    (void *)0, 
                    (OS_STK *)&AppTask1Stk[TASK_STK_SIZE-1], 
                    TASK_1_PRIO,
                    TASK_1_PRIO,
                    (OS_STK *)&AppTask1Stk[0],
                    TASK_STK_SIZE,
                    (void *)0,
                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if OS_TASK_NAME_SIZE > 16
    OSTaskNameSet(TASK_1_PRIO, "Task #1", &err);
#endif


    OSTaskCreateExt(AppTask2, 
                    (void *)0, 
                    (OS_STK *)&AppTask2Stk[TASK_STK_SIZE-1], 
                    TASK_2_PRIO,
                    TASK_2_PRIO,
                    (OS_STK *)&AppTask2Stk[0],
                    TASK_STK_SIZE,
                    (void *)0,
                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if OS_TASK_NAME_SIZE > 16
    OSTaskNameSet(TASK_2_PRIO, "Task #2", &err);
#endif
}


/*$PAGE*/
/*
*********************************************************************************************************
*                                             TASK #1
*********************************************************************************************************
*/

static void  AppTask1 (void *p_arg)
{
    (void)p_arg;
    while (TRUE) {
        LED_Toggle(0);
        OSTimeDlyHMSM(0, 0, 0, 1000);
    }
}


/*
*********************************************************************************************************
*                                             TASK #2
*********************************************************************************************************
*/

static void  AppTask2 (void *p_arg)
{
    (void)p_arg;
    while (TRUE) {
      //  LED_Toggle(1);
		OSTimeDlyHMSM(0, 0, 0, 500);
    }
}


/*
*********************************************************************************************************
*                                     uC/OS-View TERMINAL WINDOW CALLBACK
*********************************************************************************************************
*/

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




⌨️ 快捷键说明

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