The code below changes the Teensy 3 SPI SCK signal to move to pin 14, and use pin 13 as the normal LED pin. The peripheral gets SPI SCK on pin 14.
However... the code has to run after (or repeat) after the SPI port is first used. Often, an attached device using SPI (such as a wireless radio, or perhaps an SD card), is itself initialized by a call to its library. And that library initializes the SPI hardware port. That "undoes" the pin 13 mapping as above, but not pin 14 remapping. (don't know why).
So one has to repeat the at least the pin 13 remapping after the libraries involved have done their initialization.
(that took a while to figure out)
However... the code has to run after (or repeat) after the SPI port is first used. Often, an attached device using SPI (such as a wireless radio, or perhaps an SD card), is itself initialized by a call to its library. And that library initializes the SPI hardware port. That "undoes" the pin 13 mapping as above, but not pin 14 remapping. (don't know why).
So one has to repeat the at least the pin 13 remapping after the libraries involved have done their initialization.
(that took a while to figure out)
Code:
// Add by Adrien van den Bossche <vandenbo@univ-tlse2.fr>
#if defined (TEENSYDUINO)
// First reassign pin 13 to Alt1 so that it is not SCK but the LED still works
CORE_PIN13_CONFIG = PORT_PCR_MUX(1); // Alt1 = PTC5. chip pin PTC5
// and then reassign pin 14 to SCK
CORE_PIN14_CONFIG = PORT_PCR_DSE | PORT_PCR_MUX(2); // Alt2=SPIO_SCK. chip pin PTD1
#endif