User manual

Code Mercenaries
12
II
II
OO
OO
--
--
WW
WW
aa
aa
rr
rr
rr
rr
ii
ii
oo
oo
rr
rr
55
55
66
66
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
interface 0. Disabling IIC does return the pins
under control of interface 0 and pulls them high
initially.
flags contains some configuration information:
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 - speed bit 1
0 - speed bit 0
Bit 7 "Disable Pull Up" allows operation with
external pull up resistors and lower voltage levels.
When this bit is set the internal pull up resistors of
the IIC pins are disabled and the SDA/SCL pins
work as open drain. The pull up resistors can not
be enabled again while the IIC function is active.
Disabling and again enabling the IIC function is
necessary to change the status of the pull-up
resistors back to active.
Bits 0 and 1, speed of the IIC clock.
0 = standard (93.75kHz)
1 = fast (375kHz)
2 = slow (46.8kHz)
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 - data count MSB
4 - data count
3 - data count
2 - data count
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 1 to 62,
higher values cause the report to be ignored.
To do write transactions that are longer than 62
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 last report is send
which has the "Generate Stop" bit set.
Clock stretching by the slave to slow down data
transfer is supported by IO-Warrior56.
Sending just the address byte in write mode and
then terminating the transfer with a stop condition
is not supported by IOW56. Trying to send such a
command results in an error being returned. Errors
are returned also when another start condition is
attempted before issuing a stop, or if data is send
without having a valid start condition.
Any write transactions are acknowledged by a
report via interrupt-in endpoint 3:
flags contains the following bits:
7 - Error bit, 1 = error
6 - Arb loss bit, 1 = Arbitration lost
5 - data count MSB
4 - data count
3 - data count
2 - data count
1 - data count
0 - data count LSB
"data count" indicates the last byte that was
successfully transfered and acknowledged by the
slave (if any).
An error is indicated when the slave does not
acknowledge a transfer, or an invalid start/stop
condition was requested.
If another master starts transmission on the bus at
the same time and IO-Warrior56 loses the bus due
to a collision, an Arb Loss is returned.
To resolve an Arb Loss the transfer has to be
initiated again.
ReportID
$02 in
12
flags $00
34
$00 $00
... 62
$00 $00
63
$00
V 1.0.3, November 6nd 2012 for chip version V1.1.0.1