?? interfac.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 + -