const unsigned short data_port = 0x0378;
const unsigned short status_port = 0x0379;
const unsigned short control_port = 0x037A;
//const unsigned short data_port = 0x0278;
//const unsigned short status_port = 0x0279;
//const unsigned short control_port = 0x027A;
//const unsigned short data_port = 0x03BC;
//const unsigned short status_port = 0x03BD;
//const unsigned short control_port = 0x03BE;
#define RED_SWITCH 0x80
#define YELLOW_SWITCH 0x40
#define PULLUP_SWITCH 0x20
#define SWITCH_MASK 0xE0
#define LED1 0x1E // 1-1110
#define LED2 0x1D // 1-1101
#define LED3 0x1B // 1-1011
#define LED4 0x17 // 1-0111
#define LED5 0x0F // 0-1111
#define LED1_4 0x16 // 1-0110
#define LED_MASK 0x1F
#define ALL_OFF 0xFF
#define ACK 0x40
int main()
{
_outp(control_port, 0xCC); //出力モードにする
_outp(data_port, ALL_OFF);
printf("押しボタンを押している間、全LEDが点灯します.\n");
printf("何かキーを押すと終了します.\n");
_outp(data_port, PULLUP_SWITCH);
for( ; ; )
{
if ((_inp(status_port) & ACK) != 0)
{
_outp(data_port, PULLUP_SWITCH);
}
else
{
_outp(data_port, RED_SWITCH|YELLOW_SWITCH|PULLUP_SWITCH);
}
if (kbhit() != 0)
{
break;
}
}
return 0;
}
|