In most of the platform files the SPI1 is used for extrenal FLASH connected to the MCU, but you can use the SPI1 for your device also, But you should use a different CS line, otherwise when you assert CS to 0 and communicate, both your slave & flash could give some data and you'll intrepret this as unexpecetd invalid data.
Can someone please help with the following questions?
1. If I use SPI1 (albeit with a different chip select pin than flash), will this work without any changes to the platform files?
A. You have to use a different CS line,(otherwise when you asser CS to 0 and communicate both your slave & flash could give some data and you'll intrepret this as invalid)
2. Is there any other SPI interface I can use? I saw references to SPI3 in platform.h but nothing is defined in platform files
A. You can use other SPI interface as well, but ensure that pins are available on your board. also you need to decalre/define them in the platform.c file.(take SPI1 as reference)
3 What exactly is the flash code used for? Does it even make sense for me to think of sacrificing flash support to get my SPI device working?
A. Flash code is used only if you need that external flash for some data storage, otherwise that is not required.
Thank you for your input!
If I use SPI1 with different CS, I am concerned that I will have to change the flash driver to protect against the reentrancy problem discussed in the following thread:
Also, based on the above thread, I would have to use the same config across both flash and my SPI device.
I will look into defining a new SPI interface in the platform files, although it looks like I will have to think about the DMA streams and other config that I may safely use.
I am guessing I need the flash code for my WCD4_EVB because it stores some of the WiFi DCT stuff there.
So to summarize, it looks like my best option is to re-use SPI1 with different CS like you suggested.
Would you think the issues raised in the above thread are now resolved?
Yes , eventhough you're using different CS pin, you might have to do that, Are SPI APIs thread safe ?
ie; locking & unlocking using a mutex, Since you're sharing a resource you must do that.
Also ,if you're using SPI1 for multiple peripherals, the SPI modes, Clock frequency used by these modules will be different and you might have to init the SPI for each specific peripheral before doing it's corresponding SPI operation.
Got it! That sounds like a simpler solution than turning off flash or defining SPI3.
Thanks again for your timely help! I will mark this as answered.