I'm using SPI to drive a two 8-bit shift registers (74HC595) which in turn drive an LCD display (LM6029). The output loop seems a bit slow because the code needs to call spi.Write once for each output, eg:
SPI.Configuration config = new SPI.Configuration( Pins.GPIO_PIN_D10, false, 0, 0, false, true, 10, SPI.SPI_module.SPI1); spi = new SPI(config); ushort[] d = new ushort[1]; for (int i = 0; i < this.bufferSize; i++) { d[0] = buffer[i]; spi.Write(d); }
It seems it would be more efficient to be able to write the buffer array with one call to spi.Write and the method seems to be able to support it as it takes an array as the parameter, eg:
spi.Write(buffer);
Running the latter seems to result in only the last element of the array being output instead of all the elements being output sequentially.
I have compared this to Szymon's code here and he also calls write() once for each output instead of sending an array.
I'm just wondering what the the difference is between calling write with an array with one element in it, compared to calling write with an array of multiple values. I imagine calling write with one value multiple times would behave the same as calling write once but with multiple values.