Reassinging SPI pins in Due

Status
Not open for further replies.

Vaclav

New member
OK, I know this is Teensy forum but I looked in SPI.cpp build for Teensy and it includes reassigning of SPI pins.
So I figure users of this forum know something about the subject.

Unfortunately mentioned SPI.cpp covers only AVR method of reassigning the SPI pins.
It does that by accessing SPI control register - SPICR.

Not so simple in ARM / SAM.

Apparently someone put into standard, Arduino version of SPI this piece of code to do something ,
the code is not commented, perhaps it does what I am after.


Code:
 * #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

I have not found any source code / application using this code .

I could use some assistance in deciphering / implementing this code if it actually modifies standard SPI pins assignments on Due.

And if my request is really out of this forum interests, just ignore it.

Thanks
Vaclav
 
Hi Paul,
thanks for quick reply.
Yes I did post at Arduino.cc and I got the usual - why would you want to do that?
Actually I got lucky - they did not ask me to post the code.
I guess I do some more googgling and reading the doc.
Vaclav
 
Or the new ones on Kickstarter, which have 3 separate SPI ports, in addition to the Teensy version of the SPI library which supports easily reassigning pins.

But I do realize quite a few people buy Due clones from Chinese companies. That's fine, but anyone doing so should realize the level of support. The reality is Arduino.cc discontinued Due over a year ago and Arduino.org has never never contributed any code to Due's libraries. Neither have any of the Chinese cloners. Amazingly, Arduino.cc still has done some minor updates to the code, but otherwise Due is essentially an unsupported platform now.
 
Actually I got lucky - they did not ask me to post the code.

Before you consider Teensy, please do read the "Forum Rule" which appears in red at the top of every page on this forum.

If you're working on some sort of secret project where you can't post your code, where you can't even post small (but complete) programs to demonstrate whatever problems you're encountering, then Teensy probably is not the board for you.
 
Status
Not open for further replies.
Back
Top