X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device%2Flib%2Fser_ir_cts_rts.c;h=51069fe67e6fbda31f76430b43d56c4aae12ec91;hb=bb226788dab3832b0ec0cda70874ce3fce4eebc6;hp=9be6d7204764311ced5ba5d705e09039b9c74f94;hpb=ea484eb3c407aae781abb6fdea35364367f7ab76;p=fw%2Fsdcc diff --git a/device/lib/ser_ir_cts_rts.c b/device/lib/ser_ir_cts_rts.c old mode 100755 new mode 100644 index 9be6d720..51069fe6 --- a/device/lib/ser_ir_cts_rts.c +++ b/device/lib/ser_ir_cts_rts.c @@ -34,8 +34,6 @@ * so it can run on devices with _little_ memory like at89cx051. * - It won't overwrite characters which already are stored in the * receive-/transmit-buffer. -* - It checks receiver first to minimize probability for overruns -* in the serial receiver. */ /* BUG: those definitions (and the #include) should be set dynamically @@ -88,9 +86,10 @@ #define CTS P3_6 // CTS & RTS can be assigned to any free pins #define RTS P3_7 +// You might want to specify idata, pdata or xdata for the buffers static unsigned char rxbuf[RXBUFLEN], txbuf[TXBUFLEN]; static unsigned char rxcnt, txcnt, rxpos, txpos; -static unsigned char busy; +static bit busy; void ser_init() { @@ -117,7 +116,7 @@ void ser_handler(void) interrupt 4 if (RI) { RI = 0; /* don't overwrite chars already in buffer */ - if(rxcnt < RXBUFLEN) rxbuf [(rxpos + rxcnt++) % RXBUFLEN] = SBUF; + if(rxcnt < RXBUFLEN) rxbuf [(unsigned char)(rxpos + rxcnt++) % RXBUFLEN] = SBUF; if(rxcnt >= (RXBUFLEN - THRESHOLD)) CTS = DISABLE; } @@ -139,7 +138,7 @@ void ser_putc(unsigned char c) ES = 0; if (busy) { - txbuf[(txpos + txcnt++) % TXBUFLEN] = c; + txbuf[(unsigned char)(txpos + txcnt++) % TXBUFLEN] = c; } else { SBUF = c; busy = 1; @@ -163,17 +162,17 @@ unsigned char ser_getc(void) return (c); } -#pragma SAVE -#pragma NOINDUCTION +#pragma save +#pragma noinduction void ser_puts(unsigned char *s) { unsigned char c; while (c= *s++) { - if (c == LF) ser_putc(CR); + if (c == '\n') ser_putc('\r'); ser_putc (c); } } -#pragma RESTORE +#pragma restore void ser_gets(unsigned char *s, unsigned char len) { @@ -182,9 +181,9 @@ void ser_gets(unsigned char *s, unsigned char len) pos = 0; while (pos <= len) { c = ser_getc(); - if (c == CR) continue; // discard CR's + if (c == '\r') continue; // discard CR's s[pos++] = c; - if (c == LF) break; // NL terminates + if (c == '\n') break; // NL terminates } s[pos] = '\0'; // terminate string } @@ -197,4 +196,4 @@ unsigned char ser_can_xmt(void) unsigned char ser_can_rcv(void) { return rxcnt; -} \ No newline at end of file +}