Toolbox.NETMF.Hardware.MultiSPI


Toolbox.NETMF.Hardware.MultiSPI(config)
  • config The SPI configuration

Methods

  • Read(ReadBuffer) Reads from the buffer
  • Write(WriteBuffer) Writes to the buffer
  • WriteRead(WriteBuffer, ReadBuffer) Writes to the buffer, then reads from the buffer

Property

  • Config Returns the current SPI configuration

Sample code in C#

SPI.Configuration Config595 = new SPI.Configuration(
    ChipSelect_Port: Pins.GPIO_PIN_D10,
    ChipSelect_ActiveState: false,
    ChipSelect_SetupTime: 0,
    ChipSelect_HoldTime: 0,
    Clock_IdleState: true,
    Clock_Edge: true,
    Clock_RateKHz: 1500,
    SPI_mod: SPI_Devices.SPI1
);
SPI.Configuration Config165 = new SPI.Configuration(
    ChipSelect_Port: Pins.GPIO_PIN_D9,
    ChipSelect_ActiveState: true,
    ChipSelect_SetupTime: 0,
    ChipSelect_HoldTime: 0,
    Clock_IdleState: true,
    Clock_Edge: false,
    Clock_RateKHz: 1500,
    SPI_mod: SPI_Devices.SPI1
);

MultiSPI Spi595 = new MultiSPI(Config595);
MultiSPI Spi165 = new MultiSPI(Config165);

while (true)
{
    byte[] buffer = new byte[2];
    Spi595.Read(buffer);
    Spi165.Write(buffer);
}

Sample code in VB

Dim Config595 As SPI.Configuration = New SPI.Configuration(
    ChipSelect_Port:=Pins.GPIO_PIN_D10,
    ChipSelect_ActiveState:=False,
    ChipSelect_SetupTime:=0,
    ChipSelect_HoldTime:=0,
    Clock_IdleState:=True,
    Clock_Edge:=True,
    Clock_RateKHz:=1500,
    SPI_mod:=SPI_Devices.SPI1
)
Dim Config165 As SPI.Configuration = New SPI.Configuration(
    ChipSelect_Port:=Pins.GPIO_PIN_D9,
    ChipSelect_ActiveState:=True,
    ChipSelect_SetupTime:=0,
    ChipSelect_HoldTime:=0,
    Clock_IdleState:=True,
    Clock_Edge:=False,
    Clock_RateKHz:=1500,
    SPI_mod:=SPI_Devices.SPI1
)

Dim Spi595 As MultiSPI = New MultiSPI(Config595)
Dim Spi165 As MultiSPI = New MultiSPI(Config165)

Do
    Dim buffer() As Byte = {0, 0}
    Spi595.Read(buffer)
    Spi165.Write(buffer)
Loop

Last edited Jan 2, 2013 at 8:46 PM by Garrcomm, version 3