278/317
9 - A Carrier-current System for domestIc Remote Control
case 43 :
TempKeyCode >>= 1 ;
/* Shift right by one bit */
if ( CarrierDetected )
TempKeyCode |= 0x10 ;
/* Set least-significant bit to
one */
break ;
/* Key code has five bits */
case 14 :
case 16 :
case 18 :
case 20 :
case 22 :
/* Check that the next even bit sent is the complement
of the odd one. */
case 36 :
case 38 :
case 40 :
case 42 :
case 44 :
if ( ( ( TempKeyCode & 0x10 ) != 0 ) == CarrierDetected )
CycleNumber = 1 ;
/*
Reset the whole process if
incorrect check bit. */
break ;
case 45 :
CycleNumber = 1 ;
/* Stream terminated: reset cycle
counter. */
/* Check that the command is received twice identically */
if ( ( TempHouseCode2 == TempHouseCode ) && ( TempKeyCode2
== TempKeyCode ) )
{
HouseCode = TempHouseCode ;
/* Make data received
accessible to main program. */
KeyCode = TempKeyCode ;
}
break ;
default :
CycleNumber = 1 ;
/*
Reset the whole process if
incorrect bit number. */
break ;
}
}
The first thing this function does is to read the analog voltage at the output of the detector.
Then, for each bit position, the value of the bit is either recorded or checked against the rules
set forth by the X10 standard. The bits are recorded by adding them at the fourth or fifth place
for the House Code, or the Key Code, respectively, after the code has been shifted right by
one place:
TempKeyCode >>= 1 ;
/* Shift right by one bit */
if ( CarrierDetected )
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...