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
MMC_SPI shared with other multiple/devices
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: MMC_SPI shared with other multiple/devices
Hi,
The sequence is:
spiAcquire()
spiStart()
....
mmc_ops()
....
mmc_ops()
....
spiRelease()
The spiStart() is required in order to setup the MMC parameters again.
Giovanni
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
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?
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?
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: MMC_SPI shared with other multiple/devices
Hi,
It is correct, the config structure can be different.
Giovanni
It is correct, the config structure can be different.
Giovanni
Re: MMC_SPI shared with other multiple/devices
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.
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.
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: MMC_SPI shared with other multiple/devices
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
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?
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: MMC_SPI shared with other multiple/devices
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
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
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times