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.