User guide

12 HDMI5 Component Video Switch
Source Code Example of Calculating a CRC-8 Checkcode
The following is a simple “C” program that calculates the CRC-8 of the string “TestString” and
then prints the initial string with the calculated CRC-8 checkcode appended to it.
#include "stdio.h"
// Routine for updating the CRC-8 checkcode using a polynomial
// of: x^8 +x^6 +x^3 +x^2 + 1.
//
// To create the CRC8_POLY mask, we start by ignoring the highest
// bit (x^8) since it is assumed to always be 1 and lies outside
// our byte boundary, and doesn't affect our results.
//
// The rest of the bits of the polynomial are reversed from the
// polynomial's order. This allows us to read in each bit starting
// with bit 0 of each byte, instead of bit 7. This is done because
// the UART sends its LSB rst and by doing the same we are able to
// preserve the CRC's burst error detection characteristics.
//
// So:
// x^8 +x^6 +x^3 +x^2 + 1 = 101001101 = 14D hex
// Ignore X^8: 01001101 = 4D hex
// Reverse bit order: 10110010 = B2 hex
#de ne CRC8_POLY 0xB2 // polynomial mask
#de ne CRC8_INIT 0xFF // initial value
void crcByte( unsigned char *crc8, char cc)
{
unsigned char lcrc8; // local copy of CRC-8 value
int bitcount;
lcrc8 = *crc8; // get local copy of CRC-8
// update CRC-8 with 8 new bits
lcrc8 ^= cc; // test each bit against CRC-8
for (bitcount = 0; bitcount < 8; bitcount++)
{
// if resultant bit was a 1, shift and xor in mask
// else, just shift
if (lcrc8 & 0x01)
lcrc8 = ((lcrc8 >> 1) & 0x7F) ^ CRC8_POLY;
else
lcrc8 = (lcrc8 >> 1) & 0x7F;
}
*crc8 = lcrc8; // return new CRC8
}
Checksums and CRC-8’s (Contd)
17HDMI5 Component Video Switch
Where ‘mode’ settings are:
0 = Turn off front panel lights.
1 = Front panel lights are always at DIM level.
2 = Front panel lights are always at BRIGHT level.
3 = Front panel lights AUTODIM after 4 seconds.
The DIM and BRIGHT intensities range from 0=Off, to 106=Maximum brightness. You cannot set
the DIM level to be higher than or equal to the BRIGHT setting. Any attempt to do so will return
an ‘out of range’ error.
Save Power On Default Settings
Saves the current HDMI5 settings as the power on default settings.
S $ Save current settings.
S 246,$ Restore all settings to their factory defaults.
There is no Response String for this command.
Note: Any value given, other than ‘246’, will generate a range error.
Query Last IR Code Received
This command allows the controller to read the hash values returned by Zektor’s IIR™ (Intel-
ligent Infra-Red) decoding rmware. Zektors IIR™ algorithm converts all IR codes it receives to
a compressed, 72 bit value.
Each different key press of a remote control will generate a different but repeatable pattern.
This command returns a value for every IR code detected by the front panel IR sensor (or IR
jack if enabled), regardless as to whether the IR code detected was used to control the HDMI5.
The uses for this command are two fold:
1) The value returned from this command are the same values used to teach the HDMI5 new IR
codes over the serial port. (See the “Set Learnable IR Command Codes” command).
2) This command gives the controller full access to the HDMI5’s IR sensor and Zektors IIR™
algorithm. This is a very reliable way of adding IR control to any project. The IR codes generated
by Zektor’s IIR™ algorithm are immune to timing differences between universal remote control
manufacturers and to the timing errors associated with condition of the remote control’s battery.
Note 1: The Zektor’s IIR™ algorithm works with any remote control code that is time modulated.
This is pretty much every type of IR code except the Phillips RC-5, and RC-6 codes.
Note 2: Because very few controllers could handle a 72 bit decimal value, and in an effort to
HDMI5 Command Ref. (Contd)