bool Packet::_crcCheck() { return true; uint32_t crc = make_crc32(_dataBuffer(), _dataSize()); if (_crc() == crc ) return true; else LOGGER_ERROR("_crc():%d != crc:%d ", _crc(), crc); return false; }
unsigned short sbo_crc(unsigned char *data, unsigned int length) { // unsigned char input[] = {0x55,0x55,0x55,0x55}; int max_flag = 0x30; unsigned flag = 1; while (flag < max_flag) { _crc(flag); flag += 1; } //_crc(input[0], input[1]); //Debug("hard_crc = %08X\n", _crc(input[0], input[1])); // Debug("soft_crc = %04X\n", crc16by8(input, 2)); // volatile mml_crypto_regs_t *mml_crypto = (volatile mml_crypto_regs_t*)MML_CRYPTO_IOBASE; // int CRC_input = 0x0; // // lite_printf("before writing to DIN\n"); // lite_printf("add0x%x 0x%x \n",&mml_crypto->crypto_DIN_0, mml_crypto->crypto_DIN_0); // lite_printf("0x%x \n",mml_crypto->crypto_DIN_1); // lite_printf("0x%x \n",mml_crypto->crypto_DIN_2); // lite_printf("0x%x \n",mml_crypto->crypto_DIN_3); // lite_printf("Ctr0x%x \n",mml_crypto->crypto_crc_control); // lite_printf("Val 0x%x \n",mml_crypto->crypto_CRC_VAL); // lite_printf("Write CRC value to 0x0 \n"); // mml_crypto->crypto_CRC_VAL = 0x0; // lite_printf("Val 0x%x \n",mml_crypto->crypto_CRC_VAL); // // //mml_crypto->crypto_CRC_POLY=0xEDB88320;//0x04C11DB7; // mml_crypto->crypto_crc_control = 0; // mml_crypto->crypto_crc_control |= CRC_CTRL_REG_VALUE; // // lite_printf("After Control\n"); // lite_printf("Ctr0x%x \n",mml_crypto->crypto_crc_control); // lite_printf("CRC Polynomial 0x%x \n",mml_crypto->crypto_CRC_POLY); // lite_printf(" Val 0x%x \n",mml_crypto->crypto_CRC_VAL); // lite_printf("!Val 0x%x \n\n",~(mml_crypto->crypto_CRC_VAL)); // // mml_crypto->crypto_crc_control=0; // mml_crypto->crypto_CRC_VAL=0x0;//0xFFFFFFFF; // lite_printf(" Val 0x%x \n",mml_crypto->crypto_CRC_VAL); // mml_crypto->crypto_crc_control|= CRC_CTRL_REG_VALUE; // lite_printf(" Val 0x%x \n",mml_crypto->crypto_CRC_VAL); // // mml_crypto->crypto_crc_control=0; // mml_crypto->crypto_CRC_VAL=0x00000000; // mml_crypto->crypto_crc_control|= CRC_CTRL_REG_VALUE; // CRC_input=0x55555555;//0xFF0000FF; // mml_crypto->crypto_DIN_0=CRC_input; // lite_printf(" Data 0x%x \n",CRC_input); // lite_printf(" Val 0x%x \n",mml_crypto->crypto_CRC_VAL); // // mml_crypto->crypto_crc_control=0; // mml_crypto->crypto_CRC_VAL=0x00000000; // mml_crypto->crypto_crc_control|= CRC_CTRL_REG_VALUE; // CRC_input=0xAAAAAAAA;//0xFF000FFF; // mml_crypto->crypto_DIN_0=CRC_input; // lite_printf(" Data 0x%x \n",CRC_input); // lite_printf(" Val 0x%x \n",mml_crypto->crypto_CRC_VAL); // // mml_crypto->crypto_crc_control=0; // mml_crypto->crypto_CRC_VAL=0x00000000; // mml_crypto->crypto_crc_control|= CRC_CTRL_REG_VALUE; // CRC_input=0x78563412;//0xFF000FFF; // mml_crypto->crypto_DIN_0=CRC_input; // lite_printf(" Data 0x%x \n",CRC_input); // lite_printf(" Val 0x%x \n",mml_crypto->crypto_CRC_VAL); return 0; }