Browse Source

Fix SPI beginTransaction race condition (thanks to Andrew Knoll)

http://forum.pjrc.com/threads/26776-Teensyduino-1-20-Released?p=56316&viewfull=1#post56316
main
PaulStoffregen 10 years ago
parent
commit
1708ef0d34
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      SPI.h

+ 4
- 1
SPI.h View File

} else } else
#endif #endif
{ {
interruptSave = SREG;
uint8_t tmp = SREG;
cli(); cli();
interruptSave = tmp;
} }
} }
#ifdef SPI_TRANSACTION_MISMATCH_LED #ifdef SPI_TRANSACTION_MISMATCH_LED
// and configure the correct settings. // and configure the correct settings.
inline static void beginTransaction(SPISettings settings) { inline static void beginTransaction(SPISettings settings) {
if (interruptMasksUsed) { if (interruptMasksUsed) {
__disable_irq();
if (interruptMasksUsed & 0x01) { if (interruptMasksUsed & 0x01) {
interruptSave[0] = NVIC_ICER0 & interruptMask[0]; interruptSave[0] = NVIC_ICER0 & interruptMask[0];
NVIC_ICER0 = interruptSave[0]; NVIC_ICER0 = interruptSave[0];
NVIC_ICER3 = interruptSave[3]; NVIC_ICER3 = interruptSave[3];
} }
#endif #endif
__enable_irq();
} }
#ifdef SPI_TRANSACTION_MISMATCH_LED #ifdef SPI_TRANSACTION_MISMATCH_LED
if (inTransactionFlag) { if (inTransactionFlag) {

Loading…
Cancel
Save