1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include<stdio.h>
#include <conio.h>
#include<dos.h>
#define PORT (0x3F8)
#define RBR PORT
#define THR PORT
#define LSR (PORT+5)
#define IIR (PORT+2)
#define LCR (PORT+3)
#define DLL PORT
#define DLM PORT
#define IER (PORT+1)
#define MCR (PORT+4)
#define MSR (PORT+6)
void init_8250(void);
char recep_oct(void);
int main(void)
{
char c;
init_8250();
printf("Attente d'un caractere ...\n");
c=recep_oct();
printf("Le caractere recu est : %c \n",c);
getch ();
return(0);
}
void init_8250(void)
{
/*1 rapidite de modulation*/
outportb(LCR,0x80);
outportb(DLM,0x01);
outportb(DLL,0x80);
/*2 format des donnes*/
outportb(LCR,0x17);
/*3 mode de transfert : scrutation*/
outportb(IER,0);
}
char recep_oct(void)
{
char test,inter;
char c;
test=inportb(LSR);
while (test&&0x01==0)
c=inportb(RBR);
return (c);
} |
Partager