lcdtest.cpp

来自「英创386的LCD控制协议和函数,还有例程」· C++ 代码 · 共 40 行

CPP
40
字号
#include <stdio.h>
#include <dos.h>

#define LcdDatPort   0x78
#define LcdComPort   0x79
#define LcdCtlPort   0x7a

// return  = 1: LCD Ok!
//         = 0: LCD not existed
int LCDIsExisted( )
{
   int TmpDat=0;
   outportb( LcdComPort, 0x46 );
   outportb( LcdDatPort, 0xc0 );
   outportb( LcdDatPort, 0x03 );
   outportb( LcdComPort, 0x42 );
   outportb( LcdDatPort, 0x55 );
   outportb( LcdComPort, 0x42 );
   outportb( LcdDatPort, 0xaa );
   outportb( LcdComPort, 0x46 );
   outportb( LcdDatPort, 0xc0 );
   outportb( LcdDatPort, 0x03 );
   outportb( LcdComPort, 0x43 );
   TmpDat=inport( LcdDatPort );
   TmpDat=TmpDat>>8&0x00ff;
   if( TmpDat!=0x55 )
      { return 0; }

   TmpDat=inport( LcdDatPort );
   TmpDat=TmpDat>>8&0x00ff;
   if( TmpDat!=0xaa )       return 0;
   else                     return 1;
}

int main( )
{
   int i;
   i = LCDIsExisted( );
   return 0;
}

⌨️ 快捷键说明

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