Bläddra i källkod

Add notUsingInterrupt()

main
PaulStoffregen 10 år sedan
förälder
incheckning
98a75fab09
2 ändrade filer med 19 tillägg och 6 borttagningar
  1. +16
    -6
      SPI.cpp
  2. +3
    -0
      SPI.h

+ 16
- 6
SPI.cpp Visa fil

@@ -174,14 +174,24 @@ void SPIClass::usingInterrupt(IRQ_NUMBER_t interruptName)

if (n >= NVIC_NUM_INTERRUPTS) return;

Serial.print("usingInterrupt ");
Serial.println(n);
//Serial.print("usingInterrupt ");
//Serial.println(n);
interruptMasksUsed |= (1 << (n >> 5));
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] = {

+ 3
- 0
SPI.h Visa fil

@@ -298,6 +298,8 @@ private:

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

#define SPI_HAS_NOTUSINGINTERRUPT 1

class SPISettings {
public:
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {
@@ -417,6 +419,7 @@ public:
}
}
static void usingInterrupt(IRQ_NUMBER_t interruptName);
static void notUsingInterrupt(IRQ_NUMBER_t interruptName);

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

Laddar…
Avbryt
Spara