SPIOUT

 
Syntax


#include <SPI.bas>                             ' source in /Program Files/Coridium/BASIClib

SUB SPIOUT (CSpin, CLKpin, OUTpin, LSBfirst, OUTcnt, BYREF OUTlist AS STRING)

Description

SPIOUT supports the loosely defined serial protocol used by a variety of manufacturers.  The desired device is selected by asserting CS_pin LOW.  If there is no CS_pin, the value should be set to -1.

In the simplest case, out_pin is used to output data clocked by clk_pin, from the OutputList.

OutputList can contain a list of constants, variables, "constant-string" or stringame without a count. The latter will send out bytes starting from stringname(0) until a 0 byte is read.  The 0 is not shifted out, if that is required either a count should be specified so as to include the 0.

Data is shifted out MSB first and each element of the OutputList is treated as a byte. The LSBfirst can be used to change the bit order.

Data is shifted out at 300 Kbits/sec

Example

#include <SPI.bas>

DIM Astr(20) as STRING

SUB Fpu_Write(bval1)
 Astr(0) = bval1
 SPIOUT(FpuCS, FpuClk, FpuOut, 0, 1, Astr)
END SUB
 

Differences from other BASICs

See also