Reasigning SPI pins on Due to general I/O pins

My task is to reassign SPI pins from defaults to general I/O pins.

I found code which modifies SPI control register on AVR hardware.
It is little more involved on ARM architecture.

It seems this piece of (undocumented ) code in SPI.CPP file should do part of the job constructing SPI class with modified pins.

* #if SPI_INTERFACES_COUNT > 0
static void SPI_0_Init(void) {
 PIO_Configure(
      g_APinDescription[PIN_SPI_MOSI].pPort,
      g_APinDescription[PIN_SPI_MOSI].ulPinType,
      g_APinDescription[PIN_SPI_MOSI].ulPin,
      g_APinDescription[PIN_SPI_MOSI].ulPinConfiguration);
  PIO_Configure(
      g_APinDescription[PIN_SPI_MISO].pPort,
      g_APinDescription[PIN_SPI_MISO].ulPinType,
      g_APinDescription[PIN_SPI_MISO].ulPin,
      g_APinDescription[PIN_SPI_MISO].ulPinConfiguration);
  PIO_Configure(
      g_APinDescription[PIN_SPI_SCK].pPort,
      g_APinDescription[PIN_SPI_SCK].ulPinType,
      g_APinDescription[PIN_SPI_SCK].ulPin,
      g_APinDescription[PIN_SPI_SCK].ulPinConfiguration);
}


SPIClass SPI(SPI_INTERFACE, SPI_INTERFACE_ID, SPI_0_Init);
#endif

All I am asking from the forum - am I on the right track or are there better ways to accomplish this?

Jim

Why do you want to reassign the SPI pins? Also aren't they dedicated pins?

However, this may help:

Using the SPI hardware will be a LOT more efficient than shiftOut, but limited to the 3 (or 4) hardware pins.

So if I were you I would just take shiftOut() and trim off the excess fat to make it faster.