/******************** (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 ___________________________*/
#define RAM_CRC_VERIFY_DATA   0x4204

/*_____ 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)
{
	uint8_t bMN_DataBuffer[10];
  uint16_t dbMN_CrcByteCalResult;
  uint16_t i;
  
  /*	Initialize GPIO status	*/
	GPIO_Initialization();
	
  /*	Initializes and configures the CRC function	*/
	CRC_Initialization(mskCRCM_POLY_CRC16, mskCRCM_RANGE_3FDD);
  
  while(1)
  {
    for(i = 0x0; i<sizeof(bMN_DataBuffer); i++)
    {
      bMN_DataBuffer[i] = i;
    }
        
    /* Accumulate RAM buffer 10 byte by using for loop one byte CRC calculation */
    dbMN_CrcByteCalResult = CRC_ExecuteRamByteCalculation(bMN_DataBuffer, sizeof(bMN_DataBuffer));
    
    if(dbMN_CrcByteCalResult==RAM_CRC_VERIFY_DATA)
    {
      OB_IO_OUTPUT_HIGH
    }
    else
    {
      OB_IO_OUTPUT_LOW
    }	
  }

}
