X-Git-Url: http://git.kpe.io/?p=avr_bc100.git;a=blobdiff_plain;f=BaseTinyFirmware%2FGCC%2FUSI.c;fp=BaseTinyFirmware%2FGCC%2FUSI.c;h=6813d1565f317fca9c2db1965b9bcd624e72bbdd;hp=efc004fc24c22149e12d0d47ad5e3a39ad120d86;hb=edd0e551e6041f7596c880cdaef13dfa67eff6b5;hpb=5b95e754a4af80c7389486ee874ac07c166a0867 diff --git a/BaseTinyFirmware/GCC/USI.c b/BaseTinyFirmware/GCC/USI.c index efc004f..6813d15 100644 --- a/BaseTinyFirmware/GCC/USI.c +++ b/BaseTinyFirmware/GCC/USI.c @@ -44,7 +44,7 @@ // Variables //****************************************************************************** //! SPI status struct -SPI_Status_t SPI; +volatile SPI_Status_t SPI; //****************************************************************************** @@ -162,7 +162,7 @@ ISR(USI_OVF_vect) case ADR_BATTCTRL: - SPI_Put(eeprom_read_byte((unsigned char*)&BattControl + (SPI.Count))); + SPI_Put(eeprom_read_byte((unsigned char*)&BattControl + (SPI.Count))); break; case ADR_TIMERS: @@ -221,6 +221,9 @@ ISR(USI_OVF_vect) */ void SPI_Init(unsigned char spi_mode) { + unsigned char sreg_saved; + + sreg_saved = SREG; cli(); // Configure outputs and inputs, enable pull-ups for DATAIN and CLOCK pins. @@ -241,7 +244,7 @@ void SPI_Init(unsigned char spi_mode) SPI.XferComplete = FALSE; // We haven't even started a transfer yet. SPI.WriteCollision = FALSE; // ..And therefore a collision hasn't happened. - sei(); + SREG = sreg_saved; }