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

📄 uk_kernel.h

📁 非常简单的低端单片机内核, 有定时器,任务调度,状态机例子
💻 H
字号:
/*******************************************************************************
File: uK_Kernel.h

Description:
This file contains literal definitions and types that are used throughout the 
uK-Kernel RTOS.  Most source files will include this header file.

Creation:
Date:	November 2, 2004
Author:	Benjamin M. Kacenas       
*******************************************************************************/
#ifndef _UK_KERNEL_
#define _UK_KERNEL_

#define    MAX(x,y) ((x<y)?y:x)

#define    CLEAR     0
#define    SET       1  

#define    FALSE     0
#define    TRUE      1

#define    DISABLE   0
#define    ENABLE    1

#define    EMPTY     0
#define    NOT_EMPTY 1

#define    NO_ERROR        0
#define    ERROR           1
#define    TASK_QUE_FULL   1
#define    NO_DELAY_TIMERS 1

#define    TASK_QUE_SIZE      50
#define    NUM_DELAY_TIMERS   10

#define    FLAG_4MSEC       0x0001
#define    FLAG_40MSEC      0x0002
#define    FLAG_100MSEC     0x0004
#define    FLAG_200MSEC     0x0008
#define    FLAG_500MSEC     0x0010
#define    FLAG_1000MSEC    0x0020

#define    MSEC_40              10
#define    MSEC_100             27
#define    MSEC_200             49
#define    MSEC_500             123
#define    MSEC_1000            249
#define    RTX_COUNTER_LIMIT    250

// 8 bit type
typedef unsigned char byte;
 
// Type pointer to function that returns void
typedef void (code *FuncPoint)();

// Structure is the typedef for the task queue
typedef struct TaskQueue
{
    FuncPoint fp_Task;		    // Function pointer to task
    void      *p_TaskData;	    // Data pointer to pass to the task
};

// This structure is the system delay timers
typedef struct SysDelay
{
    unsigned  int i_DelayCounter; // Delay counter
    FuncPoint fp_Task;            // Function pointer variable
    void      *p_TaskData;        // Data pointer variable
};

// This is the actual task queue array
struct TaskQueue st_TaskQue[TASK_QUE_SIZE];

byte data    by_TaskQueHead;  // The task queue head pointer
byte data    y_TaskQueTail;	// The task queue tail pointer
bit  bdata   b_TaskQueEmpty;  // Task queue empty status flag

// This variable has one bit for each time slot of the interval
// dispatcher
unsigned int ui_EventTask;
byte data    by_RTX_Counter;  // Counter used for heartbeat timer
                              // divisor

// This is the delay timer array
struct SysDelay st_SysDelay[NUM_DELAY_TIMERS];

byte by_QueMax;        // Maximum tasks that have been queued 
byte by_DelaysUsedMax; // Keeps track of the number of delay timers
                       // used max

// Function prototypes
void sl_RTX_Event(void) interrupt 1;
byte sl_QueTask(FuncPoint fp_FunctionPointer, void *p_DataPointer);
void sl_IntervalDispatcher(void);
byte sl_RequestDelay(unsigned int i_Delay, FuncPoint p_FunctionPointer,
    void *p_DataPointer);

#endif // _UK_KERNEL_

⌨️ 快捷键说明

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