Syntax
void SPIOUT
(int CSpin, int out_pin, int
clk_pin, int cnt, char *OutputList);
Description
SPIOUT 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, out_pin is used to output data
clocked by clk_pin, from the OutputList. CSpin, out_pin and
clk_pin are left as and outputs.
Data is shifted out LSB first and each element of the
OutputList
is treated as a byte. This order can be changed with SPImode.
Data is shifted out at 800 Kbits/sec
Example
shortMessage [0] =
0xF3; // get version
SPIOUT
(-1,14,15,1,shortMessage); // sync
FPU
INPUT
(14); // allow FPU to drive this
bidirectional line
while
(IN(14)); // wait for FPU to drive that
line low
shortMessage [0] = 0xF2; // get string
back
SPIOUT (-1,14,15,1,shortMessage); //
sync FPU
save_time =
TIMER;
while ((TIMER - save_time) < 15)
; // wait 15 uSec
while
(1) {
SPIIN (-1,14,15, -1,-1,-1,-1,
1,shortResponse); // get 1 byte at a time back and print
it
if (shortResponse[0] == 0)
break;
printf("%x\n",shortResponse[0]);
}
See also