Sharing the SPI bus an ENC28J60 module is connected to on G400

Hi all,

I’m trying to understand if/how the SPI bus an ENC28J60 module is connected to would be shared with other devices from a software point of view. I couldn’t find any examples specific to this module - I presume the GHI.Networking.EthernetENC28J60 creates its own internal instance of the SPI bus object based on passed constructor parameters, so how does one “share” this with other devices, or am I totally missing the plot here?

As far as I know it is not possible on G120. My guess is that the SPI is not sharable when used by the FW internal Network driver.

Same as you how you would share any SPI slave, by using a chip select pin. While supported, I suggest to use the second SPI channel.

Ok, as long as it’s possible.

The reason I ask is I need the option of using either the ENC28J60 or WiFiRS9110 in a device. Since I can only bind one to the standard TCP stack, why not have them both on the same SPI bus and then have the second SPI available for other devices?

So in order to achieve this in software, how would I initialise these two objects to share SPI1?

 _ethernet = new GHI.Networking.EthernetENC28J60(SPI.SPI_module.SPI1, GHI.Pins.G400.PB5, GHI.Pins.G400.PB0, GHI.Pins.G400.PA7, 4000);

_wifi = new WiFiRS9110(SPI.SPI_module.SPI1, GHI.Pins.G400.PA28, GHI.Pins.G400.PB1, GHI.Pins.G400.PC23, 4000);

I don’t have a WiFi module to try this out.

You just use separate pins as chip select. all other pins should be wired in parallel.
Dependent on which interface you initialize, the one or the other chip select will be used.

Okay, I understand - thanks for the help