This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1352R: How to share the SPI bus between multiple devices? (SDSPI, NVS and NFC)

Part Number: CC1352R

Hello,

We are working on a setup where we will have three SPI devices connected to the CC1352.

An NFC reader IC, a SD card (using SDSPI) and the OAD external flash (using NVS).

My question now is how do I best divide this between the available resources.

Our preference is to have the NFC on a separate SPI bus and both the ext flash and SD card IC's on a shared bus.

But how do we share the access when both NVS driver and SDSPI driver claim their own access to the SPI bus.

best regards,

Marijn

  • You should be able to share a SPI bus between multiple slaves, see "Independent Slave Configuration" here: 

    Meaning that in this case you have to configure 2 or more Chip Select lines. Then you can only access one slave at a given time. 

  • Hi, 

    Sorry, maybe my question was not clear enough.

    I know that I can use multiple slaves and that each slave needs it's own CS line.  That is exactly what I want to do here.

    My question is on the TI side of things. I use the SDSPI driver (for SD card) and NVS driver (for OAD) and I want to use both on the same (physical) SPI pins.

    How do I make sure that they share the SPI resource and don't use it at the same time.

  • I would assume that in this case you have to treat the SPI based drivers as any other driver that share a resource, you have to open driver A, use it, close driver A, then open driver B, use it etc. 

    Is this in a stack context or do you have full control when the various drivers are called? 

  • Thanks,

    This could prove to be a bit challenging as I rather not close the SDSPI driver (actually the SDFATFS driver) because it takes some time to reinitialise the SD card.

    Regarding control of the driver calls. The NVS driver is used by the stack OAD function so I have no (direct) control over that. The device also needs to stay fully functional when performing OAD.

    The SDFATFS I have full control over, but as I mentioned I rather not close this complete driver because of initialisation time.

    The NFC is the only one that I directly access the SPI driver and I also have full control over. However as it needs to react immediately when a card is offered it cannot wait for access.

    Our preferred solution of course is that the TI drivers (NVS and SDFATFS) could share the SPI driver internally.

  • Disregard my last post. At the moment I'm not sure if you are able to do this in syscfg but in the board files you are able to setup different CS pin for the NVS and SDFATFS drives and by this setup different CS pins for the different drivers making it possible to share the same SPI resource with the same driver. I would suggest that you do some test with a LP with http://www.ti.com/tool/BOOSTXL-SHARP128 to verify.

  • Ok,I'v setup the different CS pins in the board file and at least I get the same handle during initialisation of both the drivers. SD card also works OK. I've not yet verified the NVS driver.

    From looking into the NVS source code I found out that there is a function NVS_lock and NVS_unlock which pends/posts a semaphore for the current NVS handle.

    I think this could also be a solution for us. If I can get the NVS_Handle from the file 

    flash_interface_ext_rtos_NVS.c I can lock the NVS driver for every SD card access that I do.