This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cc2530 的随机数发生器怎么用于计算CRC16

如题所诉。。。

  • 协议栈里面的

    /*********************************************************************
    * @fn Onboard_rand
    *
    * @brief Random number generator
    *
    * @param none
    *
    * @return uint16 - new random number
    *
    *********************************************************************/
    uint16 Onboard_rand( void )
    {
    return ( MAC_RADIO_RANDOM_WORD() );
    }

  • 这个不是计算CRC16,而是产生随机数的吧
    手册那里说可以用来计算CRC16,但是没说清楚怎么用 

  • 协议栈里面有关于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;
    }