How do you set up SPI when you want to manually handle the CS pin ?
I have a working code when I set the SPI config like this :
_spi = SpiController.FromName(socket.SpiBus).GetDevice(new SpiConnectionSettings()
{
ChipSelectType = SpiChipSelectType.Gpio,
ChipSelectLine = GpioController.GetDefault().OpenPin(socket.Cs),
Mode = SpiMode.Mode0,
ClockFrequency = 8000000
});
But if I use this :
_spi = SpiController.FromName(socket.SpiBus).GetDevice(new SpiConnectionSettings()
{
ChipSelectType = SpiChipSelectType.None,
Mode = SpiMode.Mode0,
ClockFrequency = 8000000
});
// Initialize Cs pin
_cs = GpioController.GetDefault().OpenPin(socket.Cs);
_cs.SetDriveMode(GpioPinDriveMode.Output);
_cs.Write(GpioPinValue.High);
and I add _cs.Write(GpioPinValue.Low);
and _cs.Write(GpioPinValue.High);
before and after each transaction, then the same code does not work anymore.
What am I missing ?