Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Reassinging SPI pins in Due

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    3

    Reassinging SPI pins in Due

    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

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,568
    Maybe ask on Arduino's forum?

    http://forum.arduino.cc/index.php?board=87.0

    or even Arduino.org's forum (they're the ones still making and selling Due)?

    http://www.arduino.org/forums/due

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    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

  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,256
    Or perhaps buy a Teensy 3.2 instead.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,568
    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.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,568
    Quote Originally Posted by Vaclav View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •