beautypg.com

An194 – Cirrus Logic AN194 User Manual

Page 3

background image

AN194

AN194REV1

3

}

/******************************************************************************

*

* CalculateHashIndex()

*

******************************************************************************/

BYTE CalculateHashIndex( BYTE *pMulticastAddr )

{

BYTE HashIndex;

BYTE AddrByte;

int Byte;

int Bit, j;

/* Prime the CRC */

for (j = 0; j < 32; j++ ) CRC[j] = 1;

/* For each of the six bytes of the multicast address */

for ( Byte=0; Byte<6; Byte++ )

{

/*

printf("\n%2.2x", *pMulticastAddr);

(void) getchar();

*/

AddrByte = *pMulticastAddr++;

/* For each bit of the byte */

for ( Bit=0; Bit<8; Bit++ )

{

updatecrc( (AddrByte >> Bit) & 1 );

}

}

/* Take the least significant six bits of the CRC and copy them */

/* to the HashIndex in reverse order. */

HashIndex = 0;

for( Bit=0,HashIndex=0; Bit<6; Bit++ )

{

HashIndex = (HashIndex << 1) + CRC[Bit];