private void sw_spi_init() { var gpio = GpioController.GetDefault(); if (gpio != null) { SWSpiDataPin = gpio.OpenPin(DataPin); SWSpiDataPin.Write(GpioPinValue.Low); SWSpiDataPin.SetDriveMode(GpioPinDriveMode.Output); SWSpiClockPin = gpio.OpenPin(ClockPin); SWSpiClockPin.Write(GpioPinValue.Low); SWSpiClockPin.SetDriveMode(GpioPinDriveMode.Output); } }
private void sw_spi_out(byte n) { // Bitbang SPI write for (int i = 8; 0 != i--; n <<= 1) { if (0x80 == (n & 0x80)) { SWSpiDataPin.Write(GpioPinValue.High); } else { SWSpiDataPin.Write(GpioPinValue.Low); } SWSpiClockPin.Write(GpioPinValue.High); SWSpiClockPin.Write(GpioPinValue.Low); } }
private void sw_spi_end() { // Stop 'soft' SPI SWSpiDataPin.SetDriveMode(GpioPinDriveMode.Input); SWSpiClockPin.SetDriveMode(GpioPinDriveMode.Input); }