// Set User Zone
//

// CryptoMemory Library Include Files
#include "CM_LIB.h"
#include "CM_GPA.h"

// Set User Zone
uint8_t cm_SetUserZone(uint8_t ucZoneNumber, uint8_t ucAntiTearing)
{
	uint8_t ucReturn;
	
	ucCM_InsBuff[0] = 0xb4;
	if (ucAntiTearing) ucCM_InsBuff[1] = 0x0b;
	else 	           ucCM_InsBuff[1] = 0x03;
    ucCM_InsBuff[2] = ucZoneNumber;
	ucCM_InsBuff[3] = 0x00;

    // Only zone number is included in the polynomial
	cm_GPAGen(ucZoneNumber);
	
	if ((ucReturn = CM_LOW_LEVEL.SendCommand(ucCM_InsBuff))!= SUCCESS) return ucReturn;
	
	// save zone number and anti-tearing state
    ucCM_UserZone = ucZoneNumber;
    ucCM_AntiTearing = ucAntiTearing;

    // done	
	return  SUCCESS;//CM_LOW_LEVEL.ReceiveRet(NULL,0);
}
