This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Resource Locking for SPI which has rl_fs and other devices

Hi

STM32F4, MDK, CMSIS SPI.

I have a uSD card on SPI5. I also have some other devices on SPI5. The uSD/FS and these devices may be accessed from differing tasks creating a resource locking requirement. Within the context of the FS also being on SPI5, can anyone advise how to talk to SPI devices such that the SPI lib manages resource locking?

At the moment I am accessing the devices by the following code.... HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); //CS pSPI->Send(buffer, 6); HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_SET); //CS

The problem is that:
(a) I do not know if the driver->Send locks the SPI resource so that nothing else can use it (I believe it may do from browsing the FS code)
(b) even if it did I am driving the CS line before I use the ->Send which is a conflict

I can add locking by implementing new fread, fwrite etc to add locking around fread (etc). I can also add locking on the callback the FS allows to set/reset the uSD CS. However, I am hoping someone tells me "no need, this is already a part of this system by doing.....". Something like this pSPI->Lock(); HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); //CS pSPI->Send(buffer, 6); HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_SET); //CS pSPI->Unlock();

or pSPI->Control(ARM_SPI_LOCK); HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); //CS pSPI->Send(buffer, 6); HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_SET); //CS pSPI->Control(ARM_SPI_UNLOCK);

But, it seems, ->Lock or ->Control(AMR_SPI_LOCK) do not exist. Anyone have another way of doing this that may be implemented.

Thanks
Mark