* 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 <at89x2051.h>
-#define XBUFLEN 10
-#define RBUFLEN 10
+#include <8051.h>
+#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)
{
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;
;
ES = 0;
if (busy) {
- xbuf[(xpos+xcnt++) % XBUFLEN] = c;
+ xbuf[(unsigned char)(xpos+xcnt++) % XBUFLEN] = c;
} else {
SBUF = c;
busy = 1;
ES = 1;
return (c);
}
-#pragma SAVE
-#pragma NOINDUCTION
+#pragma save
+#pragma noinduction
void ser_puts (unsigned char *s)
{
unsigned char c;
ser_putc (c);
}
}
-#pragma RESTORE
+#pragma restore
void ser_gets (unsigned char *s, unsigned char len)
{
unsigned char pos, c;