Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setMISO/setMOSI/setSCK - after begin #28

Merged

Conversation

KurtE
Copy link
Contributor

@KurtE KurtE commented Jul 19, 2017

Made the SPI code work like the old stuff where you could set the miso/mosi/sck pins after the begin.

Some people actually used this for changing SPI on the fly to use multiple sets of pins

Tested with simple app on T3.6

#include <SPI.h>

void setup() {
  while (!Serial && (millis() < 3000)) ;
  Serial.begin(9600);
  Serial.println("SPI Test");

  SPI.begin();
  SPI.setMOSI(7);
  SPI.setMISO(8);
  SPI.setSCK(14);
}

void loop() {
  SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
  int errors = 0;
  for (int i=0; i < 10; i++) {
    int j = SPI.transfer(i);
    if (i != j) {
      Serial.printf("Mismatch %d != %d\n", i, j);
      errors = 1;
    }
  }
  if (errors == 0) 
    Serial.println("No Errors");
  SPI.endTransaction();
  delay(2000);

}

I verified without a jumper between 7 and 8 and looked at Logic analyzer and then put in jumper between 7 and 8.

Made the SPI code work like the old stuff where you could set the miso/mosi/sck pins after the begin.

Some people actually used this for changing SPI on the fly to use multiple sets of pins
@PaulStoffregen PaulStoffregen merged commit 63215f6 into PaulStoffregen:master Jul 19, 2017
@PaulStoffregen
Copy link
Owner

Thanks! :)

@KurtE KurtE deleted the setMosi-Miso-CLK-After-begin branch July 19, 2017 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants