looking for more info on paul's new SPI library adaptions

Status
Not open for further replies.

Tomek

Well-known member
Hi! I started derailing a different thread (here)

Now realizing I kind of was getting off topic there, I wanted to return to the main point:

Are there any SPI libraries optimized for the teensy that I could sort of plug and play for existing libraries? I'm running Adafruit's RA8875 with modification for easy multiple fonts (I made a thread for it Here)

The best thing I have found is that paul updated some SPI code 10 days ago at https://github.com/PaulStoffregen/SPI

It looks like he's hoping to get this code eventually pushed to the main arduino SPI core. The arduino SPI core does seem to be very different.

Does anyone know if this code is usable right now? or if it's even different than the core SPI library? As far as I can tell the core SPI library doesn't have any special cases and is just one-processor-size-fits-all.

The other thing I don't know is if this library is built in such a way that I could expect swapping it out to work.
Ok! I went ahead and tried swapping things out just one for one with the old spi.h and spi.cpp. The first compiler error I get is "IRQ_number_t has not been declared and I don't really know if my hopes of swapping 1-1 without doing anything else could be expected to work.
 
The updated code is usable right now and is in the 1.20 Teesyduino. Which version are you using to thet the old one?

I wrote an updated SPI page, its inside a zip file attached to this thread. Hopefully this will show up on the PJRC site at some point.
 
Looks Like I'm using the 1.19 teensyduino. I'll try out 1.20.

Thanks for your post, Nantonos.

Do you think I'll be able to run a library designed for the older SPI.h with the new library? Well, I'll give it a shot right now anyway.
 
The old methods (which require knowing the CPU frequency) are still supported along with the new ones (which don't). Transactional SPI is there but you don't have to use transactions.
 
The old methods (which require knowing the CPU frequency) are still supported along with the new ones (which don't). Transactional SPI is there but you don't have to use transactions.

So it sounds like the initialization methods with the DIV2,32,etc will work fine. I'm not certain really what transactional SPI is (i'll look it up but I doubt I'll get more than a cursory understanding.) But it sounds like maybe this: The old RA8875 driver code will work, but not immediately utilize benefits of the new SPI library until the code is updated to utilize it. Is that correct?

Thanks,
-Tomek
 
Yes, that's correct. The new SPI library is designed to be compatible with all programs written for the old version.

The new transaction feature protects you from crashes or deadlocks that could occur when 2 different libraries use SPI at the same time, because one runs from an interrupt. Usually this is a problem when using newer SPI devices like radio modules, which require interrupts.

SPI.beginTransaction() also has a feature where you specify the maximum speed your hardware can use, rather than a divider based on Teensy's clock. The library will automatically use the fastest speed that is less than or equal to the speed you specify. When your code is used on a different board, or even the same board running at a different clock speed, the SPI library automatically adapts its settings to always give you the best speed, so you don't have to change your code for every new board and speed setting.


@Nantonos - updating the SPI web page is on my short-term to-do list. I juggling a lot of priorities at the moment, so I can't get to this for several days. But it's not lost, only delayed. I'm just one guy....
 
Status
Not open for further replies.
Back
Top