Page 1 of 2
MMC_SPI shared with other multiple/devices
Posted: Mon Dec 01, 2014 6:46 am
by vpcola
Looking at the mmc_spi.c driver implementation, it looks like the driver is not ready to be used when multiple devices are on the same SPI bus, and when multiple threads are accessing peripherals on the same bus.
I'm thinking of calling spiAcquireBus() for everytime the MMC_SPI driver is accessed (i.e. call to spiAcquireBus() before spiSelect() and spiReleaseBus() after spiUnselect(), will it solve this issue?
Regards,
Vergil
Re: MMC_SPI shared with other multiple/devices
Posted: Mon Dec 01, 2014 8:59 am
by Giovanni
Hi,
The sequence is:
spiAcquire()
spiStart()
....
mmc_ops()
....
mmc_ops()
....
spiRelease()
The spiStart() is required in order to setup the MMC parameters again.
Giovanni
Re: MMC_SPI shared with other multiple/devices
Posted: Tue Feb 17, 2015 8:46 am
by Chudik
Giovanni,
Just to cleaner understanding.
1. For using one spi port for two devices (in my case display and buttons interface) I need to create 2 drivers (SPI_Display, SPI_Buttons) with two SPIConfig: display_cfg and buttons_cfg where each of them will have it's own SNN port and SNN pin.
2. callback used only for slave mode.
Since, as you mentioned early, spiRelease() and spiStart() called every time when needed, CR1 in the SPIconfig for these devices could be either same or different.
Is it correct?
Re: MMC_SPI shared with other multiple/devices
Posted: Tue Feb 17, 2015 9:00 am
by Giovanni
Hi,
It is correct, the config structure can be different.
Giovanni
Re: MMC_SPI shared with other multiple/devices
Posted: Wed Feb 18, 2015 11:15 pm
by Chudik
Giovanni,
I guess, spiStop() should be called before calling spiReleaseBus(), correct?
And do I understand right, that if I use function, for example, spiStartSend(), it will use DMA automatically? All I need to do after that in the task - wait for the SPI_COMPLETE in the spistate.
Re: MMC_SPI shared with other multiple/devices
Posted: Thu Feb 19, 2015 9:13 am
by Giovanni
Chudik wrote:I guess, spiStop() should be called before calling spiReleaseBus(), correct?
Not necessarily, there can be consecutive spiStart() calls.
Chudik wrote:And do I understand right, that if I use function, for example, spiStartSend(), it will use DMA automatically? All I need to do after that in the task - wait for the SPI_COMPLETE in the spistate.
Use spiSend() and you will not have to wait for anything.
Giovanni
Re: MMC_SPI shared with other multiple/devices
Posted: Thu Feb 19, 2015 10:03 am
by Chudik
Giovanni wrote:Not necessarily, there can be consecutive spiStart() calls.
Even if the next one will be the other spi device on the same physical spi bus?
Giovanni wrote:Use spiSend() and you will not have to wait for anything.
Oh, I see the difference
At the end of the operation the configured callback is invoked.
Is DMA used in these functions at all?
Re: MMC_SPI shared with other multiple/devices
Posted: Thu Feb 19, 2015 10:25 am
by Giovanni
DMA is always used.
Giovanni
Re: MMC_SPI shared with other multiple/devices
Posted: Thu Feb 19, 2015 11:02 am
by Chudik
Giovanni wrote:DMA is always used.
That is great!!!
I saw that SPI, UART macros include DMA defines, but did not figured out that it means automatic DMA using for these channels.
Too much information should go through the newbie brain

Especially when it immediately goes to the project.
Please, make it clean:
Can I use consecutive spiStart() without spiStop() even in cases when I use two SPIDrivers on one physical SPI bus?
And I will not bother you for a couple of days

Re: MMC_SPI shared with other multiple/devices
Posted: Thu Feb 19, 2015 12:25 pm
by Giovanni
Yes, you can.
Giovanni