Closed djfurie closed 2 years ago
I had looked at adding this feature of allowing an alternate SPI interface a year ago, with nearly identical changes as you propose. However, I could not prove that it worked with my SAMD board, with an alternate SPI interface defined. I realized then that the Arduino SAMD implementation didn't provide for full support of alternate SPI interfaces. Since I could not test this modification, I left it. (I don't currently own a Teensy board for testing.) It seems though that you do have a Teensy board that this has been tested on, if I read your pull request correctly. If that is correct, then I can open a branch with all the changes I developed previously, including an example sketch for testing, and you can try that out for verification. Would you be willing to do that?
Yup, I’ve got a hardware platform using a Teensy 4.1 that I can test with. Should be no problem at all.
I just updated this pull request with the changes I had developed. You will need to modify Example9_AlternateSPI to test on your Teensy board.
This all seems to be working 👍
Define a specific SPI interface for the SCL3300 Inclinometer
Murata SCL3300 inclinometer is connected.
Inclinometer is still alive...
Raw X Tilt: -28 Y Tilt: -276 Z Tilt: 16106
Raw X Accel: -32 Y Accel: -316 Z Accel: 11937
SCL3300 STO register: FF WHOAMI register: C1
Raw Temperature: 5599
Serial Number Register: 2552007203B33 SL3300 Status Summary Register: 0
Inclinometer is still alive...
Raw X Tilt: -31 Y Tilt: -276 Z Tilt: 16106
Raw X Accel: -36 Y Accel: -316 Z Accel: 11962
SCL3300 STO register: FF WHOAMI register: C1
Raw Temperature: 5598
For the particular board I'm using, the SCL3300 is on alternative pins for some of the SPI functions. I had to also configure the port to use those pins before the call to begin. Not really anything I'd change in the example, just commenting on this as an FYI.
SPI1.setCS(38); // This probably doesn't matter as the library handles CS control explicitly.
SPI1.setMISO(39);
SPI1.setMOSI(26);
SPI1.setSCK(27);
Looks like a begin() function was started for this support, but the rest of the library was still hardcoded to use SPI.
For boards like the Teensy with multiple SPI hardware peripherals this change allows the user to specify which to use.