ソースを参照

Merge pull request #39 from xxxajk/master

T4 Fixes plus macros
main
Paul Stoffregen 5年前
コミット
aef639d61c
コミッターのメールアドレスに関連付けられたアカウントが存在しません
2個のファイルの変更50行の追加14行の削除
  1. +25
    -0
      SPI.cpp
  2. +25
    -14
      SPI.h

+ 25
- 0
SPI.cpp ファイルの表示

@@ -1402,6 +1402,31 @@ const SPIClass::SPI_Hardware_t spiclass_lpspi4_hardware = {
};
SPIClass SPI(&IMXRT_LPSPI4_S, &spiclass_lpspi4_hardware);

void SPIClass::usingInterrupt(IRQ_NUMBER_t interruptName)
{
uint32_t n = (uint32_t)interruptName;

if (n >= NVIC_NUM_INTERRUPTS) return;

//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]);
}

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));
}
}

void SPIClass::transfer(const void * buf, void * retbuf, size_t count)
{

+ 25
- 14
SPI.h ファイルの表示

@@ -71,7 +71,7 @@
/**********************************************************/

#if defined(__AVR__)
#define SPI_ATOMIC_VERSION 1
// define SPI_AVR_EIMSK for AVR boards with external interrupt pins
#if defined(EIMSK)
#define SPI_AVR_EIMSK EIMSK
@@ -321,6 +321,7 @@ private:
#elif defined(__arm__) && defined(TEENSYDUINO) && defined(KINETISK)

#define SPI_HAS_NOTUSINGINTERRUPT 1
#define SPI_ATOMIC_VERSION 1

class SPISettings {
public:
@@ -680,6 +681,7 @@ private:
/**********************************************************/

#elif defined(__arm__) && defined(TEENSYDUINO) && defined(KINETISL)
#define SPI_ATOMIC_VERSION 1

class SPISettings {
public:
@@ -1027,6 +1029,7 @@ private:
/**********************************************************/

#elif defined(__arm__) && defined(TEENSYDUINO) && (defined(__IMXRT1052__) || defined(__IMXRT1062__))
#define SPI_ATOMIC_VERSION 1

//#include "debug/printf.h"

@@ -1113,20 +1116,28 @@ public:
// prevent conflicts. The input interruptNumber is the number used
// with attachInterrupt. If SPI is used from a different interrupt
// (eg, a timer), interruptNumber should be 255.
/*void usingInterrupt(uint8_t n) {
if (n == 3 || n == 4 || n == 24 || n == 33) {
usingInterrupt(IRQ_PORTA);
} else if (n == 0 || n == 1 || (n >= 16 && n <= 19) || n == 25 || n == 32) {
usingInterrupt(IRQ_PORTB);
} else if ((n >= 9 && n <= 13) || n == 15 || n == 22 || n == 23
|| (n >= 27 && n <= 30)) {
usingInterrupt(IRQ_PORTC);
} else if (n == 2 || (n >= 5 && n <= 8) || n == 14 || n == 20 || n == 21) {
usingInterrupt(IRQ_PORTD);
} else if (n == 26 || n == 31) {
usingInterrupt(IRQ_PORTE);
void usingInterrupt(uint8_t n) {
if (n >= CORE_NUM_DIGITAL) return;
volatile uint32_t *gpio = portOutputRegister(n);
switch((uint32_t)gpio) {
case (uint32_t)&GPIO1_DR:
usingInterrupt(IRQ_GPIO1_0_15);
usingInterrupt(IRQ_GPIO1_16_31);
break;
case (uint32_t)&GPIO2_DR:
usingInterrupt(IRQ_GPIO2_0_15);
usingInterrupt(IRQ_GPIO2_16_31);
break;
case (uint32_t)&GPIO3_DR:
usingInterrupt(IRQ_GPIO3_0_15);
usingInterrupt(IRQ_GPIO3_16_31);
break;
case (uint32_t)&GPIO4_DR:
usingInterrupt(IRQ_GPIO4_0_15);
usingInterrupt(IRQ_GPIO4_16_31);
break;
}
}*/
}
void usingInterrupt(IRQ_NUMBER_t interruptName);
void notUsingInterrupt(IRQ_NUMBER_t interruptName);


読み込み中…
キャンセル
保存