EasyManua.ls Logo

ST ST7 - Page 278

ST ST7
317 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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 )

Table of Contents

Related product manuals