Benutzer:Siro/i2cprotokoll: Unterschied zwischen den Versionen

Aus LaborWiki
Wechseln zu: Navigation, Suche
K (Version 0.2)
KKeine Bearbeitungszusammenfassung
 
(6 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
== <b>I2C Protokoll</b> ==
== <b>I2C Protokoll</b> ==
Version 0.2
Version 0.4




Zeile 17: Zeile 17:
<li> Alle Daten werden in Paketen übertragen
<li> Alle Daten werden in Paketen übertragen
<li> Alle Daten werden vom Master "gepollt"
<li> Alle Daten werden vom Master "gepollt"
<li> Alle Devices können bis zu 254 Endpoints haben (<i>Endpoint 0 reserved</i>)
<li> Alle Devices müssen einen Endpoint 0 haben (das Device selber)
<li> Alle Devices können bis zu 254 Endpoints haben  
<li> Jeder Endpoint hat mind. 8 byte in-Buffer & mind. 8 byte out-Buffer  
<li> Jeder Endpoint hat mind. 8 byte in-Buffer & mind. 8 byte out-Buffer  
<li> Jeder Endpoint hat einen Status-Byte das Informationen über die Buffer bereitstellt
<li> Jeder Endpoint hat einen Status-Byte das Informationen über die Buffer bereitstellt




== Device Overwiev ==
== Device Overview ==
<table>
<table>
<tr><td>Device</td><td></td><td></td></tr>
<tr><td>Device</td><td></td><td></td></tr>
Zeile 29: Zeile 30:
<tr><td>&nbsp;&nbsp;</td><td>...</td><td></td></tr>
<tr><td>&nbsp;&nbsp;</td><td>...</td><td></td></tr>
<tr><td>&nbsp;&nbsp;</td><td>|----</td><td>Endpoint n</td></tr>
<tr><td>&nbsp;&nbsp;</td><td>|----</td><td>Endpoint n</td></tr>
<tr><td>&nbsp;&nbsp;</td><td></td><td>&nbsp;&nbsp;&nbsp;|---status_byte</td></tr>
<tr><td>&nbsp;&nbsp;</td><td></td><td>&nbsp;&nbsp;&nbsp;|---in_buffer</td></tr>
<tr><td>&nbsp;&nbsp;</td><td></td><td>&nbsp;&nbsp;&nbsp;|---in_buffer</td></tr>
<tr><td>&nbsp;&nbsp;</td><td></td><td>&nbsp;&nbsp;&nbsp;|---out_buffer</td></tr>
<tr><td>&nbsp;&nbsp;</td><td></td><td>&nbsp;&nbsp;&nbsp;|---out_buffer</td></tr>
Zeile 34: Zeile 36:


== 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</td><td>Bit 4</td><td>Bit 3 - 0</td></tr><tr><td><i>reserved</i></td><td><i>reserved</i></td><td>Command/!Data</td><td>Parity</td><td>Packetsize</td></tr></table>
<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 either 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'>
<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>XX1XXXXX</td><td>COMMAND</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>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 (0 or 1)</td></tr>
</table>
<br>
<i>Packet:</i>
<table border='1'>
<tr><td>Header</td><td>Byte 1</td></tr>
<tr><td>1X0XXXXX</td><td>DATA (only if <header:0> is set)</td></tr>
</table>
</table>


Zeile 51: Zeile 66:
<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>0X0XXXXX</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>
Zeile 71: Zeile 94:
copies complement of inputbuffer to outputbuffer<br>
copies complement of inputbuffer to outputbuffer<br>
to run bus-speed-test<br>
to run bus-speed-test<br>
<br><b>0x02</b>&nbsp;&nbsp;&nbsp;&nbsp;GET DEVICE DESCRIPTOR<br>
<br><b>0x02</b>&nbsp;&nbsp;&nbsp;&nbsp;GET AENDPOINT DESCRIPTOR<br>
returns information about the device<br>
max supported protocol version<br>
endpoint count<br>
...<br>
<br><b>0x03</b>&nbsp;&nbsp;&nbsp;&nbsp;GET DEVICE STATUS<br>
return device status, for example:<br>
ready for read<br>
ready for write<bR>
...<br>
<br><b>0x04</b>&nbsp;&nbsp;&nbsp;&nbsp;GET ENDPOINT DESCRIPTOR<br>
2.byte: endpoint<br>
2.byte: endpoint<br>
returns information about the endpoint<br>
returns information about any endpoint<br>
can be display, soundd. ,networkd. ,inputd. ...<br>
must be less then max. device endpoints<br>
must be less then max. device endpoints<br>
<br><b>0x05</b>&nbsp;&nbsp;&nbsp;&nbsp;SET ENDPOINT<br>
<br><b>Endpoint 0</b>&nbsp;&nbsp;&nbsp;&nbsp;GET DEVICE DESCRIPTOR<br>
returns information about the device<br>
<table border='1'>
<tr><td>Header</td><td>DATA1</td><td>DATA2</td><td>DATA3</td></tr>
<tr><td bgcolor=grey></td><td><i>protocol version</i></td><td><i>endpoint count</i></td><td>-</td></tr>
</table>
 
<br><b>0x03</b>&nbsp;&nbsp;&nbsp;&nbsp;SET CURRENT ENDPOINT<br>
2.byte: endpoint<br>
2.byte: endpoint<br>
must be less then max. device endpoints<br>
must be less then max. device endpoints<br>
<br><b>0x06</b>&nbsp;&nbsp;&nbsp;&nbsp;GET CURRENT ENDPOINT<br>
<br><b>0x04</b>&nbsp;&nbsp;&nbsp;&nbsp;GET CURRENT ENDPOINT<br>
return active endpoint (default: 0)<br>
return active endpoint (default: 0)<br>
<br><b>0x07</b>&nbsp;&nbsp;&nbsp;&nbsp;GET CENDPOINT STATUS<br>
<br><b>0x05</b>&nbsp;&nbsp;&nbsp;&nbsp;GET CENDPOINT STATUS<br>
return current endpoint status, for example:<br>
return current endpoint status, for example:<br>
ready for read<br>
ready for read<br>
ready for write<bR>
ready for write<bR>
packet was dropped<br>
packet was invalid<br>
...<br>
...<br>
<br><b>0x08</b>&nbsp;&nbsp;&nbsp;&nbsp;CONFIGURE ENDPOINT<br>
<br><b>0x06</b>&nbsp;&nbsp;&nbsp;&nbsp;CONFIGURE ENDPOINT<br>
manage power, enable/disable endpoint<br>
manage power, enable/disable endpoint<br>
...<br>
...<br>
<br><b>0x09</b>&nbsp;&nbsp;&nbsp;&nbsp;GET AENDPOINT STATUS<br>
<br><b>0x07</b>&nbsp;&nbsp;&nbsp;&nbsp;GET AENDPOINT STATUS<br>
return any endpoint status<br>
return any endpoint status<br>
2.byte: endpoint<br>
2.byte: endpoint<br>
Zeile 105: Zeile 128:
ready for write<bR>
ready for write<bR>
...<br>
...<br>
== 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 ==
== Device Response ==

Aktuelle Version vom 1. Februar 2010, 17:43 Uhr

I2C Protokoll[Bearbeiten | Quelltext bearbeiten]

Version 0.4


DEFINITIONS[Bearbeiten | Quelltext bearbeiten]

layer0Hardwareebene (i2c)
layer1Packetebene
endpoint    externe Hardware/Software (nicht näher definiert)


Vorderungen[Bearbeiten | Quelltext bearbeiten]

  • Alle Devices sollen die max. Busgeschwindigkeit verwenden
  • Alle Daten werden in Paketen übertragen
  • Alle Daten werden vom Master "gepollt"
  • Alle Devices müssen einen Endpoint 0 haben (das Device selber)
  • Alle Devices können bis zu 254 Endpoints haben
  • Jeder Endpoint hat mind. 8 byte in-Buffer & mind. 8 byte out-Buffer
  • Jeder Endpoint hat einen Status-Byte das Informationen über die Buffer bereitstellt

    Device Overview[Bearbeiten | Quelltext bearbeiten]

    Device
      |----Endpoint 0
      |----Endpoint 1
      ...
      |----Endpoint n
         |---status_byte
         |---in_buffer
         |---out_buffer

    Packet[Bearbeiten | Quelltext bearbeiten]

    Overview
    Packet:

    HeaderData
    1 Byte1-8 Byte


    Header:

    Bit 7Bit 6Bit 5 - 0
    Command&!DataParitysee below

    Note: Parity can be EVEN, ODD, XOR, NONE, Parity does include packetsize-Bits and all DATA
    Note: Command&!DATA marks this packet as either COMMAND packet or as DATA packet

    COMMAND PACKET
    Header:

    Bit 7Bit 6Bit 5Bit 4 - 1Bit 0
    1Parity0 (reserved)COMMANDData packet count (0 or 1)


    Packet:

    HeaderByte 1
    1X0XXXXXDATA (only if <header:0> is set)

    handled by layer1

    DATA PACKET
    Header:

    Bit 7Bit 6Bit 5Bit 4Bit 3 - 0
    0Parity0 (reserved)READ&!WRITEPacketsize


    Packet:

    HeaderByte 1Byte 2Byte 3Byte 4Byte 5Byte 6Byte 7Byte 8
    0X0XXXXXDATADATA (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[Bearbeiten | Quelltext bearbeiten]

    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:

  • if in_buffer is full/not ready to write the data is dropped
  • if out_buffer is not ready for read, 0 is returned
    querry status first !

    0x00
    invalid (reserved)

    0x01    PING
    copies complement of inputbuffer to outputbuffer
    to run bus-speed-test

    0x02    GET AENDPOINT DESCRIPTOR
    2.byte: endpoint
    returns information about any endpoint
    can be display, soundd. ,networkd. ,inputd. ...
    must be less then max. device endpoints

    Endpoint 0    GET DEVICE DESCRIPTOR
    returns information about the device
    HeaderDATA1DATA2DATA3
    protocol versionendpoint count-


    0x03    SET CURRENT ENDPOINT
    2.byte: endpoint
    must be less then max. device endpoints

    0x04    GET CURRENT ENDPOINT
    return active endpoint (default: 0)

    0x05    GET CENDPOINT STATUS
    return current endpoint status, for example:
    ready for read
    ready for write
    packet was dropped
    packet was invalid
    ...

    0x06    CONFIGURE ENDPOINT
    manage power, enable/disable endpoint
    ...

    0x07    GET AENDPOINT STATUS
    return any endpoint status
    2.byte: endpoint
    for example:
    ready for read
    ready for write
    ...


    DATA PACKET[Bearbeiten | Quelltext bearbeiten]

    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[Bearbeiten | Quelltext bearbeiten]

    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