C code

BufferCmp

uint8_t BufferCmp(const uint32_t* pBuffer,
		  uint32_t* pBuffer1,
                  uint16_t BufferLength)
{
    while(BufferLength--)
    {
        if(*pBuffer != *pBuffer1)
	{
	    return 0;
	}
	pBuffer++;
	pBuffer1++;
    }
    return 1;
}

异或值计算

int xorOperation(unsigned char *pBuffer,unsigned char n)
{
    unsigned char i;
    unsigned char temp;

    for(i=0;i<n;i++)
    {
	temp ^= pBuffer[i];
    }
    return temp;
}

int main()
{
    unsigned char num;
    unsigned char temp1;
    unsigned char Led_Buffer[] = {0x20,0x1F,0x06,0x00,0x04,0x10,0x00,0x01,0xA3};

    num = sizeof(Led_Buffer)/sizeof(Led_Buffer[0]);
    temp1 = xorOperation((unsigned char*)Led_Buffer,num);
    printf("%d\n",temp1);

    return 0;
}
posted @ 2022-08-10 16:04  伯宁君  阅读(121)  评论(0编辑  收藏  举报