LRC CALCULATION, (CON’T)
The following C language function
is an example of an LRC
calculation program. It accepts
two arguments: a pointer to a
buffer and a buffer length. Its
return value is the LRC value for
the specified buffer.
char Calculate LRC (char buffer,
size buffer)
{
char LRC;
size_t index;
/*
* Init the LRC using the first two
message bytes.
*/
LRC = buffer [0] ^ buffer [1];
/*
* Update the LRC using the
remainder of the buffer.
*/
for (index = 2; index < buffer; index
++)
LRC ^ = buffer[index];
/*
* If the MSB is set then clear the
MSB and change the next most
significant bit
*/
if (LRC & 0x80)
LRC ^ = 0xC0;
/* * Return the LRC value for the
buffer.*/}
COMMANDS FROM THE UR5HCSPI TO THE HOST, (CON’T)
LED Status Report
<CONTROL>
80H
<LED>
A3H
<Status 0>
xxH LED0 status:( 0=OFF; 1=ON;
2=BLINKING; 3=NO LED MODE )
<Status 1>
xxH LED1 status:( 0=OFF; 1=ON;
2=BLINKING; 3=NO LED MODE )
<Status 2>
xxH LED2 status:( 0=OFF; 1=ON;
2=BLINKING; 3=NO LED MODE)
<LRC>
xxH
The UR5HCSPI will send the LED Status Report to the host when it receives
the LED Status Request Command from the host.
Resend Request
<CONTROL>
80H
<RESEND>
A5H
<LRC>
25H
The UR5HCSPI will send this Resend Request Command to the host when
its command buffer is full, or if it detects either a parity error or an unknown
command during a system command transmission.
Copyright Semtech 1997-2001
12
DOC5-SPI-DS-117
www.semtech.com