瀏覽代碼

Add notUsingInterrupt()

main
PaulStoffregen 10 年之前
父節點
當前提交
98a75fab09
共有 2 個文件被更改,包括 19 次插入6 次删除
  1. +16
    -6
      SPI.cpp
  2. +3
    -0
      SPI.h

+ 16
- 6
SPI.cpp 查看文件

@@ -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 查看文件

@@ -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

Loading…
取消
儲存