#include
<SPI.bas>
' source in /Program Files/Coridium/BASIClib
SUB SPIIN (CSpin, INpin, CLKpin, OUTpin, LSBfirst, OUTcnt, BYREF OUTlist as STRING, INcnt, BYREF INlist as STRING)
SPIIN supports the loosely defined serial protocol used by a variety of
manufacturers. The desired device is selected by asserting CSpin
LOW. If there is no CSpin , the value should be set to -1.
In the simplest case, INpin is used to input data clocked by CLKpin, to fill the INlist. (OUTcnt will be 0 and OUTlist empty)
In bi-directional cases, OUTcnt bytes of OUTlist will be output on OUTpin before reading the INlist. OUTcnt may be -1 and OUTlist empty. If OUTcnt is 0, then OUTlist bytes will be sent until a value of 0 is found (the 0 will not be sent). An empty OUTlist can be represented by "".
It is also allowable to have INpin equal to OUTpin, in which case that pin will be driven for the OUTlist and then converted to an input for INlist.
INlist will be filled with INcnt bytes. If INcnt is 0 then the INlist will be filled with bytes until a 0, CR or LF character is received. Note that no bounds checking is performed on the input, and if a 0, CR, or LF is never received then this routine will hang.
Data is shifted in MSB first and each element of the InputList is
filled with a byte of data. The LSBfirst can be used to change the bit order.
Data is shifted in at 330 Kbits/sec