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

📄 main.c

📁 embed in keil
💻 C
字号:
/******************************************************************************************************\
*                                                                                                      *
*  File     : MAIN.C                                                                                   *
*                                                                                                      *
*  Date     : October, 2001                                                                            *
*  Version  : 0.00                                                                                     *
*  Change   : N/A                                                                                      *
*  Reason   : Initial Release                                                                          *
*                                                                                                      *
*  Author   : Antonio Fuentes - (antonio_fuentes@msl-vlc.com)                                          *
*                                                                                                      *
*  Comments:   This file contains code that is not part of the Real-Time kernel, but that actually     *                                                                                   
*              prepares the system for multitasking, and starts the system running.                    *
*                                                                                                      *
*              This code is responsible for creating the tasks that make up the whole application,     *
*              and to start the system running, by invoking kernel services.                           *
\******************************************************************************************************/
#pragma language=extended

#define  APP_GLOBALS       

#include "includes.h"   

#define  APP_MASTER_FILE 

/*<---[ Include files: ]----------------------------------------------------------------------------->*/

#include "main.h"

/*<---[ Declare OS-specific objects (queues, messages, semaphores, etc...): ]-------------------------*/

pOS_EVENT  Comm_Sem;                            /* Handle of the Communications manager semaphore     */

/*<---[ Global variables used by all modules: ]------------------------------------------------------>*/
  
ULONG  Task_Ctr[8]; 
   
/*<---[ Globals variables declared in other modules: ]----------------------------------------------->*/

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

/*<---[ Functions declared in external modules: ]---------------------------------------------------->*/

extern void  Task_0(void *);
extern void  Task_1(void *);
extern void  Task_2(void *);
extern void  Task_3(void *);
extern void  Task_4(void *);
extern void  Task_5(void *);
extern void  Task_6(void *);
extern void  Task_7(void *);
                                       
extern void  Comm_Mgr(void *);                      /* Serial Port Communications Manager             */
extern void  Clock(void *);                         /* Seconds-counting task                          */

/*<---[ Functions declared in this module: ]--------------------------------------------------------->*/

void Start_Up(void *);                              /* First task to execute in the system            */

/******************************************************************************************************\
*                                                                                                      * 
*  Function   : main()                                                                                 *
*                                                                                                      *
*  Description: C main entry point. This function initializes the 80C52, uC/OS, creates all tasks,     *
*               and starts multitasking.                                                               *
*                                                                                                      *
*               Note that the 'ticker' is neither initialized nor running at this point. The ticker    *
*               needs to be initialized by the first running task.                                     *
*                                                                                                      *
*  Input      : void                                                                                   *                                                                                
*  Output     : void                                                                                   *                                                                                 
*  Return     : void                                                                                   *
*                                                                                                      *
*  Change Log :                                                                                        *
*  Date       : Aug.-13-01                                                                             *
*  Version    : 1.0                                                                                    *
*  Change ID  : N/A                                                                                    *
*  Reason     : Initial version                                                                        *
*                                                                                                      *
*  Comments   :                                                                                        *                                                                               
\******************************************************************************************************/
void main(void)
{
/*<---[ Variables used in this function: ]----------------------------------------------------------->*/
  
/*<---[ End of variable declaration ]---------------------------------------------------------------->*/
  
 OSInit();                                                /* Initialize uC/OS-II Real-Time kernel     */   
 OSTaskCreate(Start_Up, (void *)0, (pOS_STK)0x018000, 2); /* Create Start-up (with 'xtack' at 8000h)  */
 Comm_Sem = OSSemCreate((INT16U)0);                       /* Create Serial Port access semaphore      */
 OSStart();                                               /* Start Multitasking running               */                                                  
}
/******************************************************************************************************\
*                                                                                                      *
*  Function   : Start_Up                                                                               *
*                                                                                                      *
*  Description: This function is the first task that executes under uc/OS-II. The task starts off by   *
*               initializing the 'ticker' which happens to be TIMER #0 of the 80C52. Next this task    *                           
*               creates all other tasks in this application, and finally deletes itself, as it need    *
*               never be called again.                                                                 *  
*                                                                                                      *
*  Input      : void *                                                                                 *                         
*  Output     : void                                                                                   *                                                                                
*  Return     : void                                                                                   *
*                                                                                                      *
*  Change Log :                                                                                        *
*  Date       : October, 23, 01                                                                        *
*  Version    : 1.0                                                                                    *
*  Change ID  : N/A                                                                                    *
*  Reason     : Initial version                                                                        *
*                                                                                                      *
*  Comments   : It is assumed that TIMER #0 is used as the system ticker. Because of this, TIMER #0's  *
*               interrupt should vector to 'OSTickISR()'.                                              *
\******************************************************************************************************/
void Start_Up(void *prm)
{
/*<---[ Variables used in this function: ]----------------------------------------------------------->*/

/*<---[ End of variable declaration ]---------------------------------------------------------------->*/

 prm = prm;                                   /* No parameters are needed. Prevent compiler warnings  */

/* Create all application tasks:                                                                      */

 OSTaskCreate(Task_0,   (void *)0, (pOS_STK)0x018100, 10);    /* Task stack at 8100h, priority is 10  */
 OSTaskCreate(Task_1,   (void *)0, (pOS_STK)0x018200, 12);    /* Task stack at 8200h, priority is 12  */
 OSTaskCreate(Task_2,   (void *)0, (pOS_STK)0x018300, 14);    /* Task stack at 8300h, priority is 14  */
 OSTaskCreate(Task_3,   (void *)0, (pOS_STK)0x018400, 16);    /* Task stack at 8400h, priority is 16  */
 OSTaskCreate(Task_4,   (void *)0, (pOS_STK)0x018500, 18);    /* Task stack at 8500h, priority is 18  */
 OSTaskCreate(Task_5,   (void *)0, (pOS_STK)0x018600, 20);    /* Task stack at 8600h, priority is 20  */
 OSTaskCreate(Task_6,   (void *)0, (pOS_STK)0x018700, 22);    /* Task stack at 8700h, priority is 22  */
 OSTaskCreate(Task_7,   (void *)0, (pOS_STK)0x018800, 24);    /* Task stack at 8800h, priority is 24  */

 OSTaskCreate(Clock,    (void *)0, (pOS_STK)0x018900, 60);    /* Clock task, low priority             */
 OSTaskCreate(Comm_Mgr, (void *)0, (pOS_STK)0x018A00,  5);    /* Comm. Manager task, high priority    */

 START_TIMER();                                    /* Start TIMER #0 for tick rate                    */
 OSTaskDel(OS_PRIO_SELF);                          /* Task deletes itself to let the other tasks run  */
}

⌨️ 快捷键说明

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