?? ps2test.c
字號:
/*********************************************************/
/* REncoder - R8822 INT2 Example by */
/* Lima Endustriyel Bilgisayar, March 2004 - Cem Celik */
/* Counts Pulses Generated by a Rotary Encoder */
/* Uses Console, INT2 and Pin0 of Port C : */
/* */
/* Channel A of the Encoder is connected to INT2 */
/* and provides the "quantitive" pulses */
/* Channel B is connected to Pin 0 of PortC */
/* and provides direction info */
/* The supply voltage of the Encoder is +5VDC */
/* Encoder's "Ground" needs to be common with the SBC */
/* A & B voltage is approx. 3.5V */
/* */
/* V.1.1: Corrected INT related errors per Ed's warnings */
/* */
/*********************************************************/
#define TRUE 1
#define FALSE 0
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <time.h>
#include <string.h>
#include "r8822.h"
extern void interrupt ps2_int(void);
extern void ps2_startint(void);
extern int ps2_getkey(short* key, short* shift);
extern void ps2_stopint( void );
void interrupt (*oldint)(); // to store old ISR vector
void waitmilli(long);
void main ( void )
{
char ch; // keypressed
char ok = TRUE; // control for the endless loop
short key, shift;
puts("\nPS/2 Keyboard Test Application for FL186 Ver.1.01");
puts("by Lima Endustriyel Bilgisayar - www.lima.com.tr");
outportb(0x0606, (inportb(0x0606) & 0xFB)); //Set Port C as Input
disable();
oldint = getvect(INT2NDX ); // Save old vector
setvect(INT2NDX , ps2_int); // Set new one
ps2_startint();
enable();
while( ok )
{
waitmilli(40);
if (kbhit())
ch = getch(); // Get keypress
if ( ch == 0x1B ) ok = FALSE; // Exit if [Esc] is pressed
}
if (ps2_getkey(&key, &shift))
{
fprintf(stderr, "KEY: %2.2X: SHIFT : %2.2X\n", key, shift);
}
}
printf("\n");
ps2_stopint();
// turn off the interrupt(s) and restore vector(s) to their old values
disable();
setvect(INT2NDX , oldint);
enable();
return;
}
// Replacement for Delay //
void waitmilli(long milli)
{
long ltick = clock();
while ( ((clock()- ltick) <= milli) && (ltick <= clock()) ){;}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -