Not sure if I should ask these type questions here or over on RobotSource or ...
As I mentioned on the RobotSource thread: https://community.robotsource.org/t/opencr-1-0-mapping-arduino-pins-to-capabilities/1426/2
I thought it might be fun to try to expose some additional functionality to some of the OpenCR pins, especially the expansion pins...
So for example if you are using an Adafruit shield using the Arduino pins, it would might be nice to be able to use a different SPI port to do some thing else, such as a camera or... Turns out that I believe the hardware SPI port SPI4 is exposed on our logical pins 57-60.
So I have started to update my fork/branch of the OpenCR code to hopefully introduce SPI4... It currently compiles so will try something out soon to see if it works at all...
But one thing I wondered about is SPI2 supports DMA access, which I am pretty sure you are using in the writeFast method. I would also like this for SPI2...
So going through the code it is setup to use a DMA channel, I believe DMA1_Stream4.
hdma2_tx.Instance = DMA1_Stream4;
hdma2_tx.Init.Channel = DMA_CHANNEL_0;
My question is how are these DMA Channel/Streams allocated? Code wise, I think I see some of the UARTS use DMA
hdma_rx[DRV_UART_NUM_2].Instance = DMA1_Stream5;
hdma_rx[DRV_UART_NUM_2].Init.Channel = DMA_CHANNEL_4;
hdma_rx[DRV_UART_NUM_3].Instance = DMA1_Stream1;
hdma_rx[DRV_UART_NUM_3].Init.Channel = DMA_CHANNEL_4;
So far in the code thse are the only references I see.
So need to figure out who allocates the stream and relationship to channel.
Probably need to again look over DMA section of manual, but suggestions are appreciated.
Right now I have my new SPI4 set to try to use:
DMA1_Stream6 and DMA_CHANNEL_0
But again so far it compiles, next up see if any of it works!
The DMA channel is assigned by default and I don't think we can modify them.
They are written in page 222 of the Reference Manual.
For example, USART2 RX is specifically mapped to DMA1 Stream 5 Channel 4.
We're moving our office to a new building and we might not able to respond as normally we do until next week so please be generous to it.
Thank you :)
Somehow I missed seeing the tables, must have browsed right by it... (Table 24 and 25) Now to update the code :D