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

📄 hsch51.h

📁 时间触发式51单片机嵌入式多任务系统
💻 H
字号:
/*------------------------------------------------------------------*-

   hSCH51.h (v1.00)

  ------------------------------------------------------------------

   - see hSCH51.C for details


   COPYRIGHT
   ---------

   This code is from the book:

   PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont
   [Pearson Education, 2001; ISBN: 0-201-33138-1].

   This code is copyright (c) 2001 by Michael J. Pont.

   See book for copyright details and other information.

-*------------------------------------------------------------------*/

#ifndef _hSCH51_H
#define _hSCH51_H

#include "os_cpu.h"

// ------ Public data type declarations ----------------------------

// Store in DATA area, if possible, for rapid access
// Total memory per task is 8 bytes
typedef tAutoData struct
{
   // Pointer to the task (must be a 'void (void)' function)
   void (code * pTask)(void);

   // Delay (ticks) until the function will (next) be run
   // - see SCH_Add_Task() for further details
   tWord Delay;

   // Interval (ticks) between subsequent runs.
   // - see SCH_Add_Task() for further details
   tWord Period;

   // Incremented (by scheduler) when task is due to execute
   tByte RunMe;

   // Set to 1 if task is co-operative
   // Set to 0 if task is pre-emptive
   tByte Co_op;
} sTaskH;

typedef struct
{
    // Num ticks between repeat runs
    tWord uptime;

    // Messenger use of Task 
    tByte msg;
}tyTaskMsg;

// ------ Public function prototypes -------------------------------

// Core scheduler functions
void  hSCH_Dispatch_Tasks(void);
tByte hSCH_Add_Task(tByte Index, void (code *)(void), tWord, tWord, bit);
bit   hSCH_Delete_Task(tByte);
void  hSCH_Report_Status(void);
void  hSCH_Change_rep(tByte Task_index, tWord uiRep);
void  hSCH_CtxSw(void);


// ------ Public constants -----------------------------------------

// The maximum number of tasks required at any one time
// during the execution of the program
//
// MUST BE ADJUSTED FOR EACH NEW PROJECT
#define hSCH_MAX_TASKS   mTASK_ID_MAX

// 任务类型
#define _OS_CO_OP_TASK_                 1       // 合作式任务
#define _OS_PRE_EMPTIVE_TASK_           0       // 抢占式任务

#endif

#ifdef   _HSCH51_GLOBALS
#define  _HSCH51_EXT
#else
#define  _HSCH51_EXT extern
#endif

#if _OS_REPORT_ERRORS > 0
_HSCH51_EXT tByte tAutoData Error_code_G;
#endif

/*------------------------------------------------------------------*-
  ---- END OF FILE -------------------------------------------------
-*------------------------------------------------------------------*/

⌨️ 快捷键说明

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