IIIIOO
OO----
WW
WW
aa
aarrrrrrrriiii
oo
oorrrr
55
55
66
66
5.10.3 SPI Special mode function
IO-Warrior56 has a hardware SPI interface
enabling it to talk to many peripheral devices.
IOW56 supports SPI master mode.
To enable the SPI function a report with ID 8 is
sent to interface1:
"enable" = $00 disables the SPI and $01 enables it.
"mode" contains flags specifying the operating
mode for the SPI:
7 - LSBfirst
6 - unused, write zero
5 - unused, write zero
4 - unused, write zero
3 - unused, write zero
2 - CPHA
1 - CPOL
0 - unused, write zero
"LSBfirst" selects which bit of the data byte gets
shifted first. "LSBfirst" = 0 shifts MSB first,
"LSBfirst" = 1 shifts LSB first.
"CPHA" works together with "CPOL" to specify
which clock edges are used to drive and sample
data bits.
"CPOL" = 0 causes SCK to idle low between data
bytes," CPOL" = 1 makes SCK idle high.
"CPHA" = 0 causes data to be sampled on the first
clock edge and driven on the second edge.
"CPHA" = 1 causes data to be driven on the first
edge and sampled on the second edge (this is the
opposite behaviour of IOW24 CPHA bit).
Enabling SPI takes P5.0..P5.4 out of the control of
interface zero.
clock sets the clock divider. The master clock rate
is 24 MHz which is divided by clock+1. The valid
range for clock is 2 to 255. So the fastest SCLK
rate is 8MHz, the slowest 93.75kHz.
flags contains configuration bits.
7 - Disable Pull Ups (1 = disable)
6 - unused, write zero
5 - unused, write zero
4 - unused, write zero
3 - unused, write zero
2 - unused, write zero
1 - unused, write zero
0 - unused, write zero
SPI does always shift data in and out
simultaneously. So there is only one command to
send data out of SPI that does also result in the
same number of bytes being read in and returned to
the host. If the intention is to only read data from
an external device it is still necessary to shift out
the same number of dummy bytes to that device.
Data transfers on the SPI are initiated by a report
with ID 9:
"flags" contains the following bits:
7 - useDRDY, 1 = do handshake
6 - SSactive, 1 = /SS stays active
5 - ignoreDRDY, 1 = first byte ignores /DRDY
4 - unused, zero
3 - unused, zero
2 - unused, zero
1 - unused, zero
0 - unused, zero
"useDRDY" enables a handshaking signal that
allows the slave to signal if and when it is ready to
accept or send data.
If "useDRDY" = 1 IO-Warrior56 will check for the
/DRDY signal to be low before it starts shifting a
data byte. If the slave wants to pause the data
transmission it has to pull /DRDY high before the
end of the current byte transfer.
Upon starting a data transfer it may be desired to
send the first byte without the slave signalling /
DRDY low. By setting "ignoreDRDY" to 1 the
first byte of this report is sent to the slave without
checking /DRDY. Prior to shifting the next byte
IO-Warrior56 will check the status of /DRDY.
"count" has the number of bytes to shift, values 161 are valid, others will be ignored.
IO-Warrior56 assertes /SS before starting to shift
the first data byte of this report and will deassert it
after completing the last byte, unless bit 6
"SSactive" is = 1. If "SSactive" is set /SS will stay
asserted after the last byte of the report has been
transfered, allowing more than 61 bytes to take part
of a single transfer.
Data shifted in by IO-Warrior56 during a
transaction is returned in a report with ID 9:
"count" holds the number of valid bytes in the
report.