Using SPI1 pins on the Teensy 4.1

Hey all,

I am trying to use the second set of SPI pins on my Teensy 4.1 since the first set is being used by an RFM95W. My project is nearing completion but I've decided to use the second set of SPI pins instead of the third I2C. This is mainly because SPI seems to provide the data faster. As it stands, I am using a BMP390 (I2C), BNO085 (I2C1), LC709203(I2C2), and an RFM95W (SPI). I'm hoping to use the second set of SPI pins for the BNO085.

Just to see if I can do this, I've been trying to get the BNO08X example to work on the second set of pins. If it works, I will just translate what I need from the example to my main project. (I'd post my project code, but it's about 1000 lines, and easier for me to work with this example and then make changes to my project if I can get it working.)

I haven't been able to get this working. Here is the setup code from the example BNO08X library.

Code:
// Basic demo for readings from Adafruit BNO08x
#include <Adafruit_BNO08x.h>
#include <SPI.h>

// For SPI mode, we need a CS pin
// BNO085 pin assignments/*
#define BNO08X_CS 0
#define BNO08X_INT 5
#define BNO08X_RESET 6

// Second SPI pins
#define SCK1 27
#define MISO1 1
#define MOSI1 26

#define BNO08X_RESET -1

Adafruit_BNO08x bno08x(BNO08X_RESET);
sh2_SensorValue_t sensorValue;

void setup(void) {
  Serial.begin(115200);

  SPI1.setMISO(MISO1);
  SPI1.setMOSI(MOSI1);
  SPI1.setSCK(SCK1);

  SPI1.begin();

  while (!Serial)
    delay(10); // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("Adafruit BNO08x test!");

  // Try to initialize!
  //if (!bno08x.begin_I2C()) {
    // if (!bno08x.begin_UART(&Serial1)) {  // Requires a device with > 300 byte UART buffer! 
    if (!bno08x.begin_SPI(BNO08X_CS, BNO08X_INT)) {
    Serial.println("Failed to find BNO08x chip");
    }

    else {
      Serial.println("BNO08x Found!");
    }

  for (int n = 0; n < bno08x.prodIds.numEntries; n++) {
    Serial.print("Part ");
    Serial.print(bno08x.prodIds.entry[n].swPartNumber);
    Serial.print(": Version :");
    Serial.print(bno08x.prodIds.entry[n].swVersionMajor);
    Serial.print(".");
    Serial.print(bno08x.prodIds.entry[n].swVersionMinor);
    Serial.print(".");
    Serial.print(bno08x.prodIds.entry[n].swVersionPatch);
    Serial.print(" Build ");
    Serial.println(bno08x.prodIds.entry[n].swBuildNumber);
  }

  setReports();

  Serial.println("Reading events");
  delay(100);
}
 
Back
Top