User manual

Code Mercenaries
14
II
II
OO
OO
--
--
WW
WW
aa
aa
rr
rr
rr
rr
ii
ii
oo
oo
rr
rr
5.10 Special mode I/O
To enable IO-Warrior to talk to devices that have
more complex demands we have added the special
mode functions. When any of these functions is
enabled a couple pins of IO-Warrior turn into
special function pins.
Talking to the special mode functions is handeled
via the USB interface 1, which is also configured
as generic HID compliant.
Commands to the functions are sent via endpoint 0
as SetReport requests to interface 1. Replies from
the functions are returned as interrupt in reports via
endpoint 2.
To talk to these functions and to handle different
requests to them ReportIDs are used which enable
multiple functions to use the same endpoint. All
reports to and from special mode interfaces are
always eight bytes long, including the ReportID.
The following chapters describe the individual
special mode functions.
5.10.1 IIC Special mode function
The IIC function is enabled and disabled by
sending a report with the following structure with
ReportID=1 to interface 1:
enable=$01 enables the IIC function, $00 disables
it. Other values are reserved for future use.
Upon enabling IIC the SDA and SCL pins are
pulled high and are no longer under control of
SetReport requests to interface 0. Disabling IIC
does return the pins under control of interface 0
and pulls them high initially.
flags is used to deactivate the internal pull up
resistors for SDA and SCL (only on IOW24) and/
or select the use of the Sensirion protocol:
7 - Disable Pull Ups (1 = disable) - IOW24 only
6 - Use Sensibus Protocol (1 = enable)
5 - unused, write zero
4 - unused, write zero
3 - unused, write zero
2 - unused, write zero
1 - unused, write zero
0 - unused, write zero
Bit 7 - "Disable Pull Up" is available only on
IOW24. When this bit is set the internal pull up
resistors of the IIC pins are disabled. The status of
the pull up resistors can not be changed while the
IIC function is active. Disabling and again
enabling the IIC function is necessary to change
the status of the pull-up resistors.
Bit 6 - "Use Sensibus Protocol" selects the use of
the Sensirion protocol variant if set. The only
difference is that the start and stop conditions are
handeled according to the Sensirion protocol and a
handshake on read is added. The Sensibus protocol
can be activated and deactivated while the IIC
functions is active by sending another enable
command with this bit set differently.
The timeout byte sets the maximum time IOW
waits for SCL to be released by the slave when
clock stretching handshake is used. Time is
timeout x 500sec, writing a zero sets timeout to
256x500sec.
If the timeout expires due to the slave pulling down
SCL too long, IO-Warrior will return an error, just
like when the slave generates no Ack signal.
A write request to the IIC is send with ReportID=2
and has the following format:
flags contains the following bits:
7 - Generate Start
6 - Generate Stop
5 - unused, write zero
4 - unused, write zero
3 - unused, write zero
2 - data count MSB
1 - data count
0 - data count LSB
If bit 7 - "Generate Start" is set a start signal (SDA
falling edge while SCL is high) is generated on the
IIC prior to sending out the first data byte.
Bit 6 - "Generate Stop" causes a stop signal (SDA
goes high while SCL is high) to be generated after
sending the last valid data byte of this report.
"data count" gives the number of valid data bytes
in the report. The number may range from zero to
six, higher values cause the report to be ignored.
To do write transactions that are longer than six
bytes, send the first report with just the "Generate
Start" bit set, then send additional reports with
neither bit 6 or 7 set until the report with the last
bytes is send which has the "Generate Stop" bit set.
ReportID
$01 out
12
enable flags
34
timeout $00
56
$00 $00
7
$00
ReportID
$02 out
12
flags data
34
data data
56
data data
7
data
V 1.1.0, December 2nd 2013, for chip revision V1.0.3.0 and up