Browse Source

Teensy 4 Beta 2 - create SPI1 and maybe SPI2

The second beta board may have the ability for two additional SPI ports,
So I defined them...

Next up test them when board arrives
main
Kurt Eckhardt 5 years ago
parent
commit
76263b485f
2 changed files with 41 additions and 2 deletions
  1. +36
    -0
      SPI.cpp
  2. +5
    -2
      SPI.h

+ 36
- 0
SPI.cpp View File

3 | 0x10, 3 | 0x10,
}; };
SPIClass SPI((uintptr_t)&IMXRT_LPSPI4_S, (uintptr_t)&SPIClass::spiclass_lpspi4_hardware); SPIClass SPI((uintptr_t)&IMXRT_LPSPI4_S, (uintptr_t)&SPIClass::spiclass_lpspi4_hardware);

#if defined(__IMXRT1062__)
// T4 has two other possible SPI objects...
void _spi_dma_rxISR1(void) {SPI1.dma_rxisr();}

const SPIClass::SPI_Hardware_t SPIClass::spiclass_lpspi3_hardware = {
CCM_CCGR1, CCM_CCGR1_LPSPI3(CCM_CCGR_ON),
DMAMUX_SOURCE_LPSPI3_TX, DMAMUX_SOURCE_LPSPI3_RX, _spi_dma_rxISR1,
1,
7 | 0x10,
26,
7 | 0x10,
27,
7 | 0x10,
0,
7 | 0x10,
};
SPIClass SPI1((uintptr_t)&IMXRT_LPSPI3_S, (uintptr_t)&SPIClass::spiclass_lpspi3_hardware);

void _spi_dma_rxISR2(void) {SPI2.dma_rxisr();}

const SPIClass::SPI_Hardware_t SPIClass::spiclass_lpspi1_hardware = {
CCM_CCGR1, CCM_CCGR1_LPSPI1(CCM_CCGR_ON),
DMAMUX_SOURCE_LPSPI1_TX, DMAMUX_SOURCE_LPSPI1_RX, _spi_dma_rxISR1,
34,
4 | 0x10,
35,
4 | 0x10,
37,
4 | 0x10,
36,
4 | 0x10,
};
SPIClass SPI2((uintptr_t)&IMXRT_LPSPI1_S, (uintptr_t)&SPIClass::spiclass_lpspi1_hardware);
#endif

//SPIClass SPI(&IMXRT_LPSPI4_S, &spiclass_lpspi4_hardware); //SPIClass SPI(&IMXRT_LPSPI4_S, &spiclass_lpspi4_hardware);


void SPIClass::usingInterrupt(IRQ_NUMBER_t interruptName) void SPIClass::usingInterrupt(IRQ_NUMBER_t interruptName)

+ 5
- 2
SPI.h View File

const uint32_t cs_mux[CNT_CS_PINS]; const uint32_t cs_mux[CNT_CS_PINS];
} SPI_Hardware_t; } SPI_Hardware_t;
static const SPI_Hardware_t spiclass_lpspi4_hardware; static const SPI_Hardware_t spiclass_lpspi4_hardware;

#if defined(__IMXRT1062__)
static const SPI_Hardware_t spiclass_lpspi3_hardware;
static const SPI_Hardware_t spiclass_lpspi1_hardware;
#endif
public: public:
constexpr SPIClass(uintptr_t myport, uintptr_t myhardware) constexpr SPIClass(uintptr_t myport, uintptr_t myhardware)
: port_addr(myport), hardware_addr(myhardware) { : port_addr(myport), hardware_addr(myhardware) {
#if defined(__MKL26Z64__) #if defined(__MKL26Z64__)
extern SPIClass SPI1; extern SPIClass SPI1;
#endif #endif
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__)
extern SPIClass SPI1; extern SPIClass SPI1;
extern SPIClass SPI2; extern SPIClass SPI2;
#endif #endif

Loading…
Cancel
Save