#ifndef	__CRC_H__
#define	__CRC_H__

/*_____ I N C L U D E S _________________________________*/
#include <SN8F5754.h>

/*_____ F U N C T I O N S _______________________________*/
void GPIO_Initialization(void);
void CRC_Initialization(uint8_t bMode, uint8_t bRange);
void CRC_ExecuteOneByte(uint8_t bByteData);
uint16_t CRC_GetVerifyData(void);
uint16_t CRC_ExecuteRnageCalculation(void);
uint16_t CRC_ExecuteRomByteCalculation(uint8_t	code *bptrData, uint16_t dbLength);
uint16_t CRC_ExecuteRamByteCalculation(uint8_t *bDataBuf, uint16_t dbLength);

/*_____ D E F I N I T I O N S ___________________________*/
#define CRC_CAL_EXECUTE               0  
#define CRC_CAL_DONE                  1    

#define ROM_SIZE 										0x4000
#define PAGE_SIZE 									0x20

//===========================//
//** 				CRCM						 //
//===========================//
#define	mskCRCM_ENABLE						  (0x01U<<0)
#define mskCRCM_RANGE_0FFF					(0x00U<<2)
#define mskCRCM_RANGE_1FFF					(0x01U<<2)
#define mskCRCM_RANGE_3EFF			  	(0x02U<<2)
#define mskCRCM_RANGE_3FDD  		  	(0x03U<<2)
#define mskCRCM_POLY_CRC16_CCITT		(0x00U<<4)
#define mskCRCM_POLY_CRC16					(0x01U<<4)
#define	mskCRCM_RESET								(0x01U<<5)
#define mskCRCM_BUSY								(0x01U<<6)
#define mskCRCM_RUN									(0x01U<<7)             

/*_____ D E C L A R A T I O N S _________________________*/
extern uint16_t code CRC_CHECK_DATA;

/*_____ M A C R O S _____________________________________*/
#define	IO_PORT0_OUTPUT_LOW		P0M |= 0xFF;	P0 &= 0x00;
#define	IO_PORT1_OUTPUT_LOW		P1M |= 0xFF;	P1 &= 0x00;
#define	IO_PORT2_OUTPUT_LOW		P2M |= 0xFF;	P2 &= 0x00;
#define	IO_PORT3_OUTPUT_LOW		P3M |= 0xFF;	P3 &= 0x00;


#endif  /* __CRC_H__ */
