You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LoRaGateway_BTS2A/SPI_M0/SPI_M0_RECEIVE/SPI_M0_RECEIVE.ino

25 lines
704 B
Arduino

#include <SPI.h>
#include "wiring_private.h" // pinPeripheral() function
7 years ago
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
7 years ago
void setup() {
SerialUSB.begin(9600);
mySPI.begin(); //initiate the SPI communicaton
// Assign pins 3, 4, 5 to SERCOM & SERCOM_ALT
pinPeripheral(3, PIO_SERCOM_ALT);
pinPeripheral(4, PIO_SERCOM_ALT);
pinPeripheral(5, PIO_SERCOM);
7 years ago
}
uint8_t i=0;
7 years ago
void loop() {
mySPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
int recu = 0; //create recu
recu = mySPI.transfer(2); //send and recieve using spi
SerialUSB.println(recu);
mySPI.endTransaction();
delay(100);
7 years ago
}