app.c

来自「xilinx内嵌CPU下的UCOS移植」· C语言 代码 · 共 116 行

C
116
字号
/***********************************************************************************************************                                                uC/OS-II*                                          The Real-Time Kernel**                                                  EX1_OS*** Description:  Shows an example of how to use uCOS-II with the MicroBlaze processor.  **********************************************************************************************************/#include "includes.h"/***********************************************************************************************************                                             VARIABLES*********************************************************************************************************/static  OS_STK   AppTaskFirstStk [APP_TASK_FIRST_STK_SIZE];  /* Start task stack                        *//***********************************************************************************************************                                             PROTOTYPES**********************************************************************************************************/static  void     AppTaskFirst(void *p_arg);/***********************************************************************************************************                                              main()* * Description: This is the 'standard' C startup entry point.  main() does the following:*              *              1) Initialize uC/OS-II*              2) Create a single task*              3) Start uC/OS-II** Arguments  : None** Returns    : main() should NEVER return**********************************************************************************************************/int  main (void){    INT8U    err;      /*    * Enable and initialize cache    */    #if XPAR_MICROBLAZE_0_USE_ICACHE
	    print("-- ICACHE --\r\n");       microblaze_init_icache_range(0, XPAR_MICROBLAZE_0_CACHE_BYTE_SIZE);       microblaze_enable_icache();    #endif    #if XPAR_MICROBLAZE_0_USE_DCACHE
	    print("-- DCACHE --\r\n");       microblaze_init_dcache_range(0, XPAR_MICROBLAZE_0_DCACHE_BYTE_SIZE);       microblaze_enable_dcache();    #endif     print("-- Entering main() --\r\n");    BSP_IntDisAll();                         /* Make sure interrupts are disabled on interrupt controller */    OSInit();                                /* Initialize uC/OS-II                                       */    OSTaskCreateExt(AppTaskFirst,                   (void *)0,                   &AppTaskFirstStk[APP_TASK_FIRST_STK_SIZE - 1],                   APP_TASK_FIRST_PRIO,                   APP_TASK_FIRST_ID,                   &AppTaskFirstStk[0],                   APP_TASK_FIRST_STK_SIZE,                   (void *)0,                   OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);    OSTaskNameSet(APP_TASK_FIRST_PRIO, "App Task First", &err);    OSStart();                               /* Start multitasking                                        */}/*$PAGE*//***********************************************************************************************************                                             AppTaskFirst()* * Description: This is the first task executed by uC/OS-II following OSStart()*              * Arguments  : p_arg        Argument passed to this task when task is created.  The argument is not used.** Returns    : None**********************************************************************************************************/static  void  AppTaskFirst (void *p_arg){    (void)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    while (1) {         LED_Toggle(1);        OSTimeDlyHMSM(0,0,0,300);    }}

⌨️ 快捷键说明

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