Using several SPI units om Teensy 3.6

Status
Not open for further replies.
I have just received a couple of Teensy 3.6 boards - and they are great! Works right out the box. But:
SPI only seems to work on SPI unit 0. How can I use the other units? The hardware seems to support unit 0/1/2.

I have been snooping around a little in the libraries (C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI) and it seems as if the IDE supports DMA on SPI. Is there any documentation on this? Or real working examples? Please - don't give me any Linux stuff, it wont help!
 
Couple of things:

The SPI object is for bus 0. SPI1 is for bus 1 and SPI2 is for bus 2...

Information: the datasheets always help. You can download those from: https://pjrc.com/teensy/datasheets.html

Note: Most libraries are hard coded to work with the SPI object. The most recent version of teensyduino release now has all SPI objects created from same class and now there are a few libraries that support passing in a pointer or reference to which SPI object to use... Unfortunately this is a minority of the current libraries, but hopefully over time, we will get more of them to support it. In the mean time you can always copy a library, give it a new name and edit all references from SPI to SPI1 or SPI2... Which for a majority of libraries this would be sufficient. However there are a few libraries that use the hardware registers, and for these you would also need to change those references as well. Plus if they are making use of the FIFO queues, you may have to make compensations for the fact the SPI has a queue of 4 elements and SPI1 and SPI2 have a queue of 1.

DMA - I have a version of the SPI library that does use DMA to do asynchronous transfers. Hopefully some of this will make it into the main SPI library.

Also there is another library setup to do this. You can find out more information up at: https://github.com/crteensy/DmaSpi
 
KurtE, can you give us an example of what passing in an SPI object by reference looks like? In my case, I'm using the newest RadioHead library for an RF22. It seems clear that the class wants a reference to the correct SPI port, but it's blowing up during compilation (Arduino IDE ver 1.8.8, RadioHead ver 1.8.9).
Using the Arduino IDE (ver. 1.8.8), I tried:

RH_RF22 rf22(31, 6, &SPI1);

to define my driver, and the compiler responded with: "no matching function for call to 'RH_RF22::RH_RF22(int, int, SPIClass*)'"

and then

RH_RF22 rf22(31, 6, SPI1);
and the compiler responded with: "no matching function for call to 'RH_RF22::RH_RF22(int, int, SPIClass&)"

It seems like it wants a pointer-ed reference to the SPI port, but when I did that, it seemed as if more was required.

Clearly I'm "doing it" incorrectly, but unfortunately there don't seem to be many examples of *how to do it correctly*...as you point out...
 
Status
Not open for further replies.
Back
Top