Closed KurtE closed 6 years ago
Hi, @KurtE
First, l will check out the existing examples that use SPI.
@OpusK, sounds like a good idea, to double check I did not hurt anything. Note: I have not (yet) enabled DMA on SPI1 (IMU), as I was not sure if there was some reason why it was not earlier enabled? It should be straight forward to add if desired. Just need to setup the two dma channels, and remove some ifs that are disabling.
Also not sure if you are interested, but here is one of the tests I was using to test/debug: SPI_Transfer_test-180619a.zip
As I mentioned on the thread: https://community.robotsource.org/t/spi-apis-of-opencr/1433/14 Another test program that uses two SSD1306 displays and updates them both at the same time was put in my fork/branch of sparkfun teensyview. Links up on forum thread.
@KurtE Thank you for updating the code. I'll try this with the OpenCR-Camera example and see how it works!
@KurtE You are my savior! I just simply adopted your example into the OpenCR Camera example and now I'm getting +4 FPS 👍
Most of the examples using SPI have been found to be fine.
@ROBOTIS-Will, I think the example you added should be applied with a new API. Can you modify the example in the develop after we accept this PR?
Warning: There are lots of changes here, that you probably want to carefully look at, including the idea of using a very reduced functionality of the Teensy EventResponder for doing callbacks. Could use simple callback function if desired, but made it so I could use the modified Sparkfun_TeensyView async support.
I have done some different testings, including my own test apps, ran some of the IMU tests to hopefully make sure I did not mess it up. Looks like by accident I put in a change to rename the board to include the name (develop). I use this so I can use the trick to add a board to the Arduino using a symbolic link from arduino folder/hardware and have both the changed version and the released version in the tools/boards list and be able to tell which one is which.
Remove compiler warnings on using Serial.printf...
Added SPI4 (SPI_EXT) on IO pins 57-60
Added SPI.transfer(txbuf, rxbuf, count) - where either RX or TX can be NULL...
Changed SPI.writeFast to call this transfer - DMA was not actually any faster.
Added ASYNC SPI (DMA) method: SPI.transfer(txbuf, rxbuf, count, event_responder) This uses a Teensy (PJRC) WIP Async api (EventResponder) which I removed the majority of the possible ways of using (only calls directly).
Changes SPI.beginTrasaction - SPISettings to remember the desired clock instead of clock divider and added SPI.setClock() which is used by beginTransaction. This was needed as SPI (SPI2) - has a max speed of 25mhz whereas the SPI_EXT(SPI4) has a max speed of 50mhz (so does SPI_IMU(SPI1)... So since the SPISettings in theory could be shared, needed way change depending on which one...
Fixed some of the intenal SSPI Transfer functions to allow transfers over 64K.