Advertisement
Guest User

teensylcSPIslave

a guest
Jul 5th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1.  
  2. #include <SPI.h>
  3. int ss=10;
  4.  SPISettings settingsA(250000, MSBFIRST, SPI_MODE1);
  5. void setup() {
  6.   Serial.begin(9600);
  7.   pinMode(ss, INPUT); // CS set to input for slave
  8.   SPI.begin(); // wake up the SPI bus.
  9.   SPI.setBitOrder(MSBFIRST);
  10.   attachInterrupt(ss,isrSpi,FALLING); // interrupt on cs down
  11. }
  12.  
  13. void isrSpi(){
  14.   SPI.beginTransaction(settingsA);
  15.   byte q = SPI.transfer(0);
  16.  
  17.   /*for (int i = 7; i > -1; i--){ // check binary
  18.     Serial.print((q>>i)&1);
  19.   }
  20.   Serial.print(' ');*/
  21.   Serial.print(q);
  22.   Serial.println();
  23.   SPI.endTransaction;
  24. }
  25.  
  26. void loop()
  27. {
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement