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

📄 8255a_2.cpp

📁 在纯DOS下运行的TurboC3_ucos2_ucgui bug改进版本
💻 CPP
字号:
/*   8255a_2.c
   display red light, green light  and flashing
  HD 97413083   YanGuangMing
*/

#include "interfac.h"
#include "stdio.h"
#include "conio.h"
void main()
 {  int inbyte,i;
    printf("press any key to start 8255a_2.\n");
    getch();
    inbyte=0x80;         /* 1000 0000 */
    outp(port_8255A,inbyte);
    printf("South red ,East  red , North red , West red.\n");
    inbyte=0x01;       /* 0 000 000 1 */
    outp(port_8255A,inbyte);
    inbyte=0x03;       /* 0 000 001 1 */
    outp(port_8255A,inbyte);
    inbyte=0x05;       /* 0 000 010 1 */
    outp(port_8255A,inbyte);
    inbyte=0x07;       /* 0 000 011 1 */
    outp(port_8255A,inbyte);
    sleep(3);
    printf(" any key to exit to dos . \n");
    while(!kbhit())
    {
	printf(" South green on, Nouth green on.\n");
        inbyte=0x09; /* 0 000 100 1 */
        outp(port_8255A,inbyte);
        inbyte=0x0d;    /* 0 000 110 1 */
        outp(port_8255A,inbyte);
	sleep(3);

	printf(" South green off, Nouth green off .\n");
        inbyte=0x08; /* 0 000 100 0 */
        outp(port_8255A,inbyte);
        inbyte=0x0c;    /* 0 000 110 0 */
        outp(port_8255A,inbyte);

         /* yellow light flash 8 times */
        for(i=0;i<8;i++)
          {  outp(port_B_of_8255A,0x50);
             delay(100);
             outp(port_B_of_8255A,0x0);
             delay(100);
         }

    printf("South red ,East  red , North red , West red.\n");
    inbyte=0x01;       /* 0 000 000 1 */
    outp(port_8255A,inbyte);
    inbyte=0x03;       /* 0 000 001 1 */
    outp(port_8255A,inbyte);
    inbyte=0x05;       /* 0 000 010 1 */
    outp(port_8255A,inbyte);
    inbyte=0x07;       /* 0 000 011 1 */
    outp(port_8255A,inbyte);
    sleep(3);

	printf(" East green on, West green on.\n");
        inbyte=0x0b; /* 0 000 101 1 */
        outp(port_8255A,inbyte);
        inbyte=0x0f;    /* 0 000 111 1 */
        outp(port_8255A,inbyte);
	sleep(3);

	printf(" East green off, West green off.\n");
        inbyte=0x0a; /* 0 000 101 0 */
        outp(port_8255A,inbyte);
        inbyte=0x0e;    /* 0 000 111 0 */
        outp(port_8255A,inbyte);
	sleep(3);

        /* yellow light flash 8 times */
        for(i=0;i<8;i++)
          {  outp(port_B_of_8255A,0x50);
             delay(100);
             outp(port_B_of_8255A,0x0);
             delay(100);
         }

    printf("South red ,East  red , North red , West red.\n");
    inbyte=0x01;       /* 0 000 000 1 */
    outp(port_8255A,inbyte);
    inbyte=0x03;       /* 0 000 001 1 */
    outp(port_8255A,inbyte);
    inbyte=0x05;       /* 0 000 010 1 */
    outp(port_8255A,inbyte);
    inbyte=0x07;       /* 0 000 011 1 */
    outp(port_8255A,inbyte);
    sleep(3);

 }

}




⌨️ 快捷键说明

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