Main Site Documentation

Comunicating to multiple SPI devices


#1

I thought about this today and would like your input please.

Say i have 4 SPI devices, each of which uses a different clock rate and SPI mode.
For clarity sake, here are the devices.

#1) Temp sensor (mode 0)
#2) a/d converter (mode 1)
#3) Port Replacement Unit (mode 2)
#4) Oxygen Sensor (mode 3)

what is unclear to me is if .netmf handles the following situation.

I need to read the a/d converter 10,000 times in a loop. But while doing that i get an event that i need to read the PRU. when i want to read it, the SPI will be set up for the a/d converter, do i need to change the SPI parameters to talk to it while putting the a/d converter thread on hold, and when done put the SPI parameters back ?

In a nut shell, if having events happen that need to communicate to certain SPI devices do i need to keep track of the SPI parameters, or does .netmf handle that when i set up the device ?
.


#2

Yes, you create multiple SPI.Configuration instances reflecting the variations.
then you will use Config property of the SPI class to switch the bus for communication with associated device.

Check FEZ music shield code:

http://code.tinyclr.com/project/330/fez-music-shield/


#3

Perfect, thank you.


#4

You are welcome!