arduinoprojects

git clone https://git.tarina.org/arduinoprojects
Log | Files | Refs

spi_modetest.ino (777B)


      1 #include <Adafruit_SPIDevice.h>
      2 
      3 #define SPIDEVICE_CS 10
      4 Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS, 100000, SPI_BITORDER_MSBFIRST, SPI_MODE1);
      5 //Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS, 13, 12, 11, 100000, SPI_BITORDER_MSBFIRST, SPI_MODE1);
      6 
      7 
      8 void setup() {
      9   while (!Serial) { delay(10); }
     10   Serial.begin(115200);
     11   Serial.println("SPI device mode test");
     12 
     13   if (!spi_dev.begin()) {
     14     Serial.println("Could not initialize SPI device");
     15     while (1);
     16   }
     17 }
     18 
     19 void loop() {
     20   Serial.println("\n\nTransfer test");
     21   for (uint16_t x=0; x<=0xFF; x++) {
     22     uint8_t i = x;   
     23     Serial.print("0x"); Serial.print(i, HEX); 
     24     spi_dev.read(&i, 1, i);
     25     Serial.print("/"); Serial.print(i, HEX);
     26     Serial.print(", ");
     27     delay(25);
     28   }
     29 }