/******************** (C) COPYRIGHT 2021 SONiX *******************************
* COMPANY:	SONiX
* DATE:		2021/12/27
* IC:			SN8F5754
*____________________________________________________________________________
* REVISION		Date				Author		Description
* 1.0					2021/12/27	SONiX			1. First release
*____________________________________________________________________________
*****************************************************************************/
/*_____ I N C L U D E S _________________________________*/
#define __XRAM_SFR_H__
#include <SN8F5754.h>
#include "crc.h"

/*_____ F U N C T I O N S _______________________________*/

/*_____ D E F I N I T I O N S ___________________________*/

/*_____ D E C L A R A T I O N S _________________________*/

/*_____ M A C R O S _____________________________________*/
#define OB_IO_OUTPUT_LOW   		P00=0;  P0M |=0x01; 
#define OB_IO_OUTPUT_HIGH 		P00=1;  P0M |=0x01;


/**
 *	@Brief		main: CRC Test Demo Function
 *	@param		None
 *	@retval		None
 */

void main(void)
{
  uint16_t dbMN_CrcHwResult;
  uint16_t dbMN_CrcVerifyData;
  
	/*	Initialize GPIO status	*/
	GPIO_Initialization();
	
  /*	Initializes and configures the CRC function	*/
	CRC_Initialization(mskCRCM_POLY_CRC16, mskCRCM_RANGE_3FDD);
  
	while(1)
	{		
    /*	Compare wtih hardware result and SW result, the SW result was be set on OPTIONS_SN8F5754.A51
        If HW CRC result is right, IO output high
        If HW CRC result is wrong, IO output low	*/
    dbMN_CrcHwResult = CRC_ExecuteRnageCalculation();
    dbMN_CrcVerifyData = CRC_GetVerifyData();
    
    if(dbMN_CrcHwResult==dbMN_CrcVerifyData)
    {
      OB_IO_OUTPUT_HIGH
    }
    else
    {
      OB_IO_OUTPUT_LOW
    }   
	}
}


