📄 crcgen.c
字号:
/***********************************************************************************/
/* IS54 Baseband Simulation Software */
/* */
/* File Description : IS54 VSELP CRC Generator */
/* File Name : crcgen.c */
/* Date : 12/30/93 */
/* : July, 20001 - Modified for TMS320C55x project */
/* */
/* This file contains the function crcgen(), which takes a pointer */
/* to an array of IS54 VSELP parameters, extracts the CRC bits from */
/* the VSELP parameters, and then applies a generator polynomial to */
/* generate an output CRC which is re-stored back into the CRC field */
/* of the VSELP parameter array. */
/* */
/* Inputs: */
/* vselp : Pointer to array of VSELP parameters */
/* */
/* Outputs: */
/* vselp[CRC] : The CRC field of the VSELP parameter array */
/* is updated with a re-generated CRC value. */
/* */
/* Return Value: */
/* NONE */
/* */
/***********************************************************************************/
/* Include Files */
#include "vselp.h"
/* Defines */
#define BIT0 0x0001
#define BIT1 0x0002
#define BIT2 0x0004
#define BIT3 0x0008
#define BIT4 0x0010
#define BIT5 0x0020
#define BIT6 0x0040
#define BIT7 0x0080
#define BIT8 0x0100
#define BIT9 0x0200
#define BIT10 0x0400
#define BIT11 0x0800
#define TEST_BIT(num,mask) (num & mask)
/* Function Prototypes */
void crcgen( unsigned * );
/* External Function Prototypes */
/* Data */
/* External Data */
/* Code */
void crcgen( unsigned *vselp )
{
long unsigned crcseed; /* generator polynomial */
long unsigned crcin; /* CRC embedded in VSELP data */
long unsigned remain; /* crc remainder */
long unsigned mask; /* mask to AND with crcin to
determine whether MSB is 1 or 0 */
int i; /* index value */
/* Extract CRC bits from VSELP parameters */
crcin = 0;
if( TEST_BIT( vselp[ VSELP_LPC5 ], BIT3 ) ) crcin |= BIT0;
if( TEST_BIT( vselp[ VSELP_LPC3 ], BIT3 ) ) crcin |= BIT1;
if( TEST_BIT( vselp[ VSELP_LPC1 ], BIT3 ) ) crcin |= BIT2;
if( TEST_BIT( vselp[ VSELP_LPC2 ], BIT3 ) ) crcin |= BIT3;
if( TEST_BIT( vselp[ VSELP_LPC4 ], BIT3 ) ) crcin |= BIT4;
if( TEST_BIT( vselp[ VSELP_LPC1 ], BIT4 ) ) crcin |= BIT5;
if( TEST_BIT( vselp[ VSELP_LPC3 ], BIT4 ) ) crcin |= BIT6;
if( TEST_BIT( vselp[ VSELP_LPC2 ], BIT4 ) ) crcin |= BIT7;
if( TEST_BIT( vselp[ VSELP_R0 ], BIT2 ) ) crcin |= BIT8;
if( TEST_BIT( vselp[ VSELP_LPC1 ], BIT5 ) ) crcin |= BIT9;
if( TEST_BIT( vselp[ VSELP_R0 ], BIT3 ) ) crcin |= BIT10;
if( TEST_BIT( vselp[ VSELP_R0 ], BIT4 ) ) crcin |= BIT11;
/* Apply generator polynomial to CRC bits to generate CRC */
mask = (long unsigned)0x00040000L;
remain = crcin << 7;
crcseed = (long unsigned)0x0005b800L;
for(i = 0; i < 12; i++)
{
if( remain & mask ) remain ^= crcseed;
mask >>= 1;
crcseed >>= 1;
}
/* Update CRC field in VSELP parameter array */
vselp[ VSELP_CRC ] = (unsigned)remain;
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -