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

📄 visbyapi.h

📁 一个多任务实时操作系统
💻 H
字号:
#ifndef __VISBY_KERNELDEF_H__
#define __VISBY_KERNELDEF_H__

#include "Visby.h"
#include "..\Target\44blib.h"
#include "..\Target\44b.h"

///////////////任务调度时间间隔/////////////
////////////////////////////////////////////
#define VB_TICKINTV		1000	//uint: us

/////////////////任务优先级/////////////////
////////////////////////////////////////////
#define PRIO_REAL		0x01
#define PRIO_HIGH		0x02
#define PRIO_NORMAL		0x03
#define PRIO_LOW		0x04

///////////系统软中断定义 SWI中断/////////////
////SWI定义为请求系统服务中断。用户的应用/////
//程序通过API函数,使用SWI进行系统调用,并通//
//过R1~R12寄存器组传递调用参数。/////////////
//////SWI系统请求定义如下。///////////////////
//////////////////////////////////////////////
//中断请求号
#define VB_SWI_NULL		0x0000
#define VB_SWI_POW		0x0100		//电源管理
#define	VB_SWI_TASK		0x0200		//任务请求
#define VB_SWI_MSG		0x0300		//消息管理
#define VB_SWI_DEV		0x0400		//设备操作
#define VB_SWI_INT		0x0500		//中断请求

#define SWI_POW_NORM	0x0000
#define SWI_POW_SLOW	0x0001
#define SWI_POW_IDLE	0x0002
#define SWI_POW_STOP	0x0003
#define SWI_POW_SLIDLE	0x0004

#define SWI_TASK_NEW	0x0001
#define SWI_TASK_DEL	0x0002
#define SWI_TASK_SUS	0x0003
#define SWI_TASK_SLP	0x0004
#define SWI_TASK_RSM	0x0005
#define SWI_TASK_WAI	0x0006

#define SWI_MSG_GLBL	0x0001
#define SWI_MSG_SEND	0x0002
#define SWI_MSG_URGT	0x0003


/*///////////////////CPU资源描述/////////////////////////
********************************************************/

/////////////////定时器/////////////////////
#define VB_TIMER0		0x01
#define VB_TIMER1		0x02
#define VB_TIMER2		0x03
#define VB_TIMER3		0x04
#define VB_TIMER4		0x05
#define VB_TIMER5		0x06

#define VB_RES_NUM		6


/////////////////////////消息///////////////////////////
////////////////////////////////////////////////////////
#define VB_MSG_MIN		0x00000000
#define VB_MSG_NULL		0x00000000
#define VB_MSG_KERNEL	0x000F0000
#define VB_MSG_SYSRTN	0x00F00000
#define VB_MSG_SYSTEM	0x0F000000
#define VB_MSG_USER		0xF0000000
#define VB_MSG_MAX		0xFFFFFFFF

#define MSG_WAIT_DEV	0x00100000
#define MSG_WAIT_RES	0x00200000

#define VB_MSG(type,detail)	((type&0xFFFF0000)|(detail&0x0000FFFF))
#define VB_LPARAM(uintd)	((ushort)(uintd&0x0000FFFF))
#define VB_HPARAM(uintd)	((ushort)((uintd&0xFFFF0000)>>16))

#define VB_MSG_TYPE(hmsg)	(*((uint *)(hmsg)))
#define VB_MSG_DETAIL(hmsg)	(*((void *)((hmsg) + 4)))
#define VB_MSG_NEXT(hmsg)	(*((uint *)((hmsg) + 8)))


/////////////////////任务控制块///////////////////
//任务控制块中需要指明任务种类,包括内核任务,即//
//系统服务,和普通用户任务。//////////////////////
//////////////////////////////////////////////////


//*S3C44B0X的30个中断源的处理函数指针
typedef void (*LPFUNC)(void);
#define VB_ISR_RESERVE		0

#define VB_ISR_EINT0		8 
#define VB_ISR_EINT1		9 
#define VB_ISR_EINT2		10
#define VB_ISR_EINT3		11
#define VB_ISR_EINT4567		12
#define VB_ISR_INTTICK		VB_ISR_RESERVE
#define VB_ISR_Reserve1		VB_ISR_RESERVE
#define VB_ISR_Reserve2		VB_ISR_RESERVE
#define VB_ISR_INTZDMA0		16
#define VB_ISR_INTZDMA1		17
#define VB_ISR_INTBDMA0		18
#define VB_ISR_INTBDMA1		19
#define VB_ISR_WDT			20
#define VB_ISR_USER01		21
#define VB_ISR_Reserve3		VB_ISR_RESERVE
#define VB_ISR_Reserve4		VB_ISR_RESERVE
#define VB_ISR_TIMER0		24
#define VB_ISR_TIMER1		25
#define VB_ISR_TIMER2		VB_ISR_RESERVE
#define VB_ISR_TIMER3		27
#define VB_ISR_TIMER4		28
#define VB_ISR_TIMER5		29
#define VB_ISR_Reserve5		VB_ISR_RESERVE
#define VB_ISR_Reserve6		VB_ISR_RESERVE
#define VB_ISR_URXD0		32
#define VB_ISR_URXD1		33
#define VB_ISR_IIC			34
#define VB_ISR_SIO			35
#define VB_ISR_UTXD0		36
#define VB_ISR_UTXD1		37
#define VB_ISR_Reserve7		VB_ISR_RESERVE
#define VB_ISR_Reserve8		VB_ISR_RESERVE
#define VB_ISR_RTC			40
#define VB_ISR_Reserve9		VB_ISR_RESERVE
#define VB_ISR_Reserve10	VB_ISR_RESERVE
#define VB_ISR_Reserve11	VB_ISR_RESERVE
#define VB_ISR_Reserve12	VB_ISR_RESERVE
#define VB_ISR_Reserve13	VB_ISR_RESERVE
#define VB_ISR_Reserve14	VB_ISR_RESERVE
#define VB_ISR_Reserve15	VB_ISR_RESERVE
#define VB_ISR_ADC			48

#define VB_ISR_NUM		(VB_ISR_ADC - VB_ISR_EINT0 + 1)



////////////////////////设备描述符////////////////////
//设备区别与资源在于,设备是独立与CPU的外部设备。/////
//它分为共享型设备和独占型设备两种,在设备描述符中记//
//录设备的使用状况。共享型设备可以被操作系统同时分给//
//多个任务,但是只有当使用该设备的任务完成一次操作,//
//主动将设备标志为空闲,其它任务才可以使用。//////////
//////////////////////////////////////////////////////
#define VB_DEV_OPRT_NUM		6	//设备操作方式
#define VB_DEV_OPEN			0	//打开
#define VB_DEV_CLOSE		1	//关闭
#define VB_DEV_WRITE		2	//写入
#define VB_DEV_READ			3	//读出
#define VB_DEV_TEST			4	//测试
#define VB_DEV_RESERVE		5	//保留操作

#define VB_DEV_TYPE			UCHAR
#define VB_DEV_SHARE		0
#define VB_DEV_ONE			0xFF


//////////////////////////////////////////////////////
void *heapalloc(uint nbyte);
void heapfree(void *ptr);


extern volatile uchar Visby_Started;
extern volatile uchar Visby_Critical;
extern volatile ullong Visby_Tick;


#define VB_ENCRIT do{Visby_Critical++;}while(false)
#define VB_DECRIT do{if(Visby_Critical > 0)Visby_Critical--;}while(false)


#define Visby_Time (Visby_TimeSum + (ulong)Visby_TimeSlice)
#define VB_Time		Visby_Time

void 		VB_Start(void);


void		VB_SendMsg(VB_HTASK pdestTask, uint msgType, void *pdetail);
void		VB_WaitMsg(VB_HTASK hTask, uint msgType);
void 		VB_UrgentMsg(VB_HTASK pdestTask, uint msgType, void *pdetail);
VB_HMSG		VB_DequeueMsg(void);
void 		VB_DestroyMsg(VB_HMSG pMsg);


VB_HTASK	VB_CreateTask(void (*pentry)(void), byte priority, uint stackSize);
void 		VB_DeleteTask(VB_HTASK ptask);
void 		VB_SleepTask(VB_HTASK ptask, uint tick);
void		VB_SuspendTask(VB_HTASK ptask);
void 		VB_ResumeTask(VB_HTASK ptask);
void		VB_ChangePrio(VB_HTASK ptask, byte newPrio);

BOOL		VB_SetTimer0123(uint index, float duty_ms, VB_HISR isr, VB_HISR *oldisr);
VB_HISR		VB_InstallISR(VB_HISR isr, int index);
BOOL		VB_SetISREnable(int index, BOOL enable);

#endif

⌨️ 快捷键说明

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