I have two SPI devices on the same bus on a Quail (STM32F427) and I get an exception on spi2 declaration when I run the following code :
private static void TestSPI()
{
var spiConfig1 = new SpiConnectionSettings(3)
{
ClockFrequency = 12000000,
DataBitLength = 8,
Mode = SpiMode.Mode0,
SharingMode = SpiSharingMode.Shared
};
var spi1 = SpiDevice.FromId("GHIElectronics.TinyCLR.NativeApis.STM32F4.SpiProvider\\0", spiConfig1);
var spiConfig2 = new SpiConnectionSettings(65)
{
ClockFrequency = 12000000,
DataBitLength = 8,
Mode = SpiMode.Mode0,
SharingMode = SpiSharingMode.Shared
};
var spi2 = SpiDevice.FromId("GHIElectronics.TinyCLR.NativeApis.STM32F4.SpiProvider\\0", spiConfig2);
}
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
#### Exception System.Exception - CLR_E_FAIL (1) ####
#### Message:
#### GHIElectronics.TinyCLR.Devices.Spi.Provider.DefaultSpiDeviceProvider::InitNative [IP: 0000] ####
#### GHIElectronics.TinyCLR.Devices.Spi.Provider.DefaultSpiDeviceProvider::.ctor [IP: 0029] ####
#### GHIElectronics.TinyCLR.Devices.Spi.Provider.DefaultSpiControllerProvider::GetDeviceProvider [IP: 0008] ####
#### GHIElectronics.TinyCLR.Devices.Spi.SpiDevice::FromId [IP: 004c] ####
#### TinyCLRApplication1.Program::TestSPI [IP: 0053] ####
#### TinyCLRApplication1.Program::Main [IP: 0004] ####
Exception thrown: 'System.Exception' in GHIElectronics.TinyCLR.Devices.dll
Each one is running fine alone and both are running fine as well when the second one is on another bus.
I thought that SpiSharingMode.Shared would allow that. Am I wrong ?