SPIWrite (Write to SPI Peripheral)

The SPIWrite instruction synchronously clocks out the specified number of bytes to the peripheral device. If the Source variable is type Long, the bytes are read from the most significant byte of the first element of the array first.

NOTE: Campbell Scientific documentation has been updated to replace legacy industry terms with modern terminology. Controller-peripheral are now used to describe SPI communications. The SPI controller initiates communications and makes requests of peripheral device(s). Peripheral devices process requests and return an appropriate response See https://www.oshwa.org/a-resolution-to-redefine-spi-signal-names for more information.

Syntax

SPIWrite ( BeginPort, Source, NumBytes )

Remarks

Serial Peripheral Interface (SPI) protocol is a clocked synchronous interface, used for short distance communication, generally between embedded devices.

Note that a prior understanding of the operation and details of the SPI protocol is assumed.

Parameters

BeginPort

The beginning port used for the three signals for SPI communications. The first port is the SPI clock signal. The next higher port from the clock port is the Controller Out Peripheral In (COPI) signal, and the next higher port is Controller In Peripheral Out (CIPO). BeginPort can be C1, U1, U5, or U9. If an additional chip select (CS) signal is required, it can be managed with PortSet instructions surrounding the SPI accesses.

Type: Constant

Source

The variable in which the bytes to be written are stored.

Type: Variable

NumBytes

The number of bytes that will be sent to the peripheral device.

Type: Variable or constant