diff --git a/SPI_M0/SPI_M0_RECEIVE/SPI_M0_RECEIVE.ino b/SPI_M0/SPI_M0_RECEIVE/SPI_M0_RECEIVE.ino index 8a7d013..fd4752d 100644 --- a/SPI_M0/SPI_M0_RECEIVE/SPI_M0_RECEIVE.ino +++ b/SPI_M0/SPI_M0_RECEIVE/SPI_M0_RECEIVE.ino @@ -1,19 +1,24 @@ -#include - -//SPIClass maSPI (&PERIPH_SPI, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI, PAD_SPI_TX, PAD_SPI_RX); +#include +#include "wiring_private.h" // pinPeripheral() function +SPIClass mySPI (&sercom2, 3, 5, 4, SPI_PAD_0_SCK_3, SERCOM_RX_PAD_1); //digital 3,5,4 for PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI void setup() { - // put your setup code here, to run once: -SPI.begin(); -SerialUSB.begin(9600); + Serial.begin(115200); + + // do this first, for Reasons + mySPI.begin(); + + // Assign pins 3, 4, 5 to SERCOM & SERCOM_ALT + pinPeripheral(3, PIO_SERCOM_ALT); + pinPeripheral(4, PIO_SERCOM_ALT); + pinPeripheral(5, PIO_SERCOM); } +uint8_t i=0; void loop() { - // put your main code here, to run repeatedly: - uint16_t data; -SerialUSB.println("hello2"); -delay(1000); -data = SPI.transfer(0x00); -SerialUSB.println(data); + Serial.println(i); + mySPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); + int recu = mySPI.transfer(i++); + mySPI.endTransaction(); } diff --git a/SPI_M0/SPI_M0_SEND/SPI_M0_SEND.ino b/SPI_M0/SPI_M0_SEND/SPI_M0_SEND.ino index 0242a31..04547fc 100644 --- a/SPI_M0/SPI_M0_SEND/SPI_M0_SEND.ino +++ b/SPI_M0/SPI_M0_SEND/SPI_M0_SEND.ino @@ -1,7 +1,7 @@ #include #include "wiring_private.h" // pinPeripheral() function -SPIClass mySPI (&sercom2, 3, 5, 4, SPI_PAD_0_SCK_3, SERCOM_RX_PAD_1); +SPIClass mySPI (&sercom2, 3, 5, 4, SPI_PAD_0_SCK_3, SERCOM_RX_PAD_1); //digital 3,5,4 for PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI void setup() { Serial.begin(115200); @@ -20,5 +20,6 @@ void loop() { Serial.println(i); mySPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); mySPI.transfer(i++); + mySPI.transfer(7); mySPI.endTransaction(); }