Mutex with QSPI?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Mutex with QSPI?

3,416件の閲覧回数
MQXuser
Contributor III

I am using the QSPI driver provided with MQX. I dont know if this drivers provide protection in order to

 avoid different tasks using the qspi resource.

Before I use a mutex to protect this case,  I would like to know if there is already a protection.

 

Thanks

0 件の賞賛
返信
8 返答(返信)

1,831件の閲覧回数
PetrM
Senior Contributor I

Hello,

 

in the next release, the QSPI driver will be merged into universal SPI driver.

The driver will not open twice, there will be an exclusive access to SPI.

If you try to use same SPI file descriptor in multiple tasks, you have to provide additional protection.

 

Regards, 

PetrM

 

0 件の賞賛
返信

1,831件の閲覧回数
MQXuser
Contributor III
I am using a global file pointer to control my 3 qspi devices. Any device can be used by any task at any time. Should I open different file pointers for each device or task?
0 件の賞賛
返信

1,831件の閲覧回数
PetrM
Senior Contributor I

Well, the best idea would be to create one communication task, which would be the only task accessing QSPI bus and which would be used by other tasks through messages.

In you scenario, you have to take care of exclusive QSPI access using mutexes or semaphores either way.

0 件の賞賛
返信

1,831件の閲覧回数
Joe2
Contributor II

Hi

 

To clarify, I am right in thinking that we can have a maximum of one device 'fopen'ed against spi0 at a time?  And to access multiple devices on the SPI, we have to ioctl each device's SPI definition (if they differ) for the phyical device we were going to talk to each time we're about to talk?

 

I'd erroneously expected the ability to allow multiple fopens, each with a different CS number... and the handling of multi-device read/write clashes using a mutex internal to the driver.

 

Could you let me know whether I'm now looking at the driver the right way up?

 

Thanks

 

Joe

0 件の賞賛
返信

1,831件の閲覧回数
PetrM
Senior Contributor I

Yes, only one SPI device can be opened at a time now.

If you're communicating with several devices and their physical communication settings differ, you have to switch the settings using IOCTLs everytime you switch between devices.

Think of it as generic low level driver upon which you can create any "protocol layers".

 

PetrM

 

0 件の賞賛
返信

1,831件の閲覧回数
Joe2
Contributor II

Thanks, PetrM.

 

I think I understand it properly now.

 

Joe

0 件の賞賛
返信

1,831件の閲覧回数
CarlFST60L
Senior Contributor II

As far as I know MQX functions are all thread & re entrant safe unless otherwise stated.

 

 

 

 

0 件の賞賛
返信

1,831件の閲覧回数
MQXuser
Contributor III
Thank you for your answer, I am having dificulties merging tasks that were working alone.
0 件の賞賛
返信