How to default to SPI1 on Giga for NRF24L01

I have code that works fine one an Arduino Mega that I'm looking to port to the Arduino Giga. It uses an NRF24L01 radio module - which uses SPI. The issue I'm having is that the Giga has two SPI buses and the default one is on the SPI header, which I can't use due to space constraints. I need to use the other one (SPI1, which are on pins 11-13.

When I straight connect the NRF24L01 to SPI1 it doesn't work. After some research it appears as if it's not written for boards that have more than one SPI bus.

I found a workaround by changing the code in pins_arduino.h to the following - essentially commenting out the original #defines for PIN_SPI_MISO, etc. and changing to the SPI1 pins.

// SPI
#define PIN_SPI_MISO  (12u)
#define PIN_SPI_MOSI  (11u)
#define PIN_SPI_SCK   (13u)
/*
#define PIN_SPI_MISO  (89u)
#define PIN_SPI_MOSI  (90u)
#define PIN_SPI_SCK   (91u)
*/
// Same as SPI1 for backwards compatibility
#define PIN_SPI_SS    (10u)

#define PIN_SPI_MISO1  (12u)
#define PIN_SPI_MOSI1  (11u)
#define PIN_SPI_SCK1   (13u)
#define PIN_SPI_SS1    (10u)

When I do this everything works fine. The problem is, I'd rather not modify pins_arduino.h if I can avoid it. I'm fearful that a future update to the board will overwrite that and I'd have to update it again, etc.

So - to the question - does anyone know of a way to tell the Arduino Giga via code to use SPI1 as the default instead of SPI? Again, it would probably make sense for this to be in the NRF module, perhaps as a constructor or function call passing in an SPI instance - I just don't see a way to do it there either.

After a few hours I found a 10 second solution. Posting here in case I can save anyone else the same trouble.

After reviewing the NRF code it turns out that the begin function has a version that takes an SPI instance. All I had to do was start up SPI1 with a call to it's begin and then pass that to the NRF radio's begin function

  SPI1.begin();
  radio.begin(&SPI1)
1 Like

Yup, same here.

What I run with on back of my GIGA display...

Yes! A real Nordic chip. Gonna have to fly a long wire off the IRQ, but been running nicely past few weeks.

All the best.
ps...and there is a smallish 10uF/16v cap mounted underneath.

Hi ! Which pins did you put for CE and CSN ? Thx !

You can choose any digital pins you like for CE and CSN. The ones you use are passed in when you declare the RF24 variable. They're not dependent on which SPI you're using, so no difference from what you've done before.