시스템응용

#include <stdio.h>
#include <conio.h>
#include "C:/eboard/eblib.h"
#define BASE_ADDR 0x00
#define PORTA  BASE_ADDR | 0x04
#define PORTB  BASE_ADDR | 0x05
#define PORTC  BASE_ADDR | 0x06  
#define CWR0  BASE_ADDR | 0x07 
#define CWR1  BASE_ADDR | 0X0b
void init_eboard(void)
{
 outp(CWR0,0X88);
 outp(CWR1,0x80);
 outp(PORTA, 0xff);
}
void main(void)
{
 int i,count,quot,rem;
 unsigned out;
 if(InitDriver(EB_DEVICE_PCI))
 {
  printf("Device Driver Loading Fail!rn");
  return;
 }
 //clrscr();
 init_eboard();
 printf("nPush a Button Switch (SW1,SW2,SW3,SW4).n");
 do
 {
  i=((0xff-inp(PORTC))>>4)& 0x0f;
  if(i==1)
  {for(i=1;i<11;i++)
    count=count+i;
   quot=count/10;
   rem=count%10;
   out=quot|(rem<<4);
   outportb(PORTB, out);
  }if(i==8)
  {for(i=11;i<17;i++)
    count=count+i;
    quot=count/10;
    rem=count%10;
    out=quot|(rem<<4);
    outportb(PORTB,out);  
  }count=0;
 }while(!kbhit());
 init_eboard();
}
   
 
 
#include <stdio.h>
#include <conio.h>
#include "C:/eboard/eblib.h"
#define BASE_ADDR 0x00
#define PORTA  BASE_ADDR | 0x04
#define PORTB  BASE_ADDR | 0x05
#define PORTC  BASE_ADDR | 0x06  
#define CWR0  BASE_ADDR | 0x07 
#define CWR1  BASE_ADDR | 0X0b
void init_eboard(void)
{
 outp(CWR0,0X88);
 outp(CWR1,0x80);
 outp(PORTA, 0xff);
}
void main(void)
{
 int i,j,count;
 unsigned out;
 if(InitDriver(EB_DEVICE_PCI))
 {
  printf("Device Driver Loading Fail!rn");
  return;
 }
 //clrscr();
 init_eboard();
 printf("nPush a Button Switch (SW1,SW2,SW3,SW4).n");
 do
 {
  i=((0xff-inp(PORTC))>>4)& 0x0f;
  if(i==4) {
   outp(PORTB,0x33);
   printf("Push Button 3(SW3)is on.n",i);
   delay(50);
  }
   if(i==1) {
   outp(PORTB,0x77);
   printf("Push Button 1(SW1)is on.n",i);
   delay(50);
  }
   if(i==2) {
   outp(PORTB,0x77);
   printf("Push Button 2(SW2)is on.n",i);
   delay(50);
  }
   if(i==8) {
   outp(PORTB,0x77);
   printf("Push Button 4(SW4)is on.n",i);
   delay(50);
   }
 }while(!kbhit());
 init_eboard();
}

5 thoughts on “시스템응용

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s