如题所诉。。。
VV:
协议栈里面的
/********************************************************************* * @fn Onboard_rand * * @brief Random number generator * * @param none * * @return uint16 – new random number * *********************************************************************/uint16 Onboard_rand( void ){ return ( MAC_RADIO_RANDOM_WORD() );}
gu du:
回复 VV:
这个不是计算CRC16,而是产生随机数的吧手册那里说可以用来计算CRC16,但是没说清楚怎么用
VV:
回复 gu du:
协议栈里面有关于CRC计算的软件实现的,请参考
/****************************************************************************** * @fn runPoly * * @brief Run the CRC16 Polynomial calculation over the byte parameter. * * @param crc – Running CRC calculated so far. * @param val – Value on which to run the CRC16. * * @return crc – Updated for the run. */static uint16 runPoly(uint16 crc, uint8 val){ const uint16 poly = 0x1021; uint8 cnt;
for (cnt = 0; cnt < 8; cnt++, val <<= 1) { uint8 msb = (crc & 0x8000) ? 1 : 0;
crc <<= 1; if (val & 0x80) crc |= 0x0001; if (msb) crc ^= poly; }
return crc;}