File tree Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -254,13 +254,30 @@ void SPIClass::detachInterrupt() {
254
254
// Should be disableInterrupt()
255
255
}
256
256
257
- #if SPI_INTERFACES_COUNT > 0
257
+ // default to 0
258
+ #ifndef SPI_32MHZ_INTERFACE
259
+ #define SPI_32MHZ_INTERFACE 0
260
+ #endif
261
+
262
+ #if SPI_32MHZ_INTERFACE == 0
263
+ #define _SPI_DEV NRF_SPIM3 // 32 Mhz
264
+ #define _SPI1_DEV NRF_SPIM2
265
+
266
+ #elif SPI_32MHZ_INTERFACE == 1
267
+ #define _SPI_DEV NRF_SPIM2
268
+ #define _SPI1_DEV NRF_SPIM3 // 32 Mhz
269
+
270
+ #else
271
+ #error "not supported yet"
272
+ #endif
273
+
274
+ #if SPI_INTERFACES_COUNT >= 1
258
275
// use SPIM3 for highspeed 32Mhz
259
- SPIClass SPI (NRF_SPIM3 , PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI);
276
+ SPIClass SPI (_SPI_DEV , PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI);
260
277
#endif
261
278
262
- #if SPI_INTERFACES_COUNT > 1
263
- SPIClass SPI1 (NRF_SPIM2 , PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI);
279
+ #if SPI_INTERFACES_COUNT >= 2
280
+ SPIClass SPI1 (_SPI1_DEV , PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI);
264
281
#endif
265
282
266
283
#endif // NRF52840_XXAA
Original file line number Diff line number Diff line change @@ -93,6 +93,12 @@ static const uint8_t A7 = PIN_A7 ;
93
93
*/
94
94
#define SPI_INTERFACES_COUNT 2
95
95
96
+ // nRF52840 has only one SPIM3 runing at highspeed 32Mhz
97
+ // This assign SPIM3 to either: SPI (0), SPI1 (1).
98
+ // If not defined, default to 0 or SPI.
99
+ #define SPI_32MHZ_INTERFACE 1
100
+
101
+ // SPI
96
102
#define PIN_SPI_MISO (14)
97
103
#define PIN_SPI_MOSI (15)
98
104
#define PIN_SPI_SCK (13)
@@ -102,7 +108,7 @@ static const uint8_t MOSI = PIN_SPI_MOSI ;
102
108
static const uint8_t MISO = PIN_SPI_MISO ;
103
109
static const uint8_t SCK = PIN_SPI_SCK ;
104
110
105
-
111
+ // SPI1
106
112
#define PIN_SPI1_MISO (35)
107
113
#define PIN_SPI1_MOSI (30)
108
114
#define PIN_SPI1_SCK (29)
You can’t perform that action at this time.
0 commit comments