Benutzer:Siro/i2cprotokoll: Unterschied zwischen den Versionen

Aus LaborWiki
Wechseln zu: Navigation, Suche
Keine Bearbeitungszusammenfassung
K (Version 0.2)
Zeile 1: Zeile 1:
== <b>I2C Protokoll</b> ==
== <b>I2C Protokoll</b> ==
Version 0.1
Version 0.2




Zeile 8: Zeile 8:
<tr><td>layer0</td><td>Hardwareebene (i2c)</td></tr>
<tr><td>layer0</td><td>Hardwareebene (i2c)</td></tr>
<tr><td>layer1</td><td>Packetebene</td></tr>
<tr><td>layer1</td><td>Packetebene</td></tr>
<tr><td>endpoint&nbsp;&nbsp;&nbsp;&nbsp;</td><td>externe Hardware (nicht näher definiert)</td></tr>
<tr><td>endpoint&nbsp;&nbsp;&nbsp;&nbsp;</td><td>externe Hardware/Software (nicht näher definiert)</td></tr>
</table>
</table>
<br>
<br>
Zeile 18: Zeile 18:
<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 können bis zu 254 Endpoints haben (<i>Endpoint 0 reserved</i>)
<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


== <i>Packet</i> ==
 
== Device Overwiev ==
<table>
<tr><td>Device</td><td></td><td></td></tr>
<tr><td>&nbsp;&nbsp;</td><td>|----</td><td>Endpoint 0</td></tr>
<tr><td>&nbsp;&nbsp;</td><td>|----</td><td>Endpoint 1</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>&nbsp;&nbsp;&nbsp;|---in_buffer</td></tr>
<tr><td>&nbsp;&nbsp;</td><td></td><td>&nbsp;&nbsp;&nbsp;|---out_buffer</td></tr>
</table>
 
== Packet ==


<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>
Zeile 30: Zeile 44:
<br>
<br>
<b>COMMAND PACKET</b><br>
<b>COMMAND PACKET</b><br>
COMMAND PACKET: size >= 1<br>
<table border='1'>
1. byte: COMMAND<br>
<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>
2. - 8. byte:DATA (optional)<br>
</table>
 
handled by layer1<br>
handled by layer1<br>
<br>
<br>
<b>DATA PACKET</b><br>
<b>DATA PACKET</b><br>
<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>
</table>
handled by userprogram<br>
handled by userprogram<br>
<br>
<br>


== COMMANDS ==
== COMMANDS ==
all "get" commands load data into the out_buffer & change status to ready for read<br>
all "set" commands store data into the in_buffer & change status to !ready for write<br>
<i>Note: <br>
<li>if in_buffer is full/not ready to write the data is dropped
<li>if out_buffer is not ready for read, 0 is returned
<br>
<br>
<b>0x00</b><br>
querry status first !<br>
NOP<br>
</i>
<b>0x01</b><br>
<br><b>0x00</b><br>
GET DEVICE INFO<br>
invalid (reserved)<br>
<br><b>0x01</b>&nbsp;&nbsp;&nbsp;&nbsp;PING<br>
copies complement of inputbuffer to outputbuffer<br>
to run bus-speed-test<br>
<br><b>0x02</b>&nbsp;&nbsp;&nbsp;&nbsp;GET DEVICE DESCRIPTOR<br>
returns information about the device<br>
returns information about the device<br>
max supported protocol version<br>
max supported protocol version<br>
endpoint count<br>
endpoint count<br>
...<br>
...<br>
<b>0x02</b><br>
<br><b>0x03</b>&nbsp;&nbsp;&nbsp;&nbsp;GET DEVICE STATUS<br>
GET ENDPOINT INFO<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 the endpoint<br>
must be less then max. device endpoints<br>
must be less then max. device endpoints<br>
<b>0x03</b><br>
<br><b>0x05</b>&nbsp;&nbsp;&nbsp;&nbsp;SET ENDPOINT<br>
SET 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>
<b>0x04</b><br>
<br><b>0x06</b>&nbsp;&nbsp;&nbsp;&nbsp;GET CURRENT ENDPOINT<br>
GET CURRENT ENDPOINT<br>
return active endpoint (default: 0)<br>
return active endpoint (default: 0)<br>
<b>0x05</b><br>
<br><b>0x07</b>&nbsp;&nbsp;&nbsp;&nbsp;GET CENDPOINT STATUS<br>
return current endpoint status, for example:<br>
ready for read<br>
ready for write<bR>
...<br>
<br><b>0x08</b>&nbsp;&nbsp;&nbsp;&nbsp;CONFIGURE ENDPOINT<br>
manage power, enable/disable endpoint<br>
...<br>
<br><b>0x09</b>&nbsp;&nbsp;&nbsp;&nbsp;GET AENDPOINT STATUS<br>
return any endpoint status<br>
2.byte: endpoint<br>
for example:<br>
ready for read<br>
ready for write<bR>
...<br>
 
== Device Response ==


<b>0x06</b><br>
<b> Header is ==0</b>&nbsp;&nbsp;&nbsp;&nbsp;NO VALID DATA<br>
the buffer you read from was not ready<br>
<b> Header is > 0</b>&nbsp;&nbsp;&nbsp;&nbsp;DATA<br>
VALID:<br>
data-packet length should be greater than 0<br>
packet parity does match<br>
INVALID:<br>
data-packet length is 0<br>
packet parity doesn't match<br>

Version vom 29. Januar 2010, 13:27 Uhr

I2C Protokoll

Version 0.2


DEFINITIONS

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


Vorderungen

  • Alle Devices sollen die max. Busgeschwindigkeit verwenden
  • Alle Daten werden in Paketen übertragen
  • Alle Daten werden vom Master "gepollt"
  • Alle Devices können bis zu 254 Endpoints haben (Endpoint 0 reserved)
  • 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 Overwiev

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

    Packet

    HeaderData
    1 Byte1-8 Byte

    Header:

    Bit 7Bit 6Bit 5Bit 4Bit 3 - 0
    reservedreservedCommand/!DataParityPacketsize

    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

    HeaderByte 1Byte 2Byte 3Byte 4Byte 5Byte 6Byte 7Byte 8
    XX1XXXXXCOMMANDDATA (optional)DATA (optional)DATA (optional)DATA (optional)DATA (optional)DATA (optional)DATA (optional)

    handled by layer1

    DATA PACKET

    HeaderByte 1Byte 2Byte 3Byte 4Byte 5Byte 6Byte 7Byte 8
    XX0XXXXXDATADATA (optional)DATA (optional)DATA (optional)DATA (optional)DATA (optional)DATA (optional)DATA (optional)

    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:

  • 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 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
    ...

    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