energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
794 stars 672 forks source link

Fast SPI & Uart with DMA + FIFO for the CC3200 #470

Open Juanduino opened 10 years ago

Juanduino commented 10 years ago

Dear all

I believe there is a need for faster SPI and Uart in various cases. This would be possible with a DMA + FIFO Library. This library could act as a drop in replacement for the SPI lib, when there is need for a fast direct line through.

It should be relatively easy to set up, since there is already a UDMA header int the CC3200 folder and several examples on TI E2E : http://e2e.ti.com/support/wireless_connectivity/f/968/t/353790.aspx

spirilis commented 10 years ago

I think the general idea here is that basic libraries like SPI, Wire, Serial, etc. should be "bug for bug compatible" with Arduino to enable better compatibility with Arduino sketches. To that end, "higher performance" libraries like what you're proposing can be added as an add-on library with a different name. This is an appropriate way to approach the issue, IMO, as "higher performance" libraries may have other API methods or conventions that are more appropriately suited for their operation (for example, an autonomous DMA-based system may allow asynchronous operation where the user's code registers a "callback function" to notify the sketch when the last SPI transfer completed) which may differ substantially from the basic SPI, Wire, etc. libraries. I am all ears if you have such a library in mind :)

Juanduino commented 10 years ago

I think you are right about the Arduino compatibility. Non the less the proper chip (if any) to compare CC3200 with would be on the Teensy 3.1 which in some way is part of the Arduino IDE through teensyduino. None of the AVR processors can pull off DMA + FIFO to my knowledge. Anyways, this CC3200 silicon is in my mind no less then a giant breakthrough and deserves the uttermost respect and care. Yes i would say a independent library, with the possibility to tweak some of the variables. I am no expert when it comes to DMA + FIFO. I just know its the way to move forward. If you say it will need this "callback function" i believe ya.

spirilis commented 10 years ago

I hear ya. I have been pondering something similar for SPI only in part to assist with my nRF24L01+ RF transceiver stuff. I may revisit this later on if nobody else writes such a library...

robertinant commented 10 years ago

I think we can still do DMA with the standard API. How about adding an optional parameter to begin() which is the callback for DMA transaction finished. In addition transfer() can be extended to take 2 buffers (TX/RX) which will be the buffers handed to the DMA controller. A 3rd option is to implement this like the Wire library and have beginTransmission(), write(), endTransmission() to trigger the DMA transfer and then the callback will receive a buffer with the received data.

alikian commented 10 years ago

Also we should have new SPI classes which read/write/transfer based on array of bytes, current SPI method is only send one byte at a time.