Would be most grateful for help – I’m trying to get SPI to work on my Raspberry pi 5 using .NET4.8 (Visual Studio 2022) in c# (I’m running my compiled code on the pi using Mono). It’s currently not working as I have checked there’s no SPI clock (constantly at zero volts) Looking at the Microsoft learn website, you have to tell the gpio pins to switch to alternative function to facilitate this. The code to do this is
SpiDevice.FromIdAsync() and you have to enter a BusId and “settings” as parameters. However, I can’t find what the BusId is supposed to be, and no matter what I enter, even if I try to assign a name to the BusId, the intellisense won’t accept anything and puts a a red line under whatever is entered, despite trying every one of the intellisense’s recommended fixes.I have installed the correct Nuget packages and put in “using Windows.Devices.SPI” at the start of the program, which the intellisense recognises. See my code, I’d be grateful if someone could help me to sort this problem! I’ve had the SPI working as it should in Python so I know the problem isn’t with the Pi itself. Has anyone here managed to get around this problem? If so, please put me right!
{
// Use chip select line CS0
var settings = new SpiConnectionSettings(0);
String bus;
object spi_bus0 = null;
SpiDevice device = SpiDevice.FromIdAsync(spi_bus0, settings);
// Set clock to 10M
settings.ClockFrequency = 500000;