* as/z80/z80mch.c: fixed bug #1704376: missing as-z80 errors
[fw/sdcc] / device / lib / ser_ir.c
index b09c7f0e01c0dcc9d69e2fe16e4acf6e36475210..2523d74365b9dffabbaf46eae1d1bee1a2e2eb36 100644 (file)
 *   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
 * (while linking or at runtime) to make this file a _real_ library.
 */
 #include <8051.h>
-#define XBUFLEN 10
-#define RBUFLEN 10
+#define XBUFLEN 4
+#define RBUFLEN 8
 
-static unsigned char rbuf[RBUFLEN], xbuf[XBUFLEN];
+/* You might want to specify idata, pdata or xdata for the buffers */
+static unsigned char __pdata rbuf[RBUFLEN], xbuf[XBUFLEN];
 static unsigned char rcnt, xcnt, rpos, xpos;
-static unsigned char busy;
+static __bit busy;
 
 void ser_init (void)
 {
@@ -59,13 +58,13 @@ void ser_init (void)
    ES = 1;
 }
 
-void ser_handler (void) interrupt 4
+void ser_handler (void) __interrupt 4
 {
    if (RI) {
           RI = 0;
           /* don't overwrite chars already in buffer */
           if (rcnt < RBUFLEN)
-                  rbuf [(rpos+rcnt++) % RBUFLEN] = SBUF;
+                  rbuf [(unsigned char)(rpos+rcnt++) % RBUFLEN] = SBUF;
    }
    if (TI) {
           TI = 0;
@@ -84,7 +83,7 @@ void ser_putc (unsigned char c)
           ;
    ES = 0;
    if (busy) {
-          xbuf[(xpos+xcnt++) % XBUFLEN] = c;
+          xbuf[(unsigned char)(xpos+xcnt++) % XBUFLEN] = c;
    } else {
           SBUF = c;
           busy = 1;
@@ -105,8 +104,8 @@ unsigned char ser_getc (void)
    ES = 1;
    return (c);
 }
-#pragma SAVE
-#pragma NOINDUCTION
+#pragma save
+#pragma noinduction
 void ser_puts (unsigned char *s)
 {
    unsigned char c;
@@ -115,7 +114,7 @@ void ser_puts (unsigned char *s)
           ser_putc (c);
    }
 }
-#pragma RESTORE
+#pragma restore
 void ser_gets (unsigned char *s, unsigned char len)
 {
    unsigned char pos, c;