LoRaGateway_BTS2A/SPI_M0/SPI_M0_RECEIVE/SPI_M0_RECEIVE.ino

27 lines
662 B
Arduino
Raw Normal View History

2018-04-06 15:37:25 +02:00
#include <SPI.h>
#include "wiring_private.h" // pinPeripheral() function
2018-04-05 17:51:53 +02:00
2018-04-06 15:37:25 +02:00
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
2018-04-05 17:51:53 +02:00
void setup() {
2018-04-10 11:19:32 +02:00
SerialUSB.begin(9600);
2018-04-06 15:37:25 +02:00
// 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);
2018-04-05 17:51:53 +02:00
}
2018-04-06 15:37:25 +02:00
uint8_t i=0;
2018-04-05 17:51:53 +02:00
void loop() {
2018-04-06 15:37:25 +02:00
mySPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
2018-04-10 12:39:00 +02:00
int recu = 0;
recu = mySPI.transfer(2);
2018-04-10 11:19:32 +02:00
SerialUSB.println(recu);
2018-04-06 15:37:25 +02:00
mySPI.endTransaction();
2018-04-10 11:19:32 +02:00
delay(100);
2018-04-05 17:51:53 +02:00
}