Browse Source

Add notUsingInterrupt()

main
PaulStoffregen 10 years ago
parent
commit
98a75fab09
2 changed files with 19 additions and 6 deletions
  1. +16
    -6
      SPI.cpp
  2. +3
    -0
      SPI.h

+ 16
- 6
SPI.cpp View File



if (n >= NVIC_NUM_INTERRUPTS) return; if (n >= NVIC_NUM_INTERRUPTS) return;


Serial.print("usingInterrupt ");
Serial.println(n);
//Serial.print("usingInterrupt ");
//Serial.println(n);
interruptMasksUsed |= (1 << (n >> 5)); interruptMasksUsed |= (1 << (n >> 5));
interruptMask[n >> 5] |= (1 << (n & 0x1F)); interruptMask[n >> 5] |= (1 << (n & 0x1F));
Serial.printf("interruptMasksUsed = %d\n", interruptMasksUsed);
Serial.printf("interruptMask[0] = %08X\n", interruptMask[0]);
Serial.printf("interruptMask[1] = %08X\n", interruptMask[1]);
Serial.printf("interruptMask[2] = %08X\n", interruptMask[2]);
//Serial.printf("interruptMasksUsed = %d\n", interruptMasksUsed);
//Serial.printf("interruptMask[0] = %08X\n", interruptMask[0]);
//Serial.printf("interruptMask[1] = %08X\n", interruptMask[1]);
//Serial.printf("interruptMask[2] = %08X\n", interruptMask[2]);
}

void SPIClass::notUsingInterrupt(IRQ_NUMBER_t interruptName)
{
uint32_t n = (uint32_t)interruptName;
if (n >= NVIC_NUM_INTERRUPTS) return;
interruptMask[n >> 5] &= ~(1 << (n & 0x1F));
if (interruptMask[n >> 5] == 0) {
interruptMasksUsed &= ~(1 << (n >> 5));
}
} }


const uint16_t SPISettings::ctar_div_table[23] = { const uint16_t SPISettings::ctar_div_table[23] = {

+ 3
- 0
SPI.h View File



#elif defined(__arm__) && defined(TEENSYDUINO) #elif defined(__arm__) && defined(TEENSYDUINO)


#define SPI_HAS_NOTUSINGINTERRUPT 1

class SPISettings { class SPISettings {
public: public:
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) { SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {
} }
} }
static void usingInterrupt(IRQ_NUMBER_t interruptName); static void usingInterrupt(IRQ_NUMBER_t interruptName);
static void notUsingInterrupt(IRQ_NUMBER_t interruptName);


// Before using SPI.transfer() or asserting chip select pins, // Before using SPI.transfer() or asserting chip select pins,
// this function is used to gain exclusive access to the SPI bus // this function is used to gain exclusive access to the SPI bus

Loading…
Cancel
Save