Benutzer:Siro/i2cprotokoll: Unterschied zwischen den Versionen

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




Zeile 38: Zeile 38:


<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</td><td>Bit 4</td><td>Bit 3 - 0</td></tr><tr><td><i>reserved</i></td><td><i>READ/!WRITE</i></td><td>Command/!Data</td><td>Parity</td><td>Packetsize</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>
<i>Note: READ/!WRITE is the direction of data transfers</i><br>
<br>
<br>
<b>COMMAND PACKET</b><br>
<b>COMMAND PACKET</b><br>
Zeile 79: Zeile 80:
return device status, for example:<br>
return device status, for example:<br>
ready for read<br>
ready for read<br>
ready for write<bR>
ready for write<br>
...<br>
...<br>
<br><b>0x04</b>&nbsp;&nbsp;&nbsp;&nbsp;GET ENDPOINT DESCRIPTOR<br>
<br><b>0x04</b>&nbsp;&nbsp;&nbsp;&nbsp;GET ENDPOINT DESCRIPTOR<br>
Zeile 105: Zeile 106:
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 ==

Version vom 29. Januar 2010, 13:42 Uhr

I2C Protokoll

Version 0.3


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 Overview

    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
    reservedREAD/!WRITECommand/!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
    Note: READ/!WRITE is the direction of data transfers

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

    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