From: frief Date: Fri, 22 Oct 2004 11:24:48 +0000 (+0000) Subject: integer promotion caused a call to the non-reentrant function __modsint in the interrupt X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=35d6bec7181fa75032069f25ad4301d5ee267426;p=fw%2Fsdcc integer promotion caused a call to the non-reentrant function __modsint in the interrupt function (thus corrupting math operations during serial I/O), ser_ir.c: as above, changed buffersize git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3549 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/device/lib/ser_ir.c b/device/lib/ser_ir.c index e438e631..15b162a8 100644 --- a/device/lib/ser_ir.c +++ b/device/lib/ser_ir.c @@ -31,20 +31,19 @@ * 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) { @@ -65,7 +64,7 @@ void ser_handler (void) interrupt 4 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; diff --git a/device/lib/ser_ir_cts_rts.c b/device/lib/ser_ir_cts_rts.c index 2bf1160f..51069fe6 100755 --- 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;