/******************************************************************
 * @file  CBCRC.s.c
 * @brief: 
 * @author: xuwei
 * COPYRIGHT NOTICE: (c) smartlogictech. All rights reserved. 
 * Version      Change_date         Owner         Change_content

*****************************************************************/
#include <stdlib.h>
#include <math.h>

int CRC24(int ConfigBaseAddr,int datalen, int InputAddr, int LUTAddr1,int LUTAddr2)

{
	volatile int a,b,c;
	volatile int *addr = (volatile int *)ConfigBaseAddr;

	b = (datalen & 0x3FF)>>3;
	if (b==0)
	{
		b = 128;
	}
	a = (128 - b);

	addr[0*16] = (datalen>>3)+InputAddr;

	addr[1*16] = InputAddr;
	addr[2*16] = b+InputAddr;
	addr[3*16] = (datalen+(a<<3))>>10;
	addr[4*16] = a;

	addr[8*16] = LUTAddr1+0x8000;
	addr[8*16+1] = LUTAddr1+0x8000;

	addr[9*16] = LUTAddr2+0x8000;
	addr[9*16+1] = LUTAddr2+0x8000;

	return a;
}
