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

📄 interfac.h

📁 在纯DOS下运行的TurboC3_ucos2_ucgui bug改进版本
💻 H
字号:
/*  interface.h
    interface experance
  line number:33  chip of 8255A   ,
  line number:80  chip of 8253 ,
  line number:121 chip of 8259A,
*/



#if !defined(__INTERFAC_H)
#define __INTERFAC_H

// #if ! defined(__*_H)
// define __*_H
#if !defined(__CONIO_H)
#include "conio.h"
#endif


// #define const here
#define  P8255A_A 0X218
#define  P8255A_B 0X219
#define  P8255A_C 0X21A
#define  P8255A_Ctrl 0X21B
//
//
//
unsigned int sqn(int soc,int n)
 {    for(int i=1;i<n;i++)
	 soc=soc*soc;
      return soc;
  }

// 33 start defination of 8255A

class P8255A
   {  private:
      int  Port,Byte,Bit;


      public:
	 void SetCtrl(int byte)
	     { Port=P8255A_Ctrl;
		Byte=byte;
		outp(Port,Byte);
	      }
	 void WritePort(int port,int byte)
		{ Port=port;
		  Byte=byte;
		  outp(Port,Byte);
		}
	 int ReadPort(int port)
		{ Port=port;
		  return inp(port);
		}
	 int ReadBit(int port,int bit)
		 { Port=port;
		    Bit=!!(inp(Port)&sqn(2,bit));
		   return Bit;
		 }
	 void WriteBit(int port,int bit,int num1or0)
	     // question appeared ! ! !
	      {  Port=port;
		 Bit=bit;
		 Byte=!!((ReadPort(Port)^sqn(2,Bit))&num1or0);     // ?
		 outp(Port,Byte);
	      }

	 int GetBit(int number,int bit)
	     { return(!!number&sqn(2,bit));  }

    };
// end defination of 8255A
//
//
//
//
//
//
// start defination of 8253
#define P8253_Ctrl 0x203
#define timer0 0x200
#define timer1 0x201
#define timer2 0x202

class P8253
   {  private:
      int  Port,Byte,Bit;


      public:
	 void SetCtrl(int byte)
	     { Port=P8253_Ctrl;
		Byte=byte;
		outp(Port,Byte);
	      }
	 void WritePort(int port,int byte)
		{ Port=port;
		  Byte=byte;
		  outp(Port,Byte);
		}
	 int ReadPort(int port)
		{ Port=port;
		  return inp(port);
		}
	 int ReadBit(int port,int bit)
		 { Port=port;
		    Bit=!!(inp(Port)&sqn(2,bit));
		   return Bit;
		 }

	 int GetBit(int number,int bit)
	     { return(!!number&sqn(2,bit));  }

    };
// end define of 8253
//
//
//
//
//  121 start define of 8259A
#define P8259A_2 0x20
#define P8259A_1 0x21



#endif





⌨️ 快捷键说明

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