Ejemplo n.º 1
0
        public void spiTransfer(byte opcode, byte data, int addr = 0)
        {
            //Create an array with the data to shift out
            int offset   = addr * 2;
            int maxbytes = numDevices * 2;



            for (int i = 0; i < maxbytes; i++)
            {
                spiData[i] = (byte)0;
            }

            //put our device data into the array
            spiData[offset + 1] = opcode;
            spiData[offset]     = data;

            //enable the line
            csPin.DigitalValue = false;

            //Now shift out the data
            Array.Reverse(spiData);
            SPIModule.SendReceive(spiData);
            //latch the data onto the display
            csPin.DigitalValue = true;
        }