MM32硬件 CRC32 算法实现配置
uint32_t mm32_hw_cr32(uint32_t *addr_start, uint32_t size)
{
uint32_t index;
RCC_EnableAHB1Periphs(RCC_AHB1_PERIPH_CRC, true);
RCC_ResetAHB1Periphs(RCC_AHB1_PERIPH_CRC);
CRC_Init_Type crc_init;
crc_init.Polynomial = 0x04C11DB7u; //< X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2+ X +1
crc_init.PolynomialWidth = CRC_PolynomialWidth_32b;
crc_init.InEndian = CRC_DataEndian_LittleEndian;
crc_init.OutEndian = CRC_DataEndian_BigEndian;
crc_init.InRev = CRC_Rev_Rev;
crc_init.OutRev = CRC_Rev_Rev;
CRC_Init(CRC, &crc_init);
CRC_SetSeed(CRC, 0xFFFFFFFFu);
for (index = 0; index < size; index++)
{
uint32_t crc_temp = __REV(*((uint32_t *)addr_start + index));
CRC_SetData(CRC, crc_temp);
}
return (CRC_GetResult(CRC)^0xFFFFFFFF);
}
MM32硬件 CRC32/MPEG-2算法实现配置
uint32_t mm32_hw_cr32_mpeg2(uint32_t *addr_start, uint32_t size)
{
uint32_t index;
RCC_EnableAHB1Periphs(RCC_AHB1_PERIPH_CRC, true);
RCC_ResetAHB1Periphs(RCC_AHB1_PERIPH_CRC);
CRC_Init_Type crc_init;
crc_init.Polynomial = 0x04C11DB7u; //< X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2+ X +1
crc_init.PolynomialWidth = CRC_PolynomialWidth_32b;
crc_init.InEndian = CRC_DataEndian_LittleEndian;
crc_init.OutEndian = CRC_DataEndian_LittleEndian;
crc_init.InRev = CRC_Rev_Normal;
crc_init.OutRev = CRC_Rev_Normal;
CRC_Init(CRC, &crc_init);
CRC_SetSeed(CRC, 0xFFFFFFFFu);
for (index = 0; index < size; index++)
{
uint32_t crc_temp = __REV(*((uint32_t *)addr_start + index));
CRC_SetData(CRC, crc_temp);
}
return CRC_GetResult(CRC);
}
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/Allen_Ma_/article/details/132067475
|