Benutzer:Siro/i2cprotokoll: Unterschied zwischen den Versionen
Siro (Diskussion | Beiträge) K (Version 0.3) |
Siro (Diskussion | Beiträge) K (Version 0.4) |
||
Zeile 1: | Zeile 1: | ||
== <b>I2C Protokoll</b> == | == <b>I2C Protokoll</b> == | ||
Version 0. | Version 0.4 | ||
Zeile 29: | Zeile 29: | ||
<tr><td> </td><td>...</td><td></td></tr> | <tr><td> </td><td>...</td><td></td></tr> | ||
<tr><td> </td><td>|----</td><td>Endpoint n</td></tr> | <tr><td> </td><td>|----</td><td>Endpoint n</td></tr> | ||
<tr><td> </td><td></td><td> |---status_byte</td></tr> | |||
<tr><td> </td><td></td><td> |---in_buffer</td></tr> | <tr><td> </td><td></td><td> |---in_buffer</td></tr> | ||
<tr><td> </td><td></td><td> |---out_buffer</td></tr> | <tr><td> </td><td></td><td> |---out_buffer</td></tr> | ||
Zeile 34: | Zeile 35: | ||
== Packet == | == Packet == | ||
<b>Overview</b><br> | |||
<i>Packet:</i> | |||
<table border='1'><tr><td>Header</td><td>Data</td></tr><tr><td>1 Byte</td><td>1-8 Byte</td></tr></table> | <table border='1'><tr><td>Header</td><td>Data</td></tr><tr><td>1 Byte</td><td>1-8 Byte</td></tr></table> | ||
<br> | |||
<i>Header:</i> | <i>Header:</i> | ||
<table border='1'><tr><td>Bit 7</td><td>Bit 6</td><td>Bit 5 | <table border='1'> | ||
<tr><td>Bit 7</td><td>Bit 6</td><td>Bit 5 - 0</td></tr> | |||
<tr><td><i>Command/!Data</i></td><td><i>Parity</i></td><td>see below</td></tr> | |||
</table> | |||
<i>Note: Parity can be EVEN, ODD, XOR, NONE, Parity does include packetsize-Bits and all DATA</i><br> | <i>Note: Parity can be EVEN, ODD, XOR, NONE, Parity does include packetsize-Bits and all DATA</i><br> | ||
<i>Note: Command/!DATA marks this packet as COMMAND packet or as DATA packet</i><br> | <i>Note: Command/!DATA marks this packet as COMMAND packet or as DATA packet</i><br> | ||
<br> | <br> | ||
<b>COMMAND PACKET</b><br> | <b>COMMAND PACKET</b><br> | ||
<i>Header:</i><br> | |||
<table border='1'> | |||
<tr><td>Bit 7</td><td>Bit 6</td><td>Bit 5</td><td>Bit 4 - 1</td><td>Bit 0</td></tr> | |||
<tr><td>1</td><td><i>Parity</i></td><td><i>0 (reserved)</i></td><td>COMMAND</td><td>Data packet count</td></tr> | |||
</table> | |||
<br> | |||
<i>Packet:</i> | |||
<table border='1'> | <table border='1'> | ||
<tr><td>Header</td><td>Byte 1 | <tr><td>Header</td><td>Byte 1</td></tr> | ||
<tr><td>1XXXXXXX</td><td>DATA (only if <header:0> is set)</td></tr> | |||
</table> | </table> | ||
Zeile 52: | Zeile 65: | ||
<br> | <br> | ||
<b>DATA PACKET</b><br> | <b>DATA PACKET</b><br> | ||
<i>Header:</i><br> | |||
<table border='1'> | |||
<tr><td>Bit 7</td><td>Bit 6</td><td>Bit 5</td><td>Bit 4</td><td>Bit 3 - 0</td></tr> | |||
<tr><td>0</td><td><i>Parity</i></td><td><i>0 (reserved)</i></td><td><i>READ/!WRITE</i></td><td>Packetsize</td></tr> | |||
</table> | |||
<br> | |||
<i>Packet:</i><br> | |||
<table border='1'> | <table border='1'> | ||
<tr><td>Header</td><td>Byte 1</td><td>Byte 2</td><td>Byte 3</td><td>Byte 4</td><td>Byte 5</td><td>Byte 6</td><td>Byte 7</td><td>Byte 8</td></tr><tr><td>XX0XXXXX</td><td>DATA</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td></tr> | <tr><td>Header</td><td>Byte 1</td><td>Byte 2</td><td>Byte 3</td><td>Byte 4</td><td>Byte 5</td><td>Byte 6</td><td>Byte 7</td><td>Byte 8</td></tr><tr><td>XX0XXXXX</td><td>DATA</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td><td>DATA (optional)</td></tr> | ||
</table> | </table> | ||
<i>Note: READ/!WRITE is the direction of data transfers</i><br> | |||
handled by userprogram<br> | handled by userprogram<br> | ||
<br> | <br> |
Version vom 29. Januar 2010, 21:02 Uhr
I2C Protokoll
Version 0.4
DEFINITIONS
layer0 | Hardwareebene (i2c) |
layer1 | Packetebene |
endpoint | externe Hardware/Software (nicht näher definiert) |
Vorderungen
Device Overview
Device | ||
|---- | Endpoint 0 | |
|---- | Endpoint 1 | |
... | ||
|---- | Endpoint n | |
|---status_byte | ||
|---in_buffer | ||
|---out_buffer |
Packet
Overview
Packet:
Header | Data |
1 Byte | 1-8 Byte |
Header:
Bit 7 | Bit 6 | Bit 5 - 0 |
Command/!Data | Parity | see below |
Note: Parity can be EVEN, ODD, XOR, NONE, Parity does include packetsize-Bits and all DATA
Note: Command/!DATA marks this packet as COMMAND packet or as DATA packet
COMMAND PACKET
Header:
Bit 7 | Bit 6 | Bit 5 | Bit 4 - 1 | Bit 0 |
1 | Parity | 0 (reserved) | COMMAND | Data packet count |
Packet:
Header | Byte 1 |
1XXXXXXX | DATA (only if <header:0> is set) |
handled by layer1
DATA PACKET
Header:
Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 - 0 |
0 | Parity | 0 (reserved) | READ/!WRITE | Packetsize |
Packet:
Header | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 | Byte 8 |
XX0XXXXX | DATA | DATA (optional) | DATA (optional) | DATA (optional) | DATA (optional) | DATA (optional) | DATA (optional) | DATA (optional) |
Note: READ/!WRITE is the direction of data transfers
handled by userprogram
COMMANDS
all "get" commands load data into the out_buffer & change status to ready for read
all "set" commands store data into the in_buffer & change status to !ready for write
Note:
querry status first !
0x00
invalid (reserved)
0x01 PING
copies complement of inputbuffer to outputbuffer
to run bus-speed-test
0x02 GET DEVICE DESCRIPTOR
returns information about the device
max supported protocol version
endpoint count
...
0x03 GET DEVICE STATUS
return device status, for example:
ready for read
ready for write
...
0x04 GET ENDPOINT DESCRIPTOR
2.byte: endpoint
returns information about the endpoint
must be less then max. device endpoints
0x05 SET ENDPOINT
2.byte: endpoint
must be less then max. device endpoints
0x06 GET CURRENT ENDPOINT
return active endpoint (default: 0)
0x07 GET CENDPOINT STATUS
return current endpoint status, for example:
ready for read
ready for write
...
0x08 CONFIGURE ENDPOINT
manage power, enable/disable endpoint
...
0x09 GET AENDPOINT STATUS
return any endpoint status
2.byte: endpoint
for example:
ready for read
ready for write
...
DATA PACKET
Data packets are stored in the in_buffer of the current endpoint if READ/!WRITE is 0 & buffer is ready. The users programm is notified that theres new data.
Data packets are read from the out_buffer of the current endpoint if READ/!WRITE is 1 & buffer is ready. Packet-length field should be ignored. The users programm is notified that the host request new data.
Device Response
Header is ==0 NO VALID DATA
the buffer you read from was not ready
Header is > 0 DATA
VALID:
data-packet length should be greater than 0
packet parity does match
INVALID:
data-packet length is 0
packet parity doesn't match