Merge pull request #441 from adafruit/SPIM3-variant

add macro SPI_32MHZ_INTERFACE to variant to select SPI or SPI1 to use 32mhz SPIM3
This commit is contained in:
Limor "Ladyada" Fried authored and GitHub committed 2020-02-18 10:47:18 -05:00
commit 3d8c68ae06
2 files changed
+29 -6

No files matched your search

+22 -5
View File
@@ -254,13 +254,30 @@ void SPIClass::detachInterrupt() {
// Should be disableInterrupt()
}
#if SPI_INTERFACES_COUNT > 0
// use SPIM3 for highspeed 32Mhz
SPIClass SPI(NRF_SPIM3, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI);
// default to 0
#ifndef SPI_32MHZ_INTERFACE
#define SPI_32MHZ_INTERFACE 0
#endif
#if SPI_INTERFACES_COUNT > 1
SPIClass SPI1(NRF_SPIM2, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI);
#if SPI_32MHZ_INTERFACE == 0
#define _SPI_DEV NRF_SPIM3 // 32 Mhz
#define _SPI1_DEV NRF_SPIM2
#elif SPI_32MHZ_INTERFACE == 1
#define _SPI_DEV NRF_SPIM2
#define _SPI1_DEV NRF_SPIM3 // 32 Mhz
#else
#error "not supported yet"
#endif
#if SPI_INTERFACES_COUNT >= 1
// use SPIM3 for highspeed 32Mhz
SPIClass SPI(_SPI_DEV, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI);
#endif
#if SPI_INTERFACES_COUNT >= 2
SPIClass SPI1(_SPI1_DEV, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI);
#endif
#endif // NRF52840_XXAA
+7 -1
View File
@@ -93,6 +93,12 @@ static const uint8_t A7 = PIN_A7 ;
*/
#define SPI_INTERFACES_COUNT 2
// nRF52840 has only one SPIM3 runing at highspeed 32Mhz
// This assign SPIM3 to either: SPI (0), SPI1 (1).
// If not defined, default to 0 or SPI.
#define SPI_32MHZ_INTERFACE 1
// SPI
#define PIN_SPI_MISO (14)
#define PIN_SPI_MOSI (15)
#define PIN_SPI_SCK (13)
@@ -102,7 +108,7 @@ static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK = PIN_SPI_SCK ;
// SPI1
#define PIN_SPI1_MISO (35)
#define PIN_SPI1_MOSI (30)
#define PIN_SPI1_SCK (29)