1 /*KA******************************************************************
3 **********************************************************************
5 **********************************************************************
7 * date author description
8 * --------------------------------------------------------------------
10 * 04/27/99 we comments
11 **********************************************************************
13 * This file contains a simple interrupt driven serial driver with
14 * buffer (no check for overflow!!!).
15 **********************************************************************
17 * ser_init Initialization; must be called first
18 * ser_putc output one char on the serial line
19 * ser_getc return a char if one has been received, else 0
20 * ser_printString print a 0-terminated string
21 * ser_charAvail return 1 if a char arrived on serial line
22 **********************************************************************
24 * Remember to enable all interrupts (EA=1) outside of this module!!
25 **********************************************************************
26 * COMPILE TIME OPTIONS: -
28 ******************************************************************KE*/
38 unsigned char xdata ser_txIndexIn;
39 unsigned char xdata ser_txIndexOut;
40 unsigned char xdata ser_rxIndexIn;
41 unsigned char xdata ser_rxIndexOut;
43 unsigned char xdata ser_txBuffer[0x100];
44 unsigned char xdata ser_rxBuffer[0x100];
46 static bit ser_txBusy;
62 /* Baudrate = 19200, oscillator frq. of my processor is 21.4772 MHz */
82 ser_interrupt_handler(void) interrupt 4 using 1
88 ser_rxBuffer[ser_rxIndexIn++] = SBUF;
93 if (ser_txIndexIn == ser_txIndexOut) {
97 SBUF = ser_txBuffer[ser_txIndexOut++];
105 ser_putc(unsigned char c)
110 ser_txBuffer[ser_txIndexIn++] = c;
126 if (ser_rxIndexIn != ser_rxIndexOut) {
127 tmp = ser_rxBuffer[ser_rxIndexOut++];
138 ser_printString(char *String)
150 if (ser_rxIndexIn != ser_rxIndexOut) {
157 /*********************End of File************************************/