<!-- 
//==================================================\\
||Protocol definitions file for IR protocol analyzer||
\\==================================================//
  
  XML protocol description originaly developed by 
  Ondrej Stanek, www.ostan.cz, ostan89@gmail.com
  2009-2010
 
Structure of this file was designed with a respect to user,
who may want to extend the protocol description database by himself.

Feel free to edit this file.

Any new XML protocol definitions are welcome, please send them to my email.
I will add your definition to new release of this file. Thanks. 
    
(Most protocol definitions were taken from http://www.sbprojects.com/knowledge/ir/ir.htm) 

-->
<protocols>
  <protocol name="Sony SIRC"> <!-- Attribute 'name' is essential and its value must be unique. --> 

  <!-- Section <description> is essential. Parameter 'url' should contain full web address (including the http:// prefix), or it can be entirely omitted. --> 
  <description url="http://www.sbprojects.com/knowledge/ir/sirc.htm">
    <!-- content of <description> section can be left blank if necessary -->
    The SIRC protocol uses a pulse width encoding of the bits. The pulse representing a logical "1" is a 1.2ms long burst of the 40kHz carrier, while the burst width for a logical "0" is 0.6ms long. All bursts are separated by a 0.6ms long space interval. The recommended carrier duty-cycle is 1/4 or 1/3. 
    With this protocol the LSB is transmitted first. The start burst is always 2.4ms wide, followed by a standard space of 0.6ms. Apart from signalling the start of a SIRC message this start burst is also used to adjust the gain of the IR receiver. Then the 7-bit Command is transmitted, followed by the 5-bit Device address. 
    Commands are repeated every 45ms(measured from start to start) for as long as the key on the remote control is held down.
  </description>
 
  <!-- Section <bitset> describes how 1s and 0s are coded. -->
  <bitset>
    <!--
    Tag <bit> contain time periods in microseconds (us). Prefix # or _ signalizes whether is it mark (#) or space (_) 
    Prefixes # and _ must alternate, its forbidden to use two same prefixes subsequently
    (In fact, only the first prefix in a tag is loaded by the program,
     rest prefixes are supposed to alternate and therefore they are neglected) 
    -->
    <bit value="1">  #1200 _600  </bit> 
    <bit value="0"> #600 _600  </bit>
  </bitset> 

  <packet><!-- section <packet> describes packet structure and is essential -->
    <!-- Two tags are allowed in <packet> section; <delimiter> and <data> -->
    <!-- Delimiter describes special separators, such as startbits and stopbits.
     Time periods are stated same way as in <bit> tag.
     Attribute 'name' is essential.
     First time period in a packet MUST be a mark (must have the # prefix).  
      -->
    <delimiter name="startbit">#2400 _600</delimiter>
    <!-- <data> tag describes group of bits
      attributes (all are essential):
        name - any string describing data type
        length - count of bits in data group 
        bitorder - LSB - least significant bit first
                   MSB - most significant bit first -->
    <data name="command" length="7" bitorder="LSB" />
    <data name="address" length="5" bitorder="LSB" />
  </packet>

  </protocol>
  
  <protocol name="NEC">
    <description url="http://www.sbprojects.com/knowledge/ir/nec.htm">
      The NEC protocol uses pulse distance encoding of the bits. Each pulse is a 560us long 38kHz carrier burst (about 21 cycles). A logical "1" takes 2.25ms to transmit, while a logical "0" is only half of that, being 1.125ms. The recommended carrier duty-cycle is 1/4 or 1/3.     
      A message is started by a 9ms AGC burst, which was used to set the gain of the earlier IR receivers. This AGC burst is then followed by a 4.5ms space, which is then followed by the Address and Command. Address and Command are transmitted twice. The second time all bits are inverted and can be used for verification of the received message. The total transmission time is constant because every bit is repeated with its inverted length. If you're not interested in this reliability you can ignore the inverted values, or you can expand the Address and Command to 16 bits each!</description>
    <bitset>
      <bit value="1"> #560 _1690  </bit>
      <bit value="0"> #560 _560  </bit>
    </bitset>
    <packet>
      <delimiter name="startbit">#9000 _4500</delimiter>
      <data name="address" length="16" bitorder="LSB" />
      <data name="command" length="8" bitorder="LSB" />
      <data name="!command" length="8" bitorder="LSB" />
      <delimiter name="stopbit">#560</delimiter>
    </packet>
  
  </protocol>

  <protocol name="NEC (repeat code)">
    <description url="http://www.sbprojects.com/knowledge/ir/nec.htm">
      A command is transmitted only once, even when the key on the remote control remains pressed. Every 110ms a repeat code is transmitted for as long as the key remains down. This repeat code is simply a 9ms AGC pulse followed by a 2.25ms space and a 560us burst
    </description>
    
    <packet>
      <delimiter name="startbit">#9000 _2250</delimiter>
      <delimiter name="stopbit">#560</delimiter>
    </packet>
  
  </protocol>

  <protocol name="RC-5">
   
    <description url="http://www.sbprojects.com/knowledge/ir/rc5.htm">
      The RC-5 code from Philips is possibly the most used protocol by hobbyists, probably because of the wide availability of cheap remote controls. 
      The protocol is well defined for different device types ensuring compatibility with your whole entertainment system. 
      The protocol uses bi-phase modulation (or so-called Manchester coding) of a 36kHz IR carrier frequency. All bits are of equal length of 1.778ms in this protocol, with half of the bit time filled with a burst of the 36kHz carrier and the other half being idle. A logical zero is represented by a burst in the first half of the bit time. A logical one is represented by a burst in the second half of the bit time. The pulse/pause ratio of the 36kHz carrier frequency is 1/3 or 1/4 which reduces power consumption. 

      The first two pulses are the start pulses, and are both logical "1". Please note that half a bit time is elapsed before the receiver will notice the real start of the message. 
      
      The 3rd bit is a toggle bit. This bit is inverted every time a key is released and pressed again. This way the receiver can distinguish between a key that remains down, or is pressed repeatedly. 
      The next 5 bits represent the IR device address, which is sent with MSB first. The address is followed by a 6 bit command, again sent with MSB first. 
      A message consists of a total of 14 bits, which adds up to a total duration of 25 ms. Sometimes a message may appear to be shorter because the first half of the start bit S1 remains idle. And if the last bit of the message is a logic "0" the last half bit of the message is idle too.
      
      As long as a key remains down the message will be repeated every 114ms. The toggle bit will retain the same logical level during all of these repeated messages. It is up to the receiver software to interpret this auto repeat feature.
    </description>
   
    <bitset>
      <bit value="1"> _889 #889 </bit>
      <bit value="0"> #889 _889  </bit>
    </bitset>
            
    <packet>
      <delimiter name="startbit">#889 _889 #889</delimiter>
      <data name="togglebit" length="1" bitorder="MSB" />
      <data name="address" length="5" bitorder="MSB" />
      <data name="command" length="6" bitorder="MSB" />
    </packet>
  
  </protocol>

  <protocol name="RC-5 extended">
   
    <description url="http://www.sbprojects.com/knowledge/ir/rc5.htm">
      Extended RC-5 uses only one start bit. Bit S2 is transformed to command bit 6, providing for a total of 7 command bits. The value of S2 must be inverted to get the 7th command bit though!
    </description>
   
    <bitset>
      <bit value="1"> _889 #889 </bit>
      <bit value="0"> #889 _889  </bit>
    </bitset>
            
    <packet>
      <delimiter name="startbit">#889</delimiter>
      <data name="commandBit6" length="1" bitorder="MSB" />
      <data name="togglebit" length="1" bitorder="MSB" />
      <data name="address" length="5" bitorder="MSB" />
      <data name="command" length="6" bitorder="MSB" />
    </packet>
  
  </protocol>
  
  <protocol name="Panasonic">
   
    <description>
      Protocol used in Panasonic DVD players and TVs. I didn't find any description of this protocol, so I made it up by myself. Bear in mind that data may be coded differently!  
    </description>
   
    <bitset>
      <bit value="1"> #440 _1300 </bit>
      <bit value="0"> #440 _440  </bit>
    </bitset>
            
    <packet>
      <delimiter name="startbit">#3500 _1700</delimiter>
      <data name="byte0" length="8" bitorder="LSB" />
      <data name="byte1" length="8" bitorder="LSB" />
      <data name="byte2" length="8" bitorder="LSB" />
      <data name="byte3" length="8" bitorder="LSB" />
      <data name="byte4" length="8" bitorder="LSB" />
      <data name="byte5" length="8" bitorder="LSB" />
      <delimiter name="stopbit">#440</delimiter>
    </packet>
  
  </protocol>

 <protocol name="Silverlit PicoZ">
  <description>
   Silverlit PicoZ remote control.
  </description>

  <bitset>
    <bit value="1">  #1250 _1200  </bit> 
    <bit value="0"> #650 _600  </bit>
  </bitset> 

  <packet>
    <delimiter name="startbit">#600 _600 #1250 _2979 #1950 _600</delimiter>
    <data name="channel" length="2" bitorder="MSB" />
    <data name="throttle" length="4" bitorder="MSB" />
    <data name="trim left" length="1" bitorder="MSB" />
    <data name="trim right" length="1" bitorder="MSB" />
    <data name="direction" length="3" bitorder="MSB" />
    <data name="trigger" length="4" bitorder="MSB" />
    <data name="unknown" length="3" bitorder="MSB" />
    <delimiter name="stopbit">#650</delimiter>
  </packet>

 </protocol>

 <protocol name="RCA">
    <description >
	24 bit Protocol used in RCA sound systems. It looks similar to NEC. (38 khz) I didn't find any description of this protocol, so I made it up by myself. Bear in mind that data may be coded differently! --Chad Carisch
    </description>
  <bitset>
    <bit value="1"> #562 _1937  </bit>
    <bit value="0"> #562 _937  </bit>
  </bitset>
  <packet>
    <delimiter name="startbit">#4062 _3937</delimiter>
    <data name="byte0" length="8" bitorder="LSB" />
    <data name="byte1" length="8" bitorder="LSB" />
    <data name="byte2" length="8" bitorder="LSB" />
    <delimiter name="stopbit">#562</delimiter>
  </packet>
  
 </protocol>

</protocols>
