2008-03-14 Martin Thomas <mthomas@rhrk.uni-kl.de>
[avr_bc100.git] / BaseTinyFirmware / GCC / USI.c
index efc004fc24c22149e12d0d47ad5e3a39ad120d86..6813d1565f317fca9c2db1965b9bcd624e72bbdd 100644 (file)
@@ -44,7 +44,7 @@
 // Variables\r
 //******************************************************************************\r
 //! SPI status struct\r
-SPI_Status_t SPI;\r
+volatile SPI_Status_t SPI;\r
 \r
 \r
 //******************************************************************************\r
@@ -162,7 +162,7 @@ ISR(USI_OVF_vect)
                                \r
                                \r
                                case ADR_BATTCTRL:\r
-                                  SPI_Put(eeprom_read_byte((unsigned char*)&BattControl + (SPI.Count)));\r
+                                       SPI_Put(eeprom_read_byte((unsigned char*)&BattControl + (SPI.Count)));\r
                                break;\r
                                \r
                                case ADR_TIMERS:\r
@@ -221,6 +221,9 @@ ISR(USI_OVF_vect)
  */\r
 void SPI_Init(unsigned char spi_mode)\r
 {\r
+       unsigned char sreg_saved;\r
+\r
+       sreg_saved = SREG;\r
        cli();\r
        \r
        // Configure outputs and inputs, enable pull-ups for DATAIN and CLOCK pins.\r
@@ -241,7 +244,7 @@ void SPI_Init(unsigned char spi_mode)
        SPI.XferComplete = FALSE;     // We haven't even started a transfer yet.\r
        SPI.WriteCollision = FALSE;   // ..And therefore a collision hasn't happened.\r
 \r
-       sei();\r
+       SREG = sreg_saved;\r
 }\r
 \r
 \r