static int testMTZ(void) { uchar ucData[2]; int ret; ucData[0] = 0x5a; ucData[1] = 0xa5; ret = cm_WriteConfigZone(DEFAULT_ADDRESS, 0x0A, ucData, 2, FALSE); if(0!=ret) { printf("write MTZ fail....ret=0x%x\n",ret); return -1; } ucData[0] = 0x00; ucData[1] = 0x00; ret = cm_ReadConfigZone(DEFAULT_ADDRESS, 0x0A, ucData, 2); if(0!=ret) { printf("read MTZ fail....ret=0x%x\n",ret); return -1; } if(ucData[0] != 0x5a || ucData[1] != 0xa5) { printf("testMTZ Error!! : %d : %d\n", ucData[0], ucData[1]); return -1; } return 0; }
/*********************************************************************** 函数名称: E2PROM_WriteConfigZone 函数说明: 设置配置区 修改记录: 日 期 作 者 修定 --------- --------- ----- ************************************************************************/ sint E2PROM_WriteConfigZone( uint Addr, uchar *Buffer, uint NumberToWrite, bool bAntiTearing) { sint NVMError = 0; sint CallError = 0; cm_InitI2c(); CallError = cm_WriteConfigZone( Addr,Buffer,NumberToWrite,bAntiTearing); CallError = CallError; cm_TermI2c(); return NVMError; }
/* * 写密码 */ int cryptoWriteSeed(unsigned char *seed) { unsigned char ucG[8]; int i; RETURN_CODE ucReturn; at88_config_unlock(); at88_rwead_aac(); for(i = 0 ; i < 8 ; i ++) ucG[i] = seed[i]; ucReturn = cm_WriteConfigZone(DEFAULT_ADDRESS, 0x98, ucG, 8, FALSE); if (ucReturn != SUCCESS) { printf("WRITESEED fail...ret=0x%x\n",ucReturn); return -1; } cryptoReset(); return 0; }
static int at88_rwead_aac(void) { int ret; unsigned char tempData; //dcr , device addr 0x0b tempData=0x00; ret = cm_ReadConfigZone(DEFAULT_ADDRESS, 0x18, &tempData, 1); if(ret != 0) { printf("cm_ReadConfigZone reg 0x18 fail\n"); return -1; } //printf("DCR = 0x%2x\n", tempData); if(tempData!=0xeb) { tempData=0xeb;//clear etr ret = cm_WriteConfigZone(DEFAULT_ADDRESS, 0x18, &tempData, 1, FALSE); if (ret != SUCCESS) { printf("cm_WriteConfigZone reg 0x18 fail!\n"); return -1; } } tempData=0x00; ret = cm_ReadConfigZone(DEFAULT_ADDRESS, 0x60, &tempData, 1); if(ret != 0) { printf("cm_ReadConfigZone run wrong!!\n"); return -1; } //printf("AAC1 = 0x%2x\n", tempData); if(tempData!=0xff) { tempData = 0xff; ret = cm_WriteConfigZone(DEFAULT_ADDRESS, 0x60, &tempData, 1, FALSE); if (ret != SUCCESS) { printf("cm_WriteConfigZone run wrong!\n"); return -1; } } unsigned char init_cryptogram_data[7]; init_cryptogram_data[0]=0x22; init_cryptogram_data[1]=0x22; init_cryptogram_data[2]=0x22; init_cryptogram_data[3]=0x22; init_cryptogram_data[4]=0x22; init_cryptogram_data[5]=0x22; init_cryptogram_data[6]=0x22; ret = cm_WriteConfigZone(DEFAULT_ADDRESS, 0x61, init_cryptogram_data, 7, FALSE); if (ret != SUCCESS) { printf("cm_WriteConfigZone init_cryptogram_data fail !\n"); return -1; } return 0; }