DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
[bertos.git] / drv / ser_avr.c
index 452e16b330f9d8ec3ce5b669c4313d71103a3baf..a54d3764dd35cb79f9960e48bf711631c2609cbf 100755 (executable)
 
 /*#*
  *#* $Log$
+ *#* Revision 1.21  2004/12/13 12:07:06  bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
+ *#* Revision 1.20  2004/12/13 11:51:43  bernie
+ *#* Fix a latent bug with reentrant serial IRQs.
+ *#*
+ *#* Revision 1.19  2004/12/13 11:51:08  bernie
+ *#* DISABLE_INTS/ENABLE_INTS: Convert to IRQ_DISABLE/IRQ_ENABLE.
+ *#*
+ *#* Revision 1.18  2004/12/08 08:03:48  bernie
+ *#* Doxygen fixes.
+ *#*
+ *#* Revision 1.17  2004/10/19 07:52:35  bernie
+ *#* Reset parity bits before overwriting them (Fixed by batt in project_ks).
+ *#*
  *#* Revision 1.16  2004/10/03 18:45:48  bernie
  *#* Convert to new-style config macros; Allow compiling with a C++ compiler (mostly).
  *#*
         *
         * The default is no action.
         */
+       #ifdef __doxygen__
+       #define SER_UART0_BUS_TXOFF
+       #endif
 #endif
 
 #ifndef SER_UART1_BUS_TXINIT
         *
         * \see SER_UART0_BUS_TXOFF
         */
+       #ifdef __doxygen__
+       #define SER_UART1_BUS_TXOFF
+       #endif
 #endif
 /*\}*/
 
@@ -372,7 +393,7 @@ static void uart0_setbaudrate(UNUSED(struct SerialHardware *, _hw), unsigned lon
 static void uart0_setparity(UNUSED(struct SerialHardware *, _hw), int parity)
 {
 #if !CPU_AVR_ATMEGA103
-       UCSR0C |= (parity) << UPM0;
+       UCSR0C = (UCSR0C & ~(BV(UPM1) | BV(UPM0))) | ((parity) << UPM0);
 #endif
 }
 
@@ -420,7 +441,7 @@ static void uart1_setbaudrate(UNUSED(struct SerialHardware *, _hw), unsigned lon
 
 static void uart1_setparity(UNUSED(struct SerialHardware *, _hw), int parity)
 {
-       UCSR1C |= (parity) << UPM0;
+       UCSR1C = (UCSR1C & ~(BV(UPM1) | BV(UPM0))) | ((parity) << UPM0);
 }
 
 #endif // AVR_HAS_UART1
@@ -458,7 +479,7 @@ static void spi_starttx(struct SerialHardware *_hw)
        struct AvrSerial *hw = (struct AvrSerial *)_hw;
 
        cpuflags_t flags;
-       DISABLE_IRQSAVE(flags);
+       IRQ_SAVE_DISABLE(flags);
 
        /* Send data only if the SPI is not already transmitting */
        if (!hw->sending && !fifo_isempty(&ser_spi->txfifo))
@@ -467,7 +488,7 @@ static void spi_starttx(struct SerialHardware *_hw)
                SPDR = fifo_pop(&ser_spi->txfifo);
        }
 
-       ENABLE_IRQRESTORE(flags);
+       IRQ_RESTORE(flags);
 }
 
 static void spi_setbaudrate(UNUSED(struct SerialHardware *, _hw), UNUSED(unsigned long, rate))
@@ -736,7 +757,7 @@ SIGNAL(SIG_UART0_RECV)
 
        /* Disable Recv complete IRQ */
        //UCSR0B &= ~BV(RXCIE);
-       //ENABLE_INTS;
+       //IRQ_ENABLE;
 
        /* Should be read before UDR */
        ser_uart0->status |= UCSR0A & (SERRF_RXSROVERRUN | SERRF_FRAMEERROR);
@@ -760,7 +781,7 @@ SIGNAL(SIG_UART0_RECV)
        }
 
        /* Reenable receive complete int */
-       //DISABLE_INTS;
+       //IRQ_DISABLE;
        //UCSR0B |= BV(RXCIE);
 
        SER_STROBE_OFF;
@@ -786,7 +807,7 @@ SIGNAL(SIG_UART1_RECV)
 
        /* Disable Recv complete IRQ */
        //UCSR1B &= ~BV(RXCIE);
-       //ENABLE_INTS;
+       //IRQ_ENABLE;
 
        /* Should be read before UDR */
        ser_uart1->status |= UCSR1A & (SERRF_RXSROVERRUN | SERRF_FRAMEERROR);
@@ -809,6 +830,7 @@ SIGNAL(SIG_UART1_RECV)
 #endif
        }
        /* Re-enable receive complete int */
+       //IRQ_DISABLE;
        //UCSR1B |= BV(RXCIE);
 
        SER_STROBE_OFF;